pub struct PwdGrp;
Expand description
Provider of passwd and group information, from system databases
The actual functionality is provided by methods of
PwdGrpProvider
.
These are generic over the returned string type.
This enables working with non-UTF-8 data in passwd/group files,
and also with Box<str>
.
If you just want to work with String
,
use the plain functions in the module toplevel.
Examples
use pwd_grp::Passwd;
use pwd_grp::PwdGrpProvider as _;
use pwd_grp::PwdGrp;
let pwent: Passwd<Vec<u8>> = PwdGrp.getpwuid(0).unwrap().unwrap();
assert_eq!(pwent.uid, 0);
match std::str::from_utf8(&pwent.gecos) {
Ok(s) => println!("root user gecos: {}", s),
Err(_) => println!("root user gecos is not valid UTF-8"),
}
Trait Implementations§
source§impl Ord for PwdGrp
impl Ord for PwdGrp
source§impl PartialEq<PwdGrp> for PwdGrp
impl PartialEq<PwdGrp> for PwdGrp
source§impl PartialOrd<PwdGrp> for PwdGrp
impl PartialOrd<PwdGrp> for PwdGrp
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PwdGrpProvider for PwdGrp
impl PwdGrpProvider for PwdGrp
source§fn getpwnam<S: PwdGrpString>(
&self,
name: impl AsRef<<S as Deref>::Target>
) -> Result<Option<Passwd<S>>>
fn getpwnam<S: PwdGrpString>( &self, name: impl AsRef<<S as Deref>::Target> ) -> Result<Option<Passwd<S>>>
Look up a
passwd
entry by
name,
returning strings as
S
source§fn getpwuid<S: PwdGrpString>(&self, uid: uid_t) -> Result<Option<Passwd<S>>>
fn getpwuid<S: PwdGrpString>(&self, uid: uid_t) -> Result<Option<Passwd<S>>>
Look up a
passwd
entry by
uid,
returning strings as
S
source§fn getgrnam<S: PwdGrpString>(
&self,
name: impl AsRef<<S as Deref>::Target>
) -> Result<Option<Group<S>>>
fn getgrnam<S: PwdGrpString>( &self, name: impl AsRef<<S as Deref>::Target> ) -> Result<Option<Group<S>>>
Look up a
group
entry by
name,
returning strings as
S
source§fn getgrgid<S: PwdGrpString>(&self, gid: uid_t) -> Result<Option<Group<S>>>
fn getgrgid<S: PwdGrpString>(&self, gid: uid_t) -> Result<Option<Group<S>>>
Look up a
group
entry by
gid,
returning strings as
S
source§fn getresuid(&self) -> (uid_t, uid_t, uid_t)
fn getresuid(&self) -> (uid_t, uid_t, uid_t)
Get the current process’s
real, effective and saved set-uid Read more
impl Eq for PwdGrp
impl StructuralEq for PwdGrp
impl StructuralPartialEq for PwdGrp
Auto Trait Implementations§
impl RefUnwindSafe for PwdGrp
impl Send for PwdGrp
impl Sync for PwdGrp
impl Unpin for PwdGrp
impl UnwindSafe for PwdGrp
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