Skip to content

Commit 260a1e6

Browse files
Add some more docstrings
1 parent 2ada467 commit 260a1e6

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/procrs/pid/stat.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use TaskId;
66

77
/// A struct containing information from the stat file for a process.
88
///
9-
/// This struct contains information from the /proc/[pid]/stat file
9+
/// This struct contains information from the /proc/[pid]/stat or
10+
/// /proc/[tgid]/task/[tid]/stat file, for a specific pid or tgid/tid.
1011
/// for a specific pid.
1112
#[derive(Debug, Clone, PartialEq)]
1213
pub struct PidStat {

src/procrs/pid/status.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ use ::error::{ProcError, ProcFile, ProcOper};
88
use ::{TaskId, MemSize};
99

1010
#[derive(Debug, PartialEq)]
11+
/// A struct containing information from the status file for a process.
12+
///
13+
/// This struct contains information from the /proc/[pid]/status or
14+
/// /proc/[tgid]/task/[tid]/status file, for a specific pid or tgid/tid.
1115
pub struct PidStatus {
1216
// TODO: Maybe these should all be optional, and be more annoying to call
1317
pub name: String,
@@ -95,7 +99,7 @@ macro_rules! extract_line_opt {
9599
}
96100

97101
impl PidStatus {
98-
// Generate PidStatus struct given a process directory
102+
/// Generate PidStatus struct given a process directory
99103
pub fn new(pid_dir: &Path) -> Result<Self, ProcError> {
100104
// Try opening file
101105
let status_file = try!(
@@ -115,6 +119,7 @@ impl PidStatus {
115119
Self::parse_string(lines)
116120
}
117121

122+
/// Parse an Iterator of lines as a /proc/[pid]/status file.
118123
fn parse_string<I: Iterator<Item=Result<String, ProcError>>>(mut lines: I) -> Result<Self, ProcError> {
119124
// It's quite important that these appear in the order that they
120125
// appear in the status file
@@ -161,11 +166,12 @@ lazy_static! {
161166

162167

163168

164-
// Parse anything that's parsable (type checker didn't like simple closures).
169+
/// Parse anything that's parsable from a string.
165170
fn parse_any<N: FromStr>(str: &str) -> Result<N, N::Err> {
166171
str.parse()
167172
}
168173

174+
/// Parse a set of four numbers as uids or gids.
169175
fn parse_uids(uid_str: &str) -> Result<(u32, u32, u32, u32), ProcError> {
170176
let uids = try!(
171177
uid_str.split("\t")
@@ -186,6 +192,7 @@ fn parse_uids(uid_str: &str) -> Result<(u32, u32, u32, u32), ProcError> {
186192
Ok((uids[0], uids[1], uids[2], uids[3]))
187193
}
188194

195+
/// Parse a string as a kB memory string.
189196
fn parse_mem(mem_str: &str) -> Result<MemSize, ParseIntError> {
190197
mem_str.trim_right_matches(" kB")
191198
.parse::<MemSize>()

0 commit comments

Comments
 (0)