From 646776b3628303ceb1910d8a24667302ca9aa5ff Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Mon, 15 Feb 2021 16:24:47 +0100 Subject: [PATCH] client-api: Add convenience constructors for uiaa::AuthData --- ruma-client-api/src/r0/uiaa.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ruma-client-api/src/r0/uiaa.rs b/ruma-client-api/src/r0/uiaa.rs index 5a70c90d..644291b7 100644 --- a/ruma-client-api/src/r0/uiaa.rs +++ b/ruma-client-api/src/r0/uiaa.rs @@ -48,6 +48,18 @@ pub enum AuthData<'a> { }, } +impl<'a> AuthData<'a> { + /// Creates a new `AuthData::DirectRequest` with the given login type. + pub fn direct_request(kind: &'a str) -> Self { + Self::DirectRequest { kind, session: None, auth_parameters: BTreeMap::new() } + } + + /// Creates a new `AuthData::FallbackAcknowledgement` with the given session key. + pub fn fallback_acknowledgement(session: &'a str) -> Self { + Self::FallbackAcknowledgement { session } + } +} + /// Information about available authentication flows and status for User-Interactive Authenticiation /// API. #[derive(Clone, Debug, Deserialize, Serialize)]