#[allow(non_snake_case)]
#[derive(Clone, Copy)]
pub struct Descriptor {
pub bmCapabilities: Capabilities,
pub bDataInterface: u8,
}
#[derive(Clone, Copy)]
pub struct Capabilities {
pub call_management: bool,
pub data_class: bool,
}
impl Capabilities {
fn byte(&self) -> u8 {
let mut byte = 0;
if self.call_management {
byte |= 1 << 0;
}
if self.data_class {
byte |= 1 << 1;
}
byte
}
}
impl Descriptor {
pub const SIZE: u8 = 5;
pub fn bytes(&self) -> [u8; Self::SIZE as usize] {
[
Self::SIZE,
super::CS_INTERFACE,
super::SUBTYPE_CALL,
self.bmCapabilities.byte(),
self.bDataInterface,
]
}
}