liminal-rs 0.16.2

A conversation-based messaging bus built on beamr
Documentation
//! Every counter of a [`StoreCounts`] by name, in the one order its
//! [`fmt::Display`] prints them in, so two runs compare line by line.

use std::fmt;

use super::StoreCounts;

impl StoreCounts {
    /// Every counter with its name, in the one fixed order [`fmt::Display`]
    /// prints them in.
    #[must_use]
    pub const fn named(&self) -> [(&'static str, u64); 22] {
        [
            ("append_calls", self.append_calls),
            ("append_rows", self.append_rows),
            ("append_bytes", self.append_bytes),
            ("append_all_calls", self.append_all_calls),
            ("append_all_rows", self.append_all_rows),
            ("append_all_bytes", self.append_all_bytes),
            ("read_from_calls", self.read_from_calls),
            ("read_from_rows", self.read_from_rows),
            ("read_at_calls", self.read_at_calls),
            ("read_at_rows", self.read_at_rows),
            ("cas_calls", self.cas_calls),
            ("read_value_calls", self.read_value_calls),
            (
                "read_stream_next_seq_calls",
                self.read_stream_next_seq_calls,
            ),
            ("scan_page_calls", self.scan_page_calls),
            ("scan_page_rows", self.scan_page_rows),
            ("flushes", self.flushes),
            ("truncate_calls", self.truncate_calls),
            ("truncate_rows", self.truncate_rows),
            ("apply_routed_batch_calls", self.apply_routed_batch_calls),
            ("apply_routed_batch_items", self.apply_routed_batch_items),
            ("get_routed_calls", self.get_routed_calls),
            ("get_routed_rows", self.get_routed_rows),
        ]
    }
}

/// One counter per line, `name value`, in the order of [`StoreCounts::named`],
/// so two runs compare line by line.
impl fmt::Display for StoreCounts {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        for (name, value) in self.named() {
            writeln!(formatter, "{name} {value}")?;
        }
        Ok(())
    }
}