embassy-usb-host

Crates

git

Versions

default

Flavors

VariableSizeDescriptor

Trait VariableSizeDescriptor 

Source
pub trait VariableSizeDescriptor: USBDescriptor {
    const MIN_LEN: u8;
    const MAX_LEN: u8;

    // Provided methods
    fn match_bytes(bytes: &[u8]) -> Result<(), DescriptorError> { ... }
    fn match_bytes_len(_bytes: &[u8]) -> bool { ... }
    fn prepare_bytes(bytes: &mut [u8], len: u8) -> Result<(), DescriptorError>
       where Self: WritableDescriptor { ... }
}
Expand description

Variable size descriptor.

Implementors of this trait accept multiple sizes while reading or writing.

The minimum length and the maximum length restrictions are always checked. Other restrictions should be implemented in match_bytes_len.

Required Associated Constants§

Source

const MIN_LEN: u8

Minimum length of the descriptor.

This constant is compared against byte 0 of the buffer.

Source

const MAX_LEN: u8

Maximum length of the descriptor.

This constant is compared against byte 0 of the buffer.

Provided Methods§

Source

fn match_bytes(bytes: &[u8]) -> Result<(), DescriptorError>

Matches bytes with this descriptor.

On success it returns Ok(()). On error it returns a DescriptorError.

Source

fn match_bytes_len(_bytes: &[u8]) -> bool

Matches additional restrictions of the length.

By default, there are no additional restrictions.

Source

fn prepare_bytes(bytes: &mut [u8], len: u8) -> Result<(), DescriptorError>
where Self: WritableDescriptor,

Prepares bytes to receive descriptor data.

Fills in the descriptor length and type, and zeroes the rest.

It assumes that len matches the additional restrictions of the length.

On success, it returns Ok(()). On error, it returns a DescriptorError.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§