Skip to main content

Hub

Struct Hub 

Source
pub struct Hub<'d, 'a, C: HostController> { /* private fields */ }
Expand description

An enumerated hub.

Implementations§

Source§

impl<'d, 'a, C: HostController> Hub<'d, 'a, C>

Source

pub fn open(device: &'a Device<'d, C>) -> HostResult<Self>

Select the hub’s configuration and read its class descriptor.

The hub keeps answering control requests either way, but its downstream ports cannot be powered before SET_CONFIGURATION.

Source

pub fn device(&self) -> &'a Device<'d, C>

The hub device that was enumerated.

Source

pub fn descriptor(&self) -> &HubDescriptor

The class descriptor read in open.

Source

pub fn ports(&self) -> u8

Number of downstream ports.

Source

pub fn power_ports(&self) -> HostResult<()>

Power every downstream port that is not powered yet and wait for bPwrOn2PwrGood to elapse.

A ganged hub powers all ports from one switch, so the first request already powers the rest; asking port by port is harmless and keeps the driver independent of the switching mode.

Source

pub fn port_status(&self, port: u8) -> HostResult<HubPortStatus>

Read wPortStatus and wPortChange of port.

Source

pub fn clear_port_change(&self, port: u8, change: u16) -> HostResult<()>

Clear every change bit in change.

The change bits of wPortChange map one to one onto the C_PORT_* feature selectors, which is why the selector is the bit position plus the selector of C_PORT_CONNECTION.

Source

pub fn wait_for_connection( &self, port: u8, timeout_ms: u32, ) -> HostResult<HubPortStatus>

Wait until a device is attached to port.

Source

pub fn reset_port(&self, port: u8) -> HostResult<Speed>

Reset port and report the speed of the device behind it.

This is what the root port’s reset_port does for the hub itself: the device answers at address zero afterwards and has to be enumerated with enumerate_child.

Source

pub fn enumerate_child( &self, port: u8, address: DeviceAddress, ) -> HostResult<Device<'d, C>>

Enumerate the device attached to port at address.

The port must have been reset with reset_port first.

Auto Trait Implementations§

§

impl<'d, 'a, C> Forget for Hub<'d, 'a, C>

§

impl<'d, 'a, C> Freeze for Hub<'d, 'a, C>
where &'a Device<'d, C>: Freeze,

§

impl<'d, 'a, C> Move for Hub<'d, 'a, C>

§

impl<'d, 'a, C> RefUnwindSafe for Hub<'d, 'a, C>
where &'a Device<'d, C>: RefUnwindSafe,

§

impl<'d, 'a, C> Send for Hub<'d, 'a, C>
where &'a Device<'d, C>: Send,

§

impl<'d, 'a, C> Sync for Hub<'d, 'a, C>
where &'a Device<'d, C>: Sync,

§

impl<'d, 'a, C> Unpin for Hub<'d, 'a, C>
where &'a Device<'d, C>: Unpin,

§

impl<'d, 'a, C> UnsafeUnpin for Hub<'d, 'a, C>
where &'a Device<'d, C>: UnsafeUnpin,

§

impl<'d, 'a, C> UnwindSafe for Hub<'d, 'a, C>
where &'a Device<'d, C>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.