1use core::fmt;
7
8pub type Result<T> = core::result::Result<T, Error>;
10
11#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub enum Error {
14 BufferTooSmall,
16
17 InvalidHeader,
19
20 InvalidSubmessage,
22
23 EncodingError,
25
26 DecodingError,
28
29 TransportError,
31
32 NotInitialized,
34
35 EntityNotFound,
37
38 InvalidParameter,
40
41 ResourceExhausted,
43
44 Timeout,
46
47 InvalidData,
49
50 InvalidEncoding,
52}
53
54impl fmt::Display for Error {
55 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
56 match self {
57 Error::BufferTooSmall => write!(f, "Buffer too small"),
58 Error::InvalidHeader => write!(f, "Invalid RTPS header"),
59 Error::InvalidSubmessage => write!(f, "Invalid submessage"),
60 Error::EncodingError => write!(f, "CDR encoding error"),
61 Error::DecodingError => write!(f, "CDR decoding error"),
62 Error::TransportError => write!(f, "Transport error"),
63 Error::NotInitialized => write!(f, "Participant not initialized"),
64 Error::EntityNotFound => write!(f, "Entity not found"),
65 Error::InvalidParameter => write!(f, "Invalid parameter"),
66 Error::ResourceExhausted => write!(f, "Resource exhausted"),
67 Error::Timeout => write!(f, "Operation timed out"),
68 Error::InvalidData => write!(f, "Invalid or corrupted data"),
69 Error::InvalidEncoding => write!(f, "Invalid encoding"),
70 }
71 }
72}
73
74#[cfg(feature = "std")]
75impl std::error::Error for Error {}