From 417b65def5f674aa70a313944abe052558ea624e Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 21 Aug 2020 20:40:07 +0200 Subject: [PATCH] client-api: Make two more request / response pairs non-exhaustive --- ruma-client-api/src/r0/session/sso_login.rs | 18 +++++++++++++++++- .../src/r0/user_directory/search_users.rs | 16 ++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/ruma-client-api/src/r0/session/sso_login.rs b/ruma-client-api/src/r0/session/sso_login.rs index 6e740112..98f8dba6 100644 --- a/ruma-client-api/src/r0/session/sso_login.rs +++ b/ruma-client-api/src/r0/session/sso_login.rs @@ -13,13 +13,15 @@ ruma_api! { } + #[non_exhaustive] request: { /// URL to which the homeserver should return the user after completing /// authentication with the SSO identity provider. #[ruma_api(query)] - pub redirect_url: String, + pub redirect_url: &'a str, } + #[non_exhaustive] response: { /// Redirect URL to the SSO identity provider. #[ruma_api(header = LOCATION)] @@ -28,3 +30,17 @@ ruma_api! { error: crate::Error } + +impl<'a> Request<'a> { + /// Creates a new `Request` with the given redirect URL. + pub fn new(redirect_url: &'a str) -> Self { + Self { redirect_url } + } +} + +impl Response { + /// Creates a new `Response` with the given SSO URL. + pub fn new(location: String) -> Self { + Self { location } + } +} diff --git a/ruma-client-api/src/r0/user_directory/search_users.rs b/ruma-client-api/src/r0/user_directory/search_users.rs index 99b0c966..35e177a4 100644 --- a/ruma-client-api/src/r0/user_directory/search_users.rs +++ b/ruma-client-api/src/r0/user_directory/search_users.rs @@ -15,6 +15,7 @@ ruma_api! { requires_authentication: true, } + #[non_exhaustive] request: { /// The term to search for. pub search_term: &'a str, @@ -34,6 +35,7 @@ ruma_api! { pub language: Option, } + #[non_exhaustive] response: { /// Ordered by rank and then whether or not profile info is available. pub results: Vec, @@ -45,6 +47,20 @@ ruma_api! { error: crate::Error } +impl<'a> Request<'a> { + /// Creates a new `Request` with the given search term. + pub fn new(search_term: &'a str) -> Self { + Self { search_term, limit: default_limit(), language: None } + } +} + +impl Response { + /// Creates a new `Response` with the given results and limited flag + pub fn new(results: Vec, limited: bool) -> Self { + Self { results, limited } + } +} + fn default_limit() -> UInt { uint!(10) }