use snafu::prelude::*; #[derive(Debug, Snafu)] pub enum DecodeError { #[snafu(display("Unexpected end of input"))] UnexpectedEndOfInput, #[snafu(display("Malformed whisker at position `{}`", position))] MalformedWhisker { position: usize }, #[snafu(display("Duplicate whisker at position `{}`", position))] DuplicateWhisker { position: usize }, #[snafu(display("Comment data is not valid UTF-8"))] InvalidComment, #[snafu(display("CRC checksum mismatch"))] CrcMismatch, #[snafu(display("LDPC Decode error"))] LdpcError, #[snafu(display("Given data does not fit in the CATS packet"))] Overflow, } #[derive(Debug, Snafu)] pub enum EncodeError { #[snafu(display("New data is a duplicate of an existing data"))] DuplicateData, #[snafu(display("Given data causes CATS packet to overflow"))] CatsOverflow, } #[derive(Debug, Snafu)] pub enum CommentError { #[snafu(display("CATS packet does not have comment data"))] NoComment, #[snafu(display("Given buffer too small for comment data"))] BufferOverflow, } #[derive(Debug, Snafu)] pub enum DigipeatError { #[snafu(display("No route"))] NoRoute, #[snafu(display("Identification is us"))] Us, #[snafu(display("Max hops hit"))] MaxHops, #[snafu(display("Already digipeated by this node"))] AlreadyDigipeated, #[snafu(display("Future hop(s) are already set"))] SetDestiny, } #[derive(Debug, Snafu, PartialEq, Eq)] pub enum AppendNodeError { #[snafu(display("Future hop(s) already set to a different node"))] SetFuture, #[snafu(display("Max hops hit"))] HopsOverflow, #[snafu(display("Node already in route"))] DuplicateNode, #[snafu(display("Given data causes the route whisker to overflow"))] RouteOverflow, } #[derive(Debug, Snafu, PartialEq, Eq)] pub enum PacketRouteAppendError { #[snafu(display("No route whisker on packet"))] NoRouteWhisker, #[snafu(display("Route error"))] Route { error: AppendNodeError }, #[snafu(display("CATS packet overflow"))] PacketOverflow, }