Struct Enumerator

Source
pub struct Enumerator { /* private fields */ }
Expand description

An enumeration context.

An Enumerator scans /sys for devices matching its filters. Filters are added to an Enumerator by calling its match_* and nomatch_* methods. After the filters are setup, the scan_devices() method finds devices in /sys that match the filters.

Implementations§

Source§

impl Enumerator

Source

pub fn new(context: &Context) -> Result<Self>

Creates a new Enumerator.

Source

pub fn match_is_initialized(&mut self) -> Result<()>

Adds a filter that matches only initialized devices.

Source

pub fn match_subsystem<T: AsRef<OsStr>>(&mut self, subsystem: T) -> Result<()>

Adds a filter that matches only devices that belong to the given kernel subsystem.

Source

pub fn match_attribute<T: AsRef<OsStr>, U: AsRef<OsStr>>( &mut self, attribute: T, value: U, ) -> Result<()>

Adds a filter that matches only devices with the given attribute value.

Source

pub fn match_sysname<T: AsRef<OsStr>>(&mut self, sysname: T) -> Result<()>

Adds a filter that matches only devices with the given kernel device name.

Source

pub fn match_property<T: AsRef<OsStr>, U: AsRef<OsStr>>( &mut self, property: T, value: U, ) -> Result<()>

Adds a filter that matches only devices with the given property value.

Source

pub fn match_tag<T: AsRef<OsStr>>(&mut self, tag: T) -> Result<()>

Adds a filter that matches only devices with the given tag.

Source

pub fn match_parent(&mut self, parent: &Device) -> Result<()>

Includes the parent device and all devices in the subtree of the parent device.

Source

pub fn nomatch_subsystem<T: AsRef<OsStr>>(&mut self, subsystem: T) -> Result<()>

Adds a filter that matches only devices that don’t belong to the given kernel subsystem.

Source

pub fn nomatch_attribute<T: AsRef<OsStr>, U: AsRef<OsStr>>( &mut self, attribute: T, value: U, ) -> Result<()>

Adds a filter that matches only devices that don’t have the the given attribute value.

Source

pub fn add_syspath(&mut self, syspath: &Path) -> Result<()>

Includes the device with the given syspath.

Source

pub fn scan_devices(&mut self) -> Result<Devices<'_>>

Scans /sys for devices matching the attached filters.

The devices will be sorted in dependency order.

Trait Implementations§

Source§

impl Drop for Enumerator

Source§

fn drop(&mut self)

Executes the destructor for this type. 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, 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.