Parses `/proc/swaps`, whose rows read as `Filename Type Size Used Priority`.
(content: &str)
| 164 | impl SwapArea { |
| 165 | /// Parses `/proc/swaps`, whose rows read as `Filename Type Size Used Priority`. |
| 166 | fn parse_all(content: &str) -> Vec<Self> { |
| 167 | content |
| 168 | .lines() |
| 169 | .skip(1) |
| 170 | .filter_map(|line| { |
| 171 | let mut columns = line.split_whitespace(); |
| 172 | let path = columns.next()?.to_string(); |
| 173 | // Type and Size sit between Filename and Used. |
| 174 | let used_kib = columns.nth(2)?.parse().ok()?; |
| 175 | let priority = columns.next()?.parse().ok()?; |
| 176 | |
| 177 | Some(Self { |
| 178 | path, |
| 179 | used_kib, |
| 180 | priority, |
| 181 | }) |
| 182 | }) |
| 183 | .collect() |
| 184 | } |
| 185 | |
| 186 | /// `swapon` arguments re-enabling the area with the priority it had. |
| 187 | /// `SWAP_FLAG_PREFER` only encodes `0..=32767`, so a kernel-assigned |