mini_slcan/error.rs
1use defmt::Format;
2
3#[derive(Debug, Format)]
4pub struct Error {
5 kind: ErrorKind,
6}
7
8impl Error {
9 pub(crate) fn decode() -> Self {
10 Self {
11 kind: ErrorKind::Decode,
12 }
13 }
14
15 pub(crate) fn eof() -> Self {
16 Self {
17 kind: ErrorKind::Eof,
18 }
19 }
20
21 #[inline]
22 pub fn kind(&self) -> ErrorKind {
23 self.kind
24 }
25}
26
27#[derive(Eq, PartialEq, Copy, Clone, Debug, Format)]
28#[non_exhaustive]
29pub enum ErrorKind {
30 /// Input is malformed and does not adhere to the SLCAN specification.
31 Decode,
32
33 /// More data is required to decode the input.
34 Eof,
35}
36
37// TODO: impl Display+Debug, #[cfg] Error