client-api: Add constructors for the types in unversioned
This commit is contained in:
parent
4abcc4c0bd
commit
f9639e110e
@ -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;
|
||||
|
@ -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 }
|
||||
}
|
||||
}
|
||||
|
@ -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<String>) -> Self {
|
||||
Self { versions, unstable_features: BTreeMap::new() }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user