INNER CODE UNIT · Rust

parse_labels

rustic-rs/rustic · src/config.rs:268

pub fn parse_labels(s: &str) -> Result<BTreeMap<String, String>> {
    s.split(',')
        .filter_map(|s| {
            let s = s.trim();
            (!s.is_empty()).then_some(s)
        })
        .map(|s| -> Result<_> {
            let pos = s.find('=').ok_or_else(|| {
                anyhow!("invalid prometheus label definition: no `=` found in `{s}`")
            })?;
            Ok((s[..pos].to_owned(), s[pos + 1..].to_owned()))
        })
        .try_collect()
}

impl GlobalOptions {
    pub fn is_metrics_configured(&self) -> bool {
        self.prometheus.is_some() || self.opentelemetry.is_some()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…