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