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]
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]

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)
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<only::RoomEvent>,
/// A list of room events that happened just after the requested event, in chronological
/// 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
/// 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.
pub start: String,
/// 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)
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<PresenceEvent>,
pub presence_events: Vec<EventResult<PresenceEvent>>,
}
}

View File

@ -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<Vec<Event>>,
pub events_after: Option<Vec<EventResult<Event>>>,
/// Events just before the result.
#[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.
// 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<Event>,
}
/// 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)
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<MessageEventContent>, // FIXME
}
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)
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<MemberEvent>
pub chunk: Vec<EventResult<MemberEvent>>
}
}

View File

@ -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<only::RoomEvent>,
pub chunk: Vec<EventResult<only::RoomEvent>>,
/// The token the pagination ends at.
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)
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<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_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<all::RoomEvent>,
pub events: Vec<EventResult<all::RoomEvent>>,
}
/// State events in the room.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct State {
/// 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.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AccountData {
/// 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.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Ephemeral {
/// 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.
@ -207,12 +207,12 @@ pub struct InvitedRoom {
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct InviteState {
/// A list of state events.
pub events: Vec<stripped::StrippedState>,
pub events: Vec<EventResult<stripped::StrippedState>>,
}
/// Updates to the presence status of other users.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Presence {
/// 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)
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<TagEventContent>,
}
}