externally_driven_async_rt/net/
net_error.rs1use rustix::io::Errno;
2
3use crate::NotEnoughResources;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum NetError {
8 Os(Errno),
10 NotEnoughResources(NotEnoughResources),
12}
13
14impl core::fmt::Display for NetError {
15 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
16 match self {
17 Self::Os(errno) => write!(f, "syscall failed: {errno}"),
18 Self::NotEnoughResources(err) => write!(f, "{err}"),
19 }
20 }
21}
22
23impl core::error::Error for NetError {}
24
25impl From<Errno> for NetError {
26 fn from(errno: Errno) -> Self {
27 Self::Os(errno)
28 }
29}
30
31impl From<NotEnoughResources> for NetError {
32 fn from(err: NotEnoughResources) -> Self {
33 Self::NotEnoughResources(err)
34 }
35}