2 This crate provides a safe wrapper around the native `libudev` library. It applies the RAII pattern
3 and Rust lifetimes to ensure safe usage of all `libudev` functionality. The RAII pattern ensures
4 that all acquired resources are released when they're no longer needed, and Rust lifetimes ensure
5 that resources are released in a proper order.
7 * [Documentation](http://dcuddeback.github.io/libudev-rs/libudev/)
10 In order to use the `libudev` crate, you must have a Linux system with the `libudev` library
11 installed where it can be found by `pkg-config`. To install `libudev` on Debian-based Linux
12 distributions, execute the following command:
15 sudo apt-get install libudev-dev
18 `libudev` is a Linux-specific package. It is not available for Windows, OS X, or other operating
22 The `libudev` crate can be used when cross-compiling to a foreign target. Details on how to
23 cross-compile `libudev` are explained in the [`libudev-sys` crate's
24 README](https://github.com/dcuddeback/libudev-sys#cross-compiling).
27 Add `libudev` as a dependency in `Cargo.toml`:
34 If you plan to support operating systems other than Linux, you'll need to add `libudev` as a
35 target-specific dependency:
38 [target.x86_64-unknown-linux-gnu.dependencies]
42 Import the `libudev` crate. The starting point for nearly all `libudev` functionality is to create a
49 let context = libudev::Context::new().unwrap();
50 let mut enumerator = libudev::Enumerator::new(&context).unwrap();
52 enumerator.match_subsystem("tty").unwrap();
54 for device in enumerator.scan_devices().unwrap() {
55 println!("found device: {:?}", device.syspath());
61 * [dcuddeback](https://github.com/dcuddeback)
62 * [Susurrus](https://github.com/Susurrus)
65 Copyright © 2015 David Cuddeback
67 Distributed under the [MIT License](LICENSE).