Trait libmacchina::traits::KernelReadout[][src]

pub trait KernelReadout {
    fn new() -> Self;
fn os_release(&self) -> Result<String, ReadoutError>;
fn os_type(&self) -> Result<String, ReadoutError>; fn pretty_kernel(&self) -> Result<String, ReadoutError> { ... } }
Expand description

This trait is used for implementing common functions for reading kernel properties, such as kernel name and version.

Example

use libmacchina::traits::KernelReadout;
use libmacchina::traits::ReadoutError;

pub struct MacOSKernelReadout;

impl KernelReadout for MacOSKernelReadout {
    fn new() -> Self {
        MacOSKernelReadout {}
    }

    fn os_release(&self) -> Result<String, ReadoutError> {
        // Get kernel version
        Ok(String::from("20.0.1"))
    }

    fn os_type(&self) -> Result<String, ReadoutError> {
        // Get kernel name
        Ok(String::from("Darwin"))
    }
}

Required methods

Creates a new instance of the structure which implements this trait.

This function should return the version of the kernel (e. g. 20.3.0 on macOS for Darwin).

This function should return the kernel name as a string (e. g. Darwin on macOS).

Provided methods

This function is used for getting the kernel name and version in a pretty format.

Implementors