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() -> Result<Self>

Creates a new Enumerator.

Source

pub fn with_udev(udev: Udev) -> Result<Self>

Creates a new Enumerator with an existing Udev instance

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<T: AsRef<OsStr>>(&mut self, syspath: T) -> Result<()>

Includes the device with the given syspath.

Source

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.

Trait Implementations§

Source§

impl AsRawWithContext<udev_enumerate> for Enumerator

Source§

fn as_raw(&self) -> *mut udev_enumerate

Get a reference of the underlying struct. Read more
Source§

fn udev(&self) -> &Udev

The udev context with which this struct was created. This must live at least as long as the struct itself or undefined behavior will result.
Source§

fn into_raw_with_context(self) -> (*mut udev, *mut udev_enumerate)

Convert the object into the raw udev pointer and the underlying pointer for this object. Read more
Source§

impl Clone for Enumerator

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for Enumerator

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl FromRawWithContext<udev_enumerate> for Enumerator

Source§

unsafe fn from_raw_with_context(udev: *mut udev, t: *mut udev_enumerate) -> Self

Create an object from a given raw pointer and udev context pointer. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.