Update to the new ruma-events API

This commit is contained in:
Jonas Platte 2019-08-09 00:13:14 +02:00
parent 05f181d9f1
commit 98e0bad1b1
10 changed files with 30 additions and 30 deletions

View File

@ -14,12 +14,12 @@ edition = "2018"
[dependencies] [dependencies]
ruma-api = "0.10.0" 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" ruma-identifiers = "0.14.0"
serde_json = "1.0.40" serde_json = "1.0.40"
[dependencies.js_int] [dependencies.js_int]
version = "0.1.1" version = "0.1.2"
features = ["serde"] features = ["serde"]
[dependencies.serde] [dependencies.serde]

View File

@ -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) //! [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_api::ruma_api;
use ruma_events::collections::only; use ruma_events::{collections::only, EventResult};
use ruma_identifiers::{EventId, RoomId}; use ruma_identifiers::{EventId, RoomId};
ruma_api! { ruma_api! {
@ -32,16 +32,16 @@ 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.
pub event: only::RoomEvent, pub event: EventResult<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.
pub events_after: Vec<only::RoomEvent>, pub events_after: Vec<EventResult<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.
pub events_before: Vec<only::RoomEvent>, pub events_before: Vec<EventResult<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.
pub state: Vec<only::StateEvent>, pub state: Vec<EventResult<only::StateEvent>>,
} }
} }

View File

@ -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) //! [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_api::ruma_api;
use ruma_events::presence::PresenceEvent; use ruma_events::{presence::PresenceEvent, EventResult};
use ruma_identifiers::UserId; use ruma_identifiers::UserId;
ruma_api! { ruma_api! {
@ -23,6 +23,6 @@ ruma_api! {
response { response {
/// A list of presence events for every user on this list. /// A list of presence events for every user on this list.
#[ruma_api(body)] #[ruma_api(body)]
pub presence_events: Vec<PresenceEvent>, pub presence_events: Vec<EventResult<PresenceEvent>>,
} }
} }

View File

@ -4,7 +4,7 @@ use std::collections::HashMap;
use js_int::UInt; use js_int::UInt;
use ruma_api::ruma_api; 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 ruma_identifiers::{EventId, RoomId, UserId};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -91,10 +91,10 @@ pub struct EventContextResult {
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")]
pub events_after: Option<Vec<Event>>, pub events_after: Option<Vec<EventResult<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")]
pub events_before: Option<Vec<Event>>, pub events_before: Option<Vec<EventResult<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")]
@ -206,7 +206,7 @@ pub struct SearchResult {
/// 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.
pub result: Event, pub result: EventResult<Event>,
} }
/// A user profile. /// A user profile.

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, EventType}; use ruma_events::{room::message::MessageEventContent, EventResult, EventType};
use ruma_identifiers::{EventId, RoomId}; use ruma_identifiers::{EventId, RoomId};
ruma_api! { ruma_api! {
@ -30,7 +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)]
pub data: MessageEventContent, pub data: EventResult<MessageEventContent>, // FIXME
} }
response { response {

View File

@ -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) //! [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_api::ruma_api;
use ruma_events::room::member::MemberEvent; use ruma_events::{room::member::MemberEvent, EventResult};
use ruma_identifiers::RoomId; use ruma_identifiers::RoomId;
ruma_api! { ruma_api! {
@ -22,6 +22,6 @@ ruma_api! {
response { response {
/// A list of member events. /// A list of member events.
pub chunk: Vec<MemberEvent> pub chunk: Vec<EventResult<MemberEvent>>
} }
} }

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; use ruma_events::{collections::only, EventResult};
use ruma_identifiers::RoomId; use ruma_identifiers::RoomId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -46,7 +46,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.
pub chunk: Vec<only::RoomEvent>, pub chunk: Vec<EventResult<only::RoomEvent>>,
/// The token the pagination ends at. /// The token the pagination ends at.
pub end: String, pub end: String,
} }

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::only; use ruma_events::{collections::only, EventResult};
use ruma_identifiers::RoomId; use ruma_identifiers::RoomId;
ruma_api! { 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 /// 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)]
pub room_state: Vec<only::StateEvent>, pub room_state: Vec<EventResult<only::StateEvent>>,
} }
} }

View File

@ -6,7 +6,7 @@ use js_int::UInt;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_events::{ use ruma_events::{
collections::{all, only}, collections::{all, only},
stripped, stripped, EventResult,
}; };
use ruma_identifiers::RoomId; use ruma_identifiers::RoomId;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -172,28 +172,28 @@ pub struct Timeline {
/// `/rooms/{roomId}/messages` endpoint. /// `/rooms/{roomId}/messages` endpoint.
pub prev_batch: String, pub prev_batch: String,
/// A list of events. /// A list of events.
pub events: Vec<all::RoomEvent>, pub events: Vec<EventResult<all::RoomEvent>>,
} }
/// State events in the room. /// State events in the room.
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct State { pub struct State {
/// A list of state events. /// A list of state events.
pub events: Vec<only::StateEvent>, pub events: Vec<EventResult<only::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, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AccountData { pub struct AccountData {
/// A list of events. /// A list of events.
pub events: Vec<only::Event>, pub events: Vec<EventResult<only::Event>>,
} }
/// 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, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Ephemeral { pub struct Ephemeral {
/// A list of events. /// A list of events.
pub events: Vec<only::Event>, pub events: Vec<EventResult<only::Event>>,
} }
/// Updates to the rooms that the user has been invited to. /// Updates to the rooms that the user has been invited to.
@ -207,12 +207,12 @@ pub struct InvitedRoom {
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct InviteState { pub struct InviteState {
/// A list of state events. /// A list of state events.
pub events: Vec<stripped::StrippedState>, pub events: Vec<EventResult<stripped::StrippedState>>,
} }
/// Updates to the presence status of other users. /// Updates to the presence status of other users.
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Presence { pub struct Presence {
/// A list of events. /// A list of events.
pub events: Vec<only::Event>, pub events: Vec<EventResult<only::Event>>,
} }

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; use ruma_events::{tag::TagEventContent, EventResult};
use ruma_identifiers::{RoomId, UserId}; use ruma_identifiers::{RoomId, UserId};
ruma_api! { ruma_api! {
@ -25,6 +25,6 @@ ruma_api! {
response { response {
/// The user's tags for the room. /// The user's tags for the room.
pub tags: TagEventContent, pub tags: EventResult<TagEventContent>,
} }
} }