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§
Provided Methods§
Sourcefn match_bytes(bytes: &[u8]) -> Result<(), DescriptorError>
fn match_bytes(bytes: &[u8]) -> Result<(), DescriptorError>
Matches bytes with this descriptor.
On success it returns Ok(()).
On error it returns a DescriptorError.
Sourcefn match_bytes_len(_bytes: &[u8]) -> bool
fn match_bytes_len(_bytes: &[u8]) -> bool
Matches additional restrictions of the length.
By default, there are no additional restrictions.
Sourcefn prepare_bytes(bytes: &mut [u8], len: u8) -> Result<(), DescriptorError>where
Self: WritableDescriptor,
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.