ruma_federation_api/event/get_event_by_timestamp/
unstable.rs1use ruma_common::{
6 api::{path_builder::SinglePath, request, response, Direction, Metadata},
7 MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId,
8};
9
10#[request]
12pub struct Request {
13 #[ruma_api(path)]
15 pub room_id: OwnedRoomId,
16
17 #[ruma_api(query)]
19 pub ts: MilliSecondsSinceUnixEpoch,
20
21 #[ruma_api(query)]
23 pub dir: Direction,
24}
25
26impl Request {
27 pub fn new(room_id: OwnedRoomId, ts: MilliSecondsSinceUnixEpoch, dir: Direction) -> Self {
29 Self { room_id, ts, dir }
30 }
31}
32
33impl Metadata for Request {
34 const METHOD: http::Method = super::v1::Request::METHOD;
35 const RATE_LIMITED: bool = super::v1::Request::RATE_LIMITED;
36 type Authentication = <super::v1::Request as Metadata>::Authentication;
37 type PathBuilder = <super::v1::Request as Metadata>::PathBuilder;
38 const PATH_BUILDER: Self::PathBuilder = SinglePath::new(
39 "/_matrix/federation/unstable/org.matrix.msc3030/timestamp_to_event/{room_id}",
40 );
41}
42
43impl From<super::v1::Request> for Request {
44 fn from(value: super::v1::Request) -> Self {
45 let super::v1::Request { room_id, ts, dir } = value;
46 Self { room_id, ts, dir }
47 }
48}
49
50impl From<Request> for super::v1::Request {
51 fn from(value: Request) -> Self {
52 let Request { room_id, ts, dir } = value;
53 Self { room_id, ts, dir }
54 }
55}
56
57#[response]
59pub struct Response {
60 pub event_id: OwnedEventId,
62
63 pub origin_server_ts: MilliSecondsSinceUnixEpoch,
65}
66
67impl Response {
68 pub fn new(event_id: OwnedEventId, origin_server_ts: MilliSecondsSinceUnixEpoch) -> Self {
70 Self { event_id, origin_server_ts }
71 }
72}
73
74impl From<super::v1::Response> for Response {
75 fn from(value: super::v1::Response) -> Self {
76 let super::v1::Response { event_id, origin_server_ts } = value;
77 Self { event_id, origin_server_ts }
78 }
79}
80
81impl From<Response> for super::v1::Response {
82 fn from(value: Response) -> Self {
83 let Response { event_id, origin_server_ts } = value;
84 Self { event_id, origin_server_ts }
85 }
86}