Giter VIP home page Giter VIP logo

rsys's Introduction

rsys

master crates.io crates.io Docs
Crate for aquiring information about host machine and operating system in a os-agnostic fashion.

The common api is available through Rsys struct which compiles conditionally with required methods. The error and result type is available at the root of this crate for convienience while all the methods exposed by Rsys struct are also available in each os module.

Main goals are clear and easy api with as much of the api being os-agnostic.

Example usage:

  • Cargo.toml
[dependencies]
rsys = "0.5"
  • main.rs
use rsys::{Result, Rsys};

fn main() -> Result<()> {
    // You can either use api through Rsys object
    // for os-agnostic experience
    let rsys = Rsys::new();
    println!("HOSTNAME - {}", rsys.hostname()?);
    println!("CPU - {}", rsys.cpu()?);
    println!("CPU CORES - {}", rsys.cpu_cores()?);
    println!("CPU CLOCK - {}MHz", rsys.cpu_clock()?);
    println!("UPTIME - {}s", rsys.uptime()?);
    println!("ARCH - {}", rsys.arch()?);
    println!("SWAP TOTAL - {}b", rsys.swap_total()?);
    println!("SWAP FREE - {}b", rsys.swap_free()?);
    println!("MEMORY TOTAL - {}b", rsys.memory_total()?);
    println!("MEMORY FREE - {}b", rsys.memory_free()?);

    #[cfg(target_os = "linux")]
    {
        // Or use functions in each module
        println!("KERNEL VERSION - {}", rsys::linux::kernel_release()?);
        
        // Os-specific functions are also available as methods
        println!("KERNEL_VERSION - {}", rsys.kernel_release()?);
        println!("{:#?}", rsys.pids()?);
        println!("MOUNTS - {:#?}", rsys::linux::mounts::mounts()?);
    }
    Ok(())
}

TODO

  • Finish macos common api
  • Finish windows common api
  • Add async feature for async file reads and commands etc...

License

MIT

rsys's People

Contributors

krzysztofkarpieszuk avatar vv9k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rsys's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.