Newer
Older
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("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,
}
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
80
81
82
83
84
85
86
87
88
#[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,
}