Trait libmacchina::traits::GeneralReadout [−][src]
pub trait GeneralReadout {}Show methods
fn new() -> Self; fn resolution(&self) -> Result<String, ReadoutError> { ... } fn username(&self) -> Result<String, ReadoutError> { ... } fn hostname(&self) -> Result<String, ReadoutError> { ... } fn distribution(&self) -> Result<String, ReadoutError> { ... } fn local_ip(&self) -> Result<String, ReadoutError> { ... } fn desktop_environment(&self) -> Result<String, ReadoutError> { ... } fn window_manager(&self) -> Result<String, ReadoutError> { ... } fn terminal(&self) -> Result<String, ReadoutError> { ... } fn shell(&self, _shorthand: ShellFormat) -> Result<String, ReadoutError> { ... } fn cpu_model_name(&self) -> Result<String, ReadoutError> { ... } fn cpu_usage(&self) -> Result<usize, ReadoutError> { ... } fn cpu_physical_cores(&self) -> Result<usize, ReadoutError> { ... } fn cpu_cores(&self) -> Result<usize, ReadoutError> { ... } fn uptime(&self) -> Result<usize, ReadoutError> { ... } fn machine(&self) -> Result<String, ReadoutError> { ... } fn os_name(&self) -> Result<String, ReadoutError> { ... }
Expand description
This trait provides the interface for implementing functionality used for querying general information about the running operating system and current user.
Example
use libmacchina::traits::GeneralReadout; use libmacchina::traits::ReadoutError; pub struct MacOSGeneralReadout; impl GeneralReadout for MacOSGeneralReadout { fn new() -> Self { MacOSGeneralReadout {} } fn username(&self) -> Result<String, ReadoutError> { //let username = NSUserName(); Ok(String::from("johndoe")) } // Implement other trait functions... }
Required methods
Provided methods
fn resolution(&self) -> Result<String, ReadoutError>
[src]fn username(&self) -> Result<String, ReadoutError>
[src]
fn username(&self) -> Result<String, ReadoutError>
[src]This function should return the username of the currently logged on user.
e.g. johndoe
fn hostname(&self) -> Result<String, ReadoutError>
[src]
fn hostname(&self) -> Result<String, ReadoutError>
[src]This function should return the hostname of the host’s computer.
e.g. supercomputer
fn distribution(&self) -> Result<String, ReadoutError>
[src]
fn distribution(&self) -> Result<String, ReadoutError>
[src]This function should return the name of the distribution of the operating system.
e.g. Arch Linux
fn local_ip(&self) -> Result<String, ReadoutError>
[src]
fn local_ip(&self) -> Result<String, ReadoutError>
[src]This function should return the user’s local ip address
e.g. 192.168.1.11
fn desktop_environment(&self) -> Result<String, ReadoutError>
[src]
fn desktop_environment(&self) -> Result<String, ReadoutError>
[src]This function should return the name of the used desktop environment.
e.g. Plasma
fn window_manager(&self) -> Result<String, ReadoutError>
[src]
fn window_manager(&self) -> Result<String, ReadoutError>
[src]This function should return the name of the used window manager.
e.g. KWin
fn terminal(&self) -> Result<String, ReadoutError>
[src]
fn terminal(&self) -> Result<String, ReadoutError>
[src]This function should return the name of the used terminal emulator.
e.g. kitty
fn shell(&self, _shorthand: ShellFormat) -> Result<String, ReadoutError>
[src]
fn shell(&self, _shorthand: ShellFormat) -> Result<String, ReadoutError>
[src]This function should return the currently running shell depending on the _shorthand
value.
- If
_shorthand
isShellFormat::Relative
the basename of the shell will be returned.
e.g. bash, zsh, etc.
- If
_shorthand
isShellFormat::Absolute
the absolute path of the shell will be returned.
e.g. /bin/bash, /bin/zsh, etc.
fn cpu_model_name(&self) -> Result<String, ReadoutError>
[src]
fn cpu_model_name(&self) -> Result<String, ReadoutError>
[src]This function should return the model name of the CPU
e.g. Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
fn cpu_usage(&self) -> Result<usize, ReadoutError>
[src]
fn cpu_usage(&self) -> Result<usize, ReadoutError>
[src]This function should return the average CPU usage over the last minute.
fn cpu_physical_cores(&self) -> Result<usize, ReadoutError>
[src]
fn cpu_physical_cores(&self) -> Result<usize, ReadoutError>
[src]This function should return the number of physical cores of the host’s processor.
fn cpu_cores(&self) -> Result<usize, ReadoutError>
[src]
fn cpu_cores(&self) -> Result<usize, ReadoutError>
[src]This function should return the number of logical cores of the host’s processor.
fn uptime(&self) -> Result<usize, ReadoutError>
[src]
fn uptime(&self) -> Result<usize, ReadoutError>
[src]This function should return the uptime of the OS in seconds.
fn machine(&self) -> Result<String, ReadoutError>
[src]
fn machine(&self) -> Result<String, ReadoutError>
[src]This function should return the name of the physical machine
e.g. MacBookPro11,5
fn os_name(&self) -> Result<String, ReadoutError>
[src]
fn os_name(&self) -> Result<String, ReadoutError>
[src]This function should return the name of the OS in a pretty format
e.g. macOS 11.2.2 Big Sur