Skip to main content

SystemProfile

Struct SystemProfile 

Source
pub struct SystemProfile {
    pub buses: Vec<Bus>,
}
Expand description

Root JSON returned from system_profiler and used as holder for all static USB bus data

Fields§

§buses: Vec<Bus>

system buses

Implementations§

Source§

impl SystemProfile

Source

pub fn len(&self) -> usize

Returns total number of devices across all buses

Source

pub fn is_empty(&self) -> bool

Whether all buses are empty

Source

pub fn into_flattened(&mut self)

Flattens all Buses by calling into_flattened_devices on each

In place operation so it mutates the data and tree structure is lost. Location data is still present in each device.

Source

pub fn flattened_devices(&self) -> Vec<&Device>

Returns a flattened Vec of references to all Devices in each of the buses

Source

pub fn get_bus(&self, number: u8) -> Option<&Bus>

Returns reference to Bus number if it exists in data

Source

pub fn get_bus_mut(&mut self, number: u8) -> Option<&mut Bus>

Returns mutable reference to Bus number if it exists in data

Source

pub fn get_node(&self, port_path: &PortPath) -> Option<&Device>

Search for reference to Device at PortPath on correct bus number if present else all buses

Source

pub fn get_node_mut(&mut self, port_path: &PortPath) -> Option<&mut Device>

Search for mutable reference to Device at PortPath on correct bus number if present else all buses

Source

pub fn get_node_by_path<P: AsRef<Path>>(&self, path: P) -> Option<&Device>

Search for reference to Device at port_path as Path

Source

pub fn get_node_path_by_path_mut<P: AsRef<Path>>( &mut self, path: P, ) -> Option<&mut Device>

Search for mutable reference to Device at port_path as Path

Source

pub fn get_node_by_str(&self, path: &str) -> Option<&Device>

Search for reference to Device at port path as string

Source

pub fn get_node_str_mut(&mut self, path: &str) -> Option<&mut Device>

Search for mutable reference to Device at port path as string

Source

pub fn get_config( &self, port_path: &PortPath, config: u8, ) -> Option<&Configuration>

Get reference to Configuration at port_path and config if present

Source

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

Source

pub fn get_interface(&self, device_path: &DevicePath) -> Option<&Interface>

Get reference to Interface at port_path, config and interface if present in DevicePath

Source

pub fn get_interface_mut( &mut self, device_path: &DevicePath, ) -> Option<&mut Interface>

Get mutable reference to Interface at port_path, config and interface if present in DevicePath

Source

pub fn get_endpoint(&self, endpoint_path: &EndpointPath) -> Option<&Endpoint>

Get reference to Endpoint at port_path, config, interface and endpoint if present

Source

pub fn get_endpoint_mut( &mut self, endpoint_path: &EndpointPath, ) -> Option<&mut Endpoint>

Get mutable reference to Endpoint at port_path, config, interface and endpoint if present

Source

pub fn get_id(&self, id: &DeviceId) -> Option<&Device>

Search for ::nusb::DeviceId in branches of bus and return reference

Source

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

Source

pub fn replace(&mut self, new: Device) -> Result<Device>

Replace a Device in the correct Bus and parent device based on its location_id

If the device was existing, it will be replaced with the old device and returned as Ok, else Err if the device was not found.

Source

pub fn insert(&mut self, new: Device) -> Option<Device>

Insert a Device into the correct Bus and parent device based on its location_id

If the device was existing, it will be replaced with the new device and returned as Some (without child devices), else None. None will also be returned if the device parent is not found.

Trait Implementations§

Source§

impl Debug for SystemProfile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SystemProfile

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for SystemProfile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> IntoIterator for &'a SystemProfile

Source§

type Item = &'a Device

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<<&'a SystemProfile as IntoIterator>::Item>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> IntoIter<Self::Item>

Creates an iterator from a value. Read more
Source§

impl Serialize for SystemProfile

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,