async_resol_vbus/
error.rs

1/// A common error type.
2#[derive(Debug, PartialEq)]
3pub struct Error {
4    message: String,
5}
6
7/// A common result type.
8pub type Result<T> = std::result::Result<T, Error>;
9
10pub trait IntoError: std::fmt::Display {}
11
12impl<T: IntoError> From<T> for Error {
13    fn from(other: T) -> Error {
14        let message = format!("{}", other);
15        Error { message }
16    }
17}
18
19impl IntoError for &str {}
20impl IntoError for String {}
21impl IntoError for std::io::Error {}
22impl IntoError for std::net::AddrParseError {}
23impl IntoError for std::str::Utf8Error {}