Skip to main content

fidl_fuchsia_starnix_binder_common/
fidl_fuchsia_starnix_binder_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
11pub type Fd = i32;
12
13pub const MAX_FILE_COUNT: u64 = 16;
14
15pub const MAX_HANDLE_COUNT: u64 = 4;
16
17pub const MAX_IOCTL_READ_COUNT: u64 = 16;
18
19pub const MAX_IOCTL_WRITE_COUNT: u64 = 16;
20
21pub const MAX_PATH_LENGTH: u64 = 4095;
22
23pub const MAX_REQUEST_COUNT: u64 = 16;
24
25pub const MAX_WRITE_BYTES: u64 = 32768;
26
27bitflags! {
28    /// The flags associated with an opened file.
29    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
30    pub struct FileFlags: u64 {
31        /// The owner can read the file.
32        const RIGHT_READABLE = 1;
33        /// The owner can write to fhe file.
34        const RIGHT_WRITABLE = 2;
35        /// The file is a directory.
36        const DIRECTORY = 4096;
37    }
38}
39
40impl FileFlags {
41    #[inline(always)]
42    pub fn from_bits_allow_unknown(bits: u64) -> Self {
43        Self::from_bits_retain(bits)
44    }
45
46    #[inline(always)]
47    pub fn has_unknown_bits(&self) -> bool {
48        self.get_unknown_bits() != 0
49    }
50
51    #[inline(always)]
52    pub fn get_unknown_bits(&self) -> u64 {
53        self.bits() & !Self::all().bits()
54    }
55}
56
57bitflags! {
58    /// The flags when reading from an unix domain socket
59    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
60    pub struct ReadFlags: u64 {
61        /// When set, the data must not be removed from the queue and the next read
62        /// must resend the same data.
63        const PEEK = 1;
64    }
65}
66
67impl ReadFlags {
68    #[inline(always)]
69    pub fn from_bits_allow_unknown(bits: u64) -> Self {
70        Self::from_bits_retain(bits)
71    }
72
73    #[inline(always)]
74    pub fn has_unknown_bits(&self) -> bool {
75        self.get_unknown_bits() != 0
76    }
77
78    #[inline(always)]
79    pub fn get_unknown_bits(&self) -> u64 {
80        self.bits() & !Self::all().bits()
81    }
82}
83
84#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
85pub struct BinderThreadIoctlResponse {
86    pub ioctl_writes: Vec<IoctlReadWrite>,
87}
88
89impl fidl::Persistable for BinderThreadIoctlResponse {}
90
91#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
92pub struct BinderIoctlResponse {
93    pub ioctl_writes: Vec<IoctlReadWrite>,
94}
95
96impl fidl::Persistable for BinderIoctlResponse {}
97
98/// The location and size of reads or writes for an ioctl.
99#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
100#[repr(C)]
101pub struct IoctlReadWrite {
102    /// Address in the process.
103    pub address: u64,
104    /// Offset into the VMO.
105    pub offset: u64,
106    /// Length of the buffer within the VMO.
107    pub length: u64,
108}
109
110impl fidl::Persistable for IoctlReadWrite {}
111
112#[derive(Clone, Debug, Default, PartialEq)]
113pub struct UnixDomainSocketGetEventRequest {
114    #[doc(hidden)]
115    pub __source_breaking: fidl::marker::SourceBreaking,
116}
117
118impl fidl::Persistable for UnixDomainSocketGetEventRequest {}
119
120#[derive(Clone, Debug, Default, PartialEq)]
121pub struct UnixDomainSocketReadRequest {
122    pub count: Option<u64>,
123    pub flags: Option<ReadFlags>,
124    #[doc(hidden)]
125    pub __source_breaking: fidl::marker::SourceBreaking,
126}
127
128impl fidl::Persistable for UnixDomainSocketReadRequest {}
129
130#[derive(Clone, Debug, Default, PartialEq)]
131pub struct UnixDomainSocketWriteResponse {
132    pub actual_count: Option<u64>,
133    #[doc(hidden)]
134    pub __source_breaking: fidl::marker::SourceBreaking,
135}
136
137impl fidl::Persistable for UnixDomainSocketWriteResponse {}
138
139pub mod binder_ordinals {
140    pub const SET_VMO: u64 = 0x43ee5d8f7d3acbf6;
141    pub const MAP_VMO: u64 = 0x169c824ba0a5141f;
142    pub const IOCTL: u64 = 0x1032021e21310000;
143    pub const REGISTER_THREAD_CHANNEL: u64 = 0x1eeeec1ff5de0b47;
144}
145
146pub mod binder_thread_ordinals {
147    pub const IOCTL: u64 = 0x6b9dcc61092989e4;
148}
149
150pub mod container_power_controller_ordinals {
151    pub const WAKE: u64 = 0x31dc1b2d1e00a094;
152    pub const REGISTER_WAKE_WATCHER: u64 = 0x5a08c36d7c9c5703;
153}
154
155pub mod dev_binder_ordinals {
156    pub const OPEN: u64 = 0x250f5ee034977685;
157    pub const CLOSE: u64 = 0x50b39ce5c9bae3b1;
158}
159
160pub mod lutex_controller_ordinals {
161    pub const WAIT_BITSET: u64 = 0x489feee6787d11b1;
162    pub const WAKE_BITSET: u64 = 0x58309f6ebcb0d8eb;
163    pub const CMP_REQUEUE: u64 = 0x38e55a7315bef4b5;
164}
165
166pub mod process_accessor_ordinals {
167    pub const WRITE_MEMORY: u64 = 0x666cda7c6b6d4819;
168    pub const WRITE_BYTES: u64 = 0x6f94296329cb8d17;
169    pub const FILE_REQUEST: u64 = 0xd42103a37c3f0a;
170}
171
172pub mod remote_controller_ordinals {
173    pub const START: u64 = 0x72ecbe863c65f4cf;
174}
175
176pub mod unix_domain_socket_ordinals {
177    pub const CLONE: u64 = 0x20d8a7aba2168a79;
178    pub const CLOSE: u64 = 0x5ac5d459ad7f657e;
179    pub const QUERY: u64 = 0x2658edee9decfc06;
180    pub const GET_EVENT: u64 = 0x4d79eb8f83961b41;
181    pub const READ: u64 = 0x65ece02b0a73a069;
182    pub const WRITE: u64 = 0x2339b58d4b835aee;
183}
184
185mod internal {
186    use super::*;
187    unsafe impl fidl::encoding::TypeMarker for FileFlags {
188        type Owned = Self;
189
190        #[inline(always)]
191        fn inline_align(_context: fidl::encoding::Context) -> usize {
192            8
193        }
194
195        #[inline(always)]
196        fn inline_size(_context: fidl::encoding::Context) -> usize {
197            8
198        }
199    }
200
201    impl fidl::encoding::ValueTypeMarker for FileFlags {
202        type Borrowed<'a> = Self;
203        #[inline(always)]
204        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
205            *value
206        }
207    }
208
209    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for FileFlags {
210        #[inline]
211        unsafe fn encode(
212            self,
213            encoder: &mut fidl::encoding::Encoder<'_, D>,
214            offset: usize,
215            _depth: fidl::encoding::Depth,
216        ) -> fidl::Result<()> {
217            encoder.debug_check_bounds::<Self>(offset);
218            encoder.write_num(self.bits(), offset);
219            Ok(())
220        }
221    }
222
223    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FileFlags {
224        #[inline(always)]
225        fn new_empty() -> Self {
226            Self::empty()
227        }
228
229        #[inline]
230        unsafe fn decode(
231            &mut self,
232            decoder: &mut fidl::encoding::Decoder<'_, D>,
233            offset: usize,
234            _depth: fidl::encoding::Depth,
235        ) -> fidl::Result<()> {
236            decoder.debug_check_bounds::<Self>(offset);
237            let prim = decoder.read_num::<u64>(offset);
238            *self = Self::from_bits_allow_unknown(prim);
239            Ok(())
240        }
241    }
242    unsafe impl fidl::encoding::TypeMarker for ReadFlags {
243        type Owned = Self;
244
245        #[inline(always)]
246        fn inline_align(_context: fidl::encoding::Context) -> usize {
247            8
248        }
249
250        #[inline(always)]
251        fn inline_size(_context: fidl::encoding::Context) -> usize {
252            8
253        }
254    }
255
256    impl fidl::encoding::ValueTypeMarker for ReadFlags {
257        type Borrowed<'a> = Self;
258        #[inline(always)]
259        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
260            *value
261        }
262    }
263
264    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ReadFlags {
265        #[inline]
266        unsafe fn encode(
267            self,
268            encoder: &mut fidl::encoding::Encoder<'_, D>,
269            offset: usize,
270            _depth: fidl::encoding::Depth,
271        ) -> fidl::Result<()> {
272            encoder.debug_check_bounds::<Self>(offset);
273            encoder.write_num(self.bits(), offset);
274            Ok(())
275        }
276    }
277
278    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ReadFlags {
279        #[inline(always)]
280        fn new_empty() -> Self {
281            Self::empty()
282        }
283
284        #[inline]
285        unsafe fn decode(
286            &mut self,
287            decoder: &mut fidl::encoding::Decoder<'_, D>,
288            offset: usize,
289            _depth: fidl::encoding::Depth,
290        ) -> fidl::Result<()> {
291            decoder.debug_check_bounds::<Self>(offset);
292            let prim = decoder.read_num::<u64>(offset);
293            *self = Self::from_bits_allow_unknown(prim);
294            Ok(())
295        }
296    }
297
298    impl fidl::encoding::ValueTypeMarker for BinderThreadIoctlResponse {
299        type Borrowed<'a> = &'a Self;
300        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
301            value
302        }
303    }
304
305    unsafe impl fidl::encoding::TypeMarker for BinderThreadIoctlResponse {
306        type Owned = Self;
307
308        #[inline(always)]
309        fn inline_align(_context: fidl::encoding::Context) -> usize {
310            8
311        }
312
313        #[inline(always)]
314        fn inline_size(_context: fidl::encoding::Context) -> usize {
315            16
316        }
317    }
318
319    unsafe impl<D: fidl::encoding::ResourceDialect>
320        fidl::encoding::Encode<BinderThreadIoctlResponse, D> for &BinderThreadIoctlResponse
321    {
322        #[inline]
323        unsafe fn encode(
324            self,
325            encoder: &mut fidl::encoding::Encoder<'_, D>,
326            offset: usize,
327            _depth: fidl::encoding::Depth,
328        ) -> fidl::Result<()> {
329            encoder.debug_check_bounds::<BinderThreadIoctlResponse>(offset);
330            // Delegate to tuple encoding.
331            fidl::encoding::Encode::<BinderThreadIoctlResponse, D>::encode(
332                (
333                    <fidl::encoding::Vector<IoctlReadWrite, 16> as fidl::encoding::ValueTypeMarker>::borrow(&self.ioctl_writes),
334                ),
335                encoder, offset, _depth
336            )
337        }
338    }
339    unsafe impl<
340        D: fidl::encoding::ResourceDialect,
341        T0: fidl::encoding::Encode<fidl::encoding::Vector<IoctlReadWrite, 16>, D>,
342    > fidl::encoding::Encode<BinderThreadIoctlResponse, D> for (T0,)
343    {
344        #[inline]
345        unsafe fn encode(
346            self,
347            encoder: &mut fidl::encoding::Encoder<'_, D>,
348            offset: usize,
349            depth: fidl::encoding::Depth,
350        ) -> fidl::Result<()> {
351            encoder.debug_check_bounds::<BinderThreadIoctlResponse>(offset);
352            // Zero out padding regions. There's no need to apply masks
353            // because the unmasked parts will be overwritten by fields.
354            // Write the fields.
355            self.0.encode(encoder, offset + 0, depth)?;
356            Ok(())
357        }
358    }
359
360    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
361        for BinderThreadIoctlResponse
362    {
363        #[inline(always)]
364        fn new_empty() -> Self {
365            Self { ioctl_writes: fidl::new_empty!(fidl::encoding::Vector<IoctlReadWrite, 16>, D) }
366        }
367
368        #[inline]
369        unsafe fn decode(
370            &mut self,
371            decoder: &mut fidl::encoding::Decoder<'_, D>,
372            offset: usize,
373            _depth: fidl::encoding::Depth,
374        ) -> fidl::Result<()> {
375            decoder.debug_check_bounds::<Self>(offset);
376            // Verify that padding bytes are zero.
377            fidl::decode!(fidl::encoding::Vector<IoctlReadWrite, 16>, D, &mut self.ioctl_writes, decoder, offset + 0, _depth)?;
378            Ok(())
379        }
380    }
381
382    impl fidl::encoding::ValueTypeMarker for BinderIoctlResponse {
383        type Borrowed<'a> = &'a Self;
384        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
385            value
386        }
387    }
388
389    unsafe impl fidl::encoding::TypeMarker for BinderIoctlResponse {
390        type Owned = Self;
391
392        #[inline(always)]
393        fn inline_align(_context: fidl::encoding::Context) -> usize {
394            8
395        }
396
397        #[inline(always)]
398        fn inline_size(_context: fidl::encoding::Context) -> usize {
399            16
400        }
401    }
402
403    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BinderIoctlResponse, D>
404        for &BinderIoctlResponse
405    {
406        #[inline]
407        unsafe fn encode(
408            self,
409            encoder: &mut fidl::encoding::Encoder<'_, D>,
410            offset: usize,
411            _depth: fidl::encoding::Depth,
412        ) -> fidl::Result<()> {
413            encoder.debug_check_bounds::<BinderIoctlResponse>(offset);
414            // Delegate to tuple encoding.
415            fidl::encoding::Encode::<BinderIoctlResponse, D>::encode(
416                (
417                    <fidl::encoding::Vector<IoctlReadWrite, 16> as fidl::encoding::ValueTypeMarker>::borrow(&self.ioctl_writes),
418                ),
419                encoder, offset, _depth
420            )
421        }
422    }
423    unsafe impl<
424        D: fidl::encoding::ResourceDialect,
425        T0: fidl::encoding::Encode<fidl::encoding::Vector<IoctlReadWrite, 16>, D>,
426    > fidl::encoding::Encode<BinderIoctlResponse, D> for (T0,)
427    {
428        #[inline]
429        unsafe fn encode(
430            self,
431            encoder: &mut fidl::encoding::Encoder<'_, D>,
432            offset: usize,
433            depth: fidl::encoding::Depth,
434        ) -> fidl::Result<()> {
435            encoder.debug_check_bounds::<BinderIoctlResponse>(offset);
436            // Zero out padding regions. There's no need to apply masks
437            // because the unmasked parts will be overwritten by fields.
438            // Write the fields.
439            self.0.encode(encoder, offset + 0, depth)?;
440            Ok(())
441        }
442    }
443
444    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BinderIoctlResponse {
445        #[inline(always)]
446        fn new_empty() -> Self {
447            Self { ioctl_writes: fidl::new_empty!(fidl::encoding::Vector<IoctlReadWrite, 16>, D) }
448        }
449
450        #[inline]
451        unsafe fn decode(
452            &mut self,
453            decoder: &mut fidl::encoding::Decoder<'_, D>,
454            offset: usize,
455            _depth: fidl::encoding::Depth,
456        ) -> fidl::Result<()> {
457            decoder.debug_check_bounds::<Self>(offset);
458            // Verify that padding bytes are zero.
459            fidl::decode!(fidl::encoding::Vector<IoctlReadWrite, 16>, D, &mut self.ioctl_writes, decoder, offset + 0, _depth)?;
460            Ok(())
461        }
462    }
463
464    impl fidl::encoding::ValueTypeMarker for IoctlReadWrite {
465        type Borrowed<'a> = &'a Self;
466        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
467            value
468        }
469    }
470
471    unsafe impl fidl::encoding::TypeMarker for IoctlReadWrite {
472        type Owned = Self;
473
474        #[inline(always)]
475        fn inline_align(_context: fidl::encoding::Context) -> usize {
476            8
477        }
478
479        #[inline(always)]
480        fn inline_size(_context: fidl::encoding::Context) -> usize {
481            24
482        }
483        #[inline(always)]
484        fn encode_is_copy() -> bool {
485            true
486        }
487
488        #[inline(always)]
489        fn decode_is_copy() -> bool {
490            true
491        }
492    }
493
494    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<IoctlReadWrite, D>
495        for &IoctlReadWrite
496    {
497        #[inline]
498        unsafe fn encode(
499            self,
500            encoder: &mut fidl::encoding::Encoder<'_, D>,
501            offset: usize,
502            _depth: fidl::encoding::Depth,
503        ) -> fidl::Result<()> {
504            encoder.debug_check_bounds::<IoctlReadWrite>(offset);
505            unsafe {
506                // Copy the object into the buffer.
507                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
508                (buf_ptr as *mut IoctlReadWrite)
509                    .write_unaligned((self as *const IoctlReadWrite).read());
510                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
511                // done second because the memcpy will write garbage to these bytes.
512            }
513            Ok(())
514        }
515    }
516    unsafe impl<
517        D: fidl::encoding::ResourceDialect,
518        T0: fidl::encoding::Encode<u64, D>,
519        T1: fidl::encoding::Encode<u64, D>,
520        T2: fidl::encoding::Encode<u64, D>,
521    > fidl::encoding::Encode<IoctlReadWrite, D> for (T0, T1, T2)
522    {
523        #[inline]
524        unsafe fn encode(
525            self,
526            encoder: &mut fidl::encoding::Encoder<'_, D>,
527            offset: usize,
528            depth: fidl::encoding::Depth,
529        ) -> fidl::Result<()> {
530            encoder.debug_check_bounds::<IoctlReadWrite>(offset);
531            // Zero out padding regions. There's no need to apply masks
532            // because the unmasked parts will be overwritten by fields.
533            // Write the fields.
534            self.0.encode(encoder, offset + 0, depth)?;
535            self.1.encode(encoder, offset + 8, depth)?;
536            self.2.encode(encoder, offset + 16, depth)?;
537            Ok(())
538        }
539    }
540
541    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for IoctlReadWrite {
542        #[inline(always)]
543        fn new_empty() -> Self {
544            Self {
545                address: fidl::new_empty!(u64, D),
546                offset: fidl::new_empty!(u64, D),
547                length: fidl::new_empty!(u64, D),
548            }
549        }
550
551        #[inline]
552        unsafe fn decode(
553            &mut self,
554            decoder: &mut fidl::encoding::Decoder<'_, D>,
555            offset: usize,
556            _depth: fidl::encoding::Depth,
557        ) -> fidl::Result<()> {
558            decoder.debug_check_bounds::<Self>(offset);
559            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
560            // Verify that padding bytes are zero.
561            // Copy from the buffer into the object.
562            unsafe {
563                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 24);
564            }
565            Ok(())
566        }
567    }
568
569    impl UnixDomainSocketGetEventRequest {
570        #[inline(always)]
571        fn max_ordinal_present(&self) -> u64 {
572            0
573        }
574    }
575
576    impl fidl::encoding::ValueTypeMarker for UnixDomainSocketGetEventRequest {
577        type Borrowed<'a> = &'a Self;
578        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
579            value
580        }
581    }
582
583    unsafe impl fidl::encoding::TypeMarker for UnixDomainSocketGetEventRequest {
584        type Owned = Self;
585
586        #[inline(always)]
587        fn inline_align(_context: fidl::encoding::Context) -> usize {
588            8
589        }
590
591        #[inline(always)]
592        fn inline_size(_context: fidl::encoding::Context) -> usize {
593            16
594        }
595    }
596
597    unsafe impl<D: fidl::encoding::ResourceDialect>
598        fidl::encoding::Encode<UnixDomainSocketGetEventRequest, D>
599        for &UnixDomainSocketGetEventRequest
600    {
601        unsafe fn encode(
602            self,
603            encoder: &mut fidl::encoding::Encoder<'_, D>,
604            offset: usize,
605            mut depth: fidl::encoding::Depth,
606        ) -> fidl::Result<()> {
607            encoder.debug_check_bounds::<UnixDomainSocketGetEventRequest>(offset);
608            // Vector header
609            let max_ordinal: u64 = self.max_ordinal_present();
610            encoder.write_num(max_ordinal, offset);
611            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
612            // Calling encoder.out_of_line_offset(0) is not allowed.
613            if max_ordinal == 0 {
614                return Ok(());
615            }
616            depth.increment()?;
617            let envelope_size = 8;
618            let bytes_len = max_ordinal as usize * envelope_size;
619            #[allow(unused_variables)]
620            let offset = encoder.out_of_line_offset(bytes_len);
621            let mut _prev_end_offset: usize = 0;
622
623            Ok(())
624        }
625    }
626
627    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
628        for UnixDomainSocketGetEventRequest
629    {
630        #[inline(always)]
631        fn new_empty() -> Self {
632            Self::default()
633        }
634
635        unsafe fn decode(
636            &mut self,
637            decoder: &mut fidl::encoding::Decoder<'_, D>,
638            offset: usize,
639            mut depth: fidl::encoding::Depth,
640        ) -> fidl::Result<()> {
641            decoder.debug_check_bounds::<Self>(offset);
642            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
643                None => return Err(fidl::Error::NotNullable),
644                Some(len) => len,
645            };
646            // Calling decoder.out_of_line_offset(0) is not allowed.
647            if len == 0 {
648                return Ok(());
649            };
650            depth.increment()?;
651            let envelope_size = 8;
652            let bytes_len = len * envelope_size;
653            let offset = decoder.out_of_line_offset(bytes_len)?;
654            // Decode the envelope for each type.
655            let mut _next_ordinal_to_read = 0;
656            let mut next_offset = offset;
657            let end_offset = offset + bytes_len;
658
659            // Decode the remaining unknown envelopes.
660            while next_offset < end_offset {
661                _next_ordinal_to_read += 1;
662                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
663                next_offset += envelope_size;
664            }
665
666            Ok(())
667        }
668    }
669
670    impl UnixDomainSocketReadRequest {
671        #[inline(always)]
672        fn max_ordinal_present(&self) -> u64 {
673            if let Some(_) = self.flags {
674                return 2;
675            }
676            if let Some(_) = self.count {
677                return 1;
678            }
679            0
680        }
681    }
682
683    impl fidl::encoding::ValueTypeMarker for UnixDomainSocketReadRequest {
684        type Borrowed<'a> = &'a Self;
685        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
686            value
687        }
688    }
689
690    unsafe impl fidl::encoding::TypeMarker for UnixDomainSocketReadRequest {
691        type Owned = Self;
692
693        #[inline(always)]
694        fn inline_align(_context: fidl::encoding::Context) -> usize {
695            8
696        }
697
698        #[inline(always)]
699        fn inline_size(_context: fidl::encoding::Context) -> usize {
700            16
701        }
702    }
703
704    unsafe impl<D: fidl::encoding::ResourceDialect>
705        fidl::encoding::Encode<UnixDomainSocketReadRequest, D> for &UnixDomainSocketReadRequest
706    {
707        unsafe fn encode(
708            self,
709            encoder: &mut fidl::encoding::Encoder<'_, D>,
710            offset: usize,
711            mut depth: fidl::encoding::Depth,
712        ) -> fidl::Result<()> {
713            encoder.debug_check_bounds::<UnixDomainSocketReadRequest>(offset);
714            // Vector header
715            let max_ordinal: u64 = self.max_ordinal_present();
716            encoder.write_num(max_ordinal, offset);
717            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
718            // Calling encoder.out_of_line_offset(0) is not allowed.
719            if max_ordinal == 0 {
720                return Ok(());
721            }
722            depth.increment()?;
723            let envelope_size = 8;
724            let bytes_len = max_ordinal as usize * envelope_size;
725            #[allow(unused_variables)]
726            let offset = encoder.out_of_line_offset(bytes_len);
727            let mut _prev_end_offset: usize = 0;
728            if 1 > max_ordinal {
729                return Ok(());
730            }
731
732            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
733            // are envelope_size bytes.
734            let cur_offset: usize = (1 - 1) * envelope_size;
735
736            // Zero reserved fields.
737            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
738
739            // Safety:
740            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
741            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
742            //   envelope_size bytes, there is always sufficient room.
743            fidl::encoding::encode_in_envelope_optional::<u64, D>(
744                self.count.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
745                encoder,
746                offset + cur_offset,
747                depth,
748            )?;
749
750            _prev_end_offset = cur_offset + envelope_size;
751            if 2 > max_ordinal {
752                return Ok(());
753            }
754
755            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
756            // are envelope_size bytes.
757            let cur_offset: usize = (2 - 1) * envelope_size;
758
759            // Zero reserved fields.
760            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
761
762            // Safety:
763            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
764            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
765            //   envelope_size bytes, there is always sufficient room.
766            fidl::encoding::encode_in_envelope_optional::<ReadFlags, D>(
767                self.flags.as_ref().map(<ReadFlags as fidl::encoding::ValueTypeMarker>::borrow),
768                encoder,
769                offset + cur_offset,
770                depth,
771            )?;
772
773            _prev_end_offset = cur_offset + envelope_size;
774
775            Ok(())
776        }
777    }
778
779    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
780        for UnixDomainSocketReadRequest
781    {
782        #[inline(always)]
783        fn new_empty() -> Self {
784            Self::default()
785        }
786
787        unsafe fn decode(
788            &mut self,
789            decoder: &mut fidl::encoding::Decoder<'_, D>,
790            offset: usize,
791            mut depth: fidl::encoding::Depth,
792        ) -> fidl::Result<()> {
793            decoder.debug_check_bounds::<Self>(offset);
794            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
795                None => return Err(fidl::Error::NotNullable),
796                Some(len) => len,
797            };
798            // Calling decoder.out_of_line_offset(0) is not allowed.
799            if len == 0 {
800                return Ok(());
801            };
802            depth.increment()?;
803            let envelope_size = 8;
804            let bytes_len = len * envelope_size;
805            let offset = decoder.out_of_line_offset(bytes_len)?;
806            // Decode the envelope for each type.
807            let mut _next_ordinal_to_read = 0;
808            let mut next_offset = offset;
809            let end_offset = offset + bytes_len;
810            _next_ordinal_to_read += 1;
811            if next_offset >= end_offset {
812                return Ok(());
813            }
814
815            // Decode unknown envelopes for gaps in ordinals.
816            while _next_ordinal_to_read < 1 {
817                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
818                _next_ordinal_to_read += 1;
819                next_offset += envelope_size;
820            }
821
822            let next_out_of_line = decoder.next_out_of_line();
823            let handles_before = decoder.remaining_handles();
824            if let Some((inlined, num_bytes, num_handles)) =
825                fidl::encoding::decode_envelope_header(decoder, next_offset)?
826            {
827                let member_inline_size =
828                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
829                if inlined != (member_inline_size <= 4) {
830                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
831                }
832                let inner_offset;
833                let mut inner_depth = depth.clone();
834                if inlined {
835                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
836                    inner_offset = next_offset;
837                } else {
838                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
839                    inner_depth.increment()?;
840                }
841                let val_ref = self.count.get_or_insert_with(|| fidl::new_empty!(u64, D));
842                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
843                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
844                {
845                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
846                }
847                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
848                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
849                }
850            }
851
852            next_offset += envelope_size;
853            _next_ordinal_to_read += 1;
854            if next_offset >= end_offset {
855                return Ok(());
856            }
857
858            // Decode unknown envelopes for gaps in ordinals.
859            while _next_ordinal_to_read < 2 {
860                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
861                _next_ordinal_to_read += 1;
862                next_offset += envelope_size;
863            }
864
865            let next_out_of_line = decoder.next_out_of_line();
866            let handles_before = decoder.remaining_handles();
867            if let Some((inlined, num_bytes, num_handles)) =
868                fidl::encoding::decode_envelope_header(decoder, next_offset)?
869            {
870                let member_inline_size =
871                    <ReadFlags as fidl::encoding::TypeMarker>::inline_size(decoder.context);
872                if inlined != (member_inline_size <= 4) {
873                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
874                }
875                let inner_offset;
876                let mut inner_depth = depth.clone();
877                if inlined {
878                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
879                    inner_offset = next_offset;
880                } else {
881                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
882                    inner_depth.increment()?;
883                }
884                let val_ref = self.flags.get_or_insert_with(|| fidl::new_empty!(ReadFlags, D));
885                fidl::decode!(ReadFlags, D, val_ref, decoder, inner_offset, inner_depth)?;
886                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
887                {
888                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
889                }
890                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
891                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
892                }
893            }
894
895            next_offset += envelope_size;
896
897            // Decode the remaining unknown envelopes.
898            while next_offset < end_offset {
899                _next_ordinal_to_read += 1;
900                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
901                next_offset += envelope_size;
902            }
903
904            Ok(())
905        }
906    }
907
908    impl UnixDomainSocketWriteResponse {
909        #[inline(always)]
910        fn max_ordinal_present(&self) -> u64 {
911            if let Some(_) = self.actual_count {
912                return 1;
913            }
914            0
915        }
916    }
917
918    impl fidl::encoding::ValueTypeMarker for UnixDomainSocketWriteResponse {
919        type Borrowed<'a> = &'a Self;
920        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
921            value
922        }
923    }
924
925    unsafe impl fidl::encoding::TypeMarker for UnixDomainSocketWriteResponse {
926        type Owned = Self;
927
928        #[inline(always)]
929        fn inline_align(_context: fidl::encoding::Context) -> usize {
930            8
931        }
932
933        #[inline(always)]
934        fn inline_size(_context: fidl::encoding::Context) -> usize {
935            16
936        }
937    }
938
939    unsafe impl<D: fidl::encoding::ResourceDialect>
940        fidl::encoding::Encode<UnixDomainSocketWriteResponse, D>
941        for &UnixDomainSocketWriteResponse
942    {
943        unsafe fn encode(
944            self,
945            encoder: &mut fidl::encoding::Encoder<'_, D>,
946            offset: usize,
947            mut depth: fidl::encoding::Depth,
948        ) -> fidl::Result<()> {
949            encoder.debug_check_bounds::<UnixDomainSocketWriteResponse>(offset);
950            // Vector header
951            let max_ordinal: u64 = self.max_ordinal_present();
952            encoder.write_num(max_ordinal, offset);
953            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
954            // Calling encoder.out_of_line_offset(0) is not allowed.
955            if max_ordinal == 0 {
956                return Ok(());
957            }
958            depth.increment()?;
959            let envelope_size = 8;
960            let bytes_len = max_ordinal as usize * envelope_size;
961            #[allow(unused_variables)]
962            let offset = encoder.out_of_line_offset(bytes_len);
963            let mut _prev_end_offset: usize = 0;
964            if 1 > max_ordinal {
965                return Ok(());
966            }
967
968            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
969            // are envelope_size bytes.
970            let cur_offset: usize = (1 - 1) * envelope_size;
971
972            // Zero reserved fields.
973            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
974
975            // Safety:
976            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
977            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
978            //   envelope_size bytes, there is always sufficient room.
979            fidl::encoding::encode_in_envelope_optional::<u64, D>(
980                self.actual_count.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
981                encoder,
982                offset + cur_offset,
983                depth,
984            )?;
985
986            _prev_end_offset = cur_offset + envelope_size;
987
988            Ok(())
989        }
990    }
991
992    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
993        for UnixDomainSocketWriteResponse
994    {
995        #[inline(always)]
996        fn new_empty() -> Self {
997            Self::default()
998        }
999
1000        unsafe fn decode(
1001            &mut self,
1002            decoder: &mut fidl::encoding::Decoder<'_, D>,
1003            offset: usize,
1004            mut depth: fidl::encoding::Depth,
1005        ) -> fidl::Result<()> {
1006            decoder.debug_check_bounds::<Self>(offset);
1007            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1008                None => return Err(fidl::Error::NotNullable),
1009                Some(len) => len,
1010            };
1011            // Calling decoder.out_of_line_offset(0) is not allowed.
1012            if len == 0 {
1013                return Ok(());
1014            };
1015            depth.increment()?;
1016            let envelope_size = 8;
1017            let bytes_len = len * envelope_size;
1018            let offset = decoder.out_of_line_offset(bytes_len)?;
1019            // Decode the envelope for each type.
1020            let mut _next_ordinal_to_read = 0;
1021            let mut next_offset = offset;
1022            let end_offset = offset + bytes_len;
1023            _next_ordinal_to_read += 1;
1024            if next_offset >= end_offset {
1025                return Ok(());
1026            }
1027
1028            // Decode unknown envelopes for gaps in ordinals.
1029            while _next_ordinal_to_read < 1 {
1030                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1031                _next_ordinal_to_read += 1;
1032                next_offset += envelope_size;
1033            }
1034
1035            let next_out_of_line = decoder.next_out_of_line();
1036            let handles_before = decoder.remaining_handles();
1037            if let Some((inlined, num_bytes, num_handles)) =
1038                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1039            {
1040                let member_inline_size =
1041                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1042                if inlined != (member_inline_size <= 4) {
1043                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1044                }
1045                let inner_offset;
1046                let mut inner_depth = depth.clone();
1047                if inlined {
1048                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1049                    inner_offset = next_offset;
1050                } else {
1051                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1052                    inner_depth.increment()?;
1053                }
1054                let val_ref = self.actual_count.get_or_insert_with(|| fidl::new_empty!(u64, D));
1055                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
1056                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1057                {
1058                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1059                }
1060                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1061                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1062                }
1063            }
1064
1065            next_offset += envelope_size;
1066
1067            // Decode the remaining unknown envelopes.
1068            while next_offset < end_offset {
1069                _next_ordinal_to_read += 1;
1070                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1071                next_offset += envelope_size;
1072            }
1073
1074            Ok(())
1075        }
1076    }
1077}