Update ruma-api, ruma-events

This commit is contained in:
Jonas Platte 2020-04-22 03:01:33 +02:00
parent 24b9ea7dc9
commit eb4b8e559e
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
15 changed files with 68 additions and 109 deletions

View File

@ -15,8 +15,8 @@ edition = "2018"
[dependencies] [dependencies]
http = "0.2.1" http = "0.2.1"
js_int = { version = "0.1.4", features = ["serde"] } js_int = { version = "0.1.4", features = ["serde"] }
ruma-api = "0.16.0-rc.2" ruma-api = "0.16.0-rc.3"
ruma-events = "0.20.0" ruma-events = "0.21.0-beta.1"
ruma-identifiers = "0.16.0" ruma-identifiers = "0.16.0"
ruma-serde = "0.1.0" ruma-serde = "0.1.0"
serde = { version = "1.0.106", features = ["derive"] } serde = { version = "1.0.106", features = ["derive"] }

View File

@ -3,7 +3,7 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_events::{room::message::MessageEventContent, EventResult, EventType}; use ruma_events::{room::message::MessageEventContent, EventJson, EventType};
use ruma_identifiers::UserId; use ruma_identifiers::UserId;
use super::DeviceIdOrAllDevices; use super::DeviceIdOrAllDevices;
@ -28,8 +28,7 @@ ruma_api! {
/// A map of users to devices to a message event to be sent to the user's /// A map of users to devices to a message event to be sent to the user's
/// device. Individual message events can be sent to devices, but all /// device. Individual message events can be sent to devices, but all
/// events must be of the same type. /// events must be of the same type.
#[wrap_incoming(MessageEventContent with EventResult)] pub messages: BTreeMap<UserId, BTreeMap<DeviceIdOrAllDevices, EventJson<MessageEventContent>>>
pub messages: BTreeMap<UserId, BTreeMap<DeviceIdOrAllDevices, MessageEventContent>>
} }
response {} response {}

View File

@ -1,7 +1,7 @@
//! [GET /_matrix/client/r0/user/{userId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-user-userid-account-data-type) //! [GET /_matrix/client/r0/user/{userId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-user-userid-account-data-type)
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_events::{collections::only, EventResult}; use ruma_events::{collections::only, EventJson};
use ruma_identifiers::UserId; use ruma_identifiers::UserId;
ruma_api! { ruma_api! {
@ -26,8 +26,7 @@ ruma_api! {
response { response {
/// Account data content for the given type. /// Account data content for the given type.
#[ruma_api(body)] #[ruma_api(body)]
#[wrap_incoming(with EventResult)] pub account_data: EventJson<only::Event>,
pub account_data: only::Event,
} }
error: crate::Error error: crate::Error

View File

@ -1,7 +1,7 @@
//! [GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-user-userid-rooms-roomid-account-data-type) //! [GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-user-userid-rooms-roomid-account-data-type)
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_events::{collections::only, EventResult}; use ruma_events::{collections::only, EventJson};
use ruma_identifiers::{RoomId, UserId}; use ruma_identifiers::{RoomId, UserId};
ruma_api! { ruma_api! {
@ -29,8 +29,7 @@ ruma_api! {
response { response {
/// Account data content for the given type. /// Account data content for the given type.
#[ruma_api(body)] #[ruma_api(body)]
#[wrap_incoming(with EventResult)] pub account_data: EventJson<only::Event>,
pub account_data: only::Event,
} }
error: crate::Error error: crate::Error

View File

@ -2,7 +2,7 @@
use js_int::UInt; use js_int::UInt;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_events::{collections::only, EventResult}; use ruma_events::{collections::only, EventJson};
use ruma_identifiers::{EventId, RoomId}; use ruma_identifiers::{EventId, RoomId};
use crate::r0::filter::RoomEventFilter; use crate::r0::filter::RoomEventFilter;
@ -40,21 +40,20 @@ ruma_api! {
/// A token that can be used to paginate forwards with. /// A token that can be used to paginate forwards with.
pub end: String, pub end: String,
/// Details of the requested event. /// Details of the requested event.
#[wrap_incoming(with EventResult)] pub event: EventJson<only::RoomEvent>,
pub event: only::RoomEvent,
/// A list of room events that happened just after the requested event, in chronological /// A list of room events that happened just after the requested event, in chronological
/// order. /// order.
#[wrap_incoming(only::RoomEvent with EventResult)]
pub events_after: Vec<only::RoomEvent>, pub events_after: Vec<EventJson<only::RoomEvent>>,
/// A list of room events that happened just before the requested event, in /// A list of room events that happened just before the requested event, in
/// reverse-chronological order. /// reverse-chronological order.
#[wrap_incoming(only::RoomEvent with EventResult)]
pub events_before: Vec<only::RoomEvent>, pub events_before: Vec<EventJson<only::RoomEvent>>,
/// A token that can be used to paginate backwards with. /// A token that can be used to paginate backwards with.
pub start: String, pub start: String,
/// The state of the room at the last event returned. /// The state of the room at the last event returned.
#[wrap_incoming(only::StateEvent with EventResult)]
pub state: Vec<only::StateEvent>, pub state: Vec<EventJson<only::StateEvent>>,
} }
error: crate::Error error: crate::Error

View File

@ -1,7 +1,7 @@
//! [GET /_matrix/client/r0/rooms/{roomId}/members](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-members) //! [GET /_matrix/client/r0/rooms/{roomId}/members](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-members)
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_events::{room::member::MemberEvent, EventResult}; use ruma_events::{room::member::MemberEvent, EventJson};
use ruma_identifiers::RoomId; use ruma_identifiers::RoomId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -42,8 +42,7 @@ ruma_api! {
response { response {
/// A list of member events. /// A list of member events.
#[wrap_incoming(MemberEvent with EventResult)] pub chunk: Vec<EventJson<MemberEvent>>
pub chunk: Vec<MemberEvent>
} }
error: crate::Error error: crate::Error

View File

@ -1,7 +1,7 @@
//! [PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid) //! [PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid)
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_events::{room::message::MessageEventContent, EventResult, EventType}; use ruma_events::{room::message::MessageEventContent, EventJson, EventType};
use ruma_identifiers::{EventId, RoomId}; use ruma_identifiers::{EventId, RoomId};
ruma_api! { ruma_api! {
@ -30,8 +30,7 @@ ruma_api! {
pub txn_id: String, pub txn_id: String,
/// The event's content. /// The event's content.
#[ruma_api(body)] #[ruma_api(body)]
#[wrap_incoming(with EventResult)] pub data: EventJson<MessageEventContent>,
pub data: MessageEventContent,
} }
response { response {

View File

@ -2,7 +2,7 @@
use js_int::UInt; use js_int::UInt;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_events::{collections::all::RoomEvent, EventResult}; use ruma_events::{collections::all::RoomEvent, EventJson};
use ruma_identifiers::RoomId; use ruma_identifiers::RoomId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -60,8 +60,7 @@ ruma_api! {
/// The token the pagination starts from. /// The token the pagination starts from.
pub start: String, pub start: String,
/// A list of room events. /// A list of room events.
#[wrap_incoming(RoomEvent with EventResult)] pub chunk: Vec<EventJson<RoomEvent>>,
pub chunk: Vec<RoomEvent>,
/// The token the pagination ends at. /// The token the pagination ends at.
pub end: String, pub end: String,
} }

View File

@ -3,10 +3,10 @@
use std::time::SystemTime; use std::time::SystemTime;
use js_int::UInt; use js_int::UInt;
use ruma_api::{ruma_api, Outgoing}; use ruma_api::ruma_api;
use ruma_events::{collections::all, EventResult}; use ruma_events::{collections::all, EventJson};
use ruma_identifiers::RoomId; use ruma_identifiers::RoomId;
use serde::Serialize; use serde::{Deserialize, Serialize};
use super::Action; use super::Action;
@ -46,22 +46,20 @@ ruma_api! {
/// The list of events that triggered notifications. /// The list of events that triggered notifications.
#[wrap_incoming(Notification)] pub notifications: Vec<EventJson<Notification>>,
pub notifications: Vec<Notification>,
} }
error: crate::Error error: crate::Error
} }
/// Represents a notification /// Represents a notification
#[derive(Clone, Debug, Serialize, Outgoing)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Notification { pub struct Notification {
/// The actions to perform when the conditions for this rule are met. /// The actions to perform when the conditions for this rule are met.
pub actions: Vec<Action>, pub actions: Vec<Action>,
/// The event that triggered the notification. /// The event that triggered the notification.
#[wrap_incoming(with EventResult)] pub event: EventJson<all::Event>,
pub event: all::Event,
/// The profile tag of the rule that matched this event. /// The profile tag of the rule that matched this event.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]

View File

@ -1,7 +1,7 @@
//! [POST /_matrix/client/r0/createRoom](https://matrix.org/docs/spec/client_server/r0.6.0.html#post-matrix-client-r0-createroom) //! [POST /_matrix/client/r0/createRoom](https://matrix.org/docs/spec/client_server/r0.6.0.html#post-matrix-client-r0-createroom)
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_events::{room::power_levels::PowerLevelsEventContent, EventResult}; use ruma_events::{room::power_levels::PowerLevelsEventContent, EventJson};
use ruma_identifiers::{RoomId, UserId}; use ruma_identifiers::{RoomId, UserId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::Value; use serde_json::Value;
@ -46,8 +46,7 @@ ruma_api! {
pub name: Option<String>, pub name: Option<String>,
/// Power level content to override in the default power level event. /// Power level content to override in the default power level event.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[wrap_incoming(PowerLevelsEventContent with EventResult)] pub power_level_content_override: Option<EventJson<PowerLevelsEventContent>>,
pub power_level_content_override: Option<PowerLevelsEventContent>,
/// Convenience parameter for setting various default state events based on a preset. /// Convenience parameter for setting various default state events based on a preset.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub preset: Option<RoomPreset>, pub preset: Option<RoomPreset>,

View File

@ -1,7 +1,7 @@
//! [GET /_matrix/client/r0/rooms/{roomId}/event/{eventId}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-event-eventid) //! [GET /_matrix/client/r0/rooms/{roomId}/event/{eventId}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-event-eventid)
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_events::{collections::all, EventResult}; use ruma_events::{collections::all, EventJson};
use ruma_identifiers::{EventId, RoomId}; use ruma_identifiers::{EventId, RoomId};
ruma_api! { ruma_api! {
@ -25,8 +25,7 @@ ruma_api! {
response { response {
/// Arbitrary JSON of the event body. Returns both room and state events. /// Arbitrary JSON of the event body. Returns both room and state events.
#[wrap_incoming(with EventResult)] pub event: EventJson<all::RoomEvent>,
pub event: all::RoomEvent,
} }
error: crate::Error error: crate::Error

View File

@ -3,8 +3,8 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use js_int::UInt; use js_int::UInt;
use ruma_api::{ruma_api, Outgoing}; use ruma_api::ruma_api;
use ruma_events::{collections::all::Event, EventResult}; use ruma_events::{collections::all::Event, EventJson};
use ruma_identifiers::{EventId, RoomId, UserId}; use ruma_identifiers::{EventId, RoomId, UserId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -32,7 +32,6 @@ ruma_api! {
response { response {
/// A grouping of search results by category. /// A grouping of search results by category.
#[wrap_incoming]
pub search_categories: ResultCategories, pub search_categories: ResultCategories,
} }
@ -87,18 +86,16 @@ pub struct EventContext {
} }
/// Context for search results, if requested. /// Context for search results, if requested.
#[derive(Clone, Debug, Serialize, Outgoing)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct EventContextResult { pub struct EventContextResult {
/// Pagination token for the end of the chunk. /// Pagination token for the end of the chunk.
pub end: String, pub end: String,
/// Events just after the result. /// Events just after the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[wrap_incoming(Event with EventResult)] pub events_after: Option<Vec<EventJson<Event>>>,
pub events_after: Option<Vec<Event>>,
/// Events just before the result. /// Events just before the result.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[wrap_incoming(Event with EventResult)] pub events_before: Option<Vec<EventJson<Event>>>,
pub events_before: Option<Vec<Event>>,
/// The historic profile information of the users that sent the events returned. /// The historic profile information of the users that sent the events returned.
// TODO: Not sure this is right. https://github.com/matrix-org/matrix-doc/issues/773 // TODO: Not sure this is right. https://github.com/matrix-org/matrix-doc/issues/773
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@ -157,17 +154,16 @@ pub enum OrderBy {
} }
/// Categories of events that can be searched for. /// Categories of events that can be searched for.
#[derive(Clone, Debug, Serialize, Outgoing)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ResultCategories { pub struct ResultCategories {
/// Room event results. /// Room event results.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[wrap_incoming(RoomEventResults)] pub room_events: Option<RoomEventJsons>,
pub room_events: Option<RoomEventResults>,
} }
/// Categories of events that can be searched for. /// Categories of events that can be searched for.
#[derive(Clone, Debug, Serialize, Outgoing)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct RoomEventResults { pub struct RoomEventJsons {
/// An approximate count of the total number of results found. /// An approximate count of the total number of results found.
pub count: UInt, pub count: UInt,
/// Any groups that were requested. /// Any groups that were requested.
@ -178,7 +174,6 @@ pub struct RoomEventResults {
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub next_batch: Option<String>, pub next_batch: Option<String>,
/// List of results in the requested order. /// List of results in the requested order.
#[wrap_incoming(SearchResult)]
pub results: Vec<SearchResult>, pub results: Vec<SearchResult>,
/// The current state for every room in the results. This is included if the request had the /// The current state for every room in the results. This is included if the request had the
/// `include_state` key set with a value of `true`. /// `include_state` key set with a value of `true`.
@ -202,17 +197,15 @@ pub struct ResultGroup {
} }
/// A search result. /// A search result.
#[derive(Clone, Debug, Serialize, Outgoing)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SearchResult { pub struct SearchResult {
/// Context for result, if requested. /// Context for result, if requested.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
#[wrap_incoming(EventContextResult)]
pub context: Option<EventContextResult>, pub context: Option<EventContextResult>,
/// A number that describes how closely this result matches the search. Higher is closer. /// A number that describes how closely this result matches the search. Higher is closer.
pub rank: f64, pub rank: f64,
/// The event that matched. /// The event that matched.
#[wrap_incoming(with EventResult)] pub result: EventJson<Event>,
pub result: Event,
} }
/// A user profile. /// A user profile.

View File

@ -1,7 +1,7 @@
//! [GET /_matrix/client/r0/rooms/{roomId}/state](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-rooms-roomid-state) //! [GET /_matrix/client/r0/rooms/{roomId}/state](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-rooms-roomid-state)
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_events::{collections::all::StateEvent, EventResult}; use ruma_events::{collections::all::StateEvent, EventJson};
use ruma_identifiers::RoomId; use ruma_identifiers::RoomId;
ruma_api! { ruma_api! {
@ -25,8 +25,7 @@ ruma_api! {
/// list of events. If the user has left the room then this will be the state of the /// list of events. If the user has left the room then this will be the state of the
/// room when they left as a list of events. /// room when they left as a list of events.
#[ruma_api(body)] #[ruma_api(body)]
#[wrap_incoming(StateEvent with EventResult)] pub room_state: Vec<EventJson<StateEvent>>,
pub room_state: Vec<StateEvent>,
} }
error: crate::Error error: crate::Error

View File

@ -3,7 +3,7 @@
use std::{collections::BTreeMap, time::Duration}; use std::{collections::BTreeMap, time::Duration};
use js_int::UInt; use js_int::UInt;
use ruma_api::{ruma_api, Outgoing}; use ruma_api::ruma_api;
use ruma_events::{ use ruma_events::{
collections::{ collections::{
all::{RoomEvent, StateEvent}, all::{RoomEvent, StateEvent},
@ -12,7 +12,7 @@ use ruma_events::{
presence::PresenceEvent, presence::PresenceEvent,
stripped::AnyStrippedStateEvent, stripped::AnyStrippedStateEvent,
to_device::AnyToDeviceEvent, to_device::AnyToDeviceEvent,
EventResult, EventJson,
}; };
use ruma_identifiers::RoomId; use ruma_identifiers::RoomId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -63,14 +63,11 @@ ruma_api! {
/// The batch token to supply in the `since` param of the next `/sync` request. /// The batch token to supply in the `since` param of the next `/sync` request.
pub next_batch: String, pub next_batch: String,
/// Updates to rooms. /// Updates to rooms.
#[wrap_incoming]
pub rooms: Rooms, pub rooms: Rooms,
/// Updates to the presence status of other users. /// Updates to the presence status of other users.
#[wrap_incoming]
pub presence: Presence, pub presence: Presence,
/// Messages sent dirrectly between devices. /// Messages sent dirrectly between devices.
#[serde(default, skip_serializing_if = "ToDevice::is_empty")] #[serde(default, skip_serializing_if = "ToDevice::is_empty")]
#[wrap_incoming]
pub to_device: ToDevice, pub to_device: ToDevice,
/// Information on E2E device updates. /// Information on E2E device updates.
/// ///
@ -127,36 +124,30 @@ pub enum Filter {
} }
/// Updates to rooms. /// Updates to rooms.
#[derive(Clone, Debug, Serialize, Outgoing)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Rooms { pub struct Rooms {
/// The rooms that the user has left or been banned from. /// The rooms that the user has left or been banned from.
#[wrap_incoming(LeftRoom)]
pub leave: BTreeMap<RoomId, LeftRoom>, pub leave: BTreeMap<RoomId, LeftRoom>,
/// The rooms that the user has joined. /// The rooms that the user has joined.
#[wrap_incoming(JoinedRoom)]
pub join: BTreeMap<RoomId, JoinedRoom>, pub join: BTreeMap<RoomId, JoinedRoom>,
/// The rooms that the user has been invited to. /// The rooms that the user has been invited to.
#[wrap_incoming(InvitedRoom)]
pub invite: BTreeMap<RoomId, InvitedRoom>, pub invite: BTreeMap<RoomId, InvitedRoom>,
} }
/// Historical updates to left rooms. /// Historical updates to left rooms.
#[derive(Clone, Debug, Serialize, Outgoing)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct LeftRoom { pub struct LeftRoom {
/// The timeline of messages and state changes in the room up to the point when the user /// The timeline of messages and state changes in the room up to the point when the user
/// left. /// left.
#[wrap_incoming]
pub timeline: Timeline, pub timeline: Timeline,
/// The state updates for the room up to the start of the timeline. /// The state updates for the room up to the start of the timeline.
#[wrap_incoming]
pub state: State, pub state: State,
/// The private data that this user has attached to this room. /// The private data that this user has attached to this room.
#[wrap_incoming]
pub account_data: AccountData, pub account_data: AccountData,
} }
/// Updates to joined rooms. /// Updates to joined rooms.
#[derive(Clone, Debug, Serialize, Outgoing)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct JoinedRoom { pub struct JoinedRoom {
/// Information about the room which clients may need to correctly render it /// Information about the room which clients may need to correctly render it
/// to users. /// to users.
@ -164,19 +155,15 @@ pub struct JoinedRoom {
/// Counts of unread notifications for this room. /// Counts of unread notifications for this room.
pub unread_notifications: UnreadNotificationsCount, pub unread_notifications: UnreadNotificationsCount,
/// The timeline of messages and state changes in the room. /// The timeline of messages and state changes in the room.
#[wrap_incoming]
pub timeline: Timeline, pub timeline: Timeline,
/// Updates to the state, between the time indicated by the `since` parameter, and the start /// Updates to the state, between the time indicated by the `since` parameter, and the start
/// of the `timeline` (or all state up to the start of the `timeline`, if `since` is not /// of the `timeline` (or all state up to the start of the `timeline`, if `since` is not
/// given, or `full_state` is true). /// given, or `full_state` is true).
#[wrap_incoming]
pub state: State, pub state: State,
/// The private data that this user has attached to this room. /// The private data that this user has attached to this room.
#[wrap_incoming]
pub account_data: AccountData, pub account_data: AccountData,
/// The ephemeral events in the room that aren't recorded in the timeline or state of the /// The ephemeral events in the room that aren't recorded in the timeline or state of the
/// room. e.g. typing. /// room. e.g. typing.
#[wrap_incoming]
pub ephemeral: Ephemeral, pub ephemeral: Ephemeral,
} }
@ -192,7 +179,7 @@ pub struct UnreadNotificationsCount {
} }
/// Events in the room. /// Events in the room.
#[derive(Clone, Debug, Serialize, Outgoing)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Timeline { pub struct Timeline {
/// True if the number of events returned was limited by the `limit` on the filter. /// True if the number of events returned was limited by the `limit` on the filter.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@ -202,32 +189,28 @@ pub struct Timeline {
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub prev_batch: Option<String>, pub prev_batch: Option<String>,
/// A list of events. /// A list of events.
#[wrap_incoming(RoomEvent with EventResult)] pub events: Vec<EventJson<RoomEvent>>,
pub events: Vec<RoomEvent>,
} }
/// State events in the room. /// State events in the room.
#[derive(Clone, Debug, Serialize, Outgoing)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct State { pub struct State {
/// A list of state events. /// A list of state events.
#[wrap_incoming(StateEvent with EventResult)] pub events: Vec<EventJson<StateEvent>>,
pub events: Vec<StateEvent>,
} }
/// The private data that this user has attached to this room. /// The private data that this user has attached to this room.
#[derive(Clone, Debug, Serialize, Outgoing)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AccountData { pub struct AccountData {
/// A list of events. /// A list of events.
#[wrap_incoming(NonRoomEvent with EventResult)] pub events: Vec<EventJson<NonRoomEvent>>,
pub events: Vec<NonRoomEvent>,
} }
/// Ephemeral events not recorded in the timeline or state of the room. /// Ephemeral events not recorded in the timeline or state of the room.
#[derive(Clone, Debug, Serialize, Outgoing)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Ephemeral { pub struct Ephemeral {
/// A list of events. /// A list of events.
#[wrap_incoming(NonRoomEvent with EventResult)] pub events: Vec<EventJson<NonRoomEvent>>,
pub events: Vec<NonRoomEvent>,
} }
/// Information about room for rendering to clients. /// Information about room for rendering to clients.
@ -250,35 +233,31 @@ pub struct RoomSummary {
} }
/// Updates to the rooms that the user has been invited to. /// Updates to the rooms that the user has been invited to.
#[derive(Clone, Debug, Serialize, Outgoing)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct InvitedRoom { pub struct InvitedRoom {
/// The state of a room that the user has been invited to. /// The state of a room that the user has been invited to.
#[wrap_incoming]
pub invite_state: InviteState, pub invite_state: InviteState,
} }
/// The state of a room that the user has been invited to. /// The state of a room that the user has been invited to.
#[derive(Clone, Debug, Serialize, Outgoing)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct InviteState { pub struct InviteState {
/// A list of state events. /// A list of state events.
#[wrap_incoming(AnyStrippedStateEvent with EventResult)] pub events: Vec<EventJson<AnyStrippedStateEvent>>,
pub events: Vec<AnyStrippedStateEvent>,
} }
/// Updates to the presence status of other users. /// Updates to the presence status of other users.
#[derive(Clone, Debug, Serialize, Outgoing)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Presence { pub struct Presence {
/// A list of events. /// A list of events.
#[wrap_incoming(PresenceEvent with EventResult)] pub events: Vec<EventJson<PresenceEvent>>,
pub events: Vec<PresenceEvent>,
} }
/// Messages sent dirrectly between devices. /// Messages sent dirrectly between devices.
#[derive(Clone, Debug, Serialize, Outgoing)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ToDevice { pub struct ToDevice {
/// A list of to-device events. /// A list of to-device events.
#[wrap_incoming(AnyToDeviceEvent with EventResult)] pub events: Vec<EventJson<AnyToDeviceEvent>>,
pub events: Vec<AnyToDeviceEvent>,
} }
impl ToDevice { impl ToDevice {
@ -287,7 +266,7 @@ impl ToDevice {
} }
} }
impl Default for IncomingToDevice { impl Default for ToDevice {
fn default() -> Self { fn default() -> Self {
Self { events: Vec::new() } Self { events: Vec::new() }
} }

View File

@ -1,7 +1,7 @@
//! [GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-user-userid-rooms-roomid-tags) //! [GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-user-userid-rooms-roomid-tags)
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_events::{tag::TagEventContent, EventResult}; use ruma_events::{tag::TagEventContent, EventJson};
use ruma_identifiers::{RoomId, UserId}; use ruma_identifiers::{RoomId, UserId};
ruma_api! { ruma_api! {
@ -25,8 +25,7 @@ ruma_api! {
response { response {
/// The user's tags for the room. /// The user's tags for the room.
#[wrap_incoming(with EventResult)] pub tags: EventJson<TagEventContent>,
pub tags: TagEventContent,
} }
error: crate::Error error: crate::Error