Skip to main content

simple_someip/protocol/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum Error {
5    #[error("I/O error: {0:?}")]
6    Io(embedded_io::ErrorKind),
7    #[error("Unexpected end of input")]
8    UnexpectedEof,
9    #[error("Invalid protocol version: {0:X}")]
10    InvalidProtocolVersion(u8),
11    #[error("Invalid value in MessageType field: {0:X}")]
12    InvalidMessageTypeField(u8),
13    #[error("Invalid value in ReturnCode field: {0:X}")]
14    InvalidReturnCode(u8),
15    #[error("Unsupported MessageID  {0:X?}")]
16    UnsupportedMessageID(super::MessageId),
17    #[error("Invalid value for Service Discovery entry type: {0:X}")]
18    InvalidSDEntryType(u8),
19    #[error("Invalid value for Service Discovery Option Type: {0:X}")]
20    InvalidSDOptionType(u8),
21    #[error("Invalid value for Service Discovery Option Transport Protocol: {0:X}")]
22    InvalidSDOptionTransportProtocol(u8),
23    #[error("Incorrect options size, {0} bytes remaining")]
24    IncorrectOptionsSize(usize),
25    #[error("Too many SD entries for fixed-capacity buffer")]
26    TooManyEntries,
27    #[error("Too many SD options for fixed-capacity buffer")]
28    TooManyOptions,
29    #[error(
30        "Invalid SD option length for type 0x{option_type:02X}: expected {expected}, got {actual}"
31    )]
32    InvalidSDOptionLength {
33        option_type: u8,
34        expected: u16,
35        actual: u16,
36    },
37    #[error("Configuration string too long: {0} bytes")]
38    ConfigurationStringTooLong(usize),
39    #[error("Invalid SD message: {0}")]
40    InvalidSDMessage(&'static str),
41}