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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
use std::{io, str}; #[derive(Debug)] pub enum ParseError { InvalidProtocol, InvalidLength, UnsupportedProtocolLevel, ConnectReservedFlagSet, ConnAckReservedFlagSet, InvalidClientId, UnsupportedPacketType, PacketIdRequired, MaxSizeExceeded, IoError(io::Error), Utf8Error(str::Utf8Error), } impl PartialEq for ParseError { fn eq(&self, other: &Self) -> bool { match self { ParseError::InvalidProtocol => match other { ParseError::InvalidProtocol => true, _ => false, }, ParseError::InvalidLength => match other { ParseError::InvalidLength => true, _ => false, }, ParseError::UnsupportedProtocolLevel => match other { ParseError::UnsupportedProtocolLevel => true, _ => false, }, ParseError::ConnectReservedFlagSet => match other { ParseError::ConnectReservedFlagSet => true, _ => false, }, ParseError::ConnAckReservedFlagSet => match other { ParseError::ConnAckReservedFlagSet => true, _ => false, }, ParseError::InvalidClientId => match other { ParseError::InvalidClientId => true, _ => false, }, ParseError::UnsupportedPacketType => match other { ParseError::UnsupportedPacketType => true, _ => false, }, ParseError::PacketIdRequired => match other { ParseError::PacketIdRequired => true, _ => false, }, ParseError::MaxSizeExceeded => match other { ParseError::MaxSizeExceeded => true, _ => false, }, ParseError::IoError(_) => false, ParseError::Utf8Error(_) => false, } } } impl From<io::Error> for ParseError { fn from(err: io::Error) -> Self { ParseError::IoError(err) } } impl From<str::Utf8Error> for ParseError { fn from(err: str::Utf8Error) -> Self { ParseError::Utf8Error(err) } } #[derive(Copy, Clone, Debug, PartialEq)] pub enum TopicError { InvalidTopic, InvalidLevel, }