1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use std::{
fmt::{self, Debug, Formatter},
net::SocketAddr,
path::PathBuf,
};
use failure::Fail;
pub trait Location: Debug + Send + Sync + 'static {
fn fmt_error(&self, f: &mut Formatter, error: &dyn Fail) -> fmt::Result;
}
impl Location for PathBuf {
fn fmt_error(&self, f: &mut Formatter, error: &dyn Fail) -> fmt::Result {
write!(f, "{}: {}", self.display(), error)
}
}
impl Location for SocketAddr {
fn fmt_error(&self, f: &mut Formatter, error: &dyn Fail) -> fmt::Result {
write!(f, "{}: {}", self, error)
}
}
impl Location for String {
fn fmt_error(&self, f: &mut Formatter, error: &dyn Fail) -> fmt::Result {
write!(f, "{}: {}", self, error)
}
}