Struct matrix_sdk::identities::UserIdentity[][src]

pub struct UserIdentity { /* fields omitted */ }
This is supported on encryption only.
Expand description

A struct representing a E2EE capable identity of a user.

The identity is backed by public cross signing keys that users upload.

Implementations

The ID of the user this E2EE identity belongs to.

Request an interacitve verification with this UserIdentity.

Returns a VerificationRequest object that can be used to control the verification flow.

This will send out a m.key.verification.request event to all the E2EE capable devices we have if we’re requesting verification with our own user identity or will send out the event to a DM we share with the user.

If we don’t share a DM with this user one will be created before the event gets sent out.

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 user = client.get_user_identity(&alice).await?;

if let Some(user) = user {
    let verification = user.request_verification().await?;
}

Request an interacitve verification with this UserIdentity.

Returns a VerificationRequest object that can be used to control the verification flow.

This methods behaves the same way as request_verification(), but the advertised verification methods can be manually selected.

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 user = client.get_user_identity(&alice).await?;

// We don't want to support showing a QR code, we only support SAS
// verification
let methods = vec![VerificationMethod::SasV1];

if let Some(user) = user {
    let verification = user.request_verification_with_methods(methods).await?;
}

Manually verify this UserIdentity.

This method will attempt to sign the user identity using our private cross signing key. Verifying can fail if we don’t have the private part of our user-signing key.

The state of our private cross signing keys can be inspected using the Client::cross_signing_status() method.

Examples

let user = client.get_user_identity(&alice).await?;

if let Some(user) = user {
    user.verify().await?;
}

Is the user identity considered to be verified.

A user identity is considered to be verified if it has been signed by our user-signing key, if the identity belongs to another user, or if we locally marked it as verified, if the user identity belongs to us.

If the identity belongs to another user, our own user identity needs to be verified as well for the identity to be considered to be verified.

Examples

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());
    }
}

Get the public part of the master key of this user identity.

Examples

let user = client.get_user_identity(&alice).await?;

if let Some(user) = user {
    // Let's verify the user after we confirm that the master key
    // matches what we expect, for this we fetch the first public key we
    // can find, there's currently only a single key allowed so this is
    // fine.
    if user.master_key().get_first_key() == Some("MyMasterKey") {
        println!(
            "Master keys match for user {}, marking the user as verified",
            user.user_id().as_str(),
        );
        user.verify().await?;
    } else {
        println!("Master keys don't match for user {}", user.user_id().as_str());
    }
}

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.