[go: up one dir, main page]

Struct users::mock::MockUsers [] [src]

pub struct MockUsers {
    // some fields omitted
}

A mocking users object that you can add your own users and groups to.

Methods

impl MockUsers
[src]

fn with_current_uid(current_uid: i32) -> MockUsers

Create a new, empty mock users object.

fn add_user(&mut self, user: User) -> Option<User>

Add a user to the users table.

fn add_group(&mut self, group: Group) -> Option<Group>

Add a group to the groups table.

Trait Implementations

impl Users for MockUsers
[src]

fn get_user_by_uid(&mut self, uid: i32) -> Option<User>

Return a User object if one exists for the given user ID; otherwise, return None.

fn get_user_by_name(&mut self, username: &str) -> Option<User>

Return a User object if one exists for the given username; otherwise, return None.

fn get_group_by_gid(&mut self, gid: u32) -> Option<Group>

Return a Group object if one exists for the given group ID; otherwise, return None.

fn get_group_by_name(&mut self, group_name: &str) -> Option<Group>

Return a Group object if one exists for the given groupname; otherwise, return None.

fn get_current_uid(&mut self) -> i32

Return the user ID for the user running the process.

fn get_current_username(&mut self) -> Option<String>

Return the username of the user running the process.