1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use std::ffi::{OsStr, OsString};
use std::sync::Arc;
use libc::{uid_t, gid_t};
use base::{User, Group};
pub trait Users {
fn get_user_by_uid(&self, uid: uid_t) -> Option<Arc<User>>;
fn get_user_by_name<S: AsRef<OsStr> + ?Sized>(&self, username: &S) -> Option<Arc<User>>;
fn get_current_uid(&self) -> uid_t;
fn get_current_username(&self) -> Option<Arc<OsString>>;
fn get_effective_uid(&self) -> uid_t;
fn get_effective_username(&self) -> Option<Arc<OsString>>;
}
pub trait Groups {
fn get_group_by_gid(&self, gid: gid_t) -> Option<Arc<Group>>;
fn get_group_by_name<S: AsRef<OsStr> + ?Sized>(&self, group_name: &S) -> Option<Arc<Group>>;
fn get_current_gid(&self) -> gid_t;
fn get_current_groupname(&self) -> Option<Arc<OsString>>;
fn get_effective_gid(&self) -> gid_t;
fn get_effective_groupname(&self) -> Option<Arc<OsString>>;
}