From 98e0bad1b1f53f6376c3bc3a8bc752f1b54b35bb Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 9 Aug 2019 00:13:14 +0200 Subject: [PATCH] Update to the new ruma-events API --- Cargo.toml | 4 ++-- src/r0/context/get_context.rs | 10 +++++----- src/r0/presence/get_subscribed_presences.rs | 4 ++-- src/r0/search/search_events.rs | 8 ++++---- src/r0/send/send_message_event.rs | 4 ++-- src/r0/sync/get_member_events.rs | 4 ++-- src/r0/sync/get_message_events.rs | 4 ++-- src/r0/sync/get_state_events.rs | 4 ++-- src/r0/sync/sync_events.rs | 14 +++++++------- src/r0/tag/get_tags.rs | 4 ++-- 10 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d4e37054..e913bd31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,12 +14,12 @@ edition = "2018" [dependencies] ruma-api = "0.10.0" -ruma-events = "0.12.0" +ruma-events = { git = "https://github.com/ruma/ruma-events", branch = "event-result-stub" } ruma-identifiers = "0.14.0" serde_json = "1.0.40" [dependencies.js_int] -version = "0.1.1" +version = "0.1.2" features = ["serde"] [dependencies.serde] diff --git a/src/r0/context/get_context.rs b/src/r0/context/get_context.rs index f3596019..e518dfd6 100644 --- a/src/r0/context/get_context.rs +++ b/src/r0/context/get_context.rs @@ -1,7 +1,7 @@ //! [GET /_matrix/client/r0/rooms/{roomId}/context/{eventId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-rooms-roomid-context-eventid) use ruma_api::ruma_api; -use ruma_events::collections::only; +use ruma_events::{collections::only, EventResult}; use ruma_identifiers::{EventId, RoomId}; ruma_api! { @@ -32,16 +32,16 @@ ruma_api! { /// A token that can be used to paginate forwards with. pub end: String, /// Details of the requested event. - pub event: only::RoomEvent, + pub event: EventResult, /// A list of room events that happened just after the requested event, in chronological /// order. - pub events_after: Vec, + pub events_after: Vec>, /// A list of room events that happened just before the requested event, in /// reverse-chronological order. - pub events_before: Vec, + pub events_before: Vec>, /// A token that can be used to paginate backwards with. pub start: String, /// The state of the room at the last event returned. - pub state: Vec, + pub state: Vec>, } } diff --git a/src/r0/presence/get_subscribed_presences.rs b/src/r0/presence/get_subscribed_presences.rs index d9bf384a..656b1c8a 100644 --- a/src/r0/presence/get_subscribed_presences.rs +++ b/src/r0/presence/get_subscribed_presences.rs @@ -1,7 +1,7 @@ //! [GET /_matrix/client/r0/presence/list/{userId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-presence-list-userid) use ruma_api::ruma_api; -use ruma_events::presence::PresenceEvent; +use ruma_events::{presence::PresenceEvent, EventResult}; use ruma_identifiers::UserId; ruma_api! { @@ -23,6 +23,6 @@ ruma_api! { response { /// A list of presence events for every user on this list. #[ruma_api(body)] - pub presence_events: Vec, + pub presence_events: Vec>, } } diff --git a/src/r0/search/search_events.rs b/src/r0/search/search_events.rs index 14fd814a..58796f89 100644 --- a/src/r0/search/search_events.rs +++ b/src/r0/search/search_events.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use js_int::UInt; use ruma_api::ruma_api; -use ruma_events::collections::all::Event; +use ruma_events::{collections::all::Event, EventResult}; use ruma_identifiers::{EventId, RoomId, UserId}; use serde::{Deserialize, Serialize}; @@ -91,10 +91,10 @@ pub struct EventContextResult { pub end: String, /// Events just after the result. #[serde(skip_serializing_if = "Option::is_none")] - pub events_after: Option>, + pub events_after: Option>>, /// Events just before the result. #[serde(skip_serializing_if = "Option::is_none")] - pub events_before: Option>, + pub events_before: Option>>, /// 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 #[serde(skip_serializing_if = "Option::is_none")] @@ -206,7 +206,7 @@ pub struct SearchResult { /// A number that describes how closely this result matches the search. Higher is closer. pub rank: f64, /// The event that matched. - pub result: Event, + pub result: EventResult, } /// A user profile. diff --git a/src/r0/send/send_message_event.rs b/src/r0/send/send_message_event.rs index c97fd0a1..46b3043f 100644 --- a/src/r0/send/send_message_event.rs +++ b/src/r0/send/send_message_event.rs @@ -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) use ruma_api::ruma_api; -use ruma_events::{room::message::MessageEventContent, EventType}; +use ruma_events::{room::message::MessageEventContent, EventResult, EventType}; use ruma_identifiers::{EventId, RoomId}; ruma_api! { @@ -30,7 +30,7 @@ ruma_api! { pub txn_id: String, /// The event's content. #[ruma_api(body)] - pub data: MessageEventContent, + pub data: EventResult, // FIXME } response { diff --git a/src/r0/sync/get_member_events.rs b/src/r0/sync/get_member_events.rs index 2b1919e5..aa5c9fcd 100644 --- a/src/r0/sync/get_member_events.rs +++ b/src/r0/sync/get_member_events.rs @@ -1,7 +1,7 @@ //! [GET /_matrix/client/r0/rooms/{roomId}/members](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-rooms-roomid-members) use ruma_api::ruma_api; -use ruma_events::room::member::MemberEvent; +use ruma_events::{room::member::MemberEvent, EventResult}; use ruma_identifiers::RoomId; ruma_api! { @@ -22,6 +22,6 @@ ruma_api! { response { /// A list of member events. - pub chunk: Vec + pub chunk: Vec> } } diff --git a/src/r0/sync/get_message_events.rs b/src/r0/sync/get_message_events.rs index 6c573dc0..56c542c2 100644 --- a/src/r0/sync/get_message_events.rs +++ b/src/r0/sync/get_message_events.rs @@ -2,7 +2,7 @@ use js_int::UInt; use ruma_api::ruma_api; -use ruma_events::collections::only; +use ruma_events::{collections::only, EventResult}; use ruma_identifiers::RoomId; use serde::{Deserialize, Serialize}; @@ -46,7 +46,7 @@ ruma_api! { /// The token the pagination starts from. pub start: String, /// A list of room events. - pub chunk: Vec, + pub chunk: Vec>, /// The token the pagination ends at. pub end: String, } diff --git a/src/r0/sync/get_state_events.rs b/src/r0/sync/get_state_events.rs index 0636ac73..dd122f65 100644 --- a/src/r0/sync/get_state_events.rs +++ b/src/r0/sync/get_state_events.rs @@ -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) use ruma_api::ruma_api; -use ruma_events::collections::only; +use ruma_events::{collections::only, EventResult}; use ruma_identifiers::RoomId; ruma_api! { @@ -25,6 +25,6 @@ ruma_api! { /// 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. #[ruma_api(body)] - pub room_state: Vec, + pub room_state: Vec>, } } diff --git a/src/r0/sync/sync_events.rs b/src/r0/sync/sync_events.rs index 84aaa945..e054c42e 100644 --- a/src/r0/sync/sync_events.rs +++ b/src/r0/sync/sync_events.rs @@ -6,7 +6,7 @@ use js_int::UInt; use ruma_api::ruma_api; use ruma_events::{ collections::{all, only}, - stripped, + stripped, EventResult, }; use ruma_identifiers::RoomId; use serde::{Deserialize, Serialize}; @@ -172,28 +172,28 @@ pub struct Timeline { /// `/rooms/{roomId}/messages` endpoint. pub prev_batch: String, /// A list of events. - pub events: Vec, + pub events: Vec>, } /// State events in the room. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct State { /// A list of state events. - pub events: Vec, + pub events: Vec>, } /// The private data that this user has attached to this room. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct AccountData { /// A list of events. - pub events: Vec, + pub events: Vec>, } /// Ephemeral events not recorded in the timeline or state of the room. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Ephemeral { /// A list of events. - pub events: Vec, + pub events: Vec>, } /// Updates to the rooms that the user has been invited to. @@ -207,12 +207,12 @@ pub struct InvitedRoom { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct InviteState { /// A list of state events. - pub events: Vec, + pub events: Vec>, } /// Updates to the presence status of other users. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Presence { /// A list of events. - pub events: Vec, + pub events: Vec>, } diff --git a/src/r0/tag/get_tags.rs b/src/r0/tag/get_tags.rs index 019bc4df..4f0abea0 100644 --- a/src/r0/tag/get_tags.rs +++ b/src/r0/tag/get_tags.rs @@ -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) use ruma_api::ruma_api; -use ruma_events::tag::TagEventContent; +use ruma_events::{tag::TagEventContent, EventResult}; use ruma_identifiers::{RoomId, UserId}; ruma_api! { @@ -25,6 +25,6 @@ ruma_api! { response { /// The user's tags for the room. - pub tags: TagEventContent, + pub tags: EventResult, } }