#[non_exhaustive]pub enum LoginProtocolData {
Msc4108DeviceAuthorizationGrant(AuthorizationGrant),
Msc4388DeviceAuthorizationGrant(AuthorizationGrant),
Unknown(UnknownLoginProtocol),
}e2e-encryption only.Expand description
The login protocol the new device has picked in a
QrAuthMessage::LoginProtocol message, along with the data specific to
that protocol.
On the wire, the protocol name is in the protocol field, and the protocol
specific fields sit next to it, like other Matrix structures keyed on a
discriminator field.
For the device_authorization_grant protocol, clients using the MSC4108
variant of the secure channel instead nest the data in a field named after
the protocol, i.e. "protocol": "device_authorization_grant" comes with a
"device_authorization_grant": { ... } field. Which layout is used depends
on the variant of the secure channel.
Like other known message types, a known protocol only keeps the fields it
knows about, while an UnknownLoginProtocol keeps all the fields, as we
don’t know which ones are relevant.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Msc4108DeviceAuthorizationGrant(AuthorizationGrant)
The device_authorization_grant login protocol, as sent over the
MSC4108 variant of the secure channel, with the data nested in a
device_authorization_grant field.
Contains the device authorization grant the OAuth 2.0 server has given to the new device, with the URL the existing device should use to confirm the log in.
Msc4388DeviceAuthorizationGrant(AuthorizationGrant)
The device_authorization_grant login protocol, as sent over the
MSC4388 variant of the secure channel, with the data next to the
protocol field.
Contains the device authorization grant the OAuth 2.0 server has given to the new device, with the URL the existing device should use to confirm the log in.
Unknown(UnknownLoginProtocol)
An unknown and unsupported login protocol.
Implementations§
Source§impl LoginProtocolData
impl LoginProtocolData
Sourcepub fn new(protocol: LoginProtocolType, data: JsonObject) -> Result<Self, Error>
pub fn new(protocol: LoginProtocolType, data: JsonObject) -> Result<Self, Error>
Create a new LoginProtocolData from the given login protocol and its
data.
The data contains the fields of the QrAuthMessage::LoginProtocol
message other than type, protocol and device_id. If the protocol
is a known one, the data is deserialized into the corresponding
variant and only the fields that protocol knows about are kept.
Otherwise a LoginProtocolData::Unknown is created, which keeps all
the fields verbatim.
For the LoginProtocolType::DeviceAuthorizationGrant protocol, the
layout is detected from the data: if it contains a
device_authorization_grant field, a
LoginProtocolData::Msc4108DeviceAuthorizationGrant is created,
otherwise a LoginProtocolData::Msc4388DeviceAuthorizationGrant.
Returns an error if the protocol is a known one and the data is not
valid for it, or if the protocol is unknown and the data contains one
of the type, protocol or device_id fields, as they would clash
with the fields of the message when serialized.
Sourcepub fn protocol(&self) -> LoginProtocolType
pub fn protocol(&self) -> LoginProtocolType
Get the login protocol.
Trait Implementations§
Source§impl Clone for LoginProtocolData
impl Clone for LoginProtocolData
Source§impl Debug for LoginProtocolData
impl Debug for LoginProtocolData
Source§impl<'de> Deserialize<'de> for LoginProtocolData
impl<'de> Deserialize<'de> for LoginProtocolData
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for LoginProtocolData
impl RefUnwindSafe for LoginProtocolData
impl Send for LoginProtocolData
impl Sync for LoginProtocolData
impl Unpin for LoginProtocolData
impl UnsafeUnpin for LoginProtocolData
impl UnwindSafe for LoginProtocolData
Blanket Implementations§
impl<T> AsyncTraitDeps for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
Source§impl<T> DeserialiseFromJs for Twhere
T: DeserializeOwned,
impl<T> DeserialiseFromJs for Twhere
T: DeserializeOwned,
Source§fn deserialise_from_js(js: JsValue) -> Result<T, Error>
fn deserialise_from_js(js: JsValue) -> Result<T, Error>
serde_wasm_bindgen.impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> Fruit for T
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> JsonCastable<CanonicalJsonValue> for T
impl<T> JsonCastable<Value> for T
impl<T> MaybeSendSync for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> SendOutsideWasm for Twhere
T: Send,
Source§impl<T> SerialiseToJs for Twhere
T: Serialize,
impl<T> SerialiseToJs for Twhere
T: Serialize,
Source§fn serialise_to_js(&self) -> Result<JsValue, Error>
fn serialise_to_js(&self) -> Result<JsValue, Error>
JsValue, most likely using serde_wasm_bindgen.