ramusage 0.1.0

Get the used and total amount of memory
Documentation
//! This crate allows you to query the used and total amount of memory of your system.
//!
//! # OS Support
//! - Linux
//! - OpenBSD (planned)
//!
//! # Example
//! ``` rust
//! use ramusage::Info;
//!
//! fn main() {
//!     let info = Info::read().expect("Failed to read memory info.");
//!
//!     println!("{info}"); // 4.00 GiB/16.0 GiB
//!     println!("{info:#}"); // 4.00G/16.0G
//! }
//! ```

/// An amount of bytes.
///
/// # Example
/// ``` rust
/// use ramusage::Bytes;
/// fn use_bytes(b: Bytes) {
///     println!("{b}"); // 4.20 KiB
///     println!("{b:#}"); // 4.20G
///     let raw: u64 = b.into();
///     println!("{raw}"); // 4301
/// }
///
/// use_bytes(4301.into());
/// ```
#[derive(Debug, Clone, Copy)]
pub struct Bytes(u64);

/// System RAM usage.
///
/// # Example
/// ``` rust
/// use ramusage::Info;
///
/// let info = Info::read().unwrap();
/// println!("{info}"); // 4.00 GiB/16.0 GiB
/// println!("{info:#}"); // 4.00G/16.0G
/// ```
#[derive(Debug, Clone, Copy)]
pub struct Info {
    pub total: Bytes,
    pub used: Bytes,
}

mod fmt;
mod backend;

impl From<u64> for Bytes {
    fn from(value: u64) -> Self {
        Self(value)
    }
}
impl Into<u64> for Bytes {
    fn into(self) -> u64 {
        self.0
    }
}