ax_io/error.rs
1/// Errors owned by the `ax-io` I/O capability domain.
2#[derive(Clone, Copy, Debug, Eq, PartialEq, thiserror::Error)]
3pub enum IoError {
4 /// The requested address is already bound by another endpoint.
5 #[error("address is already in use")]
6 AddrInUse,
7 /// The endpoint is already connected.
8 #[error("I/O endpoint is already connected")]
9 AlreadyConnected,
10 /// The endpoint does not support the requested address family.
11 #[error("address family is not supported")]
12 AddressFamilyUnsupported,
13 /// The requested I/O object already exists.
14 #[error("I/O object already exists")]
15 AlreadyExists,
16 /// The supplied argument list exceeds the supported limit.
17 #[error("argument list is too long")]
18 ArgumentListTooLong,
19 /// An address supplied to the I/O operation cannot be accessed.
20 #[error("bad I/O address")]
21 BadAddress,
22 /// The supplied file descriptor is invalid.
23 #[error("bad file descriptor")]
24 BadFileDescriptor,
25 /// The I/O object cannot perform the operation in its current state.
26 #[error("I/O object is in an invalid state")]
27 BadState,
28 /// The peer has closed a pipe used by the operation.
29 #[error("broken pipe")]
30 BrokenPipe,
31 /// The remote endpoint refused the connection.
32 #[error("connection refused")]
33 ConnectionRefused,
34 /// The peer reset an established connection.
35 #[error("connection reset")]
36 ConnectionReset,
37 /// The operation would cross filesystem or device boundaries.
38 #[error("operation crosses devices")]
39 CrossesDevices,
40 /// The directory must be empty before the operation can complete.
41 #[error("directory is not empty")]
42 DirectoryNotEmpty,
43 /// The operation requires a destination address.
44 #[error("destination address is required")]
45 DestAddrRequired,
46 /// Path traversal encountered a filesystem loop.
47 #[error("filesystem traversal loop detected")]
48 FilesystemLoop,
49 /// The requested file size exceeds the supported limit.
50 #[error("file is too large")]
51 FileTooLarge,
52 /// Input contains an invalid byte sequence.
53 #[error("illegal byte sequence")]
54 IllegalBytes,
55 /// The nonblocking I/O operation has started but is not complete.
56 #[error("I/O operation is in progress")]
57 InProgress,
58 /// The operation was interrupted before completion.
59 #[error("I/O operation interrupted")]
60 Interrupted,
61 /// Input data is malformed for the requested operation.
62 #[error("invalid I/O data")]
63 InvalidData,
64 /// The executable image has an unsupported or malformed format.
65 #[error("invalid executable format")]
66 InvalidExecutable,
67 /// An input parameter is invalid for the requested operation.
68 #[error("invalid I/O input")]
69 InvalidInput,
70 /// The underlying I/O operation failed without a more specific reason.
71 #[error("I/O operation failed")]
72 Io,
73 /// The operation expected a non-directory object.
74 #[error("I/O object is a directory")]
75 IsADirectory,
76 /// A path component or object name exceeds the supported limit.
77 #[error("name is too long")]
78 NameTooLong,
79 /// The message exceeds the endpoint's supported size.
80 #[error("message is too long")]
81 MessageTooLong,
82 /// Memory required by the operation could not be allocated.
83 #[error("I/O allocation failed")]
84 NoMemory,
85 /// The requested device does not exist.
86 #[error("device does not exist")]
87 NoSuchDevice,
88 /// The requested device or address does not exist.
89 #[error("device or address does not exist")]
90 NoSuchDeviceOrAddress,
91 /// The requested process does not exist.
92 #[error("process does not exist")]
93 NoSuchProcess,
94 /// The operation expected a directory object.
95 #[error("I/O object is not a directory")]
96 NotADirectory,
97 /// The operation expected a socket object.
98 #[error("I/O object is not a socket")]
99 NotASocket,
100 /// The operation expected a terminal device.
101 #[error("I/O object is not a tty")]
102 NotATty,
103 /// The endpoint is not connected.
104 #[error("I/O endpoint is not connected")]
105 NotConnected,
106 /// The requested I/O object does not exist.
107 #[error("I/O object was not found")]
108 NotFound,
109 /// The caller is not permitted to perform the operation.
110 #[error("I/O operation is not permitted")]
111 OperationNotPermitted,
112 /// The object does not support this operation.
113 #[error("I/O operation is not supported by this object")]
114 OperationNotSupported,
115 /// The operation produced a value outside its representable range.
116 #[error("I/O result is out of range")]
117 OutOfRange,
118 /// Access permissions deny the requested operation.
119 #[error("I/O permission denied")]
120 PermissionDenied,
121 /// The endpoint does not recognize the requested protocol option.
122 #[error("protocol option is not supported")]
123 ProtocolOptionUnsupported,
124 /// The target filesystem is read-only.
125 #[error("filesystem is read-only")]
126 ReadOnlyFilesystem,
127 /// A resource required by the operation is busy.
128 #[error("I/O resource is busy")]
129 ResourceBusy,
130 /// The target storage has no free space.
131 #[error("I/O storage is full")]
132 StorageFull,
133 /// The operation did not complete before its deadline.
134 #[error("I/O operation timed out")]
135 TimedOut,
136 /// The process has reached its open-file limit.
137 #[error("too many files are open")]
138 TooManyOpenFiles,
139 /// The input ended before the requested data was available.
140 #[error("unexpected end of input")]
141 UnexpectedEof,
142 /// The requested I/O capability is not implemented.
143 #[error("I/O capability is unavailable")]
144 Unsupported,
145 /// The operation cannot complete without blocking.
146 #[error("I/O operation would block")]
147 WouldBlock,
148 /// A write operation completed without writing any data.
149 #[error("write made no progress")]
150 WriteZero,
151}
152
153impl IoError {
154 /// Returns the stable I/O-domain error used by retry logic.
155 pub const fn canonicalize(self) -> Self {
156 self
157 }
158}
159
160/// A result returned by an `ax-io` capability.
161pub type IoResult<T = ()> = core::result::Result<T, IoError>;
162
163/// Standard-style name for [`IoError`].
164pub type Error = IoError;
165/// Standard-style name for the copyable [`IoError`] kind.
166pub type ErrorKind = IoError;
167/// Standard-style name for [`IoResult`].
168pub type Result<T = ()> = IoResult<T>;