pub struct AddressPool { /* private fields */ }Expand description
The addresses handed out to enumerated devices.
Address zero is reserved for enumeration and never handed out; the pool
tracks 1 through 126. A root-port device and every device behind a hub need
an address of their own, so a host that supports hubs keeps one of these
and hands each Device the address it was enumerated at.
Implementations§
Source§impl AddressPool
impl AddressPool
Sourcepub fn take(&mut self) -> Option<DeviceAddress>
pub fn take(&mut self) -> Option<DeviceAddress>
Take the lowest free address, or None when all 126 are in use.
Sourcepub fn reserve(&mut self, address: DeviceAddress)
pub fn reserve(&mut self, address: DeviceAddress)
Mark address as used, for a device that was enumerated by the
application rather than taken from this pool.
Sourcepub fn release(&mut self, address: DeviceAddress)
pub fn release(&mut self, address: DeviceAddress)
Give address back when the device is unplugged.
Sourcepub fn is_used(&self, address: DeviceAddress) -> bool
pub fn is_used(&self, address: DeviceAddress) -> bool
Whether address has been taken or reserved.
Trait Implementations§
Auto Trait Implementations§
impl Forget for AddressPool
impl Freeze for AddressPool
impl Move for AddressPool
impl RefUnwindSafe for AddressPool
impl Send for AddressPool
impl Sync for AddressPool
impl Unpin for AddressPool
impl UnsafeUnpin for AddressPool
impl UnwindSafe for AddressPool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more