@@ -8,6 +8,10 @@ use ::error::{ProcError, ProcFile, ProcOper};
8
8
use :: { TaskId , MemSize } ;
9
9
10
10
#[ 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.
11
15
pub struct PidStatus {
12
16
// TODO: Maybe these should all be optional, and be more annoying to call
13
17
pub name : String ,
@@ -95,7 +99,7 @@ macro_rules! extract_line_opt {
95
99
}
96
100
97
101
impl PidStatus {
98
- // Generate PidStatus struct given a process directory
102
+ /// Generate PidStatus struct given a process directory
99
103
pub fn new ( pid_dir : & Path ) -> Result < Self , ProcError > {
100
104
// Try opening file
101
105
let status_file = try!(
@@ -115,6 +119,7 @@ impl PidStatus {
115
119
Self :: parse_string ( lines)
116
120
}
117
121
122
+ /// Parse an Iterator of lines as a /proc/[pid]/status file.
118
123
fn parse_string < I : Iterator < Item =Result < String , ProcError > > > ( mut lines : I ) -> Result < Self , ProcError > {
119
124
// It's quite important that these appear in the order that they
120
125
// appear in the status file
@@ -161,11 +166,12 @@ lazy_static! {
161
166
162
167
163
168
164
- // Parse anything that's parsable (type checker didn't like simple closures) .
169
+ /// Parse anything that's parsable from a string .
165
170
fn parse_any < N : FromStr > ( str : & str ) -> Result < N , N :: Err > {
166
171
str. parse ( )
167
172
}
168
173
174
+ /// Parse a set of four numbers as uids or gids.
169
175
fn parse_uids ( uid_str : & str ) -> Result < ( u32 , u32 , u32 , u32 ) , ProcError > {
170
176
let uids = try!(
171
177
uid_str. split ( "\t " )
@@ -186,6 +192,7 @@ fn parse_uids(uid_str: &str) -> Result<(u32, u32, u32, u32), ProcError> {
186
192
Ok ( ( uids[ 0 ] , uids[ 1 ] , uids[ 2 ] , uids[ 3 ] ) )
187
193
}
188
194
195
+ /// Parse a string as a kB memory string.
189
196
fn parse_mem ( mem_str : & str ) -> Result < MemSize , ParseIntError > {
190
197
mem_str. trim_right_matches ( " kB" )
191
198
. parse :: < MemSize > ( )
0 commit comments