Struct matrix_sdk::identities::Device [−][src]
pub struct Device { /* fields omitted */ }
encryption
only.Expand description
A device represents a E2EE capable client or device of an user.
A device is backed by device keys that are uploaded to the server.
Implementations
Request an interactive verification with this Device
.
Returns a VerificationRequest
object that can be used to control the
verification flow.
The default methods that are supported are m.sas.v1
and
m.qr_code.show.v1
, if this isn’t desirable the
request_verification_with_methods()
method can be used to override
this. m.qr_code.show.v1
is only avaliable if the qrcode
feature is
enabled, which it is by default.
Examples
let device = client.get_device(&alice, "DEVICEID".into()).await?;
if let Some(device) = device {
let verification = device.request_verification().await?;
}
pub async fn request_verification_with_methods(
&self,
methods: Vec<VerificationMethod>
) -> Result<VerificationRequest>
pub async fn request_verification_with_methods(
&self,
methods: Vec<VerificationMethod>
) -> Result<VerificationRequest>
Request an interactive verification with this Device
.
Returns a VerificationRequest
object that can be used to control the
verification flow.
Arguments
methods
- The verification methods that we want to support. Must be non-empty.
Panics
This method will panic if methods
is empty.
Examples
let device = client.get_device(&alice, "DEVICEID".into()).await?;
// We don't want to support showing a QR code, we only support SAS
// verification
let methods = vec![VerificationMethod::SasV1];
if let Some(device) = device {
let verification = device.request_verification_with_methods(methods).await?;
}
👎 Deprecated since 0.4.0: directly starting a verification is deprecated in the spec. Users should instead use request_verification()
directly starting a verification is deprecated in the spec. Users should instead use request_verification()
Start an interactive verification with this Device
Returns a SasVerification
object that represents the interactive
verification flow.
This method has been deprecated in the spec and the
request_verification()
method should be used instead.
Examples
let device = client.get_device(&alice, "DEVICEID".into()).await?;
if let Some(device) = device {
let verification = device.start_verification().await?;
}
Manually verify this device.
This method will attempt to sign the device using our private cross signing key.
This method will always fail if the device belongs to someone else, we can only sign our own devices.
It can also fail if we don’t have the private part of our self-signing key.
The state of our private cross signing keys can be inspected using the
Client::cross_signing_status()
method.
Examples
let device = client.get_device(&alice, "DEVICEID".into()).await?;
if let Some(device) = device {
device.verify().await?;
}
Is the device considered to be verified.
A device is considered to be verified, either if it’s locally trusted, or if it’s signed by the appropriate cross signing key.
If the device belongs to our own userk, the device needs to be signed by our self-signing key and our own user identity needs to be verified.
If the device belongs to some other user, the device needs to be signed by the users signing key and the user identity of the user needs to be verified.
let user = client.get_user_identity(&alice).await?;
if let Some(user) = user {
if user.verified() {
println!("User {} is verified", user.user_id().as_str());
} else {
println!("User {} is not verified", user.user_id().as_str());
}
}
pub async fn set_local_trust(
&self,
trust_state: LocalTrust
) -> StdResult<(), CryptoStoreError>
pub async fn set_local_trust(
&self,
trust_state: LocalTrust
) -> StdResult<(), CryptoStoreError>
Set the local trust state of the device to the given state.
This won’t affect any cross signing trust state, this only sets a flag marking to have the given trust state.
Arguments
trust_state
- The new trust state that should be set for the device.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Device
impl !UnwindSafe for Device
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more