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> { ... } }

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

fn new() -> Self[src]

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

Loading content...

Provided methods

fn os_release(&self) -> Result<String, ReadoutError>[src]

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

fn os_type(&self) -> Result<String, ReadoutError>[src]

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

fn pretty_kernel(&self) -> Result<String, ReadoutError>[src]

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

Loading content...

Implementors

Loading content...