UserBuilder

Struct UserBuilder 

Source
pub struct UserBuilder { /* private fields */ }
Expand description

A builder pattern for adding Users to AllUsers. Fields are verified when the group is built via AllUsers::add_user. See the documentation of that function for default values.

Note that this builder is not available when the auth feature of the crate is disabled.

§Example

let mut allgs = AllGroups::new(Config::default()).unwrap();

let g = GroupBuilder::new("foobar")
    .user("foobar");
let foobar_g = allgs.add_group(g).unwrap();

let u = UserBuilder::new("foobar")
    .gid(foobar_g.gid)
    .name("Foo Bar")
    // Note that this directory will not be created
    .home("file:/home/foobar");

Implementations§

Source§

impl UserBuilder

Source

pub fn new(user: impl AsRef<str>) -> UserBuilder

Create a new UserBuilder with the login name for the new user.

Source

pub fn uid(self, uid: usize) -> UserBuilder

Set the user id for this user.

Source

pub fn gid(self, gid: usize) -> UserBuilder

Set the primary group id for this user.

Source

pub fn name(self, name: impl AsRef<str>) -> UserBuilder

Set the GECOS field for this user.

Source

pub fn home(self, home: impl AsRef<str>) -> UserBuilder

Set the home directory for this user.

Source

pub fn shell(self, shell: impl AsRef<str>) -> UserBuilder

Set the login shell for this user.

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.