[][src]Trait redox_users::All

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

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

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

Get an iterator borrowing all User's or Group's on the system.

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

Get an iterator mutably borrowing all User's or Group's on the system.

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

Borrow the User or Group with a given name.

Examples

Basic usage:

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

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

Mutable version of get_by_name.

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

Borrow the User or Group with the given ID.

Examples

Basic usage:

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

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

Mutable version of get_by_id.

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::new(Config::default()).unwrap();
let uid = users.get_unique_id().expect("no available uid");

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

Remove a User or Group from this All given it's name. This won't provide an indication of whether the user was removed or not, but is guaranteed to work if a user with the specified name exists.

fn remove_by_id(&mut self, id: usize)

Id version of remove_by_name.

Loading content...

Implementors

impl All for AllGroups[src]

impl All for AllUsers[src]

Loading content...