Struct matrix_sdk::identities::UserIdentity [−][src]
pub struct UserIdentity { /* fields omitted */ }
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
pub async fn request_verification(
&self
) -> Result<VerificationRequest, RequestVerificationError>
pub async fn request_verification(
&self
) -> Result<VerificationRequest, RequestVerificationError>
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?;
}
pub async fn request_verification_with_methods(
&self,
methods: Vec<VerificationMethod>
) -> Result<VerificationRequest, RequestVerificationError>
pub async fn request_verification_with_methods(
&self,
methods: Vec<VerificationMethod>
) -> Result<VerificationRequest, RequestVerificationError>
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
Auto Trait Implementations
impl !RefUnwindSafe for UserIdentity
impl Send for UserIdentity
impl Sync for UserIdentity
impl Unpin for UserIdentity
impl !UnwindSafe for UserIdentity
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more