Skip to main content

parse_diskstats

Function parse_diskstats 

Source
pub fn parse_diskstats<F>(content: &str, keep: F) -> Vec<IoCounters>
where F: Fn(&str) -> bool,
Expand description

Parses /proc/diskstats into per-device byte counters.

keep decides which device names survive; it is injected rather than hardcoded so the tests can assert against a verbatim fixture without depending on the block devices of whatever machine runs them — the #155/v0.6.2 lesson, where a “parse this fixture” test silently consulted live hardware and failed on one developer’s box.

Lines with too few fields or unparsable counters are skipped rather than defaulted to zero: a zero would render as a confident 0 B/s for a device that was never read.