pub struct User(pub User);Expand description
A value representing a user.
Tuple Fields§
§0: UserImplementations§
Source§impl User
impl User
Sourcepub fn from_uid(uid: Uid) -> Result<Self, String>
pub fn from_uid(uid: Uid) -> Result<Self, String>
Get a user by UID.
§Examples
use dmon::user::User;
let user = User::from_uid(0.into()).unwrap();
assert_eq!(user.0.name, "root");Sourcepub fn from_name(name: &str) -> Result<Self, String>
pub fn from_name(name: &str) -> Result<Self, String>
Get a user by name.
§Examples
use dmon::{nix::unistd::Uid, user::User};
let user: User = "root".parse().unwrap();
assert_eq!(user.0.uid, Uid::from_raw(0));Sourcepub unsafe fn set_env(&self)
pub unsafe fn set_env(&self)
Sets certain environment variables to the appropriate values.
Specifically, this sets the USER, HOME, and SHELL environment
variables to the values found in /etc/passwd for the user.
§Safety
This method is unsafe to call from a multi-threaded program. See
std::env::set_var for more information.
Trait Implementations§
impl Eq for User
Source§impl FromStr for User
impl FromStr for User
Source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parses the string into a User.
If the string is a number, it will be treated as the user’s UID. Otherwise, it will be treated as the user’s name.
§Examples
use dmon::{nix::unistd::Uid, user::User};
let user: User = "0".parse().unwrap();
assert_eq!(user.0.name, "root");
let user: User = "root".parse().unwrap();
assert_eq!(user.0.uid, Uid::from_raw(0));impl StructuralPartialEq for User
Auto Trait Implementations§
impl Freeze for User
impl RefUnwindSafe for User
impl Send for User
impl Sync for User
impl Unpin for User
impl UnsafeUnpin for User
impl UnwindSafe for User
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more