const FLAG_REMOTE_WAKEUP: u8 = 0x20;
const FLAG_SELF_POWERED: u8 = 0x40;
pub struct PowerConfig {
flags: u8,
max_power: u16,
}
impl PowerConfig {
pub(crate) fn new(flags: u8, max_power: u16) -> Self {
Self { flags, max_power }
}
#[must_use]
pub fn bus_powered(&self) -> bool {
!self.self_powered()
}
#[must_use]
pub fn self_powered(&self) -> bool {
self.flags & FLAG_SELF_POWERED != 0
}
#[must_use]
pub fn remote_wakeup(&self) -> bool {
self.flags & FLAG_REMOTE_WAKEUP != 0
}
#[must_use]
pub fn max_power(&self) -> u16 {
self.max_power * 2 }
}