pub trait ProductReadout {
    // Required methods
    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§

source

fn new() -> Self

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

source

fn vendor(&self) -> Result<String, ReadoutError>

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

e.g. Lenovo

This is set by the machine’s manufacturer.

source

fn family(&self) -> Result<String, ReadoutError>

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.

source

fn product(&self) -> Result<String, ReadoutError>

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

e.g. 81SW

This is set by the machine’s manufacturer.

Object Safety§

This trait is not object safe.

Implementors§