Thanks to visit codestin.com
Credit goes to docs.rs

Crate gudev

Source
Expand description

Rust bindings for the gudev library.

Libgudev is a library providing GObject bindings for libudev.

§Usage

Add the following to your Cargo.toml:

[dependencies]
gudev = "0.12"

Next:

use gudev::prelude::*;
use gudev::Client;
use gudev::Device;

fn main() {
    // Get a list of all block devices
    let devices = Client::new(&[]).query_by_subsystem(Some("block"));

    for device in devices {
        print_device(&device);
    }
}

fn print_device(device: &Device) {
    println!(
        "{} (subsystem={}, sysname={}, devtype={})",
        device.sysfs_path().unwrap_or_else(|| "---".into()),
        device.subsystem().unwrap_or_else(|| "---".into()),
        device.device_file().unwrap_or_else(|| "---".into()),
        device.devtype().unwrap_or_else(|| "---".into()),
    );
}

Re-exports§

pub use ffi;

Modules§

prelude

Structs§

Client
GLib type: GObject with reference counted clone semantics.
Device
GLib type: GObject with reference counted clone semantics.
Enumerator
GLib type: GObject with reference counted clone semantics.

Enums§

DeviceType

Type Aliases§

DeviceNumber