[][src]Struct rsys::Rsys

pub struct Rsys(_, _);

Main interface that allows for os-agnostic api.

Implementations

impl Rsys[src]

pub fn new() -> Self[src]

Creates a new instance of Rsys

pub fn hostname(&self) -> Result<String>[src]

Returns a hostname.

  • linux
    • by reading /proc/sys/kernel/hostname
  • macos
    • by calling sysctl("kern.hostname")
  • windows
    • by calling win32 api GetComputerNameA

pub fn uptime(&self) -> Result<u64>[src]

Returns time since boot in seconds.

  • linux
    • by reading /proc/uptime
  • macos
    • by calling sysctl("kern.boottime")
  • windows
    • by calling win32 api GetTickCount64

pub fn os(&self) -> String[src]

Returns operating system. Reexported env::consts::OS for convenience.

pub fn arch(&self) -> Result<String>[src]

Returns cpu architecture.

  • linux and macos
    • by calling uname -m
  • windows
    • by calling win32 api GetSystemInfo

pub fn cpu(&self) -> Result<String>[src]

Returns a cpu model name.

  • linux
    • by reading /proc/cpuinfo
  • macos
    • by calling sysctl("machdep.cpu.brand_string") ...

pub fn cpu_clock(&self) -> Result<f32>[src]

Returns clock speed of cpu.

  • linux
    • by reading /proc/cpuinfo
  • macos
    • by calling sysctl("hw.cpufrequency") ...

pub fn cpu_cores(&self) -> Result<u16>[src]

Returns cpu cores.

  • linux
    • by reading /proc/cpuinfo
  • macos
    • by calling sysctl("hw.physicalcpu")
  • windows
    • by determining if cpu is hyperthreaded and calculating from logical cores.

pub fn logical_cores(&self) -> Result<u16>[src]

Returns logical cpu cores.

  • linux
    • by reading /proc/cpuinfo
  • macos
    • by calling sysctl("hw.logicalcpu")
  • windows
    • by calling win32 api GetSystemInfo

pub fn memory_total(&self) -> Result<usize>[src]

Returns total ram memory.

  • linux
    • by reading /proc/meminfo
  • macos
    • by calling sysctl("hw.memsize")
  • windows
    • by calling win32 api GlobalMemoryStatusEx

pub fn memory_free(&self) -> Result<usize>[src]

Returns free ram memory.

  • linux
    • by reading /proc/meminfo ...

pub fn swap_total(&self) -> Result<usize>[src]

Returns total swap size.

  • linux
    • by reading /proc/meminfo
  • macos
    • by calling sysctl("hw.swapusage")
  • windows
    • by calling win32 api GlobalMemoryStatusEx

pub fn swap_free(&self) -> Result<usize>[src]

Returns free swap size.

  • linux
    • by reading /proc/meminfo
  • macos
    • by calling sysctl("hw.swapusage")
  • windows
    • by calling win32 api GlobalMemoryStatusEx

pub fn default_iface(&self) -> Result<String>[src]

Returns a default internet interface.

  • linux
    • by calling route and determining default route
  • macos
    • by calling route get default ...

pub fn ipv4(&self, iface: &str) -> Result<String>[src]

Returns IP address version 4 of interface iface.

  • linux
    • by calling ip address show <iface>
  • macos
    • by calling ipconfig getifaddr <iface> ...

pub fn ipv6(&self, iface: &str) -> Result<String>[src]

Returns IP address version 6 of interface iface.

pub fn mac(&self, iface: &str) -> Result<String>[src]

Returns a MAC address of interface iface.

  • linux
    • by calling ip address show <iface> ...

pub fn interfaces(&self) -> Result<Vec<String>>[src]

Returns a vector of names of network interfaces that are available.

  • linux
    • by calling ip address show ...

pub fn domainname(&self) -> Result<String>[src]

Returns a domain name.

  • linux
    • by reading /proc/sys/kernel/domainname
  • windows
    • by calling win32 api NetWkstaGetInfo ...

Auto Trait Implementations

impl !RefUnwindSafe for Rsys

impl !Send for Rsys

impl !Sync for Rsys

impl Unpin for Rsys

impl !UnwindSafe for Rsys

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.