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
46
47
48
use super::Status;
use core::fmt::Debug;
#[derive(Debug)]
pub struct Error<Data: Debug = ()> {
status: Status,
data: Data,
}
impl<Data: Debug> Error<Data> {
pub fn new(status: Status, data: Data) -> Self {
Self { status, data }
}
pub fn status(&self) -> Status {
self.status
}
pub fn data(&self) -> &Data {
&self.data
}
pub fn split(self) -> (Status, Data) {
(self.status, self.data)
}
}
impl From<Status> for Error<()> {
fn from(status: Status) -> Self {
Self { status, data: () }
}
}
impl From<ucs2::Error> for Error<()> {
fn from(other: ucs2::Error) -> Self {
Status::from(other).into()
}
}