Struct users::User

source · []
pub struct User { /* private fields */ }
Expand description

Information about a particular user.

For more information, see the module documentation.

Implementations

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);

Returns this user’s ID.

Examples
use users::User;

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

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"));

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);

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns a path to this user’s home directory.

Sets this user value’s home directory to the given string. Can be used to construct test users, which by default come with a dummy home directory string. Read more

Returns a path to this user’s shell.

Sets this user’s shell path to the given string. Can be used to construct test users, which by default come with a dummy shell field. Read more

Returns the user’s encrypted password.

Sets this user’s password to the given string. Can be used to construct tests users, which by default come with a dummy password field. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.