Trait All

Source
pub trait All: AllInner {
    // Provided methods
    fn iter(&self) -> Iter<'_, <Self as AllInner>::Gruser> { ... }
    fn iter_mut(&mut self) -> IterMut<'_, <Self as AllInner>::Gruser> { ... }
    fn get_by_name(
        &self,
        name: impl AsRef<str>,
    ) -> Option<&<Self as AllInner>::Gruser> { ... }
    fn get_mut_by_name(
        &mut self,
        name: impl AsRef<str>,
    ) -> Option<&mut <Self as AllInner>::Gruser> { ... }
    fn get_by_id(&self, id: usize) -> Option<&<Self as AllInner>::Gruser> { ... }
    fn get_mut_by_id(
        &mut self,
        id: usize,
    ) -> Option<&mut <Self as AllInner>::Gruser> { ... }
    fn get_unique_id(&self) -> Option<usize> { ... }
    fn remove_by_name(&mut self, name: impl AsRef<str>) -> bool { ... }
    fn remove_by_id(&mut self, id: usize) -> bool { ... }
}
Expand description

This trait is used to remove repetitive API items from AllGroups and AllUsers. It uses a hidden trait so that the implementations of functions can be implemented at the trait level. Do not try to implement this trait.

Provided Methods§

Source

fn iter(&self) -> Iter<'_, <Self as AllInner>::Gruser>

Get an iterator borrowing all Users or Groups on the system.

Source

fn iter_mut(&mut self) -> IterMut<'_, <Self as AllInner>::Gruser>

Get an iterator mutably borrowing all Users or Groups on the system.

Source

fn get_by_name( &self, name: impl AsRef<str>, ) -> Option<&<Self as AllInner>::Gruser>

Borrow the User or Group with a given name.

§Examples

Basic usage:

let users = AllUsers::basic(Config::default()).unwrap();
let user = users.get_by_name("root").unwrap();
Source

fn get_mut_by_name( &mut self, name: impl AsRef<str>, ) -> Option<&mut <Self as AllInner>::Gruser>

Mutable version of All::get_by_name.

Source

fn get_by_id(&self, id: usize) -> Option<&<Self as AllInner>::Gruser>

Borrow the User or Group with the given ID.

§Examples

Basic usage:

let users = AllUsers::basic(Config::default()).unwrap();
let user = users.get_by_id(0).unwrap();
Source

fn get_mut_by_id( &mut self, id: usize, ) -> Option<&mut <Self as AllInner>::Gruser>

Mutable version of All::get_by_id.

Source

fn get_unique_id(&self) -> Option<usize>

Provides an unused id based on the min and max values in the Config passed to the All’s constructor.

§Examples
let users = AllUsers::basic(Config::default()).unwrap();
let uid = users.get_unique_id().expect("no available uid");
Source

fn remove_by_name(&mut self, name: impl AsRef<str>) -> bool

Remove a User or Group from this All given it’s name. If the Gruser was removed return true, else return false. This ensures that the Gruser no longer exists.

Source

fn remove_by_id(&mut self, id: usize) -> bool

Id version of All::remove_by_name.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl All for AllGroups

Source§

impl<A> All for AllUsers<A>