Struct udev::Device

source · []
pub struct Device { /* private fields */ }
Expand description

A structure that provides access to sysfs/kernel devices.

Implementations

Creates a device for a given syspath.

The syspath parameter should be a path to the device file within the sysfs file system, e.g., /sys/devices/virtual/tty/tty0.

Creates a device for a given syspath, using an existing Udev instance rather than creating one automatically.

The syspath parameter should be a path to the device file within the sysfs file system, e.g., /sys/devices/virtual/tty/tty0.

Checks whether the device has already been handled by udev.

When a new device is connected to the system, udev initializes the device by setting permissions, renaming network devices, and possibly other initialization routines. This method returns true if udev has performed all of its work to initialize this device.

This method only applies to devices with device nodes or network interfaces. All other devices return true by default.

Gets the device’s major/minor number.

Returns the syspath of the device.

The path is an absolute path and includes the sys mount point. For example, the syspath for tty0 could be /sys/devices/virtual/tty/tty0, which includes the sys mount point, /sys.

Returns the kernel devpath value of the device.

The path does not contain the sys mount point, but does start with a /. For example, the devpath for tty0 could be /devices/virtual/tty/tty0.

Returns the path to the device node belonging to the device.

The path is an absolute path and starts with the device directory. For example, the device node for tty0 could be /dev/tty0.

Returns the parent of the device.

Returns the parent of the device with the matching subsystem and devtype if any.

Returns the parent of the device with the matching subsystem and devtype if any.

Returns the subsystem name of the device.

The subsystem name is a string that indicates which kernel subsystem the device belongs to. Examples of subsystem names are tty, vtconsole, block, scsi, and net.

Returns the kernel device name for the device.

The sysname is a string that differentiates the device from others in the same subsystem. For example, tty0 is the sysname for a TTY device that differentiates it from others, such as tty1.

Returns the instance number of the device.

The instance number is used to differentiate many devices of the same type. For example, /dev/tty0 and /dev/tty1 are both TTY devices but have instance numbers of 0 and 1, respectively.

Some devices don’t have instance numbers, such as /dev/console, in which case the method returns None.

Returns the devtype name of the device.

Returns the name of the kernel driver attached to the device.

Retreives the value of a device property.

Retreives the value of a device attribute.

Sets the value of a device attribute.

Returns an iterator over the device’s properties.

Example

This example prints out all of a device’s properties:

for property in device.properties() {
    println!("{:?} = {:?}", property.name(), property.value());
}

Returns an iterator over the device’s attributes.

Example

This example prints out all of a device’s attributes:

for attribute in device.attributes() {
    println!("{:?} = {:?}", attribute.name(), attribute.value());
}

Returns the device action for the device.

Trait Implementations

Get a reference of the underlying struct. Read more

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. Read more

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Create an object from a given raw pointer and udev context pointer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.