Skip to main content

sark_core/decode/
dispatch.rs

1use core::convert::Infallible;
2
3use dope_core::driver::schedule::sequence;
4
5use crate::{body, route};
6
7#[derive(Debug)]
8pub enum Error<E, B, I> {
9    Pending,
10    Busy,
11    Invalid(I),
12    Body(B),
13    Moved,
14    Encode(E),
15    Sequence(sequence::Exhausted),
16    Unsupported,
17}
18
19impl<E, B, I: route::Never> Error<E, B, I> {
20    pub fn narrow(self) -> Error<E, B, Infallible> {
21        match self {
22            Self::Pending => Error::Pending,
23            Self::Busy => Error::Busy,
24            Self::Invalid(error) => error.never(),
25            Self::Body(error) => Error::Body(error),
26            Self::Moved => Error::Moved,
27            Self::Encode(error) => Error::Encode(error),
28            Self::Sequence(error) => Error::Sequence(error),
29            Self::Unsupported => Error::Unsupported,
30        }
31    }
32}
33
34const _: () = assert!(core::mem::size_of::<Error<Infallible, Infallible, Infallible>>() == 1);
35const _: () = assert!(
36    core::mem::size_of::<Error<Infallible, body::Error, Infallible>>()
37        == core::mem::size_of::<body::Error>()
38);