diff --git a/ruma-client-api/src/r0/alias/create_alias.rs b/ruma-client-api/src/r0/alias/create_alias.rs index 9863c2dc..bbb95e1f 100644 --- a/ruma-client-api/src/r0/alias/create_alias.rs +++ b/ruma-client-api/src/r0/alias/create_alias.rs @@ -13,6 +13,7 @@ ruma_api! { requires_authentication: true, } + #[non_exhaustive] request: { /// The room alias to set. #[ruma_api(path)] @@ -22,7 +23,22 @@ ruma_api! { pub room_id: &'a RoomId, } + #[non_exhaustive] response: {} error: crate::Error } + +impl<'a> Request<'a> { + /// Creates a new `Request` with the given room alias and room id. + pub fn new(room_alias: &'a RoomAliasId, room_id: &'a RoomId) -> Self { + Self { room_alias, room_id } + } +} + +impl Response { + /// Creates an empty `Response`. + pub fn new() -> Self { + Self + } +} diff --git a/ruma-client-api/src/r0/alias/delete_alias.rs b/ruma-client-api/src/r0/alias/delete_alias.rs index 2a275713..79ac592f 100644 --- a/ruma-client-api/src/r0/alias/delete_alias.rs +++ b/ruma-client-api/src/r0/alias/delete_alias.rs @@ -13,13 +13,29 @@ ruma_api! { requires_authentication: true, } + #[non_exhaustive] request: { /// The room alias to remove. #[ruma_api(path)] pub room_alias: &'a RoomAliasId, } + #[non_exhaustive] response: {} error: crate::Error } + +impl<'a> Request<'a> { + /// Creates a new `Request` with the given room alias. + pub fn new(room_alias: &'a RoomAliasId) -> Self { + Self { room_alias } + } +} + +impl Response { + /// Creates an empty `Response`. + pub fn new() -> Self { + Self + } +} diff --git a/ruma-client-api/src/r0/alias/get_alias.rs b/ruma-client-api/src/r0/alias/get_alias.rs index 7ef3486e..cccdb27d 100644 --- a/ruma-client-api/src/r0/alias/get_alias.rs +++ b/ruma-client-api/src/r0/alias/get_alias.rs @@ -13,12 +13,14 @@ ruma_api! { requires_authentication: true, } + #[non_exhaustive] request: { /// The room alias. #[ruma_api(path)] pub room_alias: &'a RoomAliasId, } + #[non_exhaustive] response: { /// The room ID for this room alias. pub room_id: RoomId, diff --git a/ruma-client-api/src/r0/room/create_room.rs b/ruma-client-api/src/r0/room/create_room.rs index 557d5904..01ae0070 100644 --- a/ruma-client-api/src/r0/room/create_room.rs +++ b/ruma-client-api/src/r0/room/create_room.rs @@ -114,6 +114,13 @@ impl Request { } } +impl Response { + /// Creates a `Response` with the given room id. + pub fn new(room_id: RoomId) -> Self { + Self { room_id } + } +} + /// Extra options to be added to the `m.room.create` event. /// /// This is the same as the event content struct for `m.room.create`, but without some fields that diff --git a/ruma-client-api/src/r0/session/get_login_types.rs b/ruma-client-api/src/r0/session/get_login_types.rs index 4447d359..aede69af 100644 --- a/ruma-client-api/src/r0/session/get_login_types.rs +++ b/ruma-client-api/src/r0/session/get_login_types.rs @@ -13,8 +13,10 @@ ruma_api! { requires_authentication: false, } + #[non_exhaustive] request: {} + #[non_exhaustive] response: { /// The homeserver's supported login types. pub flows: Vec @@ -23,6 +25,20 @@ ruma_api! { error: crate::Error } +impl Request { + /// Creates an empty `Request`. + pub fn new() -> Self { + Self + } +} + +impl Response { + /// Creates a new `Response` with the given login types. + pub fn new(flows: Vec) -> Self { + Self { flows } + } +} + /// An authentication mechanism. #[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)] #[serde(tag = "type")] diff --git a/ruma-client-api/src/r0/session/logout.rs b/ruma-client-api/src/r0/session/logout.rs index bc3f6067..921907ab 100644 --- a/ruma-client-api/src/r0/session/logout.rs +++ b/ruma-client-api/src/r0/session/logout.rs @@ -12,9 +12,25 @@ ruma_api! { requires_authentication: true, } + #[non_exhaustive] request: {} + #[non_exhaustive] response: {} error: crate::Error } + +impl Request { + /// Creates an empty `Request`. + pub fn new() -> Self { + Self + } +} + +impl Response { + /// Creates an empty `Response`. + pub fn new() -> Self { + Self + } +} diff --git a/ruma-client-api/src/r0/session/logout_all.rs b/ruma-client-api/src/r0/session/logout_all.rs index 5a92adda..b413e28b 100644 --- a/ruma-client-api/src/r0/session/logout_all.rs +++ b/ruma-client-api/src/r0/session/logout_all.rs @@ -12,9 +12,25 @@ ruma_api! { requires_authentication: true, } + #[non_exhaustive] request: {} + #[non_exhaustive] response: {} error: crate::Error } + +impl Request { + /// Creates an empty `Request`. + pub fn new() -> Self { + Self + } +} + +impl Response { + /// Creates an empty `Response`. + pub fn new() -> Self { + Self + } +}