Struct redox_users::AllUsers

source ·
pub struct AllUsers<A> { /* private fields */ }
Expand description

AllUsers provides (borrowed) access to all the users on the system. Note that this struct implements All for all of its access functions.

§Notes

Note that everything in this section also applies to AllGroups.

  • If you mutate anything owned by an AllUsers, you must call the AllUsers::save in order for those changes to be applied to the system.
  • The API here is kept small. Most mutating actions can be accomplished via the All::get_mut_by_id and All::get_mut_by_name functions.

Implementations§

source§

impl<A: Default> AllUsers<A>

source

pub fn new(config: Config) -> Result<AllUsers<A>, Error>

source§

impl AllUsers<Basic>

source

pub fn basic(config: Config) -> Result<AllUsers<Basic>, Error>

Provide access to all user information on the system except authentication. This is adequate for almost all uses of AllUsers.

source§

impl AllUsers<Full>

source

pub fn authenticator(config: Config) -> Result<AllUsers<Full>, Error>

If access to password related methods for the Users yielded by this AllUsers is required, use this constructor.

source

pub fn add_user(&mut self, builder: UserBuilder) -> Result<&User<Full>, Error>

Consumes a builder, adding a new user to this AllUsers. Returns a reference to the created user.

Make sure to call AllUsers::save in order for the new user to be applied to the system.

Note that the user’s password is set unset (see Unset vs Blank Passwords) during this call.

Also note that the user is not added to any groups when this builder is consumed. In order to keep the system in a consistent state, it is reccomended to also use an instance of AllGroups to update group information when creating new users.

§Defaults

Fields not passed to the builder before calling this function are as follows:

  • uid: AllUsers::get_unique_id is called on self to get the next available id.
  • gid: 99. This is the default UID for the group nobody. Note that the user is NOT added to this group in /etc/groups.
  • name: The login name passed to UserBuilder::new.
  • home: "/"
  • shell: file:/bin/ion
source

pub fn save(&mut self) -> Result<(), Error>

Syncs the data stored in the AllUsers instance to the filesystem. To apply changes to the system from an AllUsers, you MUST call this function!

Trait Implementations§

source§

impl<A> All for AllUsers<A>

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. Read more
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. Read more
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. Read more
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.
source§

impl<A: Debug> Debug for AllUsers<A>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<A> Freeze for AllUsers<A>

§

impl<A> RefUnwindSafe for AllUsers<A>
where A: RefUnwindSafe,

§

impl<A> Send for AllUsers<A>
where A: Send,

§

impl<A> Sync for AllUsers<A>
where A: Sync,

§

impl<A> Unpin for AllUsers<A>
where A: Unpin,

§

impl<A> UnwindSafe for AllUsers<A>
where A: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.