ctaphid_dispatch/
types.rs

1use ctaphid_app::{Command, Error};
2use heapless_bytes::Bytes;
3
4pub const DEFAULT_MESSAGE_SIZE: usize = 7609;
5
6/// Wrapper struct that implements [`Default`][] to be able to use [`response_mut`](interchange::Responder::response_mut)
7pub struct InterchangeResponse<const N: usize>(pub Result<Bytes<N>, Error>);
8
9impl<const N: usize> Default for InterchangeResponse<N> {
10    fn default() -> Self {
11        InterchangeResponse(Ok(Default::default()))
12    }
13}
14
15impl<const N: usize> From<Result<Bytes<N>, Error>> for InterchangeResponse<N> {
16    fn from(value: Result<Bytes<N>, Error>) -> Self {
17        Self(value)
18    }
19}
20
21impl<const N: usize> From<InterchangeResponse<N>> for Result<Bytes<N>, Error> {
22    fn from(value: InterchangeResponse<N>) -> Self {
23        value.0
24    }
25}
26
27pub type Responder<'pipe, const N: usize> =
28    interchange::Responder<'pipe, (Command, Bytes<N>), InterchangeResponse<N>>;
29pub type Requester<'pipe, const N: usize> =
30    interchange::Requester<'pipe, (Command, Bytes<N>), InterchangeResponse<N>>;
31pub type Channel<const N: usize> =
32    interchange::Channel<(Command, Bytes<N>), InterchangeResponse<N>>;