sinf 0.1.0

Library for obtaining in-depth system information at both the hardware and software levels
Documentation
use crate::Error;

use super::Group;

/// A collection of groups.
pub struct Groups {
    groups: Vec<Group>,
}

impl_collection_field!(Groups, Group, groups);

impl From<Groups> for Vec<Group> {
    fn from(groups: Groups) -> Self {
        groups.groups
    }
}

impl Groups {
    /// Creates an empty [`Groups`].
    pub fn new() -> Result<Self, Error> {
        Ok(Self {
            groups: crate::sys::new_groups()?,
        })
    }

    impl_new_with_refreshed_list!(Groups);

    /// Empties the group list, then recomputes it completely.
    pub fn refresh(&mut self) {
        crate::sys::get_groups(&mut self.groups);
    }
}