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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#[non_exhaustive]
pub enum Error<I: crate::interface::Interface> {
Unsupported,
Interface(I::Error),
}
impl<I> core::fmt::Debug for Error<I>
where
I: crate::interface::Interface,
I::Error: core::fmt::Debug,
{
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::result::Result<(), core::fmt::Error> {
match (&*self,) {
(&Error::Interface(ref __self_0),) => {
let mut debug_trait_builder = f.debug_tuple("Interface");
let _ = debug_trait_builder.field(&&(*__self_0));
debug_trait_builder.finish()
}
(&Error::Unsupported,) => {
let mut debug_trait_builder = f.debug_tuple("Unsupported");
debug_trait_builder.finish()
}
}
}
}
#[non_exhaustive]
pub enum CoprocessorError<M, I, W>
where
M: crate::models::Model,
I: crate::interface::Interface,
W: crate::commands::waiter::Waiter<M, I>,
{
Unsupported,
Interface(I::Error),
Waiter(W::Error),
Fault,
}
impl<M, I, W> CoprocessorError<M, I, W>
where
M: crate::models::Model,
I: crate::interface::Interface,
W: crate::commands::waiter::Waiter<M, I>,
{
pub fn from_general_error(err: Error<I>) -> Self {
match err {
Error::Unsupported => CoprocessorError::Unsupported,
Error::Interface(e) => CoprocessorError::Interface(e),
}
}
pub fn general_result<R>(r: Result<R, Error<I>>) -> Result<R, Self> {
r.map_err(|e| Self::from_general_error(e))
}
}
impl<M, I, W> core::fmt::Debug for CoprocessorError<M, I, W>
where
M: crate::models::Model,
I: crate::interface::Interface,
W: crate::commands::waiter::Waiter<M, I>,
I::Error: core::fmt::Debug,
W::Error: core::fmt::Debug,
{
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::result::Result<(), core::fmt::Error> {
match (&*self,) {
(&CoprocessorError::Unsupported,) => {
let mut debug_trait_builder = f.debug_tuple("Unsupported");
debug_trait_builder.finish()
}
(&CoprocessorError::Interface(ref __self_0),) => {
let mut debug_trait_builder = f.debug_tuple("Interface");
let _ = debug_trait_builder.field(&&(*__self_0));
debug_trait_builder.finish()
}
(&CoprocessorError::Waiter(ref __self_0),) => {
let mut debug_trait_builder = f.debug_tuple("Waiter");
let _ = debug_trait_builder.field(&&(*__self_0));
debug_trait_builder.finish()
}
(&CoprocessorError::Fault,) => {
let mut debug_trait_builder = f.debug_tuple("Fault");
debug_trait_builder.finish()
}
}
}
}
impl<M, I, W> From<Error<I>> for CoprocessorError<M, I, W>
where
M: crate::models::Model,
I: crate::interface::Interface,
W: crate::commands::waiter::Waiter<M, I>,
{
fn from(err: Error<I>) -> Self {
Self::from_general_error(err)
}
}