sys_metrics 0.2.7

Cross-platform library to gather stats/information from the host
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::io::Error;

/// Return a utsname instance
///
/// Use it with [get_os_version_from_uname] or [get_hostname_from_uname]
///
/// [get_os_version_from_uname]: ../host/fn.get_os_version_from_uname.html
/// [get_hostname_from_uname]: ../host/fn.get_hostname_from_uname.html
pub(crate) fn get_uname() -> Result<libc::utsname, Error> {
    let mut ret = std::mem::MaybeUninit::uninit();

    if unsafe { libc::uname(ret.as_mut_ptr()) } == -1 {
        return Err(Error::last_os_error());
    }

    Ok(unsafe { ret.assume_init() })
}