Trait SysUptime

Source
pub trait SysUptime: Sealed {
    // Required method
    fn sys_uptime() -> Self;
}
Available on crate feature up only.
Expand description

System uptime

This trait represents structures that are viable containers for holding and displaying system uptime, notably, everything in the readable::time module.

readable::run types do not implement this trait as they have a relatively low upper limit of 99 hours.

This trait is sealed and can only be implemented internally on readable types.

Required Methods§

Source

fn sys_uptime() -> Self

This function creates a Self from the live system uptime and can be used on:

  • Windows
  • macOS
  • BSDs
  • Linux
§Example
// Introduce trait into scope.
use readable::up::SysUptime;

// Capture the _current_ system uptime,
// and format it into a `Uptime`.
std::thread::sleep(std::time::Duration::from_secs(1));
let mut uptime: Uptime = Uptime::sys_uptime();
assert!(uptime >= 1);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§