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
use thiserror::Error; #[derive(Debug, Error, PartialEq)] pub enum Error { #[error("mDNS: failed to join multicast group")] ErrJoiningMulticastGroup, #[error("mDNS: connection is closed")] ErrConnectionClosed, #[error("mDNS: context has elapsed")] ErrContextElapsed, #[error("mDNS: config must not be nil")] ErrNilConfig, #[error("parsing/packing of this type isn't available yet")] ErrNotStarted, #[error("parsing/packing of this section has completed")] ErrSectionDone, #[error("parsing/packing of this section is header")] ErrSectionHeader, #[error("insufficient data for base length type")] ErrBaseLen, #[error("insufficient data for calculated length type")] ErrCalcLen, #[error("segment prefix is reserved")] ErrReserved, #[error("too many pointers (>10)")] ErrTooManyPtr, #[error("invalid pointer")] ErrInvalidPtr, #[error("nil resource body")] ErrNilResourceBody, #[error("insufficient data for resource body length")] ErrResourceLen, #[error("segment length too long")] ErrSegTooLong, #[error("zero length segment")] ErrZeroSegLen, #[error("resource length too long")] ErrResTooLong, #[error("too many Questions to pack (>65535)")] ErrTooManyQuestions, #[error("too many Answers to pack (>65535)")] ErrTooManyAnswers, #[error("too many Authorities to pack (>65535)")] ErrTooManyAuthorities, #[error("too many Additionals to pack (>65535)")] ErrTooManyAdditionals, #[error("name is not in canonical format (it must end with a .)")] ErrNonCanonicalName, #[error("character string exceeds maximum length (255)")] ErrStringTooLong, #[error("compressed name in SRV resource data")] ErrCompressedSrv, #[error("empty builder msg")] ErrEmptyBuilderMsg, #[allow(non_camel_case_types)] #[error("{0}")] new(String), } impl Error { pub fn equal(&self, err: &anyhow::Error) -> bool { err.downcast_ref::<Self>().map_or(false, |e| e == self) } }