fn parse()

in netbench-collector/src/bpftrace.rs [213:234]


    fn parse(s: &str) -> Result<Self> {
        let mut parts = s.split(", ");

        macro_rules! part {
            ($name:ident) => {{
                let err = concat!("missing ", stringify!($name));
                let value = parts.next().ok_or(err)?;
                let value = value
                    .strip_prefix(concat!(stringify!($name), " "))
                    .ok_or(err)?;
                let value = value.parse().map_err(|_| err)?;
                value
            }};
        }

        let count = part!(count);
        // skip average since it can be computed with the other values
        let _average = parts.next();
        let total = part!(total);

        Ok(Self { count, total })
    }