Struct nix::unistd::Group

pub struct Group {    
    pub name: String,
    pub passwd: CString,
    pub gid: Gid,
    pub mem: Vec<String>,
}
Documentation

Representation of a Group, based on libc::group

Fields

pub name: String

Group name

pub passwd: CString

Group password

pub gid: Gid

Group ID

pub mem: Vec<String>

List of Group members

Implementations

impl Group
pub fn from_gid(gid: Gid) -> Result<Option<Self>>

Get a group by GID.

Internally, this function calls getgrgid_r(3)

Examples

use nix::unistd::{Gid, Group};
// Returns an Result<Option<Group>>, thus the double unwrap.
let res = Group::from_gid(Gid::from_raw(0)).unwrap().unwrap();
assert!(res.name == "root");
pub fn from_name(name: &str) -> Result<Option<Self>>

Get a group by name.

Internally, this function calls getgrnam_r(3)

Examples

use nix::unistd::Group;
// Returns an Result<Option<Group>>, thus the double unwrap.
let res = Group::from_name("root").unwrap().unwrap();
assert!(res.name == "root");

Trait Implementations

impl Clone for Group
fn clone(&Self) -> Group
impl Debug for Group
fn fmt(&Self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
impl From<&group> for Group
fn from(gr: &libc::group) -> Group
impl PartialEq<Group> for Group
fn eq(&Self, other: &Group) -> bool
fn ne(&Self, other: &Group) -> bool

Auto Trait Implementations

impl RefUnwindSafe for Group
impl Send for Group
impl Sync for Group
impl Unpin for Group
impl UnwindSafe for Group

Blanket Implementations

impl<T> Any for T
where
    T: 'static + ?Sized,
fn type_id(&Self) -> TypeId
impl<T> Borrow<T> for T
where
    T: ?Sized,
fn borrow(&Self) -> &T
impl<T> BorrowMut<T> for T
where
    T: ?Sized,
fn borrow_mut(&mut Self) -> &mut T
impl<T> From<T> for T
fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into<U> for T
where
    U: From<T>,
fn into(Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

impl<T> ToOwned for T
where
    T: Clone,
type Owned = T
fn to_owned(&Self) -> T
fn clone_into(&Self, target: &mut T)
impl<T, U> TryFrom<U> for T
where
    U: Into<T>,
type Error = Infallible
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for T
where
    U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn try_into(Self) -> Result<U, <U as TryFrom<T>>::Error>