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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#[derive(Debug, PartialEq, Clone)]
pub struct HcidError(pub String);
pub type HcidResult<T> = Result<T, HcidError>;
impl std::fmt::Display for HcidError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}
impl std::error::Error for HcidError {
fn description(&self) -> &str {
&self.0
}
fn cause(&self) -> Option<&std::error::Error> {
None
}
}
impl From<String> for HcidError {
fn from(error: String) -> Self {
Self(error)
}
}
impl<'a> From<&'a str> for HcidError {
fn from(error: &'a str) -> Self {
Self(error.to_string())
}
}
impl From<reed_solomon::DecoderError> for HcidError {
fn from(error: reed_solomon::DecoderError) -> Self {
Self(format!("{:?}", error))
}
}
impl From<std::num::ParseIntError> for HcidError {
fn from(error: std::num::ParseIntError) -> Self {
Self(format!("{:?}", error))
}
}