sysctl 0.2.0

Simplified interface to libc::sysctl
Documentation

This crate provides a safe interface for reading and writing information to the kernel using the sysctl interface.

Current Version

FreeBSD and macOS are supported.
Contributions for improvements and other platforms are welcome.

Documentation

Documentation is available here: https://johalun.github.io/sysctl-rs/

or, to generate documentation locally do:

$ git clone https://github.com/johalun/sysctl-rs && cd sysctl-rs
$ cargo doc --no-deps
$ firefox target/doc/sysctl/index.html

Usage

Add to Cargo.toml

[dependencies]
sysctl = "0.1.4"

Example

sysctl comes with several examples, see the examples folder.

Run with:

$ cargo run --example iterate

Or in a separate crate:

extern crate sysctl;

fn main() {
    let ctl = "kern.osrevision";
    let d: String = sysctl::description(ctl).unwrap();
    println!("Description: {:?}", d);

    let val_enum = sysctl::value(ctl).unwrap();
    if let sysctl::CtlValue::Int(val) = val_enum {
        println!("Value: {}", val);
    }
}