diff --git a/ruma-client-api/src/lib.rs b/ruma-client-api/src/lib.rs index cc57eb98..22b5a1c0 100644 --- a/ruma-client-api/src/lib.rs +++ b/ruma-client-api/src/lib.rs @@ -3,6 +3,7 @@ //! shared by client and server code. #![deny(missing_copy_implementations, missing_debug_implementations, missing_docs)] +#![allow(clippy::new_without_default)] pub mod error; pub mod r0; diff --git a/ruma-client-api/src/unversioned/discover_homeserver.rs b/ruma-client-api/src/unversioned/discover_homeserver.rs index b82ef0de..dee2c267 100644 --- a/ruma-client-api/src/unversioned/discover_homeserver.rs +++ b/ruma-client-api/src/unversioned/discover_homeserver.rs @@ -28,16 +28,46 @@ ruma_api! { error: crate::Error } +impl Request { + /// Creates an empty `Request`. + pub fn new() -> Self { + Self + } +} + +impl Response { + /// Creates a `Response` with the given `HomeserverInfo`. + pub fn new(homeserver: HomeserverInfo) -> Self { + Self { homeserver, identity_server: None } + } +} + /// Information about a discovered homeserver. #[derive(Clone, Debug, Deserialize, Hash, PartialEq, PartialOrd, Serialize)] +#[non_exhaustive] pub struct HomeserverInfo { /// The base URL for the homeserver for client-server connections. pub base_url: String, } +impl HomeserverInfo { + /// Creates a `HomeserverInfo` with the given `base_url`. + pub fn new(base_url: String) -> Self { + Self { base_url } + } +} + /// Information about a discovered identity server. #[derive(Clone, Debug, Deserialize, Hash, PartialEq, PartialOrd, Serialize)] +#[non_exhaustive] pub struct IdentityServerInfo { /// The base URL for the identity server for client-server connections. pub base_url: String, } + +impl IdentityServerInfo { + /// Creates an `IdentityServerInfo` with the given `base_url`. + pub fn new(base_url: String) -> Self { + Self { base_url } + } +} diff --git a/ruma-client-api/src/unversioned/get_supported_versions.rs b/ruma-client-api/src/unversioned/get_supported_versions.rs index f248c17e..9f9f692b 100644 --- a/ruma-client-api/src/unversioned/get_supported_versions.rs +++ b/ruma-client-api/src/unversioned/get_supported_versions.rs @@ -27,3 +27,17 @@ ruma_api! { error: crate::Error } + +impl Request { + /// Creates an empty `Request`. + pub fn new() -> Self { + Self + } +} + +impl Response { + /// Creates a `Response` with the given `versions`. + pub fn new(versions: Vec) -> Self { + Self { versions, unstable_features: BTreeMap::new() } + } +}