fidl_fuchsia_posix_socket_packet_common/
fidl_fuchsia_posix_socket_packet_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/// A network-layer protocol (above link-layer).
12///
13/// Values are defined by
14/// https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml.
15pub type Protocol = u16;
16
17pub const SOCKET_PROTOCOL_NAME: &str = "fuchsia.posix.socket.packet/Socket";
18
19/// The type of a hardware.
20#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
21#[repr(u32)]
22pub enum HardwareType {
23    /// Hardware that operates only at the network layer; a pure L3 interface.
24    ///
25    /// Hardware of this type have no L2 headers/addressing.
26    NetworkOnly = 1,
27    /// Hardware that operates on ethernet-based links.
28    Ethernet = 2,
29    /// Hardware that loops back packets.
30    Loopback = 3,
31}
32
33impl HardwareType {
34    #[inline]
35    pub fn from_primitive(prim: u32) -> Option<Self> {
36        match prim {
37            1 => Some(Self::NetworkOnly),
38            2 => Some(Self::Ethernet),
39            3 => Some(Self::Loopback),
40            _ => None,
41        }
42    }
43
44    #[inline]
45    pub const fn into_primitive(self) -> u32 {
46        self as u32
47    }
48
49    #[deprecated = "Strict enums should not use `is_unknown`"]
50    #[inline]
51    pub fn is_unknown(&self) -> bool {
52        false
53    }
54}
55
56/// A kind of packet socket.
57#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
58#[repr(u32)]
59pub enum Kind {
60    /// A packet socket that operates with network-layer packets.
61    Network = 1,
62    /// A packet socket that operates with link-layer packets.
63    ///
64    /// Packets are passed unmodified between the wire and client when the
65    /// packet socket is of this kind.
66    Link = 2,
67}
68
69impl Kind {
70    #[inline]
71    pub fn from_primitive(prim: u32) -> Option<Self> {
72        match prim {
73            1 => Some(Self::Network),
74            2 => Some(Self::Link),
75            _ => None,
76        }
77    }
78
79    #[inline]
80    pub const fn into_primitive(self) -> u32 {
81        self as u32
82    }
83
84    #[deprecated = "Strict enums should not use `is_unknown`"]
85    #[inline]
86    pub fn is_unknown(&self) -> bool {
87        false
88    }
89}
90
91/// The type of a packet.
92#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
93#[repr(u32)]
94pub enum PacketType {
95    /// A packet that arrived at its destination.
96    Host = 1,
97    /// A packet that was broadcasted.
98    Broadcast = 2,
99    /// A packet that was multicasted.
100    Multicast = 3,
101    /// A packet that arrived at a host that isn't its destination.
102    OtherHost = 4,
103    /// A packet that is being sent on a local interface, regardless of how it
104    /// is being sent (unicasted, multicasted, broadcasted).
105    Outgoing = 5,
106}
107
108impl PacketType {
109    #[inline]
110    pub fn from_primitive(prim: u32) -> Option<Self> {
111        match prim {
112            1 => Some(Self::Host),
113            2 => Some(Self::Broadcast),
114            3 => Some(Self::Multicast),
115            4 => Some(Self::OtherHost),
116            5 => Some(Self::Outgoing),
117            _ => None,
118        }
119    }
120
121    #[inline]
122    pub const fn into_primitive(self) -> u32 {
123        self as u32
124    }
125
126    #[deprecated = "Strict enums should not use `is_unknown`"]
127    #[inline]
128    pub fn is_unknown(&self) -> bool {
129        false
130    }
131}
132
133#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
134pub struct Empty;
135
136impl fidl::Persistable for Empty {}
137
138/// An interface's properties.
139#[derive(Clone, Debug, PartialEq)]
140pub struct InterfaceProperties {
141    /// The interface's ID.
142    pub id: u64,
143    /// The interface's hardware address.
144    pub addr: HardwareAddress,
145    /// The interface's hardware type.
146    pub type_: HardwareType,
147}
148
149impl fidl::Persistable for InterfaceProperties {}
150
151/// Information about a packet.
152#[derive(Clone, Debug, PartialEq)]
153pub struct PacketInfo {
154    pub protocol: u16,
155    pub interface_id: u64,
156    pub addr: HardwareAddress,
157}
158
159impl fidl::Persistable for PacketInfo {}
160
161#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
162pub struct ProviderSocketRequest {
163    pub kind: Kind,
164}
165
166impl fidl::Persistable for ProviderSocketRequest {}
167
168#[derive(Clone, Debug, PartialEq)]
169pub struct RecvPacketInfo {
170    pub packet_info: PacketInfo,
171    pub packet_type: PacketType,
172    pub interface_type: HardwareType,
173}
174
175impl fidl::Persistable for RecvPacketInfo {}
176
177#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
178pub struct SocketBindRequest {
179    pub protocol: Option<Box<ProtocolAssociation>>,
180    pub bound_interface_id: BoundInterfaceId,
181}
182
183impl fidl::Persistable for SocketBindRequest {}
184
185#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
186pub struct SocketRecvMsgRequest {
187    pub want_packet_info: bool,
188    pub data_len: u32,
189    pub want_control: bool,
190    pub flags: fidl_fuchsia_posix_socket::RecvMsgFlags,
191}
192
193impl fidl::Persistable for SocketRecvMsgRequest {}
194
195#[derive(Clone, Debug, PartialEq)]
196pub struct SocketSendMsgRequest {
197    pub packet_info: Option<Box<PacketInfo>>,
198    pub data: Vec<u8>,
199    pub control: SendControlData,
200    pub flags: fidl_fuchsia_posix_socket::SendMsgFlags,
201}
202
203impl fidl::Persistable for SocketSendMsgRequest {}
204
205#[derive(Clone, Debug, PartialEq)]
206pub struct SocketGetInfoResponse {
207    pub kind: Kind,
208    pub protocol: Option<Box<ProtocolAssociation>>,
209    pub bound_interface: BoundInterface,
210}
211
212impl fidl::Persistable for SocketGetInfoResponse {}
213
214#[derive(Clone, Debug, PartialEq)]
215pub struct SocketRecvMsgResponse {
216    pub packet_info: Option<Box<RecvPacketInfo>>,
217    pub data: Vec<u8>,
218    pub control: RecvControlData,
219    pub truncated: u32,
220}
221
222impl fidl::Persistable for SocketRecvMsgResponse {}
223
224#[derive(Clone, Debug, Default, PartialEq)]
225pub struct RecvControlData {
226    /// Socket level ancillary data.
227    pub socket: Option<fidl_fuchsia_posix_socket::SocketRecvControlData>,
228    #[doc(hidden)]
229    pub __source_breaking: fidl::marker::SourceBreaking,
230}
231
232impl fidl::Persistable for RecvControlData {}
233
234#[derive(Clone, Debug, Default, PartialEq)]
235pub struct SendControlData {
236    /// Socket level ancillary data.
237    pub socket: Option<fidl_fuchsia_posix_socket::SocketSendControlData>,
238    #[doc(hidden)]
239    pub __source_breaking: fidl::marker::SourceBreaking,
240}
241
242impl fidl::Persistable for SendControlData {}
243
244#[derive(Clone, Debug, PartialEq)]
245pub enum BoundInterface {
246    All(Empty),
247    Specified(InterfaceProperties),
248}
249
250impl BoundInterface {
251    #[inline]
252    pub fn ordinal(&self) -> u64 {
253        match *self {
254            Self::All(_) => 1,
255            Self::Specified(_) => 2,
256        }
257    }
258
259    #[deprecated = "Strict unions should not use `is_unknown`"]
260    #[inline]
261    pub fn is_unknown(&self) -> bool {
262        false
263    }
264}
265
266impl fidl::Persistable for BoundInterface {}
267
268#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
269pub enum BoundInterfaceId {
270    All(Empty),
271    Specified(u64),
272}
273
274impl BoundInterfaceId {
275    #[inline]
276    pub fn ordinal(&self) -> u64 {
277        match *self {
278            Self::All(_) => 1,
279            Self::Specified(_) => 2,
280        }
281    }
282
283    #[deprecated = "Strict unions should not use `is_unknown`"]
284    #[inline]
285    pub fn is_unknown(&self) -> bool {
286        false
287    }
288}
289
290impl fidl::Persistable for BoundInterfaceId {}
291
292/// A hardware address.
293#[derive(Clone, Debug)]
294pub enum HardwareAddress {
295    /// Indicates that the hardware does not support link-layer addressing.
296    None(Empty),
297    /// An EUI-48 based address.
298    Eui48(fidl_fuchsia_net::MacAddress),
299    #[doc(hidden)]
300    __SourceBreaking { unknown_ordinal: u64 },
301}
302
303/// Pattern that matches an unknown `HardwareAddress` member.
304#[macro_export]
305macro_rules! HardwareAddressUnknown {
306    () => {
307        _
308    };
309}
310
311// Custom PartialEq so that unknown variants are not equal to themselves.
312impl PartialEq for HardwareAddress {
313    fn eq(&self, other: &Self) -> bool {
314        match (self, other) {
315            (Self::None(x), Self::None(y)) => *x == *y,
316            (Self::Eui48(x), Self::Eui48(y)) => *x == *y,
317            _ => false,
318        }
319    }
320}
321
322impl HardwareAddress {
323    #[inline]
324    pub fn ordinal(&self) -> u64 {
325        match *self {
326            Self::None(_) => 1,
327            Self::Eui48(_) => 2,
328            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
329        }
330    }
331
332    #[inline]
333    pub fn unknown_variant_for_testing() -> Self {
334        Self::__SourceBreaking { unknown_ordinal: 0 }
335    }
336
337    #[inline]
338    pub fn is_unknown(&self) -> bool {
339        match self {
340            Self::__SourceBreaking { .. } => true,
341            _ => false,
342        }
343    }
344}
345
346impl fidl::Persistable for HardwareAddress {}
347
348/// The protocol association for a packet socket.
349#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
350pub enum ProtocolAssociation {
351    /// An association with all protocols.
352    All(Empty),
353    /// An association with a protocol.
354    Specified(u16),
355}
356
357impl ProtocolAssociation {
358    #[inline]
359    pub fn ordinal(&self) -> u64 {
360        match *self {
361            Self::All(_) => 1,
362            Self::Specified(_) => 2,
363        }
364    }
365
366    #[deprecated = "Strict unions should not use `is_unknown`"]
367    #[inline]
368    pub fn is_unknown(&self) -> bool {
369        false
370    }
371}
372
373impl fidl::Persistable for ProtocolAssociation {}
374
375mod internal {
376    use super::*;
377    unsafe impl fidl::encoding::TypeMarker for HardwareType {
378        type Owned = Self;
379
380        #[inline(always)]
381        fn inline_align(_context: fidl::encoding::Context) -> usize {
382            std::mem::align_of::<u32>()
383        }
384
385        #[inline(always)]
386        fn inline_size(_context: fidl::encoding::Context) -> usize {
387            std::mem::size_of::<u32>()
388        }
389
390        #[inline(always)]
391        fn encode_is_copy() -> bool {
392            true
393        }
394
395        #[inline(always)]
396        fn decode_is_copy() -> bool {
397            false
398        }
399    }
400
401    impl fidl::encoding::ValueTypeMarker for HardwareType {
402        type Borrowed<'a> = Self;
403        #[inline(always)]
404        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
405            *value
406        }
407    }
408
409    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for HardwareType {
410        #[inline]
411        unsafe fn encode(
412            self,
413            encoder: &mut fidl::encoding::Encoder<'_, D>,
414            offset: usize,
415            _depth: fidl::encoding::Depth,
416        ) -> fidl::Result<()> {
417            encoder.debug_check_bounds::<Self>(offset);
418            encoder.write_num(self.into_primitive(), offset);
419            Ok(())
420        }
421    }
422
423    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for HardwareType {
424        #[inline(always)]
425        fn new_empty() -> Self {
426            Self::NetworkOnly
427        }
428
429        #[inline]
430        unsafe fn decode(
431            &mut self,
432            decoder: &mut fidl::encoding::Decoder<'_, D>,
433            offset: usize,
434            _depth: fidl::encoding::Depth,
435        ) -> fidl::Result<()> {
436            decoder.debug_check_bounds::<Self>(offset);
437            let prim = decoder.read_num::<u32>(offset);
438
439            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
440            Ok(())
441        }
442    }
443    unsafe impl fidl::encoding::TypeMarker for Kind {
444        type Owned = Self;
445
446        #[inline(always)]
447        fn inline_align(_context: fidl::encoding::Context) -> usize {
448            std::mem::align_of::<u32>()
449        }
450
451        #[inline(always)]
452        fn inline_size(_context: fidl::encoding::Context) -> usize {
453            std::mem::size_of::<u32>()
454        }
455
456        #[inline(always)]
457        fn encode_is_copy() -> bool {
458            true
459        }
460
461        #[inline(always)]
462        fn decode_is_copy() -> bool {
463            false
464        }
465    }
466
467    impl fidl::encoding::ValueTypeMarker for Kind {
468        type Borrowed<'a> = Self;
469        #[inline(always)]
470        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
471            *value
472        }
473    }
474
475    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Kind {
476        #[inline]
477        unsafe fn encode(
478            self,
479            encoder: &mut fidl::encoding::Encoder<'_, D>,
480            offset: usize,
481            _depth: fidl::encoding::Depth,
482        ) -> fidl::Result<()> {
483            encoder.debug_check_bounds::<Self>(offset);
484            encoder.write_num(self.into_primitive(), offset);
485            Ok(())
486        }
487    }
488
489    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Kind {
490        #[inline(always)]
491        fn new_empty() -> Self {
492            Self::Network
493        }
494
495        #[inline]
496        unsafe fn decode(
497            &mut self,
498            decoder: &mut fidl::encoding::Decoder<'_, D>,
499            offset: usize,
500            _depth: fidl::encoding::Depth,
501        ) -> fidl::Result<()> {
502            decoder.debug_check_bounds::<Self>(offset);
503            let prim = decoder.read_num::<u32>(offset);
504
505            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
506            Ok(())
507        }
508    }
509    unsafe impl fidl::encoding::TypeMarker for PacketType {
510        type Owned = Self;
511
512        #[inline(always)]
513        fn inline_align(_context: fidl::encoding::Context) -> usize {
514            std::mem::align_of::<u32>()
515        }
516
517        #[inline(always)]
518        fn inline_size(_context: fidl::encoding::Context) -> usize {
519            std::mem::size_of::<u32>()
520        }
521
522        #[inline(always)]
523        fn encode_is_copy() -> bool {
524            true
525        }
526
527        #[inline(always)]
528        fn decode_is_copy() -> bool {
529            false
530        }
531    }
532
533    impl fidl::encoding::ValueTypeMarker for PacketType {
534        type Borrowed<'a> = Self;
535        #[inline(always)]
536        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
537            *value
538        }
539    }
540
541    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for PacketType {
542        #[inline]
543        unsafe fn encode(
544            self,
545            encoder: &mut fidl::encoding::Encoder<'_, D>,
546            offset: usize,
547            _depth: fidl::encoding::Depth,
548        ) -> fidl::Result<()> {
549            encoder.debug_check_bounds::<Self>(offset);
550            encoder.write_num(self.into_primitive(), offset);
551            Ok(())
552        }
553    }
554
555    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PacketType {
556        #[inline(always)]
557        fn new_empty() -> Self {
558            Self::Host
559        }
560
561        #[inline]
562        unsafe fn decode(
563            &mut self,
564            decoder: &mut fidl::encoding::Decoder<'_, D>,
565            offset: usize,
566            _depth: fidl::encoding::Depth,
567        ) -> fidl::Result<()> {
568            decoder.debug_check_bounds::<Self>(offset);
569            let prim = decoder.read_num::<u32>(offset);
570
571            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
572            Ok(())
573        }
574    }
575
576    impl fidl::encoding::ValueTypeMarker for Empty {
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 Empty {
584        type Owned = Self;
585
586        #[inline(always)]
587        fn inline_align(_context: fidl::encoding::Context) -> usize {
588            1
589        }
590
591        #[inline(always)]
592        fn inline_size(_context: fidl::encoding::Context) -> usize {
593            1
594        }
595    }
596
597    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Empty, D> for &Empty {
598        #[inline]
599        unsafe fn encode(
600            self,
601            encoder: &mut fidl::encoding::Encoder<'_, D>,
602            offset: usize,
603            _depth: fidl::encoding::Depth,
604        ) -> fidl::Result<()> {
605            encoder.debug_check_bounds::<Empty>(offset);
606            encoder.write_num(0u8, offset);
607            Ok(())
608        }
609    }
610
611    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Empty {
612        #[inline(always)]
613        fn new_empty() -> Self {
614            Self
615        }
616
617        #[inline]
618        unsafe fn decode(
619            &mut self,
620            decoder: &mut fidl::encoding::Decoder<'_, D>,
621            offset: usize,
622            _depth: fidl::encoding::Depth,
623        ) -> fidl::Result<()> {
624            decoder.debug_check_bounds::<Self>(offset);
625            match decoder.read_num::<u8>(offset) {
626                0 => Ok(()),
627                _ => Err(fidl::Error::Invalid),
628            }
629        }
630    }
631
632    impl fidl::encoding::ValueTypeMarker for InterfaceProperties {
633        type Borrowed<'a> = &'a Self;
634        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
635            value
636        }
637    }
638
639    unsafe impl fidl::encoding::TypeMarker for InterfaceProperties {
640        type Owned = Self;
641
642        #[inline(always)]
643        fn inline_align(_context: fidl::encoding::Context) -> usize {
644            8
645        }
646
647        #[inline(always)]
648        fn inline_size(_context: fidl::encoding::Context) -> usize {
649            32
650        }
651    }
652
653    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<InterfaceProperties, D>
654        for &InterfaceProperties
655    {
656        #[inline]
657        unsafe fn encode(
658            self,
659            encoder: &mut fidl::encoding::Encoder<'_, D>,
660            offset: usize,
661            _depth: fidl::encoding::Depth,
662        ) -> fidl::Result<()> {
663            encoder.debug_check_bounds::<InterfaceProperties>(offset);
664            // Delegate to tuple encoding.
665            fidl::encoding::Encode::<InterfaceProperties, D>::encode(
666                (
667                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
668                    <HardwareAddress as fidl::encoding::ValueTypeMarker>::borrow(&self.addr),
669                    <HardwareType as fidl::encoding::ValueTypeMarker>::borrow(&self.type_),
670                ),
671                encoder,
672                offset,
673                _depth,
674            )
675        }
676    }
677    unsafe impl<
678            D: fidl::encoding::ResourceDialect,
679            T0: fidl::encoding::Encode<u64, D>,
680            T1: fidl::encoding::Encode<HardwareAddress, D>,
681            T2: fidl::encoding::Encode<HardwareType, D>,
682        > fidl::encoding::Encode<InterfaceProperties, D> for (T0, T1, T2)
683    {
684        #[inline]
685        unsafe fn encode(
686            self,
687            encoder: &mut fidl::encoding::Encoder<'_, D>,
688            offset: usize,
689            depth: fidl::encoding::Depth,
690        ) -> fidl::Result<()> {
691            encoder.debug_check_bounds::<InterfaceProperties>(offset);
692            // Zero out padding regions. There's no need to apply masks
693            // because the unmasked parts will be overwritten by fields.
694            unsafe {
695                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
696                (ptr as *mut u64).write_unaligned(0);
697            }
698            // Write the fields.
699            self.0.encode(encoder, offset + 0, depth)?;
700            self.1.encode(encoder, offset + 8, depth)?;
701            self.2.encode(encoder, offset + 24, depth)?;
702            Ok(())
703        }
704    }
705
706    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InterfaceProperties {
707        #[inline(always)]
708        fn new_empty() -> Self {
709            Self {
710                id: fidl::new_empty!(u64, D),
711                addr: fidl::new_empty!(HardwareAddress, D),
712                type_: fidl::new_empty!(HardwareType, D),
713            }
714        }
715
716        #[inline]
717        unsafe fn decode(
718            &mut self,
719            decoder: &mut fidl::encoding::Decoder<'_, D>,
720            offset: usize,
721            _depth: fidl::encoding::Depth,
722        ) -> fidl::Result<()> {
723            decoder.debug_check_bounds::<Self>(offset);
724            // Verify that padding bytes are zero.
725            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
726            let padval = unsafe { (ptr as *const u64).read_unaligned() };
727            let mask = 0xffffffff00000000u64;
728            let maskedval = padval & mask;
729            if maskedval != 0 {
730                return Err(fidl::Error::NonZeroPadding {
731                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
732                });
733            }
734            fidl::decode!(u64, D, &mut self.id, decoder, offset + 0, _depth)?;
735            fidl::decode!(HardwareAddress, D, &mut self.addr, decoder, offset + 8, _depth)?;
736            fidl::decode!(HardwareType, D, &mut self.type_, decoder, offset + 24, _depth)?;
737            Ok(())
738        }
739    }
740
741    impl fidl::encoding::ValueTypeMarker for PacketInfo {
742        type Borrowed<'a> = &'a Self;
743        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
744            value
745        }
746    }
747
748    unsafe impl fidl::encoding::TypeMarker for PacketInfo {
749        type Owned = Self;
750
751        #[inline(always)]
752        fn inline_align(_context: fidl::encoding::Context) -> usize {
753            8
754        }
755
756        #[inline(always)]
757        fn inline_size(_context: fidl::encoding::Context) -> usize {
758            32
759        }
760    }
761
762    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PacketInfo, D>
763        for &PacketInfo
764    {
765        #[inline]
766        unsafe fn encode(
767            self,
768            encoder: &mut fidl::encoding::Encoder<'_, D>,
769            offset: usize,
770            _depth: fidl::encoding::Depth,
771        ) -> fidl::Result<()> {
772            encoder.debug_check_bounds::<PacketInfo>(offset);
773            // Delegate to tuple encoding.
774            fidl::encoding::Encode::<PacketInfo, D>::encode(
775                (
776                    <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.protocol),
777                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.interface_id),
778                    <HardwareAddress as fidl::encoding::ValueTypeMarker>::borrow(&self.addr),
779                ),
780                encoder,
781                offset,
782                _depth,
783            )
784        }
785    }
786    unsafe impl<
787            D: fidl::encoding::ResourceDialect,
788            T0: fidl::encoding::Encode<u16, D>,
789            T1: fidl::encoding::Encode<u64, D>,
790            T2: fidl::encoding::Encode<HardwareAddress, D>,
791        > fidl::encoding::Encode<PacketInfo, D> for (T0, T1, T2)
792    {
793        #[inline]
794        unsafe fn encode(
795            self,
796            encoder: &mut fidl::encoding::Encoder<'_, D>,
797            offset: usize,
798            depth: fidl::encoding::Depth,
799        ) -> fidl::Result<()> {
800            encoder.debug_check_bounds::<PacketInfo>(offset);
801            // Zero out padding regions. There's no need to apply masks
802            // because the unmasked parts will be overwritten by fields.
803            unsafe {
804                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
805                (ptr as *mut u64).write_unaligned(0);
806            }
807            // Write the fields.
808            self.0.encode(encoder, offset + 0, depth)?;
809            self.1.encode(encoder, offset + 8, depth)?;
810            self.2.encode(encoder, offset + 16, depth)?;
811            Ok(())
812        }
813    }
814
815    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PacketInfo {
816        #[inline(always)]
817        fn new_empty() -> Self {
818            Self {
819                protocol: fidl::new_empty!(u16, D),
820                interface_id: fidl::new_empty!(u64, D),
821                addr: fidl::new_empty!(HardwareAddress, D),
822            }
823        }
824
825        #[inline]
826        unsafe fn decode(
827            &mut self,
828            decoder: &mut fidl::encoding::Decoder<'_, D>,
829            offset: usize,
830            _depth: fidl::encoding::Depth,
831        ) -> fidl::Result<()> {
832            decoder.debug_check_bounds::<Self>(offset);
833            // Verify that padding bytes are zero.
834            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
835            let padval = unsafe { (ptr as *const u64).read_unaligned() };
836            let mask = 0xffffffffffff0000u64;
837            let maskedval = padval & mask;
838            if maskedval != 0 {
839                return Err(fidl::Error::NonZeroPadding {
840                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
841                });
842            }
843            fidl::decode!(u16, D, &mut self.protocol, decoder, offset + 0, _depth)?;
844            fidl::decode!(u64, D, &mut self.interface_id, decoder, offset + 8, _depth)?;
845            fidl::decode!(HardwareAddress, D, &mut self.addr, decoder, offset + 16, _depth)?;
846            Ok(())
847        }
848    }
849
850    impl fidl::encoding::ValueTypeMarker for ProviderSocketRequest {
851        type Borrowed<'a> = &'a Self;
852        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
853            value
854        }
855    }
856
857    unsafe impl fidl::encoding::TypeMarker for ProviderSocketRequest {
858        type Owned = Self;
859
860        #[inline(always)]
861        fn inline_align(_context: fidl::encoding::Context) -> usize {
862            4
863        }
864
865        #[inline(always)]
866        fn inline_size(_context: fidl::encoding::Context) -> usize {
867            4
868        }
869    }
870
871    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ProviderSocketRequest, D>
872        for &ProviderSocketRequest
873    {
874        #[inline]
875        unsafe fn encode(
876            self,
877            encoder: &mut fidl::encoding::Encoder<'_, D>,
878            offset: usize,
879            _depth: fidl::encoding::Depth,
880        ) -> fidl::Result<()> {
881            encoder.debug_check_bounds::<ProviderSocketRequest>(offset);
882            // Delegate to tuple encoding.
883            fidl::encoding::Encode::<ProviderSocketRequest, D>::encode(
884                (<Kind as fidl::encoding::ValueTypeMarker>::borrow(&self.kind),),
885                encoder,
886                offset,
887                _depth,
888            )
889        }
890    }
891    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Kind, D>>
892        fidl::encoding::Encode<ProviderSocketRequest, D> for (T0,)
893    {
894        #[inline]
895        unsafe fn encode(
896            self,
897            encoder: &mut fidl::encoding::Encoder<'_, D>,
898            offset: usize,
899            depth: fidl::encoding::Depth,
900        ) -> fidl::Result<()> {
901            encoder.debug_check_bounds::<ProviderSocketRequest>(offset);
902            // Zero out padding regions. There's no need to apply masks
903            // because the unmasked parts will be overwritten by fields.
904            // Write the fields.
905            self.0.encode(encoder, offset + 0, depth)?;
906            Ok(())
907        }
908    }
909
910    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ProviderSocketRequest {
911        #[inline(always)]
912        fn new_empty() -> Self {
913            Self { kind: fidl::new_empty!(Kind, D) }
914        }
915
916        #[inline]
917        unsafe fn decode(
918            &mut self,
919            decoder: &mut fidl::encoding::Decoder<'_, D>,
920            offset: usize,
921            _depth: fidl::encoding::Depth,
922        ) -> fidl::Result<()> {
923            decoder.debug_check_bounds::<Self>(offset);
924            // Verify that padding bytes are zero.
925            fidl::decode!(Kind, D, &mut self.kind, decoder, offset + 0, _depth)?;
926            Ok(())
927        }
928    }
929
930    impl fidl::encoding::ValueTypeMarker for RecvPacketInfo {
931        type Borrowed<'a> = &'a Self;
932        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
933            value
934        }
935    }
936
937    unsafe impl fidl::encoding::TypeMarker for RecvPacketInfo {
938        type Owned = Self;
939
940        #[inline(always)]
941        fn inline_align(_context: fidl::encoding::Context) -> usize {
942            8
943        }
944
945        #[inline(always)]
946        fn inline_size(_context: fidl::encoding::Context) -> usize {
947            40
948        }
949    }
950
951    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RecvPacketInfo, D>
952        for &RecvPacketInfo
953    {
954        #[inline]
955        unsafe fn encode(
956            self,
957            encoder: &mut fidl::encoding::Encoder<'_, D>,
958            offset: usize,
959            _depth: fidl::encoding::Depth,
960        ) -> fidl::Result<()> {
961            encoder.debug_check_bounds::<RecvPacketInfo>(offset);
962            // Delegate to tuple encoding.
963            fidl::encoding::Encode::<RecvPacketInfo, D>::encode(
964                (
965                    <PacketInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.packet_info),
966                    <PacketType as fidl::encoding::ValueTypeMarker>::borrow(&self.packet_type),
967                    <HardwareType as fidl::encoding::ValueTypeMarker>::borrow(&self.interface_type),
968                ),
969                encoder,
970                offset,
971                _depth,
972            )
973        }
974    }
975    unsafe impl<
976            D: fidl::encoding::ResourceDialect,
977            T0: fidl::encoding::Encode<PacketInfo, D>,
978            T1: fidl::encoding::Encode<PacketType, D>,
979            T2: fidl::encoding::Encode<HardwareType, D>,
980        > fidl::encoding::Encode<RecvPacketInfo, D> for (T0, T1, T2)
981    {
982        #[inline]
983        unsafe fn encode(
984            self,
985            encoder: &mut fidl::encoding::Encoder<'_, D>,
986            offset: usize,
987            depth: fidl::encoding::Depth,
988        ) -> fidl::Result<()> {
989            encoder.debug_check_bounds::<RecvPacketInfo>(offset);
990            // Zero out padding regions. There's no need to apply masks
991            // because the unmasked parts will be overwritten by fields.
992            // Write the fields.
993            self.0.encode(encoder, offset + 0, depth)?;
994            self.1.encode(encoder, offset + 32, depth)?;
995            self.2.encode(encoder, offset + 36, depth)?;
996            Ok(())
997        }
998    }
999
1000    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RecvPacketInfo {
1001        #[inline(always)]
1002        fn new_empty() -> Self {
1003            Self {
1004                packet_info: fidl::new_empty!(PacketInfo, D),
1005                packet_type: fidl::new_empty!(PacketType, D),
1006                interface_type: fidl::new_empty!(HardwareType, D),
1007            }
1008        }
1009
1010        #[inline]
1011        unsafe fn decode(
1012            &mut self,
1013            decoder: &mut fidl::encoding::Decoder<'_, D>,
1014            offset: usize,
1015            _depth: fidl::encoding::Depth,
1016        ) -> fidl::Result<()> {
1017            decoder.debug_check_bounds::<Self>(offset);
1018            // Verify that padding bytes are zero.
1019            fidl::decode!(PacketInfo, D, &mut self.packet_info, decoder, offset + 0, _depth)?;
1020            fidl::decode!(PacketType, D, &mut self.packet_type, decoder, offset + 32, _depth)?;
1021            fidl::decode!(HardwareType, D, &mut self.interface_type, decoder, offset + 36, _depth)?;
1022            Ok(())
1023        }
1024    }
1025
1026    impl fidl::encoding::ValueTypeMarker for SocketBindRequest {
1027        type Borrowed<'a> = &'a Self;
1028        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1029            value
1030        }
1031    }
1032
1033    unsafe impl fidl::encoding::TypeMarker for SocketBindRequest {
1034        type Owned = Self;
1035
1036        #[inline(always)]
1037        fn inline_align(_context: fidl::encoding::Context) -> usize {
1038            8
1039        }
1040
1041        #[inline(always)]
1042        fn inline_size(_context: fidl::encoding::Context) -> usize {
1043            32
1044        }
1045    }
1046
1047    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SocketBindRequest, D>
1048        for &SocketBindRequest
1049    {
1050        #[inline]
1051        unsafe fn encode(
1052            self,
1053            encoder: &mut fidl::encoding::Encoder<'_, D>,
1054            offset: usize,
1055            _depth: fidl::encoding::Depth,
1056        ) -> fidl::Result<()> {
1057            encoder.debug_check_bounds::<SocketBindRequest>(offset);
1058            // Delegate to tuple encoding.
1059            fidl::encoding::Encode::<SocketBindRequest, D>::encode(
1060                (
1061                    <fidl::encoding::OptionalUnion<ProtocolAssociation> as fidl::encoding::ValueTypeMarker>::borrow(&self.protocol),
1062                    <BoundInterfaceId as fidl::encoding::ValueTypeMarker>::borrow(&self.bound_interface_id),
1063                ),
1064                encoder, offset, _depth
1065            )
1066        }
1067    }
1068    unsafe impl<
1069            D: fidl::encoding::ResourceDialect,
1070            T0: fidl::encoding::Encode<fidl::encoding::OptionalUnion<ProtocolAssociation>, D>,
1071            T1: fidl::encoding::Encode<BoundInterfaceId, D>,
1072        > fidl::encoding::Encode<SocketBindRequest, D> for (T0, T1)
1073    {
1074        #[inline]
1075        unsafe fn encode(
1076            self,
1077            encoder: &mut fidl::encoding::Encoder<'_, D>,
1078            offset: usize,
1079            depth: fidl::encoding::Depth,
1080        ) -> fidl::Result<()> {
1081            encoder.debug_check_bounds::<SocketBindRequest>(offset);
1082            // Zero out padding regions. There's no need to apply masks
1083            // because the unmasked parts will be overwritten by fields.
1084            // Write the fields.
1085            self.0.encode(encoder, offset + 0, depth)?;
1086            self.1.encode(encoder, offset + 16, depth)?;
1087            Ok(())
1088        }
1089    }
1090
1091    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SocketBindRequest {
1092        #[inline(always)]
1093        fn new_empty() -> Self {
1094            Self {
1095                protocol: fidl::new_empty!(fidl::encoding::OptionalUnion<ProtocolAssociation>, D),
1096                bound_interface_id: fidl::new_empty!(BoundInterfaceId, D),
1097            }
1098        }
1099
1100        #[inline]
1101        unsafe fn decode(
1102            &mut self,
1103            decoder: &mut fidl::encoding::Decoder<'_, D>,
1104            offset: usize,
1105            _depth: fidl::encoding::Depth,
1106        ) -> fidl::Result<()> {
1107            decoder.debug_check_bounds::<Self>(offset);
1108            // Verify that padding bytes are zero.
1109            fidl::decode!(
1110                fidl::encoding::OptionalUnion<ProtocolAssociation>,
1111                D,
1112                &mut self.protocol,
1113                decoder,
1114                offset + 0,
1115                _depth
1116            )?;
1117            fidl::decode!(
1118                BoundInterfaceId,
1119                D,
1120                &mut self.bound_interface_id,
1121                decoder,
1122                offset + 16,
1123                _depth
1124            )?;
1125            Ok(())
1126        }
1127    }
1128
1129    impl fidl::encoding::ValueTypeMarker for SocketRecvMsgRequest {
1130        type Borrowed<'a> = &'a Self;
1131        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1132            value
1133        }
1134    }
1135
1136    unsafe impl fidl::encoding::TypeMarker for SocketRecvMsgRequest {
1137        type Owned = Self;
1138
1139        #[inline(always)]
1140        fn inline_align(_context: fidl::encoding::Context) -> usize {
1141            4
1142        }
1143
1144        #[inline(always)]
1145        fn inline_size(_context: fidl::encoding::Context) -> usize {
1146            12
1147        }
1148    }
1149
1150    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SocketRecvMsgRequest, D>
1151        for &SocketRecvMsgRequest
1152    {
1153        #[inline]
1154        unsafe fn encode(
1155            self,
1156            encoder: &mut fidl::encoding::Encoder<'_, D>,
1157            offset: usize,
1158            _depth: fidl::encoding::Depth,
1159        ) -> fidl::Result<()> {
1160            encoder.debug_check_bounds::<SocketRecvMsgRequest>(offset);
1161            // Delegate to tuple encoding.
1162            fidl::encoding::Encode::<SocketRecvMsgRequest, D>::encode(
1163                (
1164                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.want_packet_info),
1165                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.data_len),
1166                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.want_control),
1167                    <fidl_fuchsia_posix_socket::RecvMsgFlags as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
1168                ),
1169                encoder, offset, _depth
1170            )
1171        }
1172    }
1173    unsafe impl<
1174            D: fidl::encoding::ResourceDialect,
1175            T0: fidl::encoding::Encode<bool, D>,
1176            T1: fidl::encoding::Encode<u32, D>,
1177            T2: fidl::encoding::Encode<bool, D>,
1178            T3: fidl::encoding::Encode<fidl_fuchsia_posix_socket::RecvMsgFlags, D>,
1179        > fidl::encoding::Encode<SocketRecvMsgRequest, D> for (T0, T1, T2, T3)
1180    {
1181        #[inline]
1182        unsafe fn encode(
1183            self,
1184            encoder: &mut fidl::encoding::Encoder<'_, D>,
1185            offset: usize,
1186            depth: fidl::encoding::Depth,
1187        ) -> fidl::Result<()> {
1188            encoder.debug_check_bounds::<SocketRecvMsgRequest>(offset);
1189            // Zero out padding regions. There's no need to apply masks
1190            // because the unmasked parts will be overwritten by fields.
1191            unsafe {
1192                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1193                (ptr as *mut u32).write_unaligned(0);
1194            }
1195            unsafe {
1196                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
1197                (ptr as *mut u32).write_unaligned(0);
1198            }
1199            // Write the fields.
1200            self.0.encode(encoder, offset + 0, depth)?;
1201            self.1.encode(encoder, offset + 4, depth)?;
1202            self.2.encode(encoder, offset + 8, depth)?;
1203            self.3.encode(encoder, offset + 10, depth)?;
1204            Ok(())
1205        }
1206    }
1207
1208    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SocketRecvMsgRequest {
1209        #[inline(always)]
1210        fn new_empty() -> Self {
1211            Self {
1212                want_packet_info: fidl::new_empty!(bool, D),
1213                data_len: fidl::new_empty!(u32, D),
1214                want_control: fidl::new_empty!(bool, D),
1215                flags: fidl::new_empty!(fidl_fuchsia_posix_socket::RecvMsgFlags, D),
1216            }
1217        }
1218
1219        #[inline]
1220        unsafe fn decode(
1221            &mut self,
1222            decoder: &mut fidl::encoding::Decoder<'_, D>,
1223            offset: usize,
1224            _depth: fidl::encoding::Depth,
1225        ) -> fidl::Result<()> {
1226            decoder.debug_check_bounds::<Self>(offset);
1227            // Verify that padding bytes are zero.
1228            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1229            let padval = unsafe { (ptr as *const u32).read_unaligned() };
1230            let mask = 0xffffff00u32;
1231            let maskedval = padval & mask;
1232            if maskedval != 0 {
1233                return Err(fidl::Error::NonZeroPadding {
1234                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1235                });
1236            }
1237            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
1238            let padval = unsafe { (ptr as *const u32).read_unaligned() };
1239            let mask = 0xff00u32;
1240            let maskedval = padval & mask;
1241            if maskedval != 0 {
1242                return Err(fidl::Error::NonZeroPadding {
1243                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
1244                });
1245            }
1246            fidl::decode!(bool, D, &mut self.want_packet_info, decoder, offset + 0, _depth)?;
1247            fidl::decode!(u32, D, &mut self.data_len, decoder, offset + 4, _depth)?;
1248            fidl::decode!(bool, D, &mut self.want_control, decoder, offset + 8, _depth)?;
1249            fidl::decode!(
1250                fidl_fuchsia_posix_socket::RecvMsgFlags,
1251                D,
1252                &mut self.flags,
1253                decoder,
1254                offset + 10,
1255                _depth
1256            )?;
1257            Ok(())
1258        }
1259    }
1260
1261    impl fidl::encoding::ValueTypeMarker for SocketSendMsgRequest {
1262        type Borrowed<'a> = &'a Self;
1263        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1264            value
1265        }
1266    }
1267
1268    unsafe impl fidl::encoding::TypeMarker for SocketSendMsgRequest {
1269        type Owned = Self;
1270
1271        #[inline(always)]
1272        fn inline_align(_context: fidl::encoding::Context) -> usize {
1273            8
1274        }
1275
1276        #[inline(always)]
1277        fn inline_size(_context: fidl::encoding::Context) -> usize {
1278            48
1279        }
1280    }
1281
1282    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SocketSendMsgRequest, D>
1283        for &SocketSendMsgRequest
1284    {
1285        #[inline]
1286        unsafe fn encode(
1287            self,
1288            encoder: &mut fidl::encoding::Encoder<'_, D>,
1289            offset: usize,
1290            _depth: fidl::encoding::Depth,
1291        ) -> fidl::Result<()> {
1292            encoder.debug_check_bounds::<SocketSendMsgRequest>(offset);
1293            // Delegate to tuple encoding.
1294            fidl::encoding::Encode::<SocketSendMsgRequest, D>::encode(
1295                (
1296                    <fidl::encoding::Boxed<PacketInfo> as fidl::encoding::ValueTypeMarker>::borrow(&self.packet_info),
1297                    <fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(&self.data),
1298                    <SendControlData as fidl::encoding::ValueTypeMarker>::borrow(&self.control),
1299                    <fidl_fuchsia_posix_socket::SendMsgFlags as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
1300                ),
1301                encoder, offset, _depth
1302            )
1303        }
1304    }
1305    unsafe impl<
1306            D: fidl::encoding::ResourceDialect,
1307            T0: fidl::encoding::Encode<fidl::encoding::Boxed<PacketInfo>, D>,
1308            T1: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
1309            T2: fidl::encoding::Encode<SendControlData, D>,
1310            T3: fidl::encoding::Encode<fidl_fuchsia_posix_socket::SendMsgFlags, D>,
1311        > fidl::encoding::Encode<SocketSendMsgRequest, D> for (T0, T1, T2, T3)
1312    {
1313        #[inline]
1314        unsafe fn encode(
1315            self,
1316            encoder: &mut fidl::encoding::Encoder<'_, D>,
1317            offset: usize,
1318            depth: fidl::encoding::Depth,
1319        ) -> fidl::Result<()> {
1320            encoder.debug_check_bounds::<SocketSendMsgRequest>(offset);
1321            // Zero out padding regions. There's no need to apply masks
1322            // because the unmasked parts will be overwritten by fields.
1323            unsafe {
1324                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
1325                (ptr as *mut u64).write_unaligned(0);
1326            }
1327            // Write the fields.
1328            self.0.encode(encoder, offset + 0, depth)?;
1329            self.1.encode(encoder, offset + 8, depth)?;
1330            self.2.encode(encoder, offset + 24, depth)?;
1331            self.3.encode(encoder, offset + 40, depth)?;
1332            Ok(())
1333        }
1334    }
1335
1336    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SocketSendMsgRequest {
1337        #[inline(always)]
1338        fn new_empty() -> Self {
1339            Self {
1340                packet_info: fidl::new_empty!(fidl::encoding::Boxed<PacketInfo>, D),
1341                data: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D),
1342                control: fidl::new_empty!(SendControlData, D),
1343                flags: fidl::new_empty!(fidl_fuchsia_posix_socket::SendMsgFlags, D),
1344            }
1345        }
1346
1347        #[inline]
1348        unsafe fn decode(
1349            &mut self,
1350            decoder: &mut fidl::encoding::Decoder<'_, D>,
1351            offset: usize,
1352            _depth: fidl::encoding::Depth,
1353        ) -> fidl::Result<()> {
1354            decoder.debug_check_bounds::<Self>(offset);
1355            // Verify that padding bytes are zero.
1356            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
1357            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1358            let mask = 0xffffffffffff0000u64;
1359            let maskedval = padval & mask;
1360            if maskedval != 0 {
1361                return Err(fidl::Error::NonZeroPadding {
1362                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
1363                });
1364            }
1365            fidl::decode!(
1366                fidl::encoding::Boxed<PacketInfo>,
1367                D,
1368                &mut self.packet_info,
1369                decoder,
1370                offset + 0,
1371                _depth
1372            )?;
1373            fidl::decode!(
1374                fidl::encoding::UnboundedVector<u8>,
1375                D,
1376                &mut self.data,
1377                decoder,
1378                offset + 8,
1379                _depth
1380            )?;
1381            fidl::decode!(SendControlData, D, &mut self.control, decoder, offset + 24, _depth)?;
1382            fidl::decode!(
1383                fidl_fuchsia_posix_socket::SendMsgFlags,
1384                D,
1385                &mut self.flags,
1386                decoder,
1387                offset + 40,
1388                _depth
1389            )?;
1390            Ok(())
1391        }
1392    }
1393
1394    impl fidl::encoding::ValueTypeMarker for SocketGetInfoResponse {
1395        type Borrowed<'a> = &'a Self;
1396        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1397            value
1398        }
1399    }
1400
1401    unsafe impl fidl::encoding::TypeMarker for SocketGetInfoResponse {
1402        type Owned = Self;
1403
1404        #[inline(always)]
1405        fn inline_align(_context: fidl::encoding::Context) -> usize {
1406            8
1407        }
1408
1409        #[inline(always)]
1410        fn inline_size(_context: fidl::encoding::Context) -> usize {
1411            40
1412        }
1413    }
1414
1415    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SocketGetInfoResponse, D>
1416        for &SocketGetInfoResponse
1417    {
1418        #[inline]
1419        unsafe fn encode(
1420            self,
1421            encoder: &mut fidl::encoding::Encoder<'_, D>,
1422            offset: usize,
1423            _depth: fidl::encoding::Depth,
1424        ) -> fidl::Result<()> {
1425            encoder.debug_check_bounds::<SocketGetInfoResponse>(offset);
1426            // Delegate to tuple encoding.
1427            fidl::encoding::Encode::<SocketGetInfoResponse, D>::encode(
1428                (
1429                    <Kind as fidl::encoding::ValueTypeMarker>::borrow(&self.kind),
1430                    <fidl::encoding::OptionalUnion<ProtocolAssociation> as fidl::encoding::ValueTypeMarker>::borrow(&self.protocol),
1431                    <BoundInterface as fidl::encoding::ValueTypeMarker>::borrow(&self.bound_interface),
1432                ),
1433                encoder, offset, _depth
1434            )
1435        }
1436    }
1437    unsafe impl<
1438            D: fidl::encoding::ResourceDialect,
1439            T0: fidl::encoding::Encode<Kind, D>,
1440            T1: fidl::encoding::Encode<fidl::encoding::OptionalUnion<ProtocolAssociation>, D>,
1441            T2: fidl::encoding::Encode<BoundInterface, D>,
1442        > fidl::encoding::Encode<SocketGetInfoResponse, D> for (T0, T1, T2)
1443    {
1444        #[inline]
1445        unsafe fn encode(
1446            self,
1447            encoder: &mut fidl::encoding::Encoder<'_, D>,
1448            offset: usize,
1449            depth: fidl::encoding::Depth,
1450        ) -> fidl::Result<()> {
1451            encoder.debug_check_bounds::<SocketGetInfoResponse>(offset);
1452            // Zero out padding regions. There's no need to apply masks
1453            // because the unmasked parts will be overwritten by fields.
1454            unsafe {
1455                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1456                (ptr as *mut u64).write_unaligned(0);
1457            }
1458            // Write the fields.
1459            self.0.encode(encoder, offset + 0, depth)?;
1460            self.1.encode(encoder, offset + 8, depth)?;
1461            self.2.encode(encoder, offset + 24, depth)?;
1462            Ok(())
1463        }
1464    }
1465
1466    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SocketGetInfoResponse {
1467        #[inline(always)]
1468        fn new_empty() -> Self {
1469            Self {
1470                kind: fidl::new_empty!(Kind, D),
1471                protocol: fidl::new_empty!(fidl::encoding::OptionalUnion<ProtocolAssociation>, D),
1472                bound_interface: fidl::new_empty!(BoundInterface, D),
1473            }
1474        }
1475
1476        #[inline]
1477        unsafe fn decode(
1478            &mut self,
1479            decoder: &mut fidl::encoding::Decoder<'_, D>,
1480            offset: usize,
1481            _depth: fidl::encoding::Depth,
1482        ) -> fidl::Result<()> {
1483            decoder.debug_check_bounds::<Self>(offset);
1484            // Verify that padding bytes are zero.
1485            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1486            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1487            let mask = 0xffffffff00000000u64;
1488            let maskedval = padval & mask;
1489            if maskedval != 0 {
1490                return Err(fidl::Error::NonZeroPadding {
1491                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1492                });
1493            }
1494            fidl::decode!(Kind, D, &mut self.kind, decoder, offset + 0, _depth)?;
1495            fidl::decode!(
1496                fidl::encoding::OptionalUnion<ProtocolAssociation>,
1497                D,
1498                &mut self.protocol,
1499                decoder,
1500                offset + 8,
1501                _depth
1502            )?;
1503            fidl::decode!(
1504                BoundInterface,
1505                D,
1506                &mut self.bound_interface,
1507                decoder,
1508                offset + 24,
1509                _depth
1510            )?;
1511            Ok(())
1512        }
1513    }
1514
1515    impl fidl::encoding::ValueTypeMarker for SocketRecvMsgResponse {
1516        type Borrowed<'a> = &'a Self;
1517        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1518            value
1519        }
1520    }
1521
1522    unsafe impl fidl::encoding::TypeMarker for SocketRecvMsgResponse {
1523        type Owned = Self;
1524
1525        #[inline(always)]
1526        fn inline_align(_context: fidl::encoding::Context) -> usize {
1527            8
1528        }
1529
1530        #[inline(always)]
1531        fn inline_size(_context: fidl::encoding::Context) -> usize {
1532            48
1533        }
1534    }
1535
1536    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SocketRecvMsgResponse, D>
1537        for &SocketRecvMsgResponse
1538    {
1539        #[inline]
1540        unsafe fn encode(
1541            self,
1542            encoder: &mut fidl::encoding::Encoder<'_, D>,
1543            offset: usize,
1544            _depth: fidl::encoding::Depth,
1545        ) -> fidl::Result<()> {
1546            encoder.debug_check_bounds::<SocketRecvMsgResponse>(offset);
1547            // Delegate to tuple encoding.
1548            fidl::encoding::Encode::<SocketRecvMsgResponse, D>::encode(
1549                (
1550                    <fidl::encoding::Boxed<RecvPacketInfo> as fidl::encoding::ValueTypeMarker>::borrow(&self.packet_info),
1551                    <fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(&self.data),
1552                    <RecvControlData as fidl::encoding::ValueTypeMarker>::borrow(&self.control),
1553                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.truncated),
1554                ),
1555                encoder, offset, _depth
1556            )
1557        }
1558    }
1559    unsafe impl<
1560            D: fidl::encoding::ResourceDialect,
1561            T0: fidl::encoding::Encode<fidl::encoding::Boxed<RecvPacketInfo>, D>,
1562            T1: fidl::encoding::Encode<fidl::encoding::UnboundedVector<u8>, D>,
1563            T2: fidl::encoding::Encode<RecvControlData, D>,
1564            T3: fidl::encoding::Encode<u32, D>,
1565        > fidl::encoding::Encode<SocketRecvMsgResponse, D> for (T0, T1, T2, T3)
1566    {
1567        #[inline]
1568        unsafe fn encode(
1569            self,
1570            encoder: &mut fidl::encoding::Encoder<'_, D>,
1571            offset: usize,
1572            depth: fidl::encoding::Depth,
1573        ) -> fidl::Result<()> {
1574            encoder.debug_check_bounds::<SocketRecvMsgResponse>(offset);
1575            // Zero out padding regions. There's no need to apply masks
1576            // because the unmasked parts will be overwritten by fields.
1577            unsafe {
1578                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
1579                (ptr as *mut u64).write_unaligned(0);
1580            }
1581            // Write the fields.
1582            self.0.encode(encoder, offset + 0, depth)?;
1583            self.1.encode(encoder, offset + 8, depth)?;
1584            self.2.encode(encoder, offset + 24, depth)?;
1585            self.3.encode(encoder, offset + 40, depth)?;
1586            Ok(())
1587        }
1588    }
1589
1590    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SocketRecvMsgResponse {
1591        #[inline(always)]
1592        fn new_empty() -> Self {
1593            Self {
1594                packet_info: fidl::new_empty!(fidl::encoding::Boxed<RecvPacketInfo>, D),
1595                data: fidl::new_empty!(fidl::encoding::UnboundedVector<u8>, D),
1596                control: fidl::new_empty!(RecvControlData, D),
1597                truncated: fidl::new_empty!(u32, D),
1598            }
1599        }
1600
1601        #[inline]
1602        unsafe fn decode(
1603            &mut self,
1604            decoder: &mut fidl::encoding::Decoder<'_, D>,
1605            offset: usize,
1606            _depth: fidl::encoding::Depth,
1607        ) -> fidl::Result<()> {
1608            decoder.debug_check_bounds::<Self>(offset);
1609            // Verify that padding bytes are zero.
1610            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
1611            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1612            let mask = 0xffffffff00000000u64;
1613            let maskedval = padval & mask;
1614            if maskedval != 0 {
1615                return Err(fidl::Error::NonZeroPadding {
1616                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
1617                });
1618            }
1619            fidl::decode!(
1620                fidl::encoding::Boxed<RecvPacketInfo>,
1621                D,
1622                &mut self.packet_info,
1623                decoder,
1624                offset + 0,
1625                _depth
1626            )?;
1627            fidl::decode!(
1628                fidl::encoding::UnboundedVector<u8>,
1629                D,
1630                &mut self.data,
1631                decoder,
1632                offset + 8,
1633                _depth
1634            )?;
1635            fidl::decode!(RecvControlData, D, &mut self.control, decoder, offset + 24, _depth)?;
1636            fidl::decode!(u32, D, &mut self.truncated, decoder, offset + 40, _depth)?;
1637            Ok(())
1638        }
1639    }
1640
1641    impl RecvControlData {
1642        #[inline(always)]
1643        fn max_ordinal_present(&self) -> u64 {
1644            if let Some(_) = self.socket {
1645                return 1;
1646            }
1647            0
1648        }
1649    }
1650
1651    impl fidl::encoding::ValueTypeMarker for RecvControlData {
1652        type Borrowed<'a> = &'a Self;
1653        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1654            value
1655        }
1656    }
1657
1658    unsafe impl fidl::encoding::TypeMarker for RecvControlData {
1659        type Owned = Self;
1660
1661        #[inline(always)]
1662        fn inline_align(_context: fidl::encoding::Context) -> usize {
1663            8
1664        }
1665
1666        #[inline(always)]
1667        fn inline_size(_context: fidl::encoding::Context) -> usize {
1668            16
1669        }
1670    }
1671
1672    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RecvControlData, D>
1673        for &RecvControlData
1674    {
1675        unsafe fn encode(
1676            self,
1677            encoder: &mut fidl::encoding::Encoder<'_, D>,
1678            offset: usize,
1679            mut depth: fidl::encoding::Depth,
1680        ) -> fidl::Result<()> {
1681            encoder.debug_check_bounds::<RecvControlData>(offset);
1682            // Vector header
1683            let max_ordinal: u64 = self.max_ordinal_present();
1684            encoder.write_num(max_ordinal, offset);
1685            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1686            // Calling encoder.out_of_line_offset(0) is not allowed.
1687            if max_ordinal == 0 {
1688                return Ok(());
1689            }
1690            depth.increment()?;
1691            let envelope_size = 8;
1692            let bytes_len = max_ordinal as usize * envelope_size;
1693            #[allow(unused_variables)]
1694            let offset = encoder.out_of_line_offset(bytes_len);
1695            let mut _prev_end_offset: usize = 0;
1696            if 1 > max_ordinal {
1697                return Ok(());
1698            }
1699
1700            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1701            // are envelope_size bytes.
1702            let cur_offset: usize = (1 - 1) * envelope_size;
1703
1704            // Zero reserved fields.
1705            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1706
1707            // Safety:
1708            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1709            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1710            //   envelope_size bytes, there is always sufficient room.
1711            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_posix_socket::SocketRecvControlData, D>(
1712            self.socket.as_ref().map(<fidl_fuchsia_posix_socket::SocketRecvControlData as fidl::encoding::ValueTypeMarker>::borrow),
1713            encoder, offset + cur_offset, depth
1714        )?;
1715
1716            _prev_end_offset = cur_offset + envelope_size;
1717
1718            Ok(())
1719        }
1720    }
1721
1722    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RecvControlData {
1723        #[inline(always)]
1724        fn new_empty() -> Self {
1725            Self::default()
1726        }
1727
1728        unsafe fn decode(
1729            &mut self,
1730            decoder: &mut fidl::encoding::Decoder<'_, D>,
1731            offset: usize,
1732            mut depth: fidl::encoding::Depth,
1733        ) -> fidl::Result<()> {
1734            decoder.debug_check_bounds::<Self>(offset);
1735            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1736                None => return Err(fidl::Error::NotNullable),
1737                Some(len) => len,
1738            };
1739            // Calling decoder.out_of_line_offset(0) is not allowed.
1740            if len == 0 {
1741                return Ok(());
1742            };
1743            depth.increment()?;
1744            let envelope_size = 8;
1745            let bytes_len = len * envelope_size;
1746            let offset = decoder.out_of_line_offset(bytes_len)?;
1747            // Decode the envelope for each type.
1748            let mut _next_ordinal_to_read = 0;
1749            let mut next_offset = offset;
1750            let end_offset = offset + bytes_len;
1751            _next_ordinal_to_read += 1;
1752            if next_offset >= end_offset {
1753                return Ok(());
1754            }
1755
1756            // Decode unknown envelopes for gaps in ordinals.
1757            while _next_ordinal_to_read < 1 {
1758                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1759                _next_ordinal_to_read += 1;
1760                next_offset += envelope_size;
1761            }
1762
1763            let next_out_of_line = decoder.next_out_of_line();
1764            let handles_before = decoder.remaining_handles();
1765            if let Some((inlined, num_bytes, num_handles)) =
1766                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1767            {
1768                let member_inline_size = <fidl_fuchsia_posix_socket::SocketRecvControlData as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1769                if inlined != (member_inline_size <= 4) {
1770                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1771                }
1772                let inner_offset;
1773                let mut inner_depth = depth.clone();
1774                if inlined {
1775                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1776                    inner_offset = next_offset;
1777                } else {
1778                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1779                    inner_depth.increment()?;
1780                }
1781                let val_ref = self.socket.get_or_insert_with(|| {
1782                    fidl::new_empty!(fidl_fuchsia_posix_socket::SocketRecvControlData, D)
1783                });
1784                fidl::decode!(
1785                    fidl_fuchsia_posix_socket::SocketRecvControlData,
1786                    D,
1787                    val_ref,
1788                    decoder,
1789                    inner_offset,
1790                    inner_depth
1791                )?;
1792                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1793                {
1794                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1795                }
1796                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1797                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1798                }
1799            }
1800
1801            next_offset += envelope_size;
1802
1803            // Decode the remaining unknown envelopes.
1804            while next_offset < end_offset {
1805                _next_ordinal_to_read += 1;
1806                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1807                next_offset += envelope_size;
1808            }
1809
1810            Ok(())
1811        }
1812    }
1813
1814    impl SendControlData {
1815        #[inline(always)]
1816        fn max_ordinal_present(&self) -> u64 {
1817            if let Some(_) = self.socket {
1818                return 1;
1819            }
1820            0
1821        }
1822    }
1823
1824    impl fidl::encoding::ValueTypeMarker for SendControlData {
1825        type Borrowed<'a> = &'a Self;
1826        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1827            value
1828        }
1829    }
1830
1831    unsafe impl fidl::encoding::TypeMarker for SendControlData {
1832        type Owned = Self;
1833
1834        #[inline(always)]
1835        fn inline_align(_context: fidl::encoding::Context) -> usize {
1836            8
1837        }
1838
1839        #[inline(always)]
1840        fn inline_size(_context: fidl::encoding::Context) -> usize {
1841            16
1842        }
1843    }
1844
1845    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SendControlData, D>
1846        for &SendControlData
1847    {
1848        unsafe fn encode(
1849            self,
1850            encoder: &mut fidl::encoding::Encoder<'_, D>,
1851            offset: usize,
1852            mut depth: fidl::encoding::Depth,
1853        ) -> fidl::Result<()> {
1854            encoder.debug_check_bounds::<SendControlData>(offset);
1855            // Vector header
1856            let max_ordinal: u64 = self.max_ordinal_present();
1857            encoder.write_num(max_ordinal, offset);
1858            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1859            // Calling encoder.out_of_line_offset(0) is not allowed.
1860            if max_ordinal == 0 {
1861                return Ok(());
1862            }
1863            depth.increment()?;
1864            let envelope_size = 8;
1865            let bytes_len = max_ordinal as usize * envelope_size;
1866            #[allow(unused_variables)]
1867            let offset = encoder.out_of_line_offset(bytes_len);
1868            let mut _prev_end_offset: usize = 0;
1869            if 1 > max_ordinal {
1870                return Ok(());
1871            }
1872
1873            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1874            // are envelope_size bytes.
1875            let cur_offset: usize = (1 - 1) * envelope_size;
1876
1877            // Zero reserved fields.
1878            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1879
1880            // Safety:
1881            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1882            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1883            //   envelope_size bytes, there is always sufficient room.
1884            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_posix_socket::SocketSendControlData, D>(
1885            self.socket.as_ref().map(<fidl_fuchsia_posix_socket::SocketSendControlData as fidl::encoding::ValueTypeMarker>::borrow),
1886            encoder, offset + cur_offset, depth
1887        )?;
1888
1889            _prev_end_offset = cur_offset + envelope_size;
1890
1891            Ok(())
1892        }
1893    }
1894
1895    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SendControlData {
1896        #[inline(always)]
1897        fn new_empty() -> Self {
1898            Self::default()
1899        }
1900
1901        unsafe fn decode(
1902            &mut self,
1903            decoder: &mut fidl::encoding::Decoder<'_, D>,
1904            offset: usize,
1905            mut depth: fidl::encoding::Depth,
1906        ) -> fidl::Result<()> {
1907            decoder.debug_check_bounds::<Self>(offset);
1908            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1909                None => return Err(fidl::Error::NotNullable),
1910                Some(len) => len,
1911            };
1912            // Calling decoder.out_of_line_offset(0) is not allowed.
1913            if len == 0 {
1914                return Ok(());
1915            };
1916            depth.increment()?;
1917            let envelope_size = 8;
1918            let bytes_len = len * envelope_size;
1919            let offset = decoder.out_of_line_offset(bytes_len)?;
1920            // Decode the envelope for each type.
1921            let mut _next_ordinal_to_read = 0;
1922            let mut next_offset = offset;
1923            let end_offset = offset + bytes_len;
1924            _next_ordinal_to_read += 1;
1925            if next_offset >= end_offset {
1926                return Ok(());
1927            }
1928
1929            // Decode unknown envelopes for gaps in ordinals.
1930            while _next_ordinal_to_read < 1 {
1931                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1932                _next_ordinal_to_read += 1;
1933                next_offset += envelope_size;
1934            }
1935
1936            let next_out_of_line = decoder.next_out_of_line();
1937            let handles_before = decoder.remaining_handles();
1938            if let Some((inlined, num_bytes, num_handles)) =
1939                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1940            {
1941                let member_inline_size = <fidl_fuchsia_posix_socket::SocketSendControlData as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1942                if inlined != (member_inline_size <= 4) {
1943                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1944                }
1945                let inner_offset;
1946                let mut inner_depth = depth.clone();
1947                if inlined {
1948                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1949                    inner_offset = next_offset;
1950                } else {
1951                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1952                    inner_depth.increment()?;
1953                }
1954                let val_ref = self.socket.get_or_insert_with(|| {
1955                    fidl::new_empty!(fidl_fuchsia_posix_socket::SocketSendControlData, D)
1956                });
1957                fidl::decode!(
1958                    fidl_fuchsia_posix_socket::SocketSendControlData,
1959                    D,
1960                    val_ref,
1961                    decoder,
1962                    inner_offset,
1963                    inner_depth
1964                )?;
1965                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1966                {
1967                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1968                }
1969                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1970                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1971                }
1972            }
1973
1974            next_offset += envelope_size;
1975
1976            // Decode the remaining unknown envelopes.
1977            while next_offset < end_offset {
1978                _next_ordinal_to_read += 1;
1979                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1980                next_offset += envelope_size;
1981            }
1982
1983            Ok(())
1984        }
1985    }
1986
1987    impl fidl::encoding::ValueTypeMarker for BoundInterface {
1988        type Borrowed<'a> = &'a Self;
1989        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1990            value
1991        }
1992    }
1993
1994    unsafe impl fidl::encoding::TypeMarker for BoundInterface {
1995        type Owned = Self;
1996
1997        #[inline(always)]
1998        fn inline_align(_context: fidl::encoding::Context) -> usize {
1999            8
2000        }
2001
2002        #[inline(always)]
2003        fn inline_size(_context: fidl::encoding::Context) -> usize {
2004            16
2005        }
2006    }
2007
2008    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BoundInterface, D>
2009        for &BoundInterface
2010    {
2011        #[inline]
2012        unsafe fn encode(
2013            self,
2014            encoder: &mut fidl::encoding::Encoder<'_, D>,
2015            offset: usize,
2016            _depth: fidl::encoding::Depth,
2017        ) -> fidl::Result<()> {
2018            encoder.debug_check_bounds::<BoundInterface>(offset);
2019            encoder.write_num::<u64>(self.ordinal(), offset);
2020            match self {
2021                BoundInterface::All(ref val) => fidl::encoding::encode_in_envelope::<Empty, D>(
2022                    <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
2023                    encoder,
2024                    offset + 8,
2025                    _depth,
2026                ),
2027                BoundInterface::Specified(ref val) => {
2028                    fidl::encoding::encode_in_envelope::<InterfaceProperties, D>(
2029                        <InterfaceProperties as fidl::encoding::ValueTypeMarker>::borrow(val),
2030                        encoder,
2031                        offset + 8,
2032                        _depth,
2033                    )
2034                }
2035            }
2036        }
2037    }
2038
2039    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BoundInterface {
2040        #[inline(always)]
2041        fn new_empty() -> Self {
2042            Self::All(fidl::new_empty!(Empty, D))
2043        }
2044
2045        #[inline]
2046        unsafe fn decode(
2047            &mut self,
2048            decoder: &mut fidl::encoding::Decoder<'_, D>,
2049            offset: usize,
2050            mut depth: fidl::encoding::Depth,
2051        ) -> fidl::Result<()> {
2052            decoder.debug_check_bounds::<Self>(offset);
2053            #[allow(unused_variables)]
2054            let next_out_of_line = decoder.next_out_of_line();
2055            let handles_before = decoder.remaining_handles();
2056            let (ordinal, inlined, num_bytes, num_handles) =
2057                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2058
2059            let member_inline_size = match ordinal {
2060                1 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2061                2 => <InterfaceProperties as fidl::encoding::TypeMarker>::inline_size(
2062                    decoder.context,
2063                ),
2064                _ => return Err(fidl::Error::UnknownUnionTag),
2065            };
2066
2067            if inlined != (member_inline_size <= 4) {
2068                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2069            }
2070            let _inner_offset;
2071            if inlined {
2072                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2073                _inner_offset = offset + 8;
2074            } else {
2075                depth.increment()?;
2076                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2077            }
2078            match ordinal {
2079                1 => {
2080                    #[allow(irrefutable_let_patterns)]
2081                    if let BoundInterface::All(_) = self {
2082                        // Do nothing, read the value into the object
2083                    } else {
2084                        // Initialize `self` to the right variant
2085                        *self = BoundInterface::All(fidl::new_empty!(Empty, D));
2086                    }
2087                    #[allow(irrefutable_let_patterns)]
2088                    if let BoundInterface::All(ref mut val) = self {
2089                        fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
2090                    } else {
2091                        unreachable!()
2092                    }
2093                }
2094                2 => {
2095                    #[allow(irrefutable_let_patterns)]
2096                    if let BoundInterface::Specified(_) = self {
2097                        // Do nothing, read the value into the object
2098                    } else {
2099                        // Initialize `self` to the right variant
2100                        *self = BoundInterface::Specified(fidl::new_empty!(InterfaceProperties, D));
2101                    }
2102                    #[allow(irrefutable_let_patterns)]
2103                    if let BoundInterface::Specified(ref mut val) = self {
2104                        fidl::decode!(InterfaceProperties, D, val, decoder, _inner_offset, depth)?;
2105                    } else {
2106                        unreachable!()
2107                    }
2108                }
2109                ordinal => panic!("unexpected ordinal {:?}", ordinal),
2110            }
2111            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2112                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2113            }
2114            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2115                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2116            }
2117            Ok(())
2118        }
2119    }
2120
2121    impl fidl::encoding::ValueTypeMarker for BoundInterfaceId {
2122        type Borrowed<'a> = &'a Self;
2123        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2124            value
2125        }
2126    }
2127
2128    unsafe impl fidl::encoding::TypeMarker for BoundInterfaceId {
2129        type Owned = Self;
2130
2131        #[inline(always)]
2132        fn inline_align(_context: fidl::encoding::Context) -> usize {
2133            8
2134        }
2135
2136        #[inline(always)]
2137        fn inline_size(_context: fidl::encoding::Context) -> usize {
2138            16
2139        }
2140    }
2141
2142    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BoundInterfaceId, D>
2143        for &BoundInterfaceId
2144    {
2145        #[inline]
2146        unsafe fn encode(
2147            self,
2148            encoder: &mut fidl::encoding::Encoder<'_, D>,
2149            offset: usize,
2150            _depth: fidl::encoding::Depth,
2151        ) -> fidl::Result<()> {
2152            encoder.debug_check_bounds::<BoundInterfaceId>(offset);
2153            encoder.write_num::<u64>(self.ordinal(), offset);
2154            match self {
2155                BoundInterfaceId::All(ref val) => fidl::encoding::encode_in_envelope::<Empty, D>(
2156                    <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
2157                    encoder,
2158                    offset + 8,
2159                    _depth,
2160                ),
2161                BoundInterfaceId::Specified(ref val) => {
2162                    fidl::encoding::encode_in_envelope::<u64, D>(
2163                        <u64 as fidl::encoding::ValueTypeMarker>::borrow(val),
2164                        encoder,
2165                        offset + 8,
2166                        _depth,
2167                    )
2168                }
2169            }
2170        }
2171    }
2172
2173    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BoundInterfaceId {
2174        #[inline(always)]
2175        fn new_empty() -> Self {
2176            Self::All(fidl::new_empty!(Empty, D))
2177        }
2178
2179        #[inline]
2180        unsafe fn decode(
2181            &mut self,
2182            decoder: &mut fidl::encoding::Decoder<'_, D>,
2183            offset: usize,
2184            mut depth: fidl::encoding::Depth,
2185        ) -> fidl::Result<()> {
2186            decoder.debug_check_bounds::<Self>(offset);
2187            #[allow(unused_variables)]
2188            let next_out_of_line = decoder.next_out_of_line();
2189            let handles_before = decoder.remaining_handles();
2190            let (ordinal, inlined, num_bytes, num_handles) =
2191                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2192
2193            let member_inline_size = match ordinal {
2194                1 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2195                2 => <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2196                _ => return Err(fidl::Error::UnknownUnionTag),
2197            };
2198
2199            if inlined != (member_inline_size <= 4) {
2200                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2201            }
2202            let _inner_offset;
2203            if inlined {
2204                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2205                _inner_offset = offset + 8;
2206            } else {
2207                depth.increment()?;
2208                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2209            }
2210            match ordinal {
2211                1 => {
2212                    #[allow(irrefutable_let_patterns)]
2213                    if let BoundInterfaceId::All(_) = self {
2214                        // Do nothing, read the value into the object
2215                    } else {
2216                        // Initialize `self` to the right variant
2217                        *self = BoundInterfaceId::All(fidl::new_empty!(Empty, D));
2218                    }
2219                    #[allow(irrefutable_let_patterns)]
2220                    if let BoundInterfaceId::All(ref mut val) = self {
2221                        fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
2222                    } else {
2223                        unreachable!()
2224                    }
2225                }
2226                2 => {
2227                    #[allow(irrefutable_let_patterns)]
2228                    if let BoundInterfaceId::Specified(_) = self {
2229                        // Do nothing, read the value into the object
2230                    } else {
2231                        // Initialize `self` to the right variant
2232                        *self = BoundInterfaceId::Specified(fidl::new_empty!(u64, D));
2233                    }
2234                    #[allow(irrefutable_let_patterns)]
2235                    if let BoundInterfaceId::Specified(ref mut val) = self {
2236                        fidl::decode!(u64, D, val, decoder, _inner_offset, depth)?;
2237                    } else {
2238                        unreachable!()
2239                    }
2240                }
2241                ordinal => panic!("unexpected ordinal {:?}", ordinal),
2242            }
2243            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2244                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2245            }
2246            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2247                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2248            }
2249            Ok(())
2250        }
2251    }
2252
2253    impl fidl::encoding::ValueTypeMarker for HardwareAddress {
2254        type Borrowed<'a> = &'a Self;
2255        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2256            value
2257        }
2258    }
2259
2260    unsafe impl fidl::encoding::TypeMarker for HardwareAddress {
2261        type Owned = Self;
2262
2263        #[inline(always)]
2264        fn inline_align(_context: fidl::encoding::Context) -> usize {
2265            8
2266        }
2267
2268        #[inline(always)]
2269        fn inline_size(_context: fidl::encoding::Context) -> usize {
2270            16
2271        }
2272    }
2273
2274    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<HardwareAddress, D>
2275        for &HardwareAddress
2276    {
2277        #[inline]
2278        unsafe fn encode(
2279            self,
2280            encoder: &mut fidl::encoding::Encoder<'_, D>,
2281            offset: usize,
2282            _depth: fidl::encoding::Depth,
2283        ) -> fidl::Result<()> {
2284            encoder.debug_check_bounds::<HardwareAddress>(offset);
2285            encoder.write_num::<u64>(self.ordinal(), offset);
2286            match self {
2287                HardwareAddress::None(ref val) => fidl::encoding::encode_in_envelope::<Empty, D>(
2288                    <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
2289                    encoder,
2290                    offset + 8,
2291                    _depth,
2292                ),
2293                HardwareAddress::Eui48(ref val) => fidl::encoding::encode_in_envelope::<
2294                    fidl_fuchsia_net::MacAddress,
2295                    D,
2296                >(
2297                    <fidl_fuchsia_net::MacAddress as fidl::encoding::ValueTypeMarker>::borrow(val),
2298                    encoder,
2299                    offset + 8,
2300                    _depth,
2301                ),
2302                HardwareAddress::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2303            }
2304        }
2305    }
2306
2307    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for HardwareAddress {
2308        #[inline(always)]
2309        fn new_empty() -> Self {
2310            Self::__SourceBreaking { unknown_ordinal: 0 }
2311        }
2312
2313        #[inline]
2314        unsafe fn decode(
2315            &mut self,
2316            decoder: &mut fidl::encoding::Decoder<'_, D>,
2317            offset: usize,
2318            mut depth: fidl::encoding::Depth,
2319        ) -> fidl::Result<()> {
2320            decoder.debug_check_bounds::<Self>(offset);
2321            #[allow(unused_variables)]
2322            let next_out_of_line = decoder.next_out_of_line();
2323            let handles_before = decoder.remaining_handles();
2324            let (ordinal, inlined, num_bytes, num_handles) =
2325                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2326
2327            let member_inline_size = match ordinal {
2328                1 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2329                2 => <fidl_fuchsia_net::MacAddress as fidl::encoding::TypeMarker>::inline_size(
2330                    decoder.context,
2331                ),
2332                0 => return Err(fidl::Error::UnknownUnionTag),
2333                _ => num_bytes as usize,
2334            };
2335
2336            if inlined != (member_inline_size <= 4) {
2337                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2338            }
2339            let _inner_offset;
2340            if inlined {
2341                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2342                _inner_offset = offset + 8;
2343            } else {
2344                depth.increment()?;
2345                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2346            }
2347            match ordinal {
2348                1 => {
2349                    #[allow(irrefutable_let_patterns)]
2350                    if let HardwareAddress::None(_) = self {
2351                        // Do nothing, read the value into the object
2352                    } else {
2353                        // Initialize `self` to the right variant
2354                        *self = HardwareAddress::None(fidl::new_empty!(Empty, D));
2355                    }
2356                    #[allow(irrefutable_let_patterns)]
2357                    if let HardwareAddress::None(ref mut val) = self {
2358                        fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
2359                    } else {
2360                        unreachable!()
2361                    }
2362                }
2363                2 => {
2364                    #[allow(irrefutable_let_patterns)]
2365                    if let HardwareAddress::Eui48(_) = self {
2366                        // Do nothing, read the value into the object
2367                    } else {
2368                        // Initialize `self` to the right variant
2369                        *self = HardwareAddress::Eui48(fidl::new_empty!(
2370                            fidl_fuchsia_net::MacAddress,
2371                            D
2372                        ));
2373                    }
2374                    #[allow(irrefutable_let_patterns)]
2375                    if let HardwareAddress::Eui48(ref mut val) = self {
2376                        fidl::decode!(
2377                            fidl_fuchsia_net::MacAddress,
2378                            D,
2379                            val,
2380                            decoder,
2381                            _inner_offset,
2382                            depth
2383                        )?;
2384                    } else {
2385                        unreachable!()
2386                    }
2387                }
2388                #[allow(deprecated)]
2389                ordinal => {
2390                    for _ in 0..num_handles {
2391                        decoder.drop_next_handle()?;
2392                    }
2393                    *self = HardwareAddress::__SourceBreaking { unknown_ordinal: ordinal };
2394                }
2395            }
2396            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2397                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2398            }
2399            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2400                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2401            }
2402            Ok(())
2403        }
2404    }
2405
2406    impl fidl::encoding::ValueTypeMarker for ProtocolAssociation {
2407        type Borrowed<'a> = &'a Self;
2408        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2409            value
2410        }
2411    }
2412
2413    unsafe impl fidl::encoding::TypeMarker for ProtocolAssociation {
2414        type Owned = Self;
2415
2416        #[inline(always)]
2417        fn inline_align(_context: fidl::encoding::Context) -> usize {
2418            8
2419        }
2420
2421        #[inline(always)]
2422        fn inline_size(_context: fidl::encoding::Context) -> usize {
2423            16
2424        }
2425    }
2426
2427    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ProtocolAssociation, D>
2428        for &ProtocolAssociation
2429    {
2430        #[inline]
2431        unsafe fn encode(
2432            self,
2433            encoder: &mut fidl::encoding::Encoder<'_, D>,
2434            offset: usize,
2435            _depth: fidl::encoding::Depth,
2436        ) -> fidl::Result<()> {
2437            encoder.debug_check_bounds::<ProtocolAssociation>(offset);
2438            encoder.write_num::<u64>(self.ordinal(), offset);
2439            match self {
2440                ProtocolAssociation::All(ref val) => {
2441                    fidl::encoding::encode_in_envelope::<Empty, D>(
2442                        <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
2443                        encoder,
2444                        offset + 8,
2445                        _depth,
2446                    )
2447                }
2448                ProtocolAssociation::Specified(ref val) => {
2449                    fidl::encoding::encode_in_envelope::<u16, D>(
2450                        <u16 as fidl::encoding::ValueTypeMarker>::borrow(val),
2451                        encoder,
2452                        offset + 8,
2453                        _depth,
2454                    )
2455                }
2456            }
2457        }
2458    }
2459
2460    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ProtocolAssociation {
2461        #[inline(always)]
2462        fn new_empty() -> Self {
2463            Self::All(fidl::new_empty!(Empty, D))
2464        }
2465
2466        #[inline]
2467        unsafe fn decode(
2468            &mut self,
2469            decoder: &mut fidl::encoding::Decoder<'_, D>,
2470            offset: usize,
2471            mut depth: fidl::encoding::Depth,
2472        ) -> fidl::Result<()> {
2473            decoder.debug_check_bounds::<Self>(offset);
2474            #[allow(unused_variables)]
2475            let next_out_of_line = decoder.next_out_of_line();
2476            let handles_before = decoder.remaining_handles();
2477            let (ordinal, inlined, num_bytes, num_handles) =
2478                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2479
2480            let member_inline_size = match ordinal {
2481                1 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2482                2 => <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2483                _ => return Err(fidl::Error::UnknownUnionTag),
2484            };
2485
2486            if inlined != (member_inline_size <= 4) {
2487                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2488            }
2489            let _inner_offset;
2490            if inlined {
2491                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2492                _inner_offset = offset + 8;
2493            } else {
2494                depth.increment()?;
2495                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2496            }
2497            match ordinal {
2498                1 => {
2499                    #[allow(irrefutable_let_patterns)]
2500                    if let ProtocolAssociation::All(_) = self {
2501                        // Do nothing, read the value into the object
2502                    } else {
2503                        // Initialize `self` to the right variant
2504                        *self = ProtocolAssociation::All(fidl::new_empty!(Empty, D));
2505                    }
2506                    #[allow(irrefutable_let_patterns)]
2507                    if let ProtocolAssociation::All(ref mut val) = self {
2508                        fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
2509                    } else {
2510                        unreachable!()
2511                    }
2512                }
2513                2 => {
2514                    #[allow(irrefutable_let_patterns)]
2515                    if let ProtocolAssociation::Specified(_) = self {
2516                        // Do nothing, read the value into the object
2517                    } else {
2518                        // Initialize `self` to the right variant
2519                        *self = ProtocolAssociation::Specified(fidl::new_empty!(u16, D));
2520                    }
2521                    #[allow(irrefutable_let_patterns)]
2522                    if let ProtocolAssociation::Specified(ref mut val) = self {
2523                        fidl::decode!(u16, D, val, decoder, _inner_offset, depth)?;
2524                    } else {
2525                        unreachable!()
2526                    }
2527                }
2528                ordinal => panic!("unexpected ordinal {:?}", ordinal),
2529            }
2530            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2531                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2532            }
2533            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2534                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2535            }
2536            Ok(())
2537        }
2538    }
2539}