pub trait PackageReadout {
    // Required method
    fn new() -> Self;

    // Provided method
    fn count_pkgs(&self) -> Vec<(PackageManager, usize)> { ... }
}
Expand description

This trait provides an interface to various functions used to count packages on the host system. Almost all modern operating systems use some kind of package manager.

§Example

use libmacchina::traits::{PackageReadout, PackageManager};
use libmacchina::traits::ReadoutError;

pub struct MacOSPackageReadout;

impl PackageReadout for MacOSPackageReadout {
    fn new() -> Self {
        MacOSPackageReadout {}
    }

    fn count_pkgs(&self) -> Vec<(PackageManager, usize)> {
        // Check if homebrew 🍻 is installed and count installed packages...
        vec![(PackageManager::Homebrew, 120)]
    }
}

Required Methods§

source

fn new() -> Self

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

Provided Methods§

source

fn count_pkgs(&self) -> Vec<(PackageManager, usize)>

This function should return the number of installed packages.

Object Safety§

This trait is not object safe.

Implementors§