fn try_map<F,T>(&self, f: F) -> T
where F: FnOnce(Option<&'v str>) -> Result<T, AE> {
f(self.raw)
- .with_context(|| format!(r#"file {:?}, section "{:?}", key "{}""#,
+ .with_context(|| format!(r#"file {:?}, section {}, key "{}""#,
self.loc, self.section, self.key))?
}
}
SN::Link(LinkName { server, client })
}
}
+impl Display for SectionName {
+ #[throws(fmt::Error)]
+ fn fmt(&self, f: &mut fmt::Formatter) {
+ match self {
+ SN::Link (ref l) => Display::fmt(l, f)?,
+ SN::Client(ref c) => write!(f, "[{}]" , c)?,
+ SN::Server(ref s) => write!(f, "[{}]" , s)?,
+ SN::ServerLimit(ref s) => write!(f, "[{} LIMIT] ", s)?,
+ SN::GlobalLimit => write!(f, "[LIMIT]" )?,
+ SN::Common => write!(f, "[COMMON]" )?,
+ }
+ }
+}
impl Aggregate {
#[throws(AE)] // AE does not include path
};
let mut ic = InstanceConfig::resolve_instance(&rctx)
- .with_context(|| format!(r#"resolve config for "{:?}""#, &link))?;
+ .with_context(|| format!("resolve config for {}", &link))?;
ic.complete(end)
- .with_context(|| format!(r#"complete config for "{:?}""#, &link))?;
+ .with_context(|| format!("complete config for {}", &link))?;
ics.push(ic);
}
pub use std::collections::{BTreeSet, HashMap};
pub use std::cmp::{min, max};
pub use std::fs;
-pub use std::fmt::{self, Debug};
+pub use std::fmt::{self, Debug, Display};
pub use std::io::{self, ErrorKind, Read as _};
pub use std::mem;
pub use std::net::{IpAddr, Ipv4Addr};
ServerName(s.into())
}
}
+
+impl Display for ServerName {
+ #[throws(fmt::Error)]
+ fn fmt(&self, f: &mut fmt::Formatter) { Display::fmt(&self.0, f)?; }
+}
+impl Display for ClientName {
+ #[throws(fmt::Error)]
+ fn fmt(&self, f: &mut fmt::Formatter) { Display::fmt(&self.0, f)?; }
+}
+impl Display for LinkName {
+ #[throws(fmt::Error)]
+ fn fmt(&self, f: &mut fmt::Formatter) {
+ write!(f, "[{} {}]", &self.server, &self.client)?;
+ }
+}