Skip to main content

snap7_client/proto/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum ProtoError {
5    #[error("buffer too short: need {need} bytes, have {have}")]
6    BufferTooShort { need: usize, have: usize },
7    #[error("invalid magic byte: expected {expected:#04x}, got {got:#04x}")]
8    InvalidMagic { expected: u8, got: u8 },
9    #[error("unsupported PDU type: {0:#04x}")]
10    UnsupportedPduType(u8),
11    #[error("unsupported function code: {0:#04x}")]
12    UnsupportedFunction(u8),
13    #[error("encoding failed: {0}")]
14    EncodingFailed(String),
15    #[error("unsupported area code: {0:#04x}")]
16    UnsupportedArea(u8),
17    #[error("unsupported transport size: {0:#04x}")]
18    UnsupportedTransportSize(u8),
19    #[error("unsupported S7CommPlus version: {0:#04x}")]
20    InvalidVersion(u8),
21    #[error("S7CommPlus integrity check failed")]
22    IntegrityFailure,
23}