[][src]Struct users::User

pub struct User { /* fields omitted */ }

Information about a particular user.

For more information, see the module documentation.

Methods

impl User[src]

pub fn new<S: AsRef<OsStr> + ?Sized>(
    uid: uid_t,
    name: &S,
    primary_group: gid_t
) -> Self
[src]

Create a new User with the given user ID, name, and primary group ID, with the rest of the fields filled with dummy values.

This method does not actually create a new user on the system — it should only be used for comparing users in tests.

Examples

use users::User;

let user = User::new(501, "stevedore", 100);

pub fn uid(&self) -> uid_t[src]

Returns this user’s ID.

Examples

use users::User;

let user = User::new(501, "stevedore", 100);
assert_eq!(user.uid(), 501);

pub fn name(&self) -> &OsStr[src]

Returns this user’s name.

Examples

use std::ffi::OsStr;
use users::User;

let user = User::new(501, "stevedore", 100);
assert_eq!(user.name(), OsStr::new("stevedore"));

pub fn primary_group_id(&self) -> gid_t[src]

Returns the ID of this user’s primary group.

Examples

use users::User;

let user = User::new(501, "stevedore", 100);
assert_eq!(user.primary_group_id(), 100);

pub fn groups(&self) -> Option<Vec<Group>>[src]

Returns a list of groups this user is a member of. This involves loading the groups list, as it is not contained within this type.

libc functions used

Examples

use users::User;

let user = User::new(501, "stevedore", 100);
for group in user.groups().expect("User not found") {
    println!("User is in group: {:?}", group.name());
}

Trait Implementations

impl UserExt for User[src]

impl Clone for User[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for User[src]

Auto Trait Implementations

impl Send for User

impl Sync for User

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]