diff --git a/crates/ruma-federation-api/src/membership/create_invite/v1.rs b/crates/ruma-federation-api/src/membership/create_invite/v1.rs index b6a0f2df..4f8f04a0 100644 --- a/crates/ruma-federation-api/src/membership/create_invite/v1.rs +++ b/crates/ruma-federation-api/src/membership/create_invite/v1.rs @@ -110,7 +110,7 @@ pub struct RequestInit<'a> { } impl<'a> From> for Request<'a> { - /// Creates a new `Request` with the given parameters. + /// Creates a new `Request` from `RequestInit`. fn from(init: RequestInit<'a>) -> Self { Self { room_id: init.room_id, diff --git a/crates/ruma-federation-api/src/membership/create_invite/v2.rs b/crates/ruma-federation-api/src/membership/create_invite/v2.rs index 11761c70..058f8f4f 100644 --- a/crates/ruma-federation-api/src/membership/create_invite/v2.rs +++ b/crates/ruma-federation-api/src/membership/create_invite/v2.rs @@ -41,7 +41,8 @@ ruma_api! { } impl Request { - /// Creates a new `Request` with the given parameters. + /// Creates a new `Request` with the given room ID, event ID, room version, event and invite + /// room state. pub fn new( room_id: RoomId, event_id: EventId, diff --git a/crates/ruma-federation-api/src/membership/create_leave_event/v1.rs b/crates/ruma-federation-api/src/membership/create_leave_event/v1.rs index bc43c69b..d91b7dc7 100644 --- a/crates/ruma-federation-api/src/membership/create_leave_event/v1.rs +++ b/crates/ruma-federation-api/src/membership/create_leave_event/v1.rs @@ -68,29 +68,55 @@ ruma_api! { } } -impl<'a> Request<'a> { - /// Creates a new `Request` with: - /// * the room ID that is about to be left. - /// * the event ID for the leave event. - /// * the user ID of the leaving member. - /// * the name of the leaving homeserver. - /// * a timestamp added by the leaving homeserver. - /// * the value `m.room.member`. - /// * the user ID of the leaving member. - /// * the content of the event. - /// * this field must be present but is ignored; it may be 0. - #[allow(clippy::too_many_arguments)] - pub fn new( - room_id: &'a RoomId, - event_id: &'a EventId, - sender: &'a UserId, - origin: &'a ServerName, - origin_server_ts: MilliSecondsSinceUnixEpoch, - event_type: EventType, - state_key: &'a str, - content: Raw, - depth: UInt, - ) -> Self { +/// Initial set of fields of `Request`. +/// +/// This struct will not be updated even if additional fields are added to `Request` in a +/// new (non-breaking) release of the Matrix specification. +#[derive(Debug)] +#[allow(clippy::exhaustive_structs)] +pub struct RequestInit<'a> { + /// The room ID that is about to be left. + pub room_id: &'a RoomId, + + /// The event ID for the leave event. + pub event_id: &'a EventId, + + /// The user ID of the leaving member. + pub sender: &'a UserId, + + /// The name of the leaving homeserver. + pub origin: &'a ServerName, + + /// A timestamp added by the leaving homeserver. + pub origin_server_ts: MilliSecondsSinceUnixEpoch, + + /// The value `m.room.member`. + pub event_type: EventType, + + /// The user ID of the leaving member. + pub state_key: &'a str, + + /// The content of the event. + pub content: Raw, + + /// This field must be present but is ignored; it may be 0. + pub depth: UInt, +} + +impl<'a> From> for Request<'a> { + /// Creates a new `Request` from `RequestInit`. + fn from(init: RequestInit<'a>) -> Self { + let RequestInit { + room_id, + event_id, + sender, + origin, + origin_server_ts, + event_type, + state_key, + content, + depth, + } = init; Self { room_id, event_id,