1pub type Result<T> = std::result::Result<T, Error>;
2
3#[derive(Debug)]
5pub enum Error {
6 IncorrectBufferSize,
7 NotIpv4Packet,
8 NotIcmpPacket,
9 NotIcmpv6Packet,
10 PayloadTooShort { got: usize, want: usize },
11 IOError(String),
12 NotEchoReply,
13 NotV6EchoReply,
14 Timeout,
15 OtherICMP,
16 InvalidSize,
17 InvalidPacket,
18 TooSmallHeader,
19 InvalidHeaderSize,
20 InvalidVersion,
21 UnknownProtocol,
22 Unimplemented,
23}
24
25impl From<std::io::Error> for Error {
26 fn from(error: std::io::Error) -> Self {
27 Self::IOError(error.to_string())
28 }
29}
30
31impl std::fmt::Display for Error {
32 fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33 Ok(())
34 }
35}
36
37impl std::error::Error for Error {}