1use thiserror::Error;
6
7use crate::frame::FrameTypeMarker;
8use crate::Role;
9
10#[derive(Error, Debug)]
12pub enum FrameParseError {
13 #[error("Provided buffer is too small")]
14 BufferTooSmall,
15 #[error("Invalid buffer size provided. Expected: {}, Actual: {}", .0, .1)]
16 InvalidBufferLength(usize, usize),
17 #[error("FCS check for the Frame failed")]
18 FCSCheckFailed,
19 #[error("Invalid Role when parsing frame: {:?}", .0)]
20 InvalidRole(Role),
21 #[error("DLCI ({:?}) is invalid", .0)]
22 InvalidDLCI(u8),
23 #[error("Frame is invalid")]
24 InvalidFrame,
25 #[error("Frame type not supported before mux startup: {:?})", .0)]
26 InvalidFrameBeforeMuxStartup(FrameTypeMarker),
27 #[error("Frame type is unsupported")]
28 UnsupportedFrameType,
29 #[error("Mux Command type {} is unsupported", .0)]
30 UnsupportedMuxCommandType(u8),
31 #[error("Value is out of range")]
32 OutOfRange,
33 #[error(transparent)]
34 Other(#[from] anyhow::Error),
35}