Struct Message

Source
pub struct Message {
    pub channel: u32,
    pub command: Command,
    pub sequence: u8,
    pub payload_len: usize,
    pub payload: Vec<u8>,
}
Expand description

A complete CTAP2 message, which is built from one or many packets.

The initial packet is an InitPacket then multiple ContPacket are used to populate a large payload which is larger than the maximum packet size.

Fields§

§channel: u32

Channel Identifier. This is 4 bytes, but the endianness is not defined by the spec hence we will simply use the native endianness since its actual value is just important on the wire.

§command: Command

Command identifier. This comes from the InitPacket.

§sequence: u8

Total number of continuation packets used to create this message. Used for internal state.

§payload_len: usize

Total Payload length. This is represented as a Big Endian u16 on the wire.

§payload: Vec<u8>

Payload bytes.

Implementations§

Source§

impl Message

Source

pub fn new( channel: u32, command: Command, data: &[u8], ) -> Result<Self, CreationError>

Create a new message for the given channel of the given command type with the data payload.

Source

pub fn send<W: Write>(self, writer: &mut W) -> Result<(), Error>

Send a message to the client by breaking it up into CTAP2 HID packets and sending them in sequence.

Trait Implementations§

Source§

impl Debug for Message

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.