fidl_fuchsia_posix_common/
fidl_fuchsia_posix_common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11/// `EDEADLOCK` is aliased to `EDEADLK`.
12pub const EDEADLOCK: Errno = Errno::Edeadlk;
13
14/// `ENOTSUP` is aliased to `EOPNOTSUPP`.
15pub const ENOTSUP: Errno = Errno::Eopnotsupp;
16
17/// `EWOULDBLOCK` is aliased to `EAGAIN`.
18pub const EWOULDBLOCK: Errno = Errno::Eagain;
19
20/// POSIX style errnos.
21///
22/// See https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html for more information.
23#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
24#[repr(i32)]
25pub enum Errno {
26    Eperm = 1,
27    Enoent = 2,
28    Esrch = 3,
29    Eintr = 4,
30    Eio = 5,
31    Enxio = 6,
32    E2Big = 7,
33    Enoexec = 8,
34    Ebadf = 9,
35    Echild = 10,
36    Eagain = 11,
37    Enomem = 12,
38    Eacces = 13,
39    Efault = 14,
40    Enotblk = 15,
41    Ebusy = 16,
42    Eexist = 17,
43    Exdev = 18,
44    Enodev = 19,
45    Enotdir = 20,
46    Eisdir = 21,
47    Einval = 22,
48    Enfile = 23,
49    Emfile = 24,
50    Enotty = 25,
51    Etxtbsy = 26,
52    Efbig = 27,
53    Enospc = 28,
54    Espipe = 29,
55    Erofs = 30,
56    Emlink = 31,
57    Epipe = 32,
58    Edom = 33,
59    Erange = 34,
60    Edeadlk = 35,
61    Enametoolong = 36,
62    Enolck = 37,
63    Enosys = 38,
64    Enotempty = 39,
65    Eloop = 40,
66    Enomsg = 42,
67    Eidrm = 43,
68    Echrng = 44,
69    El2Nsync = 45,
70    El3Hlt = 46,
71    El3Rst = 47,
72    Elnrng = 48,
73    Eunatch = 49,
74    Enocsi = 50,
75    El2Hlt = 51,
76    Ebade = 52,
77    Ebadr = 53,
78    Exfull = 54,
79    Enoano = 55,
80    Ebadrqc = 56,
81    Ebadslt = 57,
82    Ebfont = 59,
83    Enostr = 60,
84    Enodata = 61,
85    Etime = 62,
86    Enosr = 63,
87    Enonet = 64,
88    Enopkg = 65,
89    Eremote = 66,
90    Enolink = 67,
91    Eadv = 68,
92    Esrmnt = 69,
93    Ecomm = 70,
94    Eproto = 71,
95    Emultihop = 72,
96    Edotdot = 73,
97    Ebadmsg = 74,
98    Eoverflow = 75,
99    Enotuniq = 76,
100    Ebadfd = 77,
101    Eremchg = 78,
102    Elibacc = 79,
103    Elibbad = 80,
104    Elibscn = 81,
105    Elibmax = 82,
106    Elibexec = 83,
107    Eilseq = 84,
108    Erestart = 85,
109    Estrpipe = 86,
110    Eusers = 87,
111    Enotsock = 88,
112    Edestaddrreq = 89,
113    Emsgsize = 90,
114    Eprototype = 91,
115    Enoprotoopt = 92,
116    Eprotonosupport = 93,
117    Esocktnosupport = 94,
118    Eopnotsupp = 95,
119    Epfnosupport = 96,
120    Eafnosupport = 97,
121    Eaddrinuse = 98,
122    Eaddrnotavail = 99,
123    Enetdown = 100,
124    Enetunreach = 101,
125    Enetreset = 102,
126    Econnaborted = 103,
127    Econnreset = 104,
128    Enobufs = 105,
129    Eisconn = 106,
130    Enotconn = 107,
131    Eshutdown = 108,
132    Etoomanyrefs = 109,
133    Etimedout = 110,
134    Econnrefused = 111,
135    Ehostdown = 112,
136    Ehostunreach = 113,
137    Ealready = 114,
138    Einprogress = 115,
139    Estale = 116,
140    Euclean = 117,
141    Enotnam = 118,
142    Enavail = 119,
143    Eisnam = 120,
144    Eremoteio = 121,
145    Edquot = 122,
146    Enomedium = 123,
147    Emediumtype = 124,
148    Ecanceled = 125,
149    Enokey = 126,
150    Ekeyexpired = 127,
151    Ekeyrevoked = 128,
152    Ekeyrejected = 129,
153    Eownerdead = 130,
154    Enotrecoverable = 131,
155    Erfkill = 132,
156    Ehwpoison = 133,
157}
158
159impl Errno {
160    #[inline]
161    pub fn from_primitive(prim: i32) -> Option<Self> {
162        match prim {
163            1 => Some(Self::Eperm),
164            2 => Some(Self::Enoent),
165            3 => Some(Self::Esrch),
166            4 => Some(Self::Eintr),
167            5 => Some(Self::Eio),
168            6 => Some(Self::Enxio),
169            7 => Some(Self::E2Big),
170            8 => Some(Self::Enoexec),
171            9 => Some(Self::Ebadf),
172            10 => Some(Self::Echild),
173            11 => Some(Self::Eagain),
174            12 => Some(Self::Enomem),
175            13 => Some(Self::Eacces),
176            14 => Some(Self::Efault),
177            15 => Some(Self::Enotblk),
178            16 => Some(Self::Ebusy),
179            17 => Some(Self::Eexist),
180            18 => Some(Self::Exdev),
181            19 => Some(Self::Enodev),
182            20 => Some(Self::Enotdir),
183            21 => Some(Self::Eisdir),
184            22 => Some(Self::Einval),
185            23 => Some(Self::Enfile),
186            24 => Some(Self::Emfile),
187            25 => Some(Self::Enotty),
188            26 => Some(Self::Etxtbsy),
189            27 => Some(Self::Efbig),
190            28 => Some(Self::Enospc),
191            29 => Some(Self::Espipe),
192            30 => Some(Self::Erofs),
193            31 => Some(Self::Emlink),
194            32 => Some(Self::Epipe),
195            33 => Some(Self::Edom),
196            34 => Some(Self::Erange),
197            35 => Some(Self::Edeadlk),
198            36 => Some(Self::Enametoolong),
199            37 => Some(Self::Enolck),
200            38 => Some(Self::Enosys),
201            39 => Some(Self::Enotempty),
202            40 => Some(Self::Eloop),
203            42 => Some(Self::Enomsg),
204            43 => Some(Self::Eidrm),
205            44 => Some(Self::Echrng),
206            45 => Some(Self::El2Nsync),
207            46 => Some(Self::El3Hlt),
208            47 => Some(Self::El3Rst),
209            48 => Some(Self::Elnrng),
210            49 => Some(Self::Eunatch),
211            50 => Some(Self::Enocsi),
212            51 => Some(Self::El2Hlt),
213            52 => Some(Self::Ebade),
214            53 => Some(Self::Ebadr),
215            54 => Some(Self::Exfull),
216            55 => Some(Self::Enoano),
217            56 => Some(Self::Ebadrqc),
218            57 => Some(Self::Ebadslt),
219            59 => Some(Self::Ebfont),
220            60 => Some(Self::Enostr),
221            61 => Some(Self::Enodata),
222            62 => Some(Self::Etime),
223            63 => Some(Self::Enosr),
224            64 => Some(Self::Enonet),
225            65 => Some(Self::Enopkg),
226            66 => Some(Self::Eremote),
227            67 => Some(Self::Enolink),
228            68 => Some(Self::Eadv),
229            69 => Some(Self::Esrmnt),
230            70 => Some(Self::Ecomm),
231            71 => Some(Self::Eproto),
232            72 => Some(Self::Emultihop),
233            73 => Some(Self::Edotdot),
234            74 => Some(Self::Ebadmsg),
235            75 => Some(Self::Eoverflow),
236            76 => Some(Self::Enotuniq),
237            77 => Some(Self::Ebadfd),
238            78 => Some(Self::Eremchg),
239            79 => Some(Self::Elibacc),
240            80 => Some(Self::Elibbad),
241            81 => Some(Self::Elibscn),
242            82 => Some(Self::Elibmax),
243            83 => Some(Self::Elibexec),
244            84 => Some(Self::Eilseq),
245            85 => Some(Self::Erestart),
246            86 => Some(Self::Estrpipe),
247            87 => Some(Self::Eusers),
248            88 => Some(Self::Enotsock),
249            89 => Some(Self::Edestaddrreq),
250            90 => Some(Self::Emsgsize),
251            91 => Some(Self::Eprototype),
252            92 => Some(Self::Enoprotoopt),
253            93 => Some(Self::Eprotonosupport),
254            94 => Some(Self::Esocktnosupport),
255            95 => Some(Self::Eopnotsupp),
256            96 => Some(Self::Epfnosupport),
257            97 => Some(Self::Eafnosupport),
258            98 => Some(Self::Eaddrinuse),
259            99 => Some(Self::Eaddrnotavail),
260            100 => Some(Self::Enetdown),
261            101 => Some(Self::Enetunreach),
262            102 => Some(Self::Enetreset),
263            103 => Some(Self::Econnaborted),
264            104 => Some(Self::Econnreset),
265            105 => Some(Self::Enobufs),
266            106 => Some(Self::Eisconn),
267            107 => Some(Self::Enotconn),
268            108 => Some(Self::Eshutdown),
269            109 => Some(Self::Etoomanyrefs),
270            110 => Some(Self::Etimedout),
271            111 => Some(Self::Econnrefused),
272            112 => Some(Self::Ehostdown),
273            113 => Some(Self::Ehostunreach),
274            114 => Some(Self::Ealready),
275            115 => Some(Self::Einprogress),
276            116 => Some(Self::Estale),
277            117 => Some(Self::Euclean),
278            118 => Some(Self::Enotnam),
279            119 => Some(Self::Enavail),
280            120 => Some(Self::Eisnam),
281            121 => Some(Self::Eremoteio),
282            122 => Some(Self::Edquot),
283            123 => Some(Self::Enomedium),
284            124 => Some(Self::Emediumtype),
285            125 => Some(Self::Ecanceled),
286            126 => Some(Self::Enokey),
287            127 => Some(Self::Ekeyexpired),
288            128 => Some(Self::Ekeyrevoked),
289            129 => Some(Self::Ekeyrejected),
290            130 => Some(Self::Eownerdead),
291            131 => Some(Self::Enotrecoverable),
292            132 => Some(Self::Erfkill),
293            133 => Some(Self::Ehwpoison),
294            _ => None,
295        }
296    }
297
298    #[inline]
299    pub const fn into_primitive(self) -> i32 {
300        self as i32
301    }
302
303    #[deprecated = "Strict enums should not use `is_unknown`"]
304    #[inline]
305    pub fn is_unknown(&self) -> bool {
306        false
307    }
308}
309
310mod internal {
311    use super::*;
312    unsafe impl fidl::encoding::TypeMarker for Errno {
313        type Owned = Self;
314
315        #[inline(always)]
316        fn inline_align(_context: fidl::encoding::Context) -> usize {
317            std::mem::align_of::<i32>()
318        }
319
320        #[inline(always)]
321        fn inline_size(_context: fidl::encoding::Context) -> usize {
322            std::mem::size_of::<i32>()
323        }
324
325        #[inline(always)]
326        fn encode_is_copy() -> bool {
327            true
328        }
329
330        #[inline(always)]
331        fn decode_is_copy() -> bool {
332            false
333        }
334    }
335
336    impl fidl::encoding::ValueTypeMarker for Errno {
337        type Borrowed<'a> = Self;
338        #[inline(always)]
339        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
340            *value
341        }
342    }
343
344    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Errno {
345        #[inline]
346        unsafe fn encode(
347            self,
348            encoder: &mut fidl::encoding::Encoder<'_, D>,
349            offset: usize,
350            _depth: fidl::encoding::Depth,
351        ) -> fidl::Result<()> {
352            encoder.debug_check_bounds::<Self>(offset);
353            encoder.write_num(self.into_primitive(), offset);
354            Ok(())
355        }
356    }
357
358    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Errno {
359        #[inline(always)]
360        fn new_empty() -> Self {
361            Self::Eperm
362        }
363
364        #[inline]
365        unsafe fn decode(
366            &mut self,
367            decoder: &mut fidl::encoding::Decoder<'_, D>,
368            offset: usize,
369            _depth: fidl::encoding::Depth,
370        ) -> fidl::Result<()> {
371            decoder.debug_check_bounds::<Self>(offset);
372            let prim = decoder.read_num::<i32>(offset);
373
374            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
375            Ok(())
376        }
377    }
378}