embassy/embassy-usb/src/types.rs

38 lines
863 B
Rust
Raw Normal View History

2023-01-31 22:27:19 +01:00
//! USB types.
2022-03-09 01:34:35 +01:00
/// A handle for a USB interface that contains its number.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
2022-03-09 01:34:35 +01:00
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
2023-02-07 23:45:01 +01:00
#[repr(transparent)]
pub struct InterfaceNumber(pub u8);
2022-03-09 01:34:35 +01:00
impl InterfaceNumber {
2023-10-15 23:45:44 +02:00
pub(crate) const fn new(index: u8) -> InterfaceNumber {
2022-03-09 01:34:35 +01:00
InterfaceNumber(index)
}
}
impl From<InterfaceNumber> for u8 {
fn from(n: InterfaceNumber) -> u8 {
n.0
}
}
/// A handle for a USB string descriptor that contains its index.
#[derive(Copy, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
2023-02-07 23:45:01 +01:00
#[repr(transparent)]
pub struct StringIndex(pub u8);
2022-03-09 01:34:35 +01:00
impl StringIndex {
2023-10-15 23:45:44 +02:00
pub(crate) const fn new(index: u8) -> StringIndex {
2022-03-09 01:34:35 +01:00
StringIndex(index)
}
}
impl From<StringIndex> for u8 {
fn from(i: StringIndex) -> u8 {
i.0
}
}