123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- #![cfg_attr(not(any(test, feature = "std")), no_std)]
- #![deny(unsafe_code)]
- #![cfg_attr(all(any(feature = "proto-ipv4", feature = "proto-ipv6"), feature = "medium-ethernet"), deny(unused))]
- #![allow(clippy::match_like_matches_macro)]
- #![allow(clippy::redundant_field_names)]
- #![allow(clippy::identity_op)]
- #![allow(clippy::option_map_unit_fn)]
- #![allow(clippy::unit_arg)]
- #[cfg(feature = "alloc")]
- extern crate alloc;
- #[cfg(not(any(feature = "proto-ipv4", feature = "proto-ipv6")))]
- compile_error!("You must enable at least one of the following features: proto-ipv4, proto-ipv6");
- #[cfg(all(
- feature = "socket",
- not(any(
- feature = "socket-raw",
- feature = "socket-udp",
- feature = "socket-tcp",
- feature = "socket-icmp",
- ))
- ))]
- compile_error!("If you enable the socket feature, you must enable at least one of the following features: socket-raw, socket-udp, socket-tcp, socket-icmp");
- #[cfg(all(feature = "defmt", feature = "log"))]
- compile_error!("You must enable at most one of the following features: defmt, log");
- use core::fmt;
- #[macro_use]
- mod macros;
- mod parsers;
- pub mod storage;
- pub mod phy;
- pub mod wire;
- pub mod iface;
- #[cfg(feature = "socket")]
- pub mod socket;
- pub mod time;
- #[derive(Debug, Clone, Copy, PartialEq, Eq)]
- #[non_exhaustive]
- #[cfg_attr(feature = "defmt", derive(defmt::Format))]
- pub enum Error {
-
- Exhausted,
-
- Illegal,
-
-
-
- Unaddressable,
-
-
-
- Finished,
-
-
- Truncated,
-
- Checksum,
-
-
- Unrecognized,
-
-
- Fragmented,
-
-
- Malformed,
-
-
- Dropped,
- }
- pub type Result<T> = core::result::Result<T, Error>;
- impl fmt::Display for Error {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match *self {
- Error::Exhausted => write!(f, "buffer space exhausted"),
- Error::Illegal => write!(f, "illegal operation"),
- Error::Unaddressable => write!(f, "unaddressable destination"),
- Error::Finished => write!(f, "operation finished"),
- Error::Truncated => write!(f, "truncated packet"),
- Error::Checksum => write!(f, "checksum error"),
- Error::Unrecognized => write!(f, "unrecognized packet"),
- Error::Fragmented => write!(f, "fragmented packet"),
- Error::Malformed => write!(f, "malformed packet"),
- Error::Dropped => write!(f, "dropped by socket"),
- }
- }
- }
|