pub struct Bus {
pub name: String,
pub host_controller: String,
pub host_controller_vendor: Option<String>,
pub host_controller_device: Option<String>,
pub pci_vendor: Option<u16>,
pub pci_device: Option<u16>,
pub pci_revision: Option<u16>,
pub usb_bus_number: Option<u8>,
pub devices: Option<Vec<Device>>,
/* private fields */
}Expand description
USB bus returned from system_profiler but now used for other platforms.
It is a merging of the PCI Host Controller information and root hub device data (if present). Essentially a root hub but not as a pseudo device but an explicit type - since the root hub is a bit confusing in that sense.
Fields§
§name: StringSystem internal bus name based on Root Hub device name
Normally something generic like ‘Root Hub’, ‘USB 3.0 Bus’
host_controller: StringSystem internal bus provider name
host_controller_vendor: Option<String>Vendor name of PCI Host Controller from pci.ids
host_controller_device: Option<String>Device name of PCI Host Controller from pci.ids
pci_vendor: Option<u16>PCI vendor ID (VID)
pci_device: Option<u16>PCI device ID (PID)
pci_revision: Option<u16>PCI Revsision ID
usb_bus_number: Option<u8>Number of bus on system
devices: Option<Vec<Device>>Devices on the Bus. Since a device can have devices too, need to walk down all devices to get all devices on the bus
On Linux, the root hub is also included in this list
Implementations§
Source§impl Bus
Returns of Vec of devices in the Bus as a reference
impl Bus
Returns of Vec of devices in the Bus as a reference
Sourcepub fn into_flattened_devices(&mut self)
pub fn into_flattened_devices(&mut self)
Flattens the bus by copying each device into a new devices Vec
Unlike the flattened_devices which returns references that may still contain a Vec of Device, this function makes those None too since it is doing a hard copy.
Not very pretty or efficient, probably a better way…
Sourcepub fn flattened_devices(&self) -> Vec<&Device>
pub fn flattened_devices(&self) -> Vec<&Device>
Returns a flattened Vec of references to all Devices on the bus
Note that whilst Vec of references is flat, the Devices still contain a devices Vec where the references point; recursive functions on the returned Vec will produce weird results
Sourcepub fn has_empty_hubs(&self) -> bool
pub fn has_empty_hubs(&self) -> bool
Whether the bus has just empty hubs
Sourcepub fn get_bus_number(&self) -> Option<u8>
pub fn get_bus_number(&self) -> Option<u8>
usb_bus_number is not always present in system_profiler output so try to get from first device instead
Sourcepub fn interface(&self) -> Option<DevicePath>
pub fn interface(&self) -> Option<DevicePath>
sysfs style path to bus interface
Sourcepub fn remove_root_hub_device(&mut self)
pub fn remove_root_hub_device(&mut self)
Remove the root_hub if existing in bus
Sourcepub fn get_root_hub_device(&self) -> Option<&Device>
pub fn get_root_hub_device(&self) -> Option<&Device>
Gets the device that is the root_hub associated with this bus - Linux only but exists in case of using –from-json
Sourcepub fn get_root_hub_device_mut(&mut self) -> Option<&mut Device>
pub fn get_root_hub_device_mut(&mut self) -> Option<&mut Device>
Gets a mutable device that is the root_hub associated with this bus - Linux only but exists in case of using –from-json
Sourcepub fn get_node(&self, port_path: &PortPath) -> Option<&Device>
pub fn get_node(&self, port_path: &PortPath) -> Option<&Device>
Search for Device in branches of bus and return reference
Sourcepub fn get_node_mut(&mut self, port_path: &PortPath) -> Option<&mut Device>
pub fn get_node_mut(&mut self, port_path: &PortPath) -> Option<&mut Device>
Search for Device in branches of bus and return mutable if found
Sourcepub fn get_node_by_path<P: AsRef<Path>>(&self, port_path: P) -> Option<&Device>
pub fn get_node_by_path<P: AsRef<Path>>(&self, port_path: P) -> Option<&Device>
Search for Device in branches of bus by Path and return reference
Sourcepub fn get_node_path_by_path_mut<P: AsRef<Path>>(
&mut self,
port_path: P,
) -> Option<&mut Device>
pub fn get_node_path_by_path_mut<P: AsRef<Path>>( &mut self, port_path: P, ) -> Option<&mut Device>
Search for Device in branches of bus by Path and return mutable reference
Sourcepub fn get_node_by_str(&self, path: &str) -> Option<&Device>
pub fn get_node_by_str(&self, path: &str) -> Option<&Device>
Search for reference to Device at port path as string
Sourcepub fn get_node_str_mut(&mut self, path: &str) -> Option<&mut Device>
pub fn get_node_str_mut(&mut self, path: &str) -> Option<&mut Device>
Search for mutable reference to Device at port path as string
Sourcepub fn get_config(
&self,
port_path: &PortPath,
config: u8,
) -> Option<&Configuration>
pub fn get_config( &self, port_path: &PortPath, config: u8, ) -> Option<&Configuration>
Get reference to Configuration at PortPath and config if present
Sourcepub fn get_config_mut(
&mut self,
port_path: &PortPath,
config: u8,
) -> Option<&mut Configuration>
pub fn get_config_mut( &mut self, port_path: &PortPath, config: u8, ) -> Option<&mut Configuration>
Get mutable reference to Configuration at PortPath and config if present
Sourcepub fn get_interface(&self, device_path: &DevicePath) -> Option<&Interface>
pub fn get_interface(&self, device_path: &DevicePath) -> Option<&Interface>
Get reference to Interface at DevicePath if config and interface are present
Sourcepub fn get_interface_mut(
&mut self,
device_path: &DevicePath,
) -> Option<&mut Interface>
pub fn get_interface_mut( &mut self, device_path: &DevicePath, ) -> Option<&mut Interface>
Get mutable reference to Interface at DevicePath if config and interface are present
Sourcepub fn get_endpoint(&self, endpoint_path: &EndpointPath) -> Option<&Endpoint>
pub fn get_endpoint(&self, endpoint_path: &EndpointPath) -> Option<&Endpoint>
Get reference to Endpoint at EndpointPath if config and interface are present
Sourcepub fn get_endpoint_mut(
&mut self,
endpoint_path: &EndpointPath,
) -> Option<&mut Endpoint>
pub fn get_endpoint_mut( &mut self, endpoint_path: &EndpointPath, ) -> Option<&mut Endpoint>
Get mutable reference to Endpoint at EndpointPath if config and interface are present
Sourcepub fn get_id(&self, id: &DeviceId) -> Option<&Device>
pub fn get_id(&self, id: &DeviceId) -> Option<&Device>
Search for ::nusb::DeviceId in branches of bus and return reference
Sourcepub fn get_id_mut(&mut self, id: &DeviceId) -> Option<&mut Device>
pub fn get_id_mut(&mut self, id: &DeviceId) -> Option<&mut Device>
Search for ::nusb::DeviceId in branches of bus and returns a mutable reference if found
Sourcepub fn to_lsusb_string(&self) -> String
pub fn to_lsusb_string(&self) -> String
Generate a String from self like lsusb default list device
Sourcepub fn to_lsusb_tree_string(&self, verbosity: u8) -> Vec<String>
pub fn to_lsusb_tree_string(&self, verbosity: u8) -> Vec<String>
Generate a Vec of Strings from self in lsusb tree self in order of verbosity
Only Linux systems with a root_hub will contain accurate data, others are mainly for styling
Should the bus be hidden when printing
Sourcepub fn is_expanded(&self) -> bool
pub fn is_expanded(&self) -> bool
Should the bus be expanded when printing
Sourcepub fn toggle_expanded(&mut self)
pub fn toggle_expanded(&mut self)
Toggle the expanded state of the bus
Sourcepub fn set_all_expanded(&mut self, expanded: bool)
pub fn set_all_expanded(&mut self, expanded: bool)
Set the expanded state of the bus and all devices
Trait Implementations§
Source§impl Block<BusBlocks, Bus> for BusBlocks
impl Block<BusBlocks, Bus> for BusBlocks
Source§fn default_blocks(verbose: bool) -> Vec<Self>
fn default_blocks(verbose: bool) -> Vec<Self>
verbose for maximum verbositySource§fn len(&self, d: &[&Bus]) -> usize
fn len(&self, d: &[&Bus]) -> usize
Source§fn generate_padding(d: &[&Bus]) -> HashMap<Self, usize>
fn generate_padding(d: &[&Bus]) -> HashMap<Self, usize>
d Vec or heading if > this; values can then be padded to match thisSource§fn colour(&self, s: &str, ct: &ColourTheme) -> ColoredString
fn colour(&self, s: &str, ct: &ColourTheme) -> ColoredString
Source§fn format_value(
&self,
bus: &Bus,
pad: &HashMap<Self, usize>,
settings: &PrintSettings,
) -> Option<String>
fn format_value( &self, bus: &Bus, pad: &HashMap<Self, usize>, settings: &PrintSettings, ) -> Option<String>
Source§fn heading(&self) -> &str
fn heading(&self) -> &str
Source§fn heading_padded(&self, pad: &HashMap<Self, usize>) -> String
fn heading_padded(&self, pad: &HashMap<Self, usize>) -> String
Source§fn block_length(&self) -> BlockLength
fn block_length(&self) -> BlockLength
BlockLength::Variable will be heading usize without actual device dataSource§fn example_blocks() -> Vec<Self>where
Self: Sized,
fn example_blocks() -> Vec<Self>where
Self: Sized,
Source§fn value_is_variable_length(&self) -> bool
fn value_is_variable_length(&self) -> bool
Source§fn format_base_u16(v: u16, settings: &PrintSettings) -> String
fn format_base_u16(v: u16, settings: &PrintSettings) -> String
Source§fn format_base_u8(v: u8, settings: &PrintSettings) -> String
fn format_base_u8(v: u8, settings: &PrintSettings) -> String
Source§fn format_vidpid(
v: Option<u16>,
p: Option<u16>,
settings: &PrintSettings,
) -> String
fn format_vidpid( v: Option<u16>, p: Option<u16>, settings: &PrintSettings, ) -> String
Source§fn all_blocks() -> &'static [B]where
Self: Sized,
fn all_blocks() -> &'static [B]where
Self: Sized,
Source§impl<'de> Deserialize<'de> for Bus
impl<'de> Deserialize<'de> for Bus
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<u8> for Bus
A generic Bus from a u8 bus number - used if Bus profiling is not available
impl From<u8> for Bus
A generic Bus from a u8 bus number - used if Bus profiling is not available
Source§impl<'a> IntoIterator for &'a Bus
impl<'a> IntoIterator for &'a Bus
Auto Trait Implementations§
impl Freeze for Bus
impl RefUnwindSafe for Bus
impl Send for Bus
impl Sync for Bus
impl Unpin for Bus
impl UnsafeUnpin for Bus
impl UnwindSafe for Bus
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more