Trait libmacchina::traits::ProductReadout[][src]

pub trait ProductReadout {
    fn new() -> Self;

    fn version(&self) -> Result<String, ReadoutError> { ... }
fn vendor(&self) -> Result<String, ReadoutError> { ... }
fn family(&self) -> Result<String, ReadoutError> { ... }
fn name(&self) -> Result<String, ReadoutError> { ... }
fn product(&self) -> Result<String, ReadoutError> { ... } }
Expand description

This trait provides the interface for implementing functionality used for getting product information about the hosts operating system.

Example

use libmacchina::traits::ProductReadout;
use libmacchina::traits::ReadoutError;

pub struct MacOSProductReadout;

impl ProductReadout for MacOSProductReadout {
    fn new() -> Self {
        MacOSProductReadout {}
    }

    fn vendor(&self) -> Result<String, ReadoutError> {
        Ok(String::from("Apple"))
    }

    fn family(&self) -> Result<String, ReadoutError> {
        Ok(String::from("Unix, Macintosh"))
    }

    fn name(&self) -> Result<String, ReadoutError> {
        // Get name of os release...
        Ok(String::from("Big Sur"))
    }

    fn product(&self) -> Result<String, ReadoutError> {
        Ok(String::from("macOS"))
    }
}

Required methods

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

Provided methods

This function should return the version of the host’s machine.

e.g. Lenovo IdeaPad S540-15IWL GTX

This is set by the machine’s manufacturer.

This function should return the vendor name of the host’s machine.

e.g. Lenovo

This is set by the machine’s manufacturer.

This function should return the family name of the host’s machine.

e.g. IdeaPad S540-15IWL GTX

This is set by the machine’s manufacturer.

This function should return the name of the host’s machine.

e.g. 81SW

This is set by the machine’s manufacturer.

This function should return the product name of the hosts machine.

e.g. IdeaPad S540-15IWL GTX

This is set by the machine’s manufacturer.

Implementors