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
impl UserBuilder
Sourcepub fn new(user: impl AsRef<str>) -> UserBuilder
pub fn new(user: impl AsRef<str>) -> UserBuilder
Create a new UserBuilder with the login name for the new user.
Sourcepub fn uid(self, uid: usize) -> UserBuilder
pub fn uid(self, uid: usize) -> UserBuilder
Set the user id for this user.
Sourcepub fn gid(self, gid: usize) -> UserBuilder
pub fn gid(self, gid: usize) -> UserBuilder
Set the primary group id for this user.
Sourcepub fn name(self, name: impl AsRef<str>) -> UserBuilder
pub fn name(self, name: impl AsRef<str>) -> UserBuilder
Set the GECOS field for this user.
Sourcepub fn home(self, home: impl AsRef<str>) -> UserBuilder
pub fn home(self, home: impl AsRef<str>) -> UserBuilder
Set the home directory for this user.
Sourcepub fn shell(self, shell: impl AsRef<str>) -> UserBuilder
pub fn shell(self, shell: impl AsRef<str>) -> UserBuilder
Set the login shell for this user.