pub struct User { /* private fields */ }
Expand description
A record(line) in the user database /etc/passwd
found in most linux systems.
Implementations§
Source§impl User
impl User
pub const fn get_shadow(&self) -> Option<&Shadow>
pub fn remove_in(&self, content: &str) -> String
pub fn username(&mut self, name: String) -> &mut Self
pub fn disable_password(&mut self) -> &mut Self
pub fn uid(&mut self, uid: u32) -> &mut Self
pub fn gid(&mut self, gid: u32) -> &mut Self
pub fn home_dir(&mut self, path: String) -> &mut Self
pub fn shell_path(&mut self, path: String) -> &mut Self
pub fn add_group(&mut self, group_type: Membership, group: Group) -> &mut Self
pub const fn get_groups(&self) -> &Vec<(Membership, Group)>
Trait Implementations§
Source§impl NewFromString for User
impl NewFromString for User
Source§fn new_from_string(line: String, position: u32) -> Result<Self, UserLibError>where
Self: Sized,
fn new_from_string(line: String, position: u32) -> Result<Self, UserLibError>where
Self: Sized,
Parse a line formatted like one in /etc/passwd
and construct a matching User
instance
§Example
use crate::umanux::api::UserRead;
use umanux::NewFromString;
let pwd = umanux::User::new_from_string(
"testuser:testpassword:1001:1001:full Name,,,,:/home/test:/bin/test".to_string(), 0).unwrap();
assert_eq!(pwd.get_username().unwrap(), "testuser");
§Errors
When parsing fails this function returns a UserLibError::Message
containing some information as to why the function failed.
Source§impl Ord for User
impl Ord for User
Source§impl PartialOrd for User
impl PartialOrd for User
Source§impl UserRead for User
impl UserRead for User
fn get_username(&self) -> Option<&str>
fn get_password(&self) -> Option<&str>
fn get_uid(&self) -> u32
fn get_gid(&self) -> u32
fn get_gecos(&self) -> Option<&Gecos>
fn get_home_dir(&self) -> Option<&str>
fn get_shell_path(&self) -> Option<&str>
fn get_full_name(&self) -> Option<&str>
fn get_room(&self) -> Option<&str>
fn get_phone_work(&self) -> Option<&str>
fn get_phone_home(&self) -> Option<&str>
fn get_other(&self) -> Option<&Vec<String>>
impl Eq for User
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 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