pub fn value_as<T>(name: &str) -> Result<Box<T>, SysctlError>Expand description
A generic function that takes a string as argument and returns a result containing the sysctl value if success, or a SysctlError on failure.
Can only be called for sysctls of type Opaque or Struct.
Example
extern crate sysctl;
extern crate libc;
use libc::c_int;
#[derive(Debug)]
#[repr(C)]
struct ClockInfo {
hz: c_int, /* clock frequency */
tick: c_int, /* micro-seconds per hz tick */
spare: c_int,
stathz: c_int, /* statistics clock frequency */
profhz: c_int, /* profiling clock frequency */
}
fn main() {
println!("{:?}", sysctl::value_as::<ClockInfo>("kern.clockrate"));
}