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

pub trait ProductReadout {
    fn new() -> Self;
fn vendor(&self) -> Result<String, ReadoutError>;
fn family(&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 host machine.

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("MacBook Pro"))
    }

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

Required methods

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

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 product name of the host’s machine.

e.g. 81SW

This is set by the machine’s manufacturer.

Implementors