[][src]Crate proc_getter

how to use

The layout of this crate is very like the /proc/ directory layout.

Each file correspond to a module which contains everything to interoperate with the file. Majority modules has a function which has the same name as the file.

However, function reside in process directories is a little different. They receive an u32 argument to specify the target process, and the function name has a "_of" suffix.

use proc_getter::cmdline::*;
use proc_getter::pid::cmdline::*;

fn main() {
    //  /proc/cmdline
    println!("{:?}", cmdline());
    
    //  /proc/1/cmdline
    println!("{:?}", cmdline_of(1));
}Run

Everything under proc mod is re-export, so crate::proc::cmdline equals to crate::cmdline.

Returning value

The returning value has different type depends on the files. Some function simply return the content of the file, including ending \n. Some function parse the content and return the wrapping type.

There are tow possbile cases where return an Err:

  1. there is a bug because we parse the file content incorrectlly.
  2. the file corresponding to the function is not exist in your computer.

Otherwise all the function should success in theory, since files under proc file system are not real file.

which files is supported

It's very depends on th system. Here is a list from red hat, every file in this list should be supported.

Re-exports

pub use proc::*;

Modules

proc

Enums

Error

all kind of error may occurs in the crate.