1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
pub use crate::protocol::Error; use crate::protocol::{AmqpError, ProtocolId}; use crate::types::Descriptor; #[derive(Debug, Display, From, Clone)] pub enum AmqpParseError { #[display(fmt = "Loaded item size is invalid")] InvalidSize, #[display(fmt = "More data required during frame parsing: '{:?}'", "_0")] Incomplete(Option<usize>), #[from(ignore)] #[display(fmt = "Unexpected format code: '{}'", "_0")] InvalidFormatCode(u8), #[display(fmt = "Invalid value converting to char: {}", "_0")] InvalidChar(u32), #[display(fmt = "Unexpected descriptor: '{:?}'", "_0")] InvalidDescriptor(Descriptor), #[from(ignore)] #[display(fmt = "Unexpected frame type: '{:?}'", "_0")] UnexpectedFrameType(u8), #[from(ignore)] #[display(fmt = "Required field '{:?}' was omitted.", "_0")] RequiredFieldOmitted(&'static str), #[from(ignore)] #[display(fmt = "Unknown {:?} option.", "_0")] UnknownEnumOption(&'static str), UuidParseError(uuid::Error), #[from(ignore)] #[display(fmt = "Unexpected type: '{:?}'", "_0")] UnexpectedType(&'static str), Utf8Error(std::str::Utf8Error), } #[derive(Debug, Display, From, Clone)] pub enum AmqpCodecError { ParseError(AmqpParseError), #[display(fmt = "bytes left unparsed at the frame trail")] UnparsedBytesLeft, #[display(fmt = "max inbound frame size exceeded")] MaxSizeExceeded, } #[derive(Debug, Display, From, Clone)] pub enum ProtocolIdError { InvalidHeader, Incompatible, Unknown, #[display(fmt = "Expected {:?} protocol id, seen {:?} instead.", exp, got)] Unexpected { exp: ProtocolId, got: ProtocolId, }, } impl From<()> for Error { fn from(_: ()) -> Error { Error { condition: AmqpError::InternalError.into(), description: None, info: None, } } }