pub enum QrVerificationData {
    Verification(VerificationData),
    SelfVerification(SelfVerificationData),
    SelfVerificationNoMasterKey(SelfVerificationNoMasterKey),
}
Expand description

An enum representing the different modes a QR verification can be in.

Variants

Verification(VerificationData)

The QR verification is verifying another user

SelfVerification(SelfVerificationData)

The QR verification is self-verifying and the current device trusts or owns the master key

SelfVerificationNoMasterKey(SelfVerificationNoMasterKey)

The QR verification is self-verifying in which the current device does not yet trust the master key

Implementations

Decode and parse an image of a QR code into a QrVerificationData

The image will be converted into a grey scale image before decoding is attempted

Arguments
  • image - The image containing the QR code.
Example
use image;

let image = image::open("/path/to/my/image.png").unwrap();
let result = QrVerificationData::from_image(image)?;

Decode and parse an grey scale image of a QR code into a QrVerificationData

Arguments
  • image - The grey scale image containing the QR code.
Example
use image;

let image = image::open("/path/to/my/image.png").unwrap();
let image = image.to_luma8();
let result = QrVerificationData::from_luma(image)?;

Parse the decoded payload of a QR code in byte slice form as a QrVerificationData

This method is useful if you would like to do your own custom QR code decoding.

Arguments
  • bytes - The raw bytes of a decoded QR code.
Example
let data = b"MATRIX\
             \x02\x02\x00\x07\
             FLOW_ID\
             kS /\x92i\x1e6\xcd'g\xf9#\x11\xd8\x8a\xa2\xf61\x05\x1b6\xef\xfc\xa4%\x80\x1a\x0c\xd2\xe8\x04\
             \xbdR|\xf8n\x07\xa4\x1f\xb4\xcc3\x0eBT\xe7[~\xfd\x87\xd06B\xdfoVv%\x9b\x86\xae\xbcM\
             SHARED_SECRET";

let result = QrVerificationData::from_bytes(data)?;

Encode the QrVerificationData into a QrCode.

This method turns the QrVerificationData into a QR code that can be rendered and presented to be scanned.

The encoding can fail if the data doesn’t fit into a QR code or if the identity keys that should be encoded into the QR code are not valid base64.

Example
let data = b"MATRIX\
             \x02\x02\x00\x07\
             FLOW_ID\
             kS /\x92i\x1e6\xcd'g\xf9#\x11\xd8\x8a\xa2\xf61\x05\x1b6\xef\xfc\xa4%\x80\x1a\x0c\xd2\xe8\x04\
             \xbdR|\xf8n\x07\xa4\x1f\xb4\xcc3\x0eBT\xe7[~\xfd\x87\xd06B\xdfoVv%\x9b\x86\xae\xbcM\
             SHARED_SECRET";

let result = QrVerificationData::from_bytes(data)?;
let encoded = result.to_qr_code().unwrap();

Encode the QrVerificationData into a vector of bytes that can be encoded as a QR code.

The encoding can fail if the identity keys that should be encoded are not valid base64.

Example
let data = b"MATRIX\
             \x02\x02\x00\x07\
             FLOW_ID\
             kS /\x92i\x1e6\xcd'g\xf9#\x11\xd8\x8a\xa2\xf61\x05\x1b6\xef\xfc\xa4%\x80\x1a\x0c\xd2\xe8\x04\
             \xbdR|\xf8n\x07\xa4\x1f\xb4\xcc3\x0eBT\xe7[~\xfd\x87\xd06B\xdfoVv%\x9b\x86\xae\xbcM\
             SHARED_SECRET";

let result = QrVerificationData::from_bytes(data)?;
let encoded = result.to_bytes().unwrap();

assert_eq!(data.as_ref(), encoded.as_slice());

Get the flow id for this QrVerificationData.

This represents the ID as a string even if it is a EventId.

Get the first key of this QrVerificationData.

Get the second key of this QrVerificationData.

Get the secret of this QrVerificationData.

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

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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.

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.

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

Returns the argument unchanged.

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

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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)

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.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more