client-api: Move Direction to ruma-common::api
This commit is contained in:
parent
d0b2ed3609
commit
74c6e38a6b
@ -6,7 +6,7 @@ Breaking changes:
|
||||
* Use `sync::sync_events::DeviceLists` instead
|
||||
* `fully_read` field in `read_marker::set_read_marker` is no longer required
|
||||
* Remove the `fully_read` argument from `read_marker::set_read_marker::Request::new`
|
||||
* Move `message::get_message_events::v3::Direction` to the root of the crate
|
||||
* Move `message::get_message_events::v3::Direction` to `ruma-common::api`
|
||||
* Make `push::set_pusher::v3::Request` use an enum to differentiate when deleting a pusher
|
||||
* Move `push::get_pushers::v3::Pusher` to `push` and make it use the new `PusherIds` type
|
||||
* Remove `push::set_pusher::v3::Pusher` and use the common type instead
|
||||
|
@ -52,7 +52,6 @@ pub mod voip;
|
||||
use std::fmt;
|
||||
|
||||
pub use error::Error;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
// Wrapper around `Box<str>` that cannot be used in a meaningful way outside of
|
||||
// this crate. Used for string enums because their `_Custom` variant can't be
|
||||
@ -66,17 +65,3 @@ impl fmt::Debug for PrivOwnedStr {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
/// The direction to return events from.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
|
||||
#[allow(clippy::exhaustive_enums)]
|
||||
pub enum Direction {
|
||||
/// Return events backwards in time from the requested `from` token.
|
||||
#[default]
|
||||
#[serde(rename = "b")]
|
||||
Backward,
|
||||
|
||||
/// Return events forwards in time from the requested `from` token.
|
||||
#[serde(rename = "f")]
|
||||
Forward,
|
||||
}
|
||||
|
@ -9,14 +9,14 @@ pub mod v3 {
|
||||
|
||||
use js_int::{uint, UInt};
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
api::{request, response, Direction, Metadata},
|
||||
events::{AnyStateEvent, AnyTimelineEvent},
|
||||
metadata,
|
||||
serde::Raw,
|
||||
OwnedRoomId,
|
||||
};
|
||||
|
||||
use crate::{filter::RoomEventFilter, Direction};
|
||||
use crate::filter::RoomEventFilter;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: GET,
|
||||
@ -174,15 +174,12 @@ pub mod v3 {
|
||||
mod tests {
|
||||
use js_int::uint;
|
||||
use ruma_common::{
|
||||
api::{MatrixVersion, OutgoingRequest, SendAccessToken},
|
||||
api::{Direction, MatrixVersion, OutgoingRequest, SendAccessToken},
|
||||
room_id,
|
||||
};
|
||||
|
||||
use super::Request;
|
||||
use crate::{
|
||||
filter::{LazyLoadOptions, RoomEventFilter},
|
||||
Direction,
|
||||
};
|
||||
use crate::filter::{LazyLoadOptions, RoomEventFilter};
|
||||
|
||||
#[test]
|
||||
fn serialize_some_room_event_filter() {
|
||||
|
@ -9,15 +9,13 @@ pub mod v1 {
|
||||
|
||||
use js_int::UInt;
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
api::{request, response, Direction, Metadata},
|
||||
events::AnyMessageLikeEvent,
|
||||
metadata,
|
||||
serde::Raw,
|
||||
OwnedEventId, OwnedRoomId,
|
||||
};
|
||||
|
||||
use crate::Direction;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: GET,
|
||||
rate_limited: false,
|
||||
|
@ -8,12 +8,10 @@ pub mod unstable {
|
||||
//! [MSC3030]: https://github.com/matrix-org/matrix-spec-proposals/pull/3030
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Metadata},
|
||||
api::{request, response, Direction, Metadata},
|
||||
metadata, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId,
|
||||
};
|
||||
|
||||
use crate::Direction;
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: GET,
|
||||
rate_limited: true,
|
||||
@ -23,7 +21,7 @@ pub mod unstable {
|
||||
}
|
||||
};
|
||||
|
||||
/// Request type for the `get_event_for_timestamp` endpoint.
|
||||
/// Request type for the `get_event_by_timestamp` endpoint.
|
||||
#[request(error = crate::Error)]
|
||||
pub struct Request {
|
||||
/// The ID of the room the event is in.
|
||||
@ -39,7 +37,7 @@ pub mod unstable {
|
||||
pub dir: Direction,
|
||||
}
|
||||
|
||||
/// Response type for the `get_room_event` endpoint.
|
||||
/// Response type for the `get_event_by_timestamp` endpoint.
|
||||
#[response(error = crate::Error)]
|
||||
pub struct Response {
|
||||
/// The ID of the event found.
|
||||
|
@ -15,6 +15,7 @@
|
||||
use std::{convert::TryInto as _, error::Error as StdError};
|
||||
|
||||
use bytes::BufMut;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::UserId;
|
||||
|
||||
@ -421,6 +422,20 @@ pub enum AuthScheme {
|
||||
ServerSignatures,
|
||||
}
|
||||
|
||||
/// The direction to return events from.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
|
||||
#[allow(clippy::exhaustive_enums)]
|
||||
pub enum Direction {
|
||||
/// Return events backwards in time from the requested `from` token.
|
||||
#[default]
|
||||
#[serde(rename = "b")]
|
||||
Backward,
|
||||
|
||||
/// Return events forwards in time from the requested `from` token.
|
||||
#[serde(rename = "f")]
|
||||
Forward,
|
||||
}
|
||||
|
||||
/// Convenient constructor for [`Metadata`] constants.
|
||||
///
|
||||
/// Usage:
|
||||
|
Loading…
x
Reference in New Issue
Block a user