1#[derive(Debug, PartialEq, Clone)]
3pub struct HcidError(pub String);
4
5pub type HcidResult<T> = Result<T, HcidError>;
7
8impl std::fmt::Display for HcidError {
9 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
10 write!(f, "{:?}", self)
11 }
12}
13
14impl std::error::Error for HcidError {
15 fn description(&self) -> &str {
16 &self.0
17 }
18 fn cause(&self) -> Option<&std::error::Error> {
19 None
20 }
21}
22
23impl From<String> for HcidError {
24 fn from(error: String) -> Self {
25 Self(error)
26 }
27}
28
29impl<'a> From<&'a str> for HcidError {
30 fn from(error: &'a str) -> Self {
31 Self(error.to_string())
32 }
33}
34
35impl From<reed_solomon::DecoderError> for HcidError {
36 fn from(error: reed_solomon::DecoderError) -> Self {
37 Self(format!("{:?}", error))
38 }
39}
40
41impl From<std::num::ParseIntError> for HcidError {
42 fn from(error: std::num::ParseIntError) -> Self {
43 Self(format!("{:?}", error))
44 }
45}