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
impl Enumerator
Sourcepub fn with_udev(udev: Udev) -> Result<Self>
pub fn with_udev(udev: Udev) -> Result<Self>
Creates a new Enumerator
with an existing Udev
instance
Sourcepub fn match_is_initialized(&mut self) -> Result<()>
pub fn match_is_initialized(&mut self) -> Result<()>
Adds a filter that matches only initialized devices.
Sourcepub fn match_subsystem<T: AsRef<OsStr>>(&mut self, subsystem: T) -> Result<()>
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.
Sourcepub fn match_attribute<T: AsRef<OsStr>, U: AsRef<OsStr>>(
&mut self,
attribute: T,
value: U,
) -> Result<()>
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.
Sourcepub fn match_sysname<T: AsRef<OsStr>>(&mut self, sysname: T) -> Result<()>
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.
Sourcepub fn match_property<T: AsRef<OsStr>, U: AsRef<OsStr>>(
&mut self,
property: T,
value: U,
) -> Result<()>
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.
Sourcepub fn match_tag<T: AsRef<OsStr>>(&mut self, tag: T) -> Result<()>
pub fn match_tag<T: AsRef<OsStr>>(&mut self, tag: T) -> Result<()>
Adds a filter that matches only devices with the given tag.
Sourcepub fn match_parent(&mut self, parent: &Device) -> Result<()>
pub fn match_parent(&mut self, parent: &Device) -> Result<()>
Includes the parent device and all devices in the subtree of the parent device.
Sourcepub fn nomatch_subsystem<T: AsRef<OsStr>>(&mut self, subsystem: T) -> Result<()>
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.
Sourcepub fn nomatch_attribute<T: AsRef<OsStr>, U: AsRef<OsStr>>(
&mut self,
attribute: T,
value: U,
) -> Result<()>
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.
Sourcepub fn add_syspath<T: AsRef<OsStr>>(&mut self, syspath: T) -> Result<()>
pub fn add_syspath<T: AsRef<OsStr>>(&mut self, syspath: T) -> Result<()>
Includes the device with the given syspath.
Sourcepub fn scan_devices(&mut self) -> Result<List<'_, Enumerator, Device>>
pub fn scan_devices(&mut self) -> Result<List<'_, Enumerator, Device>>
Scans /sys
for devices matching the attached filters.
The devices will be sorted in dependency order.