Struct users::cache::UsersCache
source · [−]pub struct UsersCache { /* private fields */ }
Expand description
A producer of user and group instances that caches every result.
For more information, see the users::cache
module documentation.
Implementations
sourceimpl UsersCache
impl UsersCache
sourcepub unsafe fn with_all_users() -> Self
pub unsafe fn with_all_users() -> Self
Creates a new cache that contains all the users present on the system.
Safety
This is unsafe
because we cannot prevent data races if two caches
were attempted to be initialised on different threads at the same time.
For more information, see the all_users
documentation.
Examples
use users::cache::UsersCache;
let cache = unsafe { UsersCache::with_all_users() };
Trait Implementations
sourceimpl Default for UsersCache
impl Default for UsersCache
sourceimpl Groups for UsersCache
impl Groups for UsersCache
sourcefn get_group_by_gid(&self, gid: gid_t) -> Option<Arc<Group>>
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
.
sourcefn get_group_by_name<S: AsRef<OsStr> + ?Sized>(
&self,
group_name: &S
) -> Option<Arc<Group>>
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
.
sourcefn get_current_gid(&self) -> gid_t
fn get_current_gid(&self) -> gid_t
Returns the group ID for the user running the process.
sourcefn get_current_groupname(&self) -> Option<Arc<OsStr>>
fn get_current_groupname(&self) -> Option<Arc<OsStr>>
Returns the group name of the user running the process.
sourcefn get_effective_gid(&self) -> gid_t
fn get_effective_gid(&self) -> gid_t
Returns the effective group id.
sourcefn get_effective_groupname(&self) -> Option<Arc<OsStr>>
fn get_effective_groupname(&self) -> Option<Arc<OsStr>>
Returns the effective group name.
sourceimpl Users for UsersCache
impl Users for UsersCache
sourcefn get_user_by_uid(&self, uid: uid_t) -> Option<Arc<User>>
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
.
sourcefn get_user_by_name<S: AsRef<OsStr> + ?Sized>(
&self,
username: &S
) -> Option<Arc<User>>
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
.
sourcefn get_current_uid(&self) -> uid_t
fn get_current_uid(&self) -> uid_t
Returns the user ID for the user running the process.
sourcefn get_current_username(&self) -> Option<Arc<OsStr>>
fn get_current_username(&self) -> Option<Arc<OsStr>>
Returns the username of the user running the process.
sourcefn get_effective_uid(&self) -> uid_t
fn get_effective_uid(&self) -> uid_t
Returns the effective user id.
sourcefn get_effective_username(&self) -> Option<Arc<OsStr>>
fn get_effective_username(&self) -> Option<Arc<OsStr>>
Returns the effective username.
Auto Trait Implementations
impl !RefUnwindSafe for UsersCache
impl Send for UsersCache
impl !Sync for UsersCache
impl Unpin for UsersCache
impl UnwindSafe for UsersCache
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more