#ffi #udev #glib

gudev

Rust API for gudev, the glib support library for libudev

18 releases (breaking)

0.15.0 Aug 3, 2023
0.14.0 Feb 17, 2023
0.13.0 Oct 22, 2022
0.12.0 Feb 5, 2022
0.1.1 Nov 30, 2016

#275 in Hardware support

Download history 43/week @ 2023-08-14 8/week @ 2023-08-21 26/week @ 2023-08-28 57/week @ 2023-09-04 14/week @ 2023-09-11 15/week @ 2023-09-18 14/week @ 2023-09-25 13/week @ 2023-10-02 13/week @ 2023-10-09 16/week @ 2023-10-16 26/week @ 2023-10-23 44/week @ 2023-10-30 16/week @ 2023-11-06 35/week @ 2023-11-13 35/week @ 2023-11-20 69/week @ 2023-11-27

160 downloads per month
Used in gnome-egpu

MIT license

51KB
1K SLoC

gudev

gudev is a crate that provide Rust idiomatic bindings for GUDev.

It follows the release of glib-rs.

To use in your project, just add gudev = "^0.11.0" to your Cargo.toml.

Please file issues at:

https://github.com/hfiguiere/gudev-rs/

The latest autogenerated online documentation is at:

https://docs.rs/gudev/latest/gudev/


lib.rs:

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()),
    );
}

Dependencies

~6.5MB
~131K SLoC