Skip to content

Commit 6e70bc9

Browse files
committed
Added documentation
1 parent 072f523 commit 6e70bc9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/unistd.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,22 @@ pub use self::linux::*;
2424
pub struct Uid(uid_t);
2525

2626
impl Uid {
27+
/// Creates `Uid` from raw `uid_t`.
2728
pub fn from_raw(uid: uid_t) -> Self {
2829
Uid(uid)
2930
}
3031

32+
/// Returns Uid of calling process. This is practically a more Rusty alias for `getuid`.
3133
pub fn current() -> Self {
3234
getuid()
3335
}
3436

37+
/// Returns effective Uid of calling process. This is practically a more Rusty alias for `geteuid`.
3538
pub fn effective() -> Self {
3639
geteuid()
3740
}
3841

42+
/// Returns true if the `Uid` represents privileged user - root. (If it equals zero.)
3943
pub fn is_root(&self) -> bool {
4044
self.0 == 0
4145
}
@@ -64,14 +68,17 @@ pub const ROOT: Uid = Uid(0);
6468
pub struct Gid(gid_t);
6569

6670
impl Gid {
71+
/// Creates `Gid` from raw `gid_t`.
6772
pub fn from_raw(gid: gid_t) -> Self {
6873
Gid(gid)
6974
}
7075

76+
/// Returns Gid of calling process. This is practically a more Rusty alias for `getgid`.
7177
pub fn current() -> Self {
7278
getgid()
7379
}
7480

81+
/// Returns effective Gid of calling process. This is practically a more Rusty alias for `getgid`.
7582
pub fn effective() -> Self {
7683
getegid()
7784
}
@@ -97,14 +104,17 @@ impl fmt::Display for Gid {
97104
pub struct Pid(pid_t);
98105

99106
impl Pid {
107+
/// Creates `Pid` from raw `pid_t`.
100108
pub fn from_raw(pid: pid_t) -> Self {
101109
Pid(pid)
102110
}
103111

112+
/// Returns PID of calling process
104113
pub fn this() -> Self {
105114
getpid()
106115
}
107116

117+
/// Returns PID of parent of calling process
108118
pub fn parent() -> Self {
109119
getppid()
110120
}

0 commit comments

Comments
 (0)