-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtypes.rs
More file actions
32 lines (26 loc) · 1.1 KB
/
types.rs
File metadata and controls
32 lines (26 loc) · 1.1 KB
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
use ctaphid_app::{Command, Error};
use heapless_bytes::Bytes;
pub const DEFAULT_MESSAGE_SIZE: usize = 7609;
/// Wrapper struct that implements [`Default`][] to be able to use [`response_mut`](interchange::Responder::response_mut)
pub struct InterchangeResponse<const N: usize>(pub Result<Bytes<N>, Error>);
impl<const N: usize> Default for InterchangeResponse<N> {
fn default() -> Self {
InterchangeResponse(Ok(Default::default()))
}
}
impl<const N: usize> From<Result<Bytes<N>, Error>> for InterchangeResponse<N> {
fn from(value: Result<Bytes<N>, Error>) -> Self {
Self(value)
}
}
impl<const N: usize> From<InterchangeResponse<N>> for Result<Bytes<N>, Error> {
fn from(value: InterchangeResponse<N>) -> Self {
value.0
}
}
pub type Responder<'pipe, const N: usize> =
interchange::Responder<'pipe, (Command, Bytes<N>), InterchangeResponse<N>>;
pub type Requester<'pipe, const N: usize> =
interchange::Requester<'pipe, (Command, Bytes<N>), InterchangeResponse<N>>;
pub type Channel<const N: usize> =
interchange::Channel<(Command, Bytes<N>), InterchangeResponse<N>>;