Skip to main content

MockUsers

Struct MockUsers 

Source
pub struct MockUsers { /* private fields */ }
Expand description

A mocking users table that you can add your own users and groups to.

Implementations§

Source§

impl MockUsers

Source

pub fn with_current_uid(current_uid: uid_t) -> Self

Create a new, empty mock users table.

Source

pub fn add_user(&mut self, user: User) -> Option<Arc<User>>

Add a user to the users table.

Source

pub fn add_group(&mut self, group: Group) -> Option<Arc<Group>>

Add a group to the groups table.

Trait Implementations§

Source§

impl Groups for MockUsers

Source§

fn get_group_by_gid(&self, gid: gid_t) -> Option<Arc<Group>>

Returns a Group if one exists for the given group ID; otherwise, returns None.
Source§

fn get_group_by_name<S: AsRef<OsStr> + ?Sized>( &self, group_name: &S, ) -> Option<Arc<Group>>

Returns a Group if one exists for the given groupname; otherwise, returns None.
Source§

fn get_current_gid(&self) -> uid_t

Returns the group ID for the user running the process.
Source§

fn get_current_groupname(&self) -> Option<Arc<OsStr>>

Returns the group name of the user running the process.
Source§

fn get_effective_gid(&self) -> uid_t

Returns the effective group id.
Source§

fn get_effective_groupname(&self) -> Option<Arc<OsStr>>

Returns the effective group name.
Source§

impl Users for MockUsers

Source§

fn get_user_by_uid(&self, uid: uid_t) -> Option<Arc<User>>

Returns a User if one exists for the given user ID; otherwise, returns None.
Source§

fn get_user_by_name<S: AsRef<OsStr> + ?Sized>( &self, username: &S, ) -> Option<Arc<User>>

Returns a User if one exists for the given username; otherwise, returns None.
Source§

fn get_current_uid(&self) -> uid_t

Returns the user ID for the user running the process.
Source§

fn get_current_username(&self) -> Option<Arc<OsStr>>

Returns the username of the user running the process.
Source§

fn get_effective_uid(&self) -> uid_t

Returns the effective user id.
Source§

fn get_effective_username(&self) -> Option<Arc<OsStr>>

Returns the effective username.

Auto Trait Implementations§

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>,

Source§

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>,

Source§

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.