fidl_fuchsia_net_matchers__common/
fidl_fuchsia_net_matchers__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
11bitflags! {
12    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
13    pub struct TcpState: u32 {
14        const ESTABLISHED = 1;
15        const SYN_SENT = 2;
16        const SYN_RECV = 4;
17        const FIN_WAIT1 = 8;
18        const FIN_WAIT2 = 16;
19        const TIME_WAIT = 32;
20        const CLOSE = 64;
21        const CLOSE_WAIT = 128;
22        const LAST_ACK = 256;
23        const LISTEN = 512;
24        const CLOSING = 1024;
25    }
26}
27
28impl TcpState {}
29
30bitflags! {
31    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
32    pub struct UdpState: u32 {
33        /// The UDP socket is bound but not connected.
34        const BOUND = 1;
35        /// The UDP socket is explicitly connected.
36        const CONNECTED = 2;
37    }
38}
39
40impl UdpState {}
41
42/// A matcher for IP addresses.
43#[derive(Clone, Debug, PartialEq)]
44pub struct Address {
45    pub matcher: AddressMatcherType,
46    /// Whether to check for an "inverse" or "negative" match (in which case,
47    /// if the matcher criteria do *not* apply, it *is* considered a match, and
48    /// vice versa).
49    pub invert: bool,
50}
51
52impl fidl::Persistable for Address {}
53
54#[derive(Clone, Debug, PartialEq)]
55pub struct AddressRange {
56    /// The inclusive start of the address range.
57    pub start: fidl_fuchsia_net__common::IpAddress,
58    /// The inclusive end of the address range.
59    pub end: fidl_fuchsia_net__common::IpAddress,
60}
61
62impl fidl::Persistable for AddressRange {}
63
64#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
65#[repr(C)]
66pub struct Between {
67    /// Start of the range, inclusive.
68    pub start: u32,
69    /// End of the range, inclusive.
70    pub end: u32,
71}
72
73impl fidl::Persistable for Between {}
74
75/// An empty type for use in unions.
76#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
77pub struct Empty;
78
79impl fidl::Persistable for Empty {}
80
81/// Matches the mark in a specific domain.
82#[derive(Clone, Debug, PartialEq)]
83pub struct MarkInDomain {
84    /// The mark's domain.
85    pub domain: fidl_fuchsia_net__common::MarkDomain,
86    /// The mark matcher to apply to the mark in the specified domain.
87    pub mark: Mark,
88}
89
90impl fidl::Persistable for MarkInDomain {}
91
92#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
93pub struct Marked {
94    /// Mask to apply before comparing to the range in `between`.
95    pub mask: u32,
96    /// The mark is between the given range.
97    pub between: Between,
98    /// Whether to check for an "inverse" or "negative" match.
99    ///
100    /// The mask is applied as normal, but the value is checked for
101    /// inequality.
102    pub invert: bool,
103}
104
105impl fidl::Persistable for Marked {}
106
107/// A matcher for transport-layer port numbers.
108///
109/// `start` must <= `end`.
110#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
111pub struct Port {
112    /// The inclusive start of the port range.
113    pub start: u16,
114    /// The inclusive end of the port range.
115    pub end: u16,
116    /// Whether to check for an "inverse" or "negative" match.
117    pub invert: bool,
118}
119
120impl fidl::Persistable for Port {}
121
122/// A matcher for a socket's cookie.
123#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
124pub struct SocketCookie {
125    /// The cookie value to compare for equality.
126    pub cookie: u64,
127    /// Whether to check for an "inverse" or "negative" match.
128    pub invert: bool,
129}
130
131impl fidl::Persistable for SocketCookie {}
132
133#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
134pub struct Unbound;
135
136impl fidl::Persistable for Unbound {}
137
138#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
139pub struct Unmarked;
140
141impl fidl::Persistable for Unmarked {}
142
143/// A matcher for ICMPv4 packets.
144#[derive(Clone, Debug, Default, PartialEq)]
145pub struct IcmpPacket {
146    #[doc(hidden)]
147    pub __source_breaking: fidl::marker::SourceBreaking,
148}
149
150impl fidl::Persistable for IcmpPacket {}
151
152/// A matcher for ICMPv6 packets.
153#[derive(Clone, Debug, Default, PartialEq)]
154pub struct Icmpv6Packet {
155    #[doc(hidden)]
156    pub __source_breaking: fidl::marker::SourceBreaking,
157}
158
159impl fidl::Persistable for Icmpv6Packet {}
160
161/// A matcher for TCP packets.
162#[derive(Clone, Debug, Default, PartialEq)]
163pub struct TcpPacket {
164    /// Matcher for the TCP source port.
165    pub src_port: Option<Port>,
166    /// Matcher for the TCP destination port.
167    pub dst_port: Option<Port>,
168    #[doc(hidden)]
169    pub __source_breaking: fidl::marker::SourceBreaking,
170}
171
172impl fidl::Persistable for TcpPacket {}
173
174/// A matcher for UDP packets.
175#[derive(Clone, Debug, Default, PartialEq)]
176pub struct UdpPacket {
177    /// Matcher for the UDP source port.
178    pub src_port: Option<Port>,
179    /// Matcher for the UDP destination port.
180    pub dst_port: Option<Port>,
181    #[doc(hidden)]
182    pub __source_breaking: fidl::marker::SourceBreaking,
183}
184
185impl fidl::Persistable for UdpPacket {}
186
187#[derive(Clone, Debug)]
188pub enum AddressMatcherType {
189    /// The subnet that must contain the IP address in the packet header in
190    /// order for it to match.
191    Subnet(fidl_fuchsia_net__common::Subnet),
192    /// The range of addresses that must include the IP address in the
193    /// packet header in order for it to match.
194    ///
195    /// The endpoints of the range must be in the same address family, and
196    /// `start` must <= `end`. (Comparisons are performed on the numerical
197    /// big-endian representation of the IP address.)
198    Range(AddressRange),
199    #[doc(hidden)]
200    __SourceBreaking { unknown_ordinal: u64 },
201}
202
203/// Pattern that matches an unknown `AddressMatcherType` member.
204#[macro_export]
205macro_rules! AddressMatcherTypeUnknown {
206    () => {
207        _
208    };
209}
210
211// Custom PartialEq so that unknown variants are not equal to themselves.
212impl PartialEq for AddressMatcherType {
213    fn eq(&self, other: &Self) -> bool {
214        match (self, other) {
215            (Self::Subnet(x), Self::Subnet(y)) => *x == *y,
216            (Self::Range(x), Self::Range(y)) => *x == *y,
217            _ => false,
218        }
219    }
220}
221
222impl AddressMatcherType {
223    #[inline]
224    pub fn ordinal(&self) -> u64 {
225        match *self {
226            Self::Subnet(_) => 1,
227            Self::Range(_) => 2,
228            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
229        }
230    }
231
232    #[inline]
233    pub fn unknown_variant_for_testing() -> Self {
234        Self::__SourceBreaking { unknown_ordinal: 0 }
235    }
236
237    #[inline]
238    pub fn is_unknown(&self) -> bool {
239        match self {
240            Self::__SourceBreaking { .. } => true,
241            _ => false,
242        }
243    }
244}
245
246impl fidl::Persistable for AddressMatcherType {}
247
248/// A matcher for network interfaces where it might be unbound (`BindToDevice`
249/// has not been called).
250#[derive(Clone, Debug)]
251pub enum BoundInterface {
252    /// Matches iff the socket is bound to a matching interface (see
253    /// [`Interface`] for matching criteria).
254    Bound(Interface),
255    /// Matches iff the outgoing traffic is not bound to a device.
256    Unbound(Unbound),
257    #[doc(hidden)]
258    __SourceBreaking { unknown_ordinal: u64 },
259}
260
261/// Pattern that matches an unknown `BoundInterface` member.
262#[macro_export]
263macro_rules! BoundInterfaceUnknown {
264    () => {
265        _
266    };
267}
268
269// Custom PartialEq so that unknown variants are not equal to themselves.
270impl PartialEq for BoundInterface {
271    fn eq(&self, other: &Self) -> bool {
272        match (self, other) {
273            (Self::Bound(x), Self::Bound(y)) => *x == *y,
274            (Self::Unbound(x), Self::Unbound(y)) => *x == *y,
275            _ => false,
276        }
277    }
278}
279
280impl BoundInterface {
281    #[inline]
282    pub fn ordinal(&self) -> u64 {
283        match *self {
284            Self::Bound(_) => 1,
285            Self::Unbound(_) => 2,
286            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
287        }
288    }
289
290    #[inline]
291    pub fn unknown_variant_for_testing() -> Self {
292        Self::__SourceBreaking { unknown_ordinal: 0 }
293    }
294
295    #[inline]
296    pub fn is_unknown(&self) -> bool {
297        match self {
298            Self::__SourceBreaking { .. } => true,
299            _ => false,
300        }
301    }
302}
303
304impl fidl::Persistable for BoundInterface {}
305
306/// A matcher for network interfaces.
307#[derive(Clone, Debug)]
308pub enum Interface {
309    /// The ID of the interface as assigned by the netstack.
310    Id(u64),
311    /// The name of the interface.
312    Name(String),
313    /// The port class of the interface.
314    PortClass(fidl_fuchsia_net_interfaces__common::PortClass),
315    #[doc(hidden)]
316    __SourceBreaking { unknown_ordinal: u64 },
317}
318
319/// Pattern that matches an unknown `Interface` member.
320#[macro_export]
321macro_rules! InterfaceUnknown {
322    () => {
323        _
324    };
325}
326
327// Custom PartialEq so that unknown variants are not equal to themselves.
328impl PartialEq for Interface {
329    fn eq(&self, other: &Self) -> bool {
330        match (self, other) {
331            (Self::Id(x), Self::Id(y)) => *x == *y,
332            (Self::Name(x), Self::Name(y)) => *x == *y,
333            (Self::PortClass(x), Self::PortClass(y)) => *x == *y,
334            _ => false,
335        }
336    }
337}
338
339impl Interface {
340    #[inline]
341    pub fn ordinal(&self) -> u64 {
342        match *self {
343            Self::Id(_) => 1,
344            Self::Name(_) => 2,
345            Self::PortClass(_) => 3,
346            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
347        }
348    }
349
350    #[inline]
351    pub fn unknown_variant_for_testing() -> Self {
352        Self::__SourceBreaking { unknown_ordinal: 0 }
353    }
354
355    #[inline]
356    pub fn is_unknown(&self) -> bool {
357        match self {
358            Self::__SourceBreaking { .. } => true,
359            _ => false,
360        }
361    }
362}
363
364impl fidl::Persistable for Interface {}
365
366/// Matches the mark value of a packet or socket.
367#[derive(Clone, Debug)]
368pub enum Mark {
369    /// This mark domain does not have a mark.
370    Unmarked(Unmarked),
371    Marked(Marked),
372    #[doc(hidden)]
373    __SourceBreaking {
374        unknown_ordinal: u64,
375    },
376}
377
378/// Pattern that matches an unknown `Mark` member.
379#[macro_export]
380macro_rules! MarkUnknown {
381    () => {
382        _
383    };
384}
385
386// Custom PartialEq so that unknown variants are not equal to themselves.
387impl PartialEq for Mark {
388    fn eq(&self, other: &Self) -> bool {
389        match (self, other) {
390            (Self::Unmarked(x), Self::Unmarked(y)) => *x == *y,
391            (Self::Marked(x), Self::Marked(y)) => *x == *y,
392            _ => false,
393        }
394    }
395}
396
397impl Mark {
398    #[inline]
399    pub fn ordinal(&self) -> u64 {
400        match *self {
401            Self::Unmarked(_) => 1,
402            Self::Marked(_) => 2,
403            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
404        }
405    }
406
407    #[inline]
408    pub fn unknown_variant_for_testing() -> Self {
409        Self::__SourceBreaking { unknown_ordinal: 0 }
410    }
411
412    #[inline]
413    pub fn is_unknown(&self) -> bool {
414        match self {
415            Self::__SourceBreaking { .. } => true,
416            _ => false,
417        }
418    }
419}
420
421impl fidl::Persistable for Mark {}
422
423/// A matcher for transport-layer information in packets.
424#[derive(Clone, Debug)]
425pub enum PacketTransportProtocol {
426    Tcp(TcpPacket),
427    Udp(UdpPacket),
428    Icmp(IcmpPacket),
429    Icmpv6(Icmpv6Packet),
430    #[doc(hidden)]
431    __SourceBreaking {
432        unknown_ordinal: u64,
433    },
434}
435
436/// Pattern that matches an unknown `PacketTransportProtocol` member.
437#[macro_export]
438macro_rules! PacketTransportProtocolUnknown {
439    () => {
440        _
441    };
442}
443
444// Custom PartialEq so that unknown variants are not equal to themselves.
445impl PartialEq for PacketTransportProtocol {
446    fn eq(&self, other: &Self) -> bool {
447        match (self, other) {
448            (Self::Tcp(x), Self::Tcp(y)) => *x == *y,
449            (Self::Udp(x), Self::Udp(y)) => *x == *y,
450            (Self::Icmp(x), Self::Icmp(y)) => *x == *y,
451            (Self::Icmpv6(x), Self::Icmpv6(y)) => *x == *y,
452            _ => false,
453        }
454    }
455}
456
457impl PacketTransportProtocol {
458    #[inline]
459    pub fn ordinal(&self) -> u64 {
460        match *self {
461            Self::Tcp(_) => 1,
462            Self::Udp(_) => 2,
463            Self::Icmp(_) => 3,
464            Self::Icmpv6(_) => 4,
465            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
466        }
467    }
468
469    #[inline]
470    pub fn unknown_variant_for_testing() -> Self {
471        Self::__SourceBreaking { unknown_ordinal: 0 }
472    }
473
474    #[inline]
475    pub fn is_unknown(&self) -> bool {
476        match self {
477            Self::__SourceBreaking { .. } => true,
478            _ => false,
479        }
480    }
481}
482
483impl fidl::Persistable for PacketTransportProtocol {}
484
485/// A matcher for transport-layer fields of a socket.
486#[derive(Clone, Debug)]
487pub enum SocketTransportProtocol {
488    /// Matches against TCP fields.
489    Tcp(TcpSocket),
490    /// Matches against UDP fields.
491    Udp(UdpSocket),
492    #[doc(hidden)]
493    __SourceBreaking { unknown_ordinal: u64 },
494}
495
496/// Pattern that matches an unknown `SocketTransportProtocol` member.
497#[macro_export]
498macro_rules! SocketTransportProtocolUnknown {
499    () => {
500        _
501    };
502}
503
504// Custom PartialEq so that unknown variants are not equal to themselves.
505impl PartialEq for SocketTransportProtocol {
506    fn eq(&self, other: &Self) -> bool {
507        match (self, other) {
508            (Self::Tcp(x), Self::Tcp(y)) => *x == *y,
509            (Self::Udp(x), Self::Udp(y)) => *x == *y,
510            _ => false,
511        }
512    }
513}
514
515impl SocketTransportProtocol {
516    #[inline]
517    pub fn ordinal(&self) -> u64 {
518        match *self {
519            Self::Tcp(_) => 1,
520            Self::Udp(_) => 2,
521            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
522        }
523    }
524
525    #[inline]
526    pub fn unknown_variant_for_testing() -> Self {
527        Self::__SourceBreaking { unknown_ordinal: 0 }
528    }
529
530    #[inline]
531    pub fn is_unknown(&self) -> bool {
532        match self {
533            Self::__SourceBreaking { .. } => true,
534            _ => false,
535        }
536    }
537}
538
539impl fidl::Persistable for SocketTransportProtocol {}
540
541/// A matcher for TCP sockets.
542#[derive(Clone, Debug)]
543pub enum TcpSocket {
544    /// Only matches against the transport protocol and nothing else.
545    Empty(Empty),
546    /// Match against the source port of TCP sockets.
547    SrcPort(Port),
548    /// Match against the destination port of TCP sockets.
549    DstPort(Port),
550    /// The TCP socket's state must be contained in the set of states. If unset,
551    /// matches all states, just as if it was fully set.
552    ///
553    /// The constants are structured to correspond to the enum values of
554    /// fuchsia.net.tcp.States.
555    States(TcpState),
556    #[doc(hidden)]
557    __SourceBreaking { unknown_ordinal: u64 },
558}
559
560/// Pattern that matches an unknown `TcpSocket` member.
561#[macro_export]
562macro_rules! TcpSocketUnknown {
563    () => {
564        _
565    };
566}
567
568// Custom PartialEq so that unknown variants are not equal to themselves.
569impl PartialEq for TcpSocket {
570    fn eq(&self, other: &Self) -> bool {
571        match (self, other) {
572            (Self::Empty(x), Self::Empty(y)) => *x == *y,
573            (Self::SrcPort(x), Self::SrcPort(y)) => *x == *y,
574            (Self::DstPort(x), Self::DstPort(y)) => *x == *y,
575            (Self::States(x), Self::States(y)) => *x == *y,
576            _ => false,
577        }
578    }
579}
580
581impl TcpSocket {
582    #[inline]
583    pub fn ordinal(&self) -> u64 {
584        match *self {
585            Self::Empty(_) => 1,
586            Self::SrcPort(_) => 2,
587            Self::DstPort(_) => 3,
588            Self::States(_) => 4,
589            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
590        }
591    }
592
593    #[inline]
594    pub fn unknown_variant_for_testing() -> Self {
595        Self::__SourceBreaking { unknown_ordinal: 0 }
596    }
597
598    #[inline]
599    pub fn is_unknown(&self) -> bool {
600        match self {
601            Self::__SourceBreaking { .. } => true,
602            _ => false,
603        }
604    }
605}
606
607impl fidl::Persistable for TcpSocket {}
608
609/// A matcher for UDP sockets.
610#[derive(Clone, Debug)]
611pub enum UdpSocket {
612    /// Only matches against the transport protocol and nothing else.
613    Empty(Empty),
614    /// Match against the source port of UDP sockets.
615    SrcPort(Port),
616    /// Match against the destination port of UDP sockets.
617    DstPort(Port),
618    /// The UDP socket's state must be contained in the set of states.
619    ///
620    /// If unset, matches all states, just as if it was fully set.
621    States(UdpState),
622    #[doc(hidden)]
623    __SourceBreaking { unknown_ordinal: u64 },
624}
625
626/// Pattern that matches an unknown `UdpSocket` member.
627#[macro_export]
628macro_rules! UdpSocketUnknown {
629    () => {
630        _
631    };
632}
633
634// Custom PartialEq so that unknown variants are not equal to themselves.
635impl PartialEq for UdpSocket {
636    fn eq(&self, other: &Self) -> bool {
637        match (self, other) {
638            (Self::Empty(x), Self::Empty(y)) => *x == *y,
639            (Self::SrcPort(x), Self::SrcPort(y)) => *x == *y,
640            (Self::DstPort(x), Self::DstPort(y)) => *x == *y,
641            (Self::States(x), Self::States(y)) => *x == *y,
642            _ => false,
643        }
644    }
645}
646
647impl UdpSocket {
648    #[inline]
649    pub fn ordinal(&self) -> u64 {
650        match *self {
651            Self::Empty(_) => 1,
652            Self::SrcPort(_) => 2,
653            Self::DstPort(_) => 3,
654            Self::States(_) => 4,
655            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
656        }
657    }
658
659    #[inline]
660    pub fn unknown_variant_for_testing() -> Self {
661        Self::__SourceBreaking { unknown_ordinal: 0 }
662    }
663
664    #[inline]
665    pub fn is_unknown(&self) -> bool {
666        match self {
667            Self::__SourceBreaking { .. } => true,
668            _ => false,
669        }
670    }
671}
672
673impl fidl::Persistable for UdpSocket {}
674
675mod internal {
676    use super::*;
677    unsafe impl fidl::encoding::TypeMarker for TcpState {
678        type Owned = Self;
679
680        #[inline(always)]
681        fn inline_align(_context: fidl::encoding::Context) -> usize {
682            4
683        }
684
685        #[inline(always)]
686        fn inline_size(_context: fidl::encoding::Context) -> usize {
687            4
688        }
689    }
690
691    impl fidl::encoding::ValueTypeMarker for TcpState {
692        type Borrowed<'a> = Self;
693        #[inline(always)]
694        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
695            *value
696        }
697    }
698
699    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for TcpState {
700        #[inline]
701        unsafe fn encode(
702            self,
703            encoder: &mut fidl::encoding::Encoder<'_, D>,
704            offset: usize,
705            _depth: fidl::encoding::Depth,
706        ) -> fidl::Result<()> {
707            encoder.debug_check_bounds::<Self>(offset);
708            if self.bits() & Self::all().bits() != self.bits() {
709                return Err(fidl::Error::InvalidBitsValue);
710            }
711            encoder.write_num(self.bits(), offset);
712            Ok(())
713        }
714    }
715
716    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TcpState {
717        #[inline(always)]
718        fn new_empty() -> Self {
719            Self::empty()
720        }
721
722        #[inline]
723        unsafe fn decode(
724            &mut self,
725            decoder: &mut fidl::encoding::Decoder<'_, D>,
726            offset: usize,
727            _depth: fidl::encoding::Depth,
728        ) -> fidl::Result<()> {
729            decoder.debug_check_bounds::<Self>(offset);
730            let prim = decoder.read_num::<u32>(offset);
731            *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
732            Ok(())
733        }
734    }
735    unsafe impl fidl::encoding::TypeMarker for UdpState {
736        type Owned = Self;
737
738        #[inline(always)]
739        fn inline_align(_context: fidl::encoding::Context) -> usize {
740            4
741        }
742
743        #[inline(always)]
744        fn inline_size(_context: fidl::encoding::Context) -> usize {
745            4
746        }
747    }
748
749    impl fidl::encoding::ValueTypeMarker for UdpState {
750        type Borrowed<'a> = Self;
751        #[inline(always)]
752        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
753            *value
754        }
755    }
756
757    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for UdpState {
758        #[inline]
759        unsafe fn encode(
760            self,
761            encoder: &mut fidl::encoding::Encoder<'_, D>,
762            offset: usize,
763            _depth: fidl::encoding::Depth,
764        ) -> fidl::Result<()> {
765            encoder.debug_check_bounds::<Self>(offset);
766            if self.bits() & Self::all().bits() != self.bits() {
767                return Err(fidl::Error::InvalidBitsValue);
768            }
769            encoder.write_num(self.bits(), offset);
770            Ok(())
771        }
772    }
773
774    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UdpState {
775        #[inline(always)]
776        fn new_empty() -> Self {
777            Self::empty()
778        }
779
780        #[inline]
781        unsafe fn decode(
782            &mut self,
783            decoder: &mut fidl::encoding::Decoder<'_, D>,
784            offset: usize,
785            _depth: fidl::encoding::Depth,
786        ) -> fidl::Result<()> {
787            decoder.debug_check_bounds::<Self>(offset);
788            let prim = decoder.read_num::<u32>(offset);
789            *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
790            Ok(())
791        }
792    }
793
794    impl fidl::encoding::ValueTypeMarker for Address {
795        type Borrowed<'a> = &'a Self;
796        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
797            value
798        }
799    }
800
801    unsafe impl fidl::encoding::TypeMarker for Address {
802        type Owned = Self;
803
804        #[inline(always)]
805        fn inline_align(_context: fidl::encoding::Context) -> usize {
806            8
807        }
808
809        #[inline(always)]
810        fn inline_size(_context: fidl::encoding::Context) -> usize {
811            24
812        }
813    }
814
815    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Address, D> for &Address {
816        #[inline]
817        unsafe fn encode(
818            self,
819            encoder: &mut fidl::encoding::Encoder<'_, D>,
820            offset: usize,
821            _depth: fidl::encoding::Depth,
822        ) -> fidl::Result<()> {
823            encoder.debug_check_bounds::<Address>(offset);
824            // Delegate to tuple encoding.
825            fidl::encoding::Encode::<Address, D>::encode(
826                (
827                    <AddressMatcherType as fidl::encoding::ValueTypeMarker>::borrow(&self.matcher),
828                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.invert),
829                ),
830                encoder,
831                offset,
832                _depth,
833            )
834        }
835    }
836    unsafe impl<
837        D: fidl::encoding::ResourceDialect,
838        T0: fidl::encoding::Encode<AddressMatcherType, D>,
839        T1: fidl::encoding::Encode<bool, D>,
840    > fidl::encoding::Encode<Address, D> for (T0, T1)
841    {
842        #[inline]
843        unsafe fn encode(
844            self,
845            encoder: &mut fidl::encoding::Encoder<'_, D>,
846            offset: usize,
847            depth: fidl::encoding::Depth,
848        ) -> fidl::Result<()> {
849            encoder.debug_check_bounds::<Address>(offset);
850            // Zero out padding regions. There's no need to apply masks
851            // because the unmasked parts will be overwritten by fields.
852            unsafe {
853                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
854                (ptr as *mut u64).write_unaligned(0);
855            }
856            // Write the fields.
857            self.0.encode(encoder, offset + 0, depth)?;
858            self.1.encode(encoder, offset + 16, depth)?;
859            Ok(())
860        }
861    }
862
863    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Address {
864        #[inline(always)]
865        fn new_empty() -> Self {
866            Self {
867                matcher: fidl::new_empty!(AddressMatcherType, D),
868                invert: fidl::new_empty!(bool, D),
869            }
870        }
871
872        #[inline]
873        unsafe fn decode(
874            &mut self,
875            decoder: &mut fidl::encoding::Decoder<'_, D>,
876            offset: usize,
877            _depth: fidl::encoding::Depth,
878        ) -> fidl::Result<()> {
879            decoder.debug_check_bounds::<Self>(offset);
880            // Verify that padding bytes are zero.
881            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
882            let padval = unsafe { (ptr as *const u64).read_unaligned() };
883            let mask = 0xffffffffffffff00u64;
884            let maskedval = padval & mask;
885            if maskedval != 0 {
886                return Err(fidl::Error::NonZeroPadding {
887                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
888                });
889            }
890            fidl::decode!(AddressMatcherType, D, &mut self.matcher, decoder, offset + 0, _depth)?;
891            fidl::decode!(bool, D, &mut self.invert, decoder, offset + 16, _depth)?;
892            Ok(())
893        }
894    }
895
896    impl fidl::encoding::ValueTypeMarker for AddressRange {
897        type Borrowed<'a> = &'a Self;
898        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
899            value
900        }
901    }
902
903    unsafe impl fidl::encoding::TypeMarker for AddressRange {
904        type Owned = Self;
905
906        #[inline(always)]
907        fn inline_align(_context: fidl::encoding::Context) -> usize {
908            8
909        }
910
911        #[inline(always)]
912        fn inline_size(_context: fidl::encoding::Context) -> usize {
913            32
914        }
915    }
916
917    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<AddressRange, D>
918        for &AddressRange
919    {
920        #[inline]
921        unsafe fn encode(
922            self,
923            encoder: &mut fidl::encoding::Encoder<'_, D>,
924            offset: usize,
925            _depth: fidl::encoding::Depth,
926        ) -> fidl::Result<()> {
927            encoder.debug_check_bounds::<AddressRange>(offset);
928            // Delegate to tuple encoding.
929            fidl::encoding::Encode::<AddressRange, D>::encode(
930                (
931                    <fidl_fuchsia_net__common::IpAddress as fidl::encoding::ValueTypeMarker>::borrow(&self.start),
932                    <fidl_fuchsia_net__common::IpAddress as fidl::encoding::ValueTypeMarker>::borrow(&self.end),
933                ),
934                encoder, offset, _depth
935            )
936        }
937    }
938    unsafe impl<
939        D: fidl::encoding::ResourceDialect,
940        T0: fidl::encoding::Encode<fidl_fuchsia_net__common::IpAddress, D>,
941        T1: fidl::encoding::Encode<fidl_fuchsia_net__common::IpAddress, D>,
942    > fidl::encoding::Encode<AddressRange, D> for (T0, T1)
943    {
944        #[inline]
945        unsafe fn encode(
946            self,
947            encoder: &mut fidl::encoding::Encoder<'_, D>,
948            offset: usize,
949            depth: fidl::encoding::Depth,
950        ) -> fidl::Result<()> {
951            encoder.debug_check_bounds::<AddressRange>(offset);
952            // Zero out padding regions. There's no need to apply masks
953            // because the unmasked parts will be overwritten by fields.
954            // Write the fields.
955            self.0.encode(encoder, offset + 0, depth)?;
956            self.1.encode(encoder, offset + 16, depth)?;
957            Ok(())
958        }
959    }
960
961    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for AddressRange {
962        #[inline(always)]
963        fn new_empty() -> Self {
964            Self {
965                start: fidl::new_empty!(fidl_fuchsia_net__common::IpAddress, D),
966                end: fidl::new_empty!(fidl_fuchsia_net__common::IpAddress, D),
967            }
968        }
969
970        #[inline]
971        unsafe fn decode(
972            &mut self,
973            decoder: &mut fidl::encoding::Decoder<'_, D>,
974            offset: usize,
975            _depth: fidl::encoding::Depth,
976        ) -> fidl::Result<()> {
977            decoder.debug_check_bounds::<Self>(offset);
978            // Verify that padding bytes are zero.
979            fidl::decode!(
980                fidl_fuchsia_net__common::IpAddress,
981                D,
982                &mut self.start,
983                decoder,
984                offset + 0,
985                _depth
986            )?;
987            fidl::decode!(
988                fidl_fuchsia_net__common::IpAddress,
989                D,
990                &mut self.end,
991                decoder,
992                offset + 16,
993                _depth
994            )?;
995            Ok(())
996        }
997    }
998
999    impl fidl::encoding::ValueTypeMarker for Between {
1000        type Borrowed<'a> = &'a Self;
1001        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1002            value
1003        }
1004    }
1005
1006    unsafe impl fidl::encoding::TypeMarker for Between {
1007        type Owned = Self;
1008
1009        #[inline(always)]
1010        fn inline_align(_context: fidl::encoding::Context) -> usize {
1011            4
1012        }
1013
1014        #[inline(always)]
1015        fn inline_size(_context: fidl::encoding::Context) -> usize {
1016            8
1017        }
1018        #[inline(always)]
1019        fn encode_is_copy() -> bool {
1020            true
1021        }
1022
1023        #[inline(always)]
1024        fn decode_is_copy() -> bool {
1025            true
1026        }
1027    }
1028
1029    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Between, D> for &Between {
1030        #[inline]
1031        unsafe fn encode(
1032            self,
1033            encoder: &mut fidl::encoding::Encoder<'_, D>,
1034            offset: usize,
1035            _depth: fidl::encoding::Depth,
1036        ) -> fidl::Result<()> {
1037            encoder.debug_check_bounds::<Between>(offset);
1038            unsafe {
1039                // Copy the object into the buffer.
1040                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1041                (buf_ptr as *mut Between).write_unaligned((self as *const Between).read());
1042                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1043                // done second because the memcpy will write garbage to these bytes.
1044            }
1045            Ok(())
1046        }
1047    }
1048    unsafe impl<
1049        D: fidl::encoding::ResourceDialect,
1050        T0: fidl::encoding::Encode<u32, D>,
1051        T1: fidl::encoding::Encode<u32, D>,
1052    > fidl::encoding::Encode<Between, D> for (T0, T1)
1053    {
1054        #[inline]
1055        unsafe fn encode(
1056            self,
1057            encoder: &mut fidl::encoding::Encoder<'_, D>,
1058            offset: usize,
1059            depth: fidl::encoding::Depth,
1060        ) -> fidl::Result<()> {
1061            encoder.debug_check_bounds::<Between>(offset);
1062            // Zero out padding regions. There's no need to apply masks
1063            // because the unmasked parts will be overwritten by fields.
1064            // Write the fields.
1065            self.0.encode(encoder, offset + 0, depth)?;
1066            self.1.encode(encoder, offset + 4, depth)?;
1067            Ok(())
1068        }
1069    }
1070
1071    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Between {
1072        #[inline(always)]
1073        fn new_empty() -> Self {
1074            Self { start: fidl::new_empty!(u32, D), end: fidl::new_empty!(u32, D) }
1075        }
1076
1077        #[inline]
1078        unsafe fn decode(
1079            &mut self,
1080            decoder: &mut fidl::encoding::Decoder<'_, D>,
1081            offset: usize,
1082            _depth: fidl::encoding::Depth,
1083        ) -> fidl::Result<()> {
1084            decoder.debug_check_bounds::<Self>(offset);
1085            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1086            // Verify that padding bytes are zero.
1087            // Copy from the buffer into the object.
1088            unsafe {
1089                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
1090            }
1091            Ok(())
1092        }
1093    }
1094
1095    impl fidl::encoding::ValueTypeMarker for Empty {
1096        type Borrowed<'a> = &'a Self;
1097        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1098            value
1099        }
1100    }
1101
1102    unsafe impl fidl::encoding::TypeMarker for Empty {
1103        type Owned = Self;
1104
1105        #[inline(always)]
1106        fn inline_align(_context: fidl::encoding::Context) -> usize {
1107            1
1108        }
1109
1110        #[inline(always)]
1111        fn inline_size(_context: fidl::encoding::Context) -> usize {
1112            1
1113        }
1114    }
1115
1116    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Empty, D> for &Empty {
1117        #[inline]
1118        unsafe fn encode(
1119            self,
1120            encoder: &mut fidl::encoding::Encoder<'_, D>,
1121            offset: usize,
1122            _depth: fidl::encoding::Depth,
1123        ) -> fidl::Result<()> {
1124            encoder.debug_check_bounds::<Empty>(offset);
1125            encoder.write_num(0u8, offset);
1126            Ok(())
1127        }
1128    }
1129
1130    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Empty {
1131        #[inline(always)]
1132        fn new_empty() -> Self {
1133            Self
1134        }
1135
1136        #[inline]
1137        unsafe fn decode(
1138            &mut self,
1139            decoder: &mut fidl::encoding::Decoder<'_, D>,
1140            offset: usize,
1141            _depth: fidl::encoding::Depth,
1142        ) -> fidl::Result<()> {
1143            decoder.debug_check_bounds::<Self>(offset);
1144            match decoder.read_num::<u8>(offset) {
1145                0 => Ok(()),
1146                _ => Err(fidl::Error::Invalid),
1147            }
1148        }
1149    }
1150
1151    impl fidl::encoding::ValueTypeMarker for MarkInDomain {
1152        type Borrowed<'a> = &'a Self;
1153        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1154            value
1155        }
1156    }
1157
1158    unsafe impl fidl::encoding::TypeMarker for MarkInDomain {
1159        type Owned = Self;
1160
1161        #[inline(always)]
1162        fn inline_align(_context: fidl::encoding::Context) -> usize {
1163            8
1164        }
1165
1166        #[inline(always)]
1167        fn inline_size(_context: fidl::encoding::Context) -> usize {
1168            24
1169        }
1170    }
1171
1172    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<MarkInDomain, D>
1173        for &MarkInDomain
1174    {
1175        #[inline]
1176        unsafe fn encode(
1177            self,
1178            encoder: &mut fidl::encoding::Encoder<'_, D>,
1179            offset: usize,
1180            _depth: fidl::encoding::Depth,
1181        ) -> fidl::Result<()> {
1182            encoder.debug_check_bounds::<MarkInDomain>(offset);
1183            // Delegate to tuple encoding.
1184            fidl::encoding::Encode::<MarkInDomain, D>::encode(
1185                (
1186                    <fidl_fuchsia_net__common::MarkDomain as fidl::encoding::ValueTypeMarker>::borrow(&self.domain),
1187                    <Mark as fidl::encoding::ValueTypeMarker>::borrow(&self.mark),
1188                ),
1189                encoder, offset, _depth
1190            )
1191        }
1192    }
1193    unsafe impl<
1194        D: fidl::encoding::ResourceDialect,
1195        T0: fidl::encoding::Encode<fidl_fuchsia_net__common::MarkDomain, D>,
1196        T1: fidl::encoding::Encode<Mark, D>,
1197    > fidl::encoding::Encode<MarkInDomain, D> for (T0, T1)
1198    {
1199        #[inline]
1200        unsafe fn encode(
1201            self,
1202            encoder: &mut fidl::encoding::Encoder<'_, D>,
1203            offset: usize,
1204            depth: fidl::encoding::Depth,
1205        ) -> fidl::Result<()> {
1206            encoder.debug_check_bounds::<MarkInDomain>(offset);
1207            // Zero out padding regions. There's no need to apply masks
1208            // because the unmasked parts will be overwritten by fields.
1209            unsafe {
1210                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1211                (ptr as *mut u64).write_unaligned(0);
1212            }
1213            // Write the fields.
1214            self.0.encode(encoder, offset + 0, depth)?;
1215            self.1.encode(encoder, offset + 8, depth)?;
1216            Ok(())
1217        }
1218    }
1219
1220    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MarkInDomain {
1221        #[inline(always)]
1222        fn new_empty() -> Self {
1223            Self {
1224                domain: fidl::new_empty!(fidl_fuchsia_net__common::MarkDomain, D),
1225                mark: fidl::new_empty!(Mark, D),
1226            }
1227        }
1228
1229        #[inline]
1230        unsafe fn decode(
1231            &mut self,
1232            decoder: &mut fidl::encoding::Decoder<'_, D>,
1233            offset: usize,
1234            _depth: fidl::encoding::Depth,
1235        ) -> fidl::Result<()> {
1236            decoder.debug_check_bounds::<Self>(offset);
1237            // Verify that padding bytes are zero.
1238            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1239            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1240            let mask = 0xffffffffffffff00u64;
1241            let maskedval = padval & mask;
1242            if maskedval != 0 {
1243                return Err(fidl::Error::NonZeroPadding {
1244                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1245                });
1246            }
1247            fidl::decode!(
1248                fidl_fuchsia_net__common::MarkDomain,
1249                D,
1250                &mut self.domain,
1251                decoder,
1252                offset + 0,
1253                _depth
1254            )?;
1255            fidl::decode!(Mark, D, &mut self.mark, decoder, offset + 8, _depth)?;
1256            Ok(())
1257        }
1258    }
1259
1260    impl fidl::encoding::ValueTypeMarker for Marked {
1261        type Borrowed<'a> = &'a Self;
1262        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1263            value
1264        }
1265    }
1266
1267    unsafe impl fidl::encoding::TypeMarker for Marked {
1268        type Owned = Self;
1269
1270        #[inline(always)]
1271        fn inline_align(_context: fidl::encoding::Context) -> usize {
1272            4
1273        }
1274
1275        #[inline(always)]
1276        fn inline_size(_context: fidl::encoding::Context) -> usize {
1277            16
1278        }
1279    }
1280
1281    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Marked, D> for &Marked {
1282        #[inline]
1283        unsafe fn encode(
1284            self,
1285            encoder: &mut fidl::encoding::Encoder<'_, D>,
1286            offset: usize,
1287            _depth: fidl::encoding::Depth,
1288        ) -> fidl::Result<()> {
1289            encoder.debug_check_bounds::<Marked>(offset);
1290            // Delegate to tuple encoding.
1291            fidl::encoding::Encode::<Marked, D>::encode(
1292                (
1293                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.mask),
1294                    <Between as fidl::encoding::ValueTypeMarker>::borrow(&self.between),
1295                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.invert),
1296                ),
1297                encoder,
1298                offset,
1299                _depth,
1300            )
1301        }
1302    }
1303    unsafe impl<
1304        D: fidl::encoding::ResourceDialect,
1305        T0: fidl::encoding::Encode<u32, D>,
1306        T1: fidl::encoding::Encode<Between, D>,
1307        T2: fidl::encoding::Encode<bool, D>,
1308    > fidl::encoding::Encode<Marked, D> for (T0, T1, T2)
1309    {
1310        #[inline]
1311        unsafe fn encode(
1312            self,
1313            encoder: &mut fidl::encoding::Encoder<'_, D>,
1314            offset: usize,
1315            depth: fidl::encoding::Depth,
1316        ) -> fidl::Result<()> {
1317            encoder.debug_check_bounds::<Marked>(offset);
1318            // Zero out padding regions. There's no need to apply masks
1319            // because the unmasked parts will be overwritten by fields.
1320            unsafe {
1321                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(12);
1322                (ptr as *mut u32).write_unaligned(0);
1323            }
1324            // Write the fields.
1325            self.0.encode(encoder, offset + 0, depth)?;
1326            self.1.encode(encoder, offset + 4, depth)?;
1327            self.2.encode(encoder, offset + 12, depth)?;
1328            Ok(())
1329        }
1330    }
1331
1332    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Marked {
1333        #[inline(always)]
1334        fn new_empty() -> Self {
1335            Self {
1336                mask: fidl::new_empty!(u32, D),
1337                between: fidl::new_empty!(Between, D),
1338                invert: fidl::new_empty!(bool, D),
1339            }
1340        }
1341
1342        #[inline]
1343        unsafe fn decode(
1344            &mut self,
1345            decoder: &mut fidl::encoding::Decoder<'_, D>,
1346            offset: usize,
1347            _depth: fidl::encoding::Depth,
1348        ) -> fidl::Result<()> {
1349            decoder.debug_check_bounds::<Self>(offset);
1350            // Verify that padding bytes are zero.
1351            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(12) };
1352            let padval = unsafe { (ptr as *const u32).read_unaligned() };
1353            let mask = 0xffffff00u32;
1354            let maskedval = padval & mask;
1355            if maskedval != 0 {
1356                return Err(fidl::Error::NonZeroPadding {
1357                    padding_start: offset + 12 + ((mask as u64).trailing_zeros() / 8) as usize,
1358                });
1359            }
1360            fidl::decode!(u32, D, &mut self.mask, decoder, offset + 0, _depth)?;
1361            fidl::decode!(Between, D, &mut self.between, decoder, offset + 4, _depth)?;
1362            fidl::decode!(bool, D, &mut self.invert, decoder, offset + 12, _depth)?;
1363            Ok(())
1364        }
1365    }
1366
1367    impl fidl::encoding::ValueTypeMarker for Port {
1368        type Borrowed<'a> = &'a Self;
1369        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1370            value
1371        }
1372    }
1373
1374    unsafe impl fidl::encoding::TypeMarker for Port {
1375        type Owned = Self;
1376
1377        #[inline(always)]
1378        fn inline_align(_context: fidl::encoding::Context) -> usize {
1379            2
1380        }
1381
1382        #[inline(always)]
1383        fn inline_size(_context: fidl::encoding::Context) -> usize {
1384            6
1385        }
1386    }
1387
1388    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Port, D> for &Port {
1389        #[inline]
1390        unsafe fn encode(
1391            self,
1392            encoder: &mut fidl::encoding::Encoder<'_, D>,
1393            offset: usize,
1394            _depth: fidl::encoding::Depth,
1395        ) -> fidl::Result<()> {
1396            encoder.debug_check_bounds::<Port>(offset);
1397            // Delegate to tuple encoding.
1398            fidl::encoding::Encode::<Port, D>::encode(
1399                (
1400                    <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.start),
1401                    <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.end),
1402                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.invert),
1403                ),
1404                encoder,
1405                offset,
1406                _depth,
1407            )
1408        }
1409    }
1410    unsafe impl<
1411        D: fidl::encoding::ResourceDialect,
1412        T0: fidl::encoding::Encode<u16, D>,
1413        T1: fidl::encoding::Encode<u16, D>,
1414        T2: fidl::encoding::Encode<bool, D>,
1415    > fidl::encoding::Encode<Port, D> for (T0, T1, T2)
1416    {
1417        #[inline]
1418        unsafe fn encode(
1419            self,
1420            encoder: &mut fidl::encoding::Encoder<'_, D>,
1421            offset: usize,
1422            depth: fidl::encoding::Depth,
1423        ) -> fidl::Result<()> {
1424            encoder.debug_check_bounds::<Port>(offset);
1425            // Zero out padding regions. There's no need to apply masks
1426            // because the unmasked parts will be overwritten by fields.
1427            unsafe {
1428                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
1429                (ptr as *mut u16).write_unaligned(0);
1430            }
1431            // Write the fields.
1432            self.0.encode(encoder, offset + 0, depth)?;
1433            self.1.encode(encoder, offset + 2, depth)?;
1434            self.2.encode(encoder, offset + 4, depth)?;
1435            Ok(())
1436        }
1437    }
1438
1439    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Port {
1440        #[inline(always)]
1441        fn new_empty() -> Self {
1442            Self {
1443                start: fidl::new_empty!(u16, D),
1444                end: fidl::new_empty!(u16, D),
1445                invert: fidl::new_empty!(bool, D),
1446            }
1447        }
1448
1449        #[inline]
1450        unsafe fn decode(
1451            &mut self,
1452            decoder: &mut fidl::encoding::Decoder<'_, D>,
1453            offset: usize,
1454            _depth: fidl::encoding::Depth,
1455        ) -> fidl::Result<()> {
1456            decoder.debug_check_bounds::<Self>(offset);
1457            // Verify that padding bytes are zero.
1458            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
1459            let padval = unsafe { (ptr as *const u16).read_unaligned() };
1460            let mask = 0xff00u16;
1461            let maskedval = padval & mask;
1462            if maskedval != 0 {
1463                return Err(fidl::Error::NonZeroPadding {
1464                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
1465                });
1466            }
1467            fidl::decode!(u16, D, &mut self.start, decoder, offset + 0, _depth)?;
1468            fidl::decode!(u16, D, &mut self.end, decoder, offset + 2, _depth)?;
1469            fidl::decode!(bool, D, &mut self.invert, decoder, offset + 4, _depth)?;
1470            Ok(())
1471        }
1472    }
1473
1474    impl fidl::encoding::ValueTypeMarker for SocketCookie {
1475        type Borrowed<'a> = &'a Self;
1476        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1477            value
1478        }
1479    }
1480
1481    unsafe impl fidl::encoding::TypeMarker for SocketCookie {
1482        type Owned = Self;
1483
1484        #[inline(always)]
1485        fn inline_align(_context: fidl::encoding::Context) -> usize {
1486            8
1487        }
1488
1489        #[inline(always)]
1490        fn inline_size(_context: fidl::encoding::Context) -> usize {
1491            16
1492        }
1493    }
1494
1495    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SocketCookie, D>
1496        for &SocketCookie
1497    {
1498        #[inline]
1499        unsafe fn encode(
1500            self,
1501            encoder: &mut fidl::encoding::Encoder<'_, D>,
1502            offset: usize,
1503            _depth: fidl::encoding::Depth,
1504        ) -> fidl::Result<()> {
1505            encoder.debug_check_bounds::<SocketCookie>(offset);
1506            // Delegate to tuple encoding.
1507            fidl::encoding::Encode::<SocketCookie, D>::encode(
1508                (
1509                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.cookie),
1510                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.invert),
1511                ),
1512                encoder,
1513                offset,
1514                _depth,
1515            )
1516        }
1517    }
1518    unsafe impl<
1519        D: fidl::encoding::ResourceDialect,
1520        T0: fidl::encoding::Encode<u64, D>,
1521        T1: fidl::encoding::Encode<bool, D>,
1522    > fidl::encoding::Encode<SocketCookie, D> for (T0, T1)
1523    {
1524        #[inline]
1525        unsafe fn encode(
1526            self,
1527            encoder: &mut fidl::encoding::Encoder<'_, D>,
1528            offset: usize,
1529            depth: fidl::encoding::Depth,
1530        ) -> fidl::Result<()> {
1531            encoder.debug_check_bounds::<SocketCookie>(offset);
1532            // Zero out padding regions. There's no need to apply masks
1533            // because the unmasked parts will be overwritten by fields.
1534            unsafe {
1535                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
1536                (ptr as *mut u64).write_unaligned(0);
1537            }
1538            // Write the fields.
1539            self.0.encode(encoder, offset + 0, depth)?;
1540            self.1.encode(encoder, offset + 8, depth)?;
1541            Ok(())
1542        }
1543    }
1544
1545    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SocketCookie {
1546        #[inline(always)]
1547        fn new_empty() -> Self {
1548            Self { cookie: fidl::new_empty!(u64, D), invert: fidl::new_empty!(bool, D) }
1549        }
1550
1551        #[inline]
1552        unsafe fn decode(
1553            &mut self,
1554            decoder: &mut fidl::encoding::Decoder<'_, D>,
1555            offset: usize,
1556            _depth: fidl::encoding::Depth,
1557        ) -> fidl::Result<()> {
1558            decoder.debug_check_bounds::<Self>(offset);
1559            // Verify that padding bytes are zero.
1560            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
1561            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1562            let mask = 0xffffffffffffff00u64;
1563            let maskedval = padval & mask;
1564            if maskedval != 0 {
1565                return Err(fidl::Error::NonZeroPadding {
1566                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
1567                });
1568            }
1569            fidl::decode!(u64, D, &mut self.cookie, decoder, offset + 0, _depth)?;
1570            fidl::decode!(bool, D, &mut self.invert, decoder, offset + 8, _depth)?;
1571            Ok(())
1572        }
1573    }
1574
1575    impl fidl::encoding::ValueTypeMarker for Unbound {
1576        type Borrowed<'a> = &'a Self;
1577        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1578            value
1579        }
1580    }
1581
1582    unsafe impl fidl::encoding::TypeMarker for Unbound {
1583        type Owned = Self;
1584
1585        #[inline(always)]
1586        fn inline_align(_context: fidl::encoding::Context) -> usize {
1587            1
1588        }
1589
1590        #[inline(always)]
1591        fn inline_size(_context: fidl::encoding::Context) -> usize {
1592            1
1593        }
1594    }
1595
1596    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Unbound, D> for &Unbound {
1597        #[inline]
1598        unsafe fn encode(
1599            self,
1600            encoder: &mut fidl::encoding::Encoder<'_, D>,
1601            offset: usize,
1602            _depth: fidl::encoding::Depth,
1603        ) -> fidl::Result<()> {
1604            encoder.debug_check_bounds::<Unbound>(offset);
1605            encoder.write_num(0u8, offset);
1606            Ok(())
1607        }
1608    }
1609
1610    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Unbound {
1611        #[inline(always)]
1612        fn new_empty() -> Self {
1613            Self
1614        }
1615
1616        #[inline]
1617        unsafe fn decode(
1618            &mut self,
1619            decoder: &mut fidl::encoding::Decoder<'_, D>,
1620            offset: usize,
1621            _depth: fidl::encoding::Depth,
1622        ) -> fidl::Result<()> {
1623            decoder.debug_check_bounds::<Self>(offset);
1624            match decoder.read_num::<u8>(offset) {
1625                0 => Ok(()),
1626                _ => Err(fidl::Error::Invalid),
1627            }
1628        }
1629    }
1630
1631    impl fidl::encoding::ValueTypeMarker for Unmarked {
1632        type Borrowed<'a> = &'a Self;
1633        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1634            value
1635        }
1636    }
1637
1638    unsafe impl fidl::encoding::TypeMarker for Unmarked {
1639        type Owned = Self;
1640
1641        #[inline(always)]
1642        fn inline_align(_context: fidl::encoding::Context) -> usize {
1643            1
1644        }
1645
1646        #[inline(always)]
1647        fn inline_size(_context: fidl::encoding::Context) -> usize {
1648            1
1649        }
1650    }
1651
1652    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Unmarked, D> for &Unmarked {
1653        #[inline]
1654        unsafe fn encode(
1655            self,
1656            encoder: &mut fidl::encoding::Encoder<'_, D>,
1657            offset: usize,
1658            _depth: fidl::encoding::Depth,
1659        ) -> fidl::Result<()> {
1660            encoder.debug_check_bounds::<Unmarked>(offset);
1661            encoder.write_num(0u8, offset);
1662            Ok(())
1663        }
1664    }
1665
1666    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Unmarked {
1667        #[inline(always)]
1668        fn new_empty() -> Self {
1669            Self
1670        }
1671
1672        #[inline]
1673        unsafe fn decode(
1674            &mut self,
1675            decoder: &mut fidl::encoding::Decoder<'_, D>,
1676            offset: usize,
1677            _depth: fidl::encoding::Depth,
1678        ) -> fidl::Result<()> {
1679            decoder.debug_check_bounds::<Self>(offset);
1680            match decoder.read_num::<u8>(offset) {
1681                0 => Ok(()),
1682                _ => Err(fidl::Error::Invalid),
1683            }
1684        }
1685    }
1686
1687    impl IcmpPacket {
1688        #[inline(always)]
1689        fn max_ordinal_present(&self) -> u64 {
1690            0
1691        }
1692    }
1693
1694    impl fidl::encoding::ValueTypeMarker for IcmpPacket {
1695        type Borrowed<'a> = &'a Self;
1696        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1697            value
1698        }
1699    }
1700
1701    unsafe impl fidl::encoding::TypeMarker for IcmpPacket {
1702        type Owned = Self;
1703
1704        #[inline(always)]
1705        fn inline_align(_context: fidl::encoding::Context) -> usize {
1706            8
1707        }
1708
1709        #[inline(always)]
1710        fn inline_size(_context: fidl::encoding::Context) -> usize {
1711            16
1712        }
1713    }
1714
1715    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<IcmpPacket, D>
1716        for &IcmpPacket
1717    {
1718        unsafe fn encode(
1719            self,
1720            encoder: &mut fidl::encoding::Encoder<'_, D>,
1721            offset: usize,
1722            mut depth: fidl::encoding::Depth,
1723        ) -> fidl::Result<()> {
1724            encoder.debug_check_bounds::<IcmpPacket>(offset);
1725            // Vector header
1726            let max_ordinal: u64 = self.max_ordinal_present();
1727            encoder.write_num(max_ordinal, offset);
1728            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1729            // Calling encoder.out_of_line_offset(0) is not allowed.
1730            if max_ordinal == 0 {
1731                return Ok(());
1732            }
1733            depth.increment()?;
1734            let envelope_size = 8;
1735            let bytes_len = max_ordinal as usize * envelope_size;
1736            #[allow(unused_variables)]
1737            let offset = encoder.out_of_line_offset(bytes_len);
1738            let mut _prev_end_offset: usize = 0;
1739
1740            Ok(())
1741        }
1742    }
1743
1744    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for IcmpPacket {
1745        #[inline(always)]
1746        fn new_empty() -> Self {
1747            Self::default()
1748        }
1749
1750        unsafe fn decode(
1751            &mut self,
1752            decoder: &mut fidl::encoding::Decoder<'_, D>,
1753            offset: usize,
1754            mut depth: fidl::encoding::Depth,
1755        ) -> fidl::Result<()> {
1756            decoder.debug_check_bounds::<Self>(offset);
1757            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1758                None => return Err(fidl::Error::NotNullable),
1759                Some(len) => len,
1760            };
1761            // Calling decoder.out_of_line_offset(0) is not allowed.
1762            if len == 0 {
1763                return Ok(());
1764            };
1765            depth.increment()?;
1766            let envelope_size = 8;
1767            let bytes_len = len * envelope_size;
1768            let offset = decoder.out_of_line_offset(bytes_len)?;
1769            // Decode the envelope for each type.
1770            let mut _next_ordinal_to_read = 0;
1771            let mut next_offset = offset;
1772            let end_offset = offset + bytes_len;
1773
1774            // Decode the remaining unknown envelopes.
1775            while next_offset < end_offset {
1776                _next_ordinal_to_read += 1;
1777                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1778                next_offset += envelope_size;
1779            }
1780
1781            Ok(())
1782        }
1783    }
1784
1785    impl Icmpv6Packet {
1786        #[inline(always)]
1787        fn max_ordinal_present(&self) -> u64 {
1788            0
1789        }
1790    }
1791
1792    impl fidl::encoding::ValueTypeMarker for Icmpv6Packet {
1793        type Borrowed<'a> = &'a Self;
1794        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1795            value
1796        }
1797    }
1798
1799    unsafe impl fidl::encoding::TypeMarker for Icmpv6Packet {
1800        type Owned = Self;
1801
1802        #[inline(always)]
1803        fn inline_align(_context: fidl::encoding::Context) -> usize {
1804            8
1805        }
1806
1807        #[inline(always)]
1808        fn inline_size(_context: fidl::encoding::Context) -> usize {
1809            16
1810        }
1811    }
1812
1813    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Icmpv6Packet, D>
1814        for &Icmpv6Packet
1815    {
1816        unsafe fn encode(
1817            self,
1818            encoder: &mut fidl::encoding::Encoder<'_, D>,
1819            offset: usize,
1820            mut depth: fidl::encoding::Depth,
1821        ) -> fidl::Result<()> {
1822            encoder.debug_check_bounds::<Icmpv6Packet>(offset);
1823            // Vector header
1824            let max_ordinal: u64 = self.max_ordinal_present();
1825            encoder.write_num(max_ordinal, offset);
1826            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1827            // Calling encoder.out_of_line_offset(0) is not allowed.
1828            if max_ordinal == 0 {
1829                return Ok(());
1830            }
1831            depth.increment()?;
1832            let envelope_size = 8;
1833            let bytes_len = max_ordinal as usize * envelope_size;
1834            #[allow(unused_variables)]
1835            let offset = encoder.out_of_line_offset(bytes_len);
1836            let mut _prev_end_offset: usize = 0;
1837
1838            Ok(())
1839        }
1840    }
1841
1842    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Icmpv6Packet {
1843        #[inline(always)]
1844        fn new_empty() -> Self {
1845            Self::default()
1846        }
1847
1848        unsafe fn decode(
1849            &mut self,
1850            decoder: &mut fidl::encoding::Decoder<'_, D>,
1851            offset: usize,
1852            mut depth: fidl::encoding::Depth,
1853        ) -> fidl::Result<()> {
1854            decoder.debug_check_bounds::<Self>(offset);
1855            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1856                None => return Err(fidl::Error::NotNullable),
1857                Some(len) => len,
1858            };
1859            // Calling decoder.out_of_line_offset(0) is not allowed.
1860            if len == 0 {
1861                return Ok(());
1862            };
1863            depth.increment()?;
1864            let envelope_size = 8;
1865            let bytes_len = len * envelope_size;
1866            let offset = decoder.out_of_line_offset(bytes_len)?;
1867            // Decode the envelope for each type.
1868            let mut _next_ordinal_to_read = 0;
1869            let mut next_offset = offset;
1870            let end_offset = offset + bytes_len;
1871
1872            // Decode the remaining unknown envelopes.
1873            while next_offset < end_offset {
1874                _next_ordinal_to_read += 1;
1875                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1876                next_offset += envelope_size;
1877            }
1878
1879            Ok(())
1880        }
1881    }
1882
1883    impl TcpPacket {
1884        #[inline(always)]
1885        fn max_ordinal_present(&self) -> u64 {
1886            if let Some(_) = self.dst_port {
1887                return 2;
1888            }
1889            if let Some(_) = self.src_port {
1890                return 1;
1891            }
1892            0
1893        }
1894    }
1895
1896    impl fidl::encoding::ValueTypeMarker for TcpPacket {
1897        type Borrowed<'a> = &'a Self;
1898        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1899            value
1900        }
1901    }
1902
1903    unsafe impl fidl::encoding::TypeMarker for TcpPacket {
1904        type Owned = Self;
1905
1906        #[inline(always)]
1907        fn inline_align(_context: fidl::encoding::Context) -> usize {
1908            8
1909        }
1910
1911        #[inline(always)]
1912        fn inline_size(_context: fidl::encoding::Context) -> usize {
1913            16
1914        }
1915    }
1916
1917    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<TcpPacket, D>
1918        for &TcpPacket
1919    {
1920        unsafe fn encode(
1921            self,
1922            encoder: &mut fidl::encoding::Encoder<'_, D>,
1923            offset: usize,
1924            mut depth: fidl::encoding::Depth,
1925        ) -> fidl::Result<()> {
1926            encoder.debug_check_bounds::<TcpPacket>(offset);
1927            // Vector header
1928            let max_ordinal: u64 = self.max_ordinal_present();
1929            encoder.write_num(max_ordinal, offset);
1930            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1931            // Calling encoder.out_of_line_offset(0) is not allowed.
1932            if max_ordinal == 0 {
1933                return Ok(());
1934            }
1935            depth.increment()?;
1936            let envelope_size = 8;
1937            let bytes_len = max_ordinal as usize * envelope_size;
1938            #[allow(unused_variables)]
1939            let offset = encoder.out_of_line_offset(bytes_len);
1940            let mut _prev_end_offset: usize = 0;
1941            if 1 > max_ordinal {
1942                return Ok(());
1943            }
1944
1945            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1946            // are envelope_size bytes.
1947            let cur_offset: usize = (1 - 1) * envelope_size;
1948
1949            // Zero reserved fields.
1950            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1951
1952            // Safety:
1953            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1954            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1955            //   envelope_size bytes, there is always sufficient room.
1956            fidl::encoding::encode_in_envelope_optional::<Port, D>(
1957                self.src_port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
1958                encoder,
1959                offset + cur_offset,
1960                depth,
1961            )?;
1962
1963            _prev_end_offset = cur_offset + envelope_size;
1964            if 2 > max_ordinal {
1965                return Ok(());
1966            }
1967
1968            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1969            // are envelope_size bytes.
1970            let cur_offset: usize = (2 - 1) * envelope_size;
1971
1972            // Zero reserved fields.
1973            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1974
1975            // Safety:
1976            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1977            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1978            //   envelope_size bytes, there is always sufficient room.
1979            fidl::encoding::encode_in_envelope_optional::<Port, D>(
1980                self.dst_port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
1981                encoder,
1982                offset + cur_offset,
1983                depth,
1984            )?;
1985
1986            _prev_end_offset = cur_offset + envelope_size;
1987
1988            Ok(())
1989        }
1990    }
1991
1992    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TcpPacket {
1993        #[inline(always)]
1994        fn new_empty() -> Self {
1995            Self::default()
1996        }
1997
1998        unsafe fn decode(
1999            &mut self,
2000            decoder: &mut fidl::encoding::Decoder<'_, D>,
2001            offset: usize,
2002            mut depth: fidl::encoding::Depth,
2003        ) -> fidl::Result<()> {
2004            decoder.debug_check_bounds::<Self>(offset);
2005            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2006                None => return Err(fidl::Error::NotNullable),
2007                Some(len) => len,
2008            };
2009            // Calling decoder.out_of_line_offset(0) is not allowed.
2010            if len == 0 {
2011                return Ok(());
2012            };
2013            depth.increment()?;
2014            let envelope_size = 8;
2015            let bytes_len = len * envelope_size;
2016            let offset = decoder.out_of_line_offset(bytes_len)?;
2017            // Decode the envelope for each type.
2018            let mut _next_ordinal_to_read = 0;
2019            let mut next_offset = offset;
2020            let end_offset = offset + bytes_len;
2021            _next_ordinal_to_read += 1;
2022            if next_offset >= end_offset {
2023                return Ok(());
2024            }
2025
2026            // Decode unknown envelopes for gaps in ordinals.
2027            while _next_ordinal_to_read < 1 {
2028                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2029                _next_ordinal_to_read += 1;
2030                next_offset += envelope_size;
2031            }
2032
2033            let next_out_of_line = decoder.next_out_of_line();
2034            let handles_before = decoder.remaining_handles();
2035            if let Some((inlined, num_bytes, num_handles)) =
2036                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2037            {
2038                let member_inline_size =
2039                    <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2040                if inlined != (member_inline_size <= 4) {
2041                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2042                }
2043                let inner_offset;
2044                let mut inner_depth = depth.clone();
2045                if inlined {
2046                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2047                    inner_offset = next_offset;
2048                } else {
2049                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2050                    inner_depth.increment()?;
2051                }
2052                let val_ref = self.src_port.get_or_insert_with(|| fidl::new_empty!(Port, D));
2053                fidl::decode!(Port, D, val_ref, decoder, inner_offset, inner_depth)?;
2054                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2055                {
2056                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2057                }
2058                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2059                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2060                }
2061            }
2062
2063            next_offset += envelope_size;
2064            _next_ordinal_to_read += 1;
2065            if next_offset >= end_offset {
2066                return Ok(());
2067            }
2068
2069            // Decode unknown envelopes for gaps in ordinals.
2070            while _next_ordinal_to_read < 2 {
2071                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2072                _next_ordinal_to_read += 1;
2073                next_offset += envelope_size;
2074            }
2075
2076            let next_out_of_line = decoder.next_out_of_line();
2077            let handles_before = decoder.remaining_handles();
2078            if let Some((inlined, num_bytes, num_handles)) =
2079                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2080            {
2081                let member_inline_size =
2082                    <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2083                if inlined != (member_inline_size <= 4) {
2084                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2085                }
2086                let inner_offset;
2087                let mut inner_depth = depth.clone();
2088                if inlined {
2089                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2090                    inner_offset = next_offset;
2091                } else {
2092                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2093                    inner_depth.increment()?;
2094                }
2095                let val_ref = self.dst_port.get_or_insert_with(|| fidl::new_empty!(Port, D));
2096                fidl::decode!(Port, D, val_ref, decoder, inner_offset, inner_depth)?;
2097                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2098                {
2099                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2100                }
2101                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2102                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2103                }
2104            }
2105
2106            next_offset += envelope_size;
2107
2108            // Decode the remaining unknown envelopes.
2109            while next_offset < end_offset {
2110                _next_ordinal_to_read += 1;
2111                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2112                next_offset += envelope_size;
2113            }
2114
2115            Ok(())
2116        }
2117    }
2118
2119    impl UdpPacket {
2120        #[inline(always)]
2121        fn max_ordinal_present(&self) -> u64 {
2122            if let Some(_) = self.dst_port {
2123                return 2;
2124            }
2125            if let Some(_) = self.src_port {
2126                return 1;
2127            }
2128            0
2129        }
2130    }
2131
2132    impl fidl::encoding::ValueTypeMarker for UdpPacket {
2133        type Borrowed<'a> = &'a Self;
2134        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2135            value
2136        }
2137    }
2138
2139    unsafe impl fidl::encoding::TypeMarker for UdpPacket {
2140        type Owned = Self;
2141
2142        #[inline(always)]
2143        fn inline_align(_context: fidl::encoding::Context) -> usize {
2144            8
2145        }
2146
2147        #[inline(always)]
2148        fn inline_size(_context: fidl::encoding::Context) -> usize {
2149            16
2150        }
2151    }
2152
2153    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<UdpPacket, D>
2154        for &UdpPacket
2155    {
2156        unsafe fn encode(
2157            self,
2158            encoder: &mut fidl::encoding::Encoder<'_, D>,
2159            offset: usize,
2160            mut depth: fidl::encoding::Depth,
2161        ) -> fidl::Result<()> {
2162            encoder.debug_check_bounds::<UdpPacket>(offset);
2163            // Vector header
2164            let max_ordinal: u64 = self.max_ordinal_present();
2165            encoder.write_num(max_ordinal, offset);
2166            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2167            // Calling encoder.out_of_line_offset(0) is not allowed.
2168            if max_ordinal == 0 {
2169                return Ok(());
2170            }
2171            depth.increment()?;
2172            let envelope_size = 8;
2173            let bytes_len = max_ordinal as usize * envelope_size;
2174            #[allow(unused_variables)]
2175            let offset = encoder.out_of_line_offset(bytes_len);
2176            let mut _prev_end_offset: usize = 0;
2177            if 1 > max_ordinal {
2178                return Ok(());
2179            }
2180
2181            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2182            // are envelope_size bytes.
2183            let cur_offset: usize = (1 - 1) * envelope_size;
2184
2185            // Zero reserved fields.
2186            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2187
2188            // Safety:
2189            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2190            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2191            //   envelope_size bytes, there is always sufficient room.
2192            fidl::encoding::encode_in_envelope_optional::<Port, D>(
2193                self.src_port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
2194                encoder,
2195                offset + cur_offset,
2196                depth,
2197            )?;
2198
2199            _prev_end_offset = cur_offset + envelope_size;
2200            if 2 > max_ordinal {
2201                return Ok(());
2202            }
2203
2204            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2205            // are envelope_size bytes.
2206            let cur_offset: usize = (2 - 1) * envelope_size;
2207
2208            // Zero reserved fields.
2209            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2210
2211            // Safety:
2212            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2213            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2214            //   envelope_size bytes, there is always sufficient room.
2215            fidl::encoding::encode_in_envelope_optional::<Port, D>(
2216                self.dst_port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
2217                encoder,
2218                offset + cur_offset,
2219                depth,
2220            )?;
2221
2222            _prev_end_offset = cur_offset + envelope_size;
2223
2224            Ok(())
2225        }
2226    }
2227
2228    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UdpPacket {
2229        #[inline(always)]
2230        fn new_empty() -> Self {
2231            Self::default()
2232        }
2233
2234        unsafe fn decode(
2235            &mut self,
2236            decoder: &mut fidl::encoding::Decoder<'_, D>,
2237            offset: usize,
2238            mut depth: fidl::encoding::Depth,
2239        ) -> fidl::Result<()> {
2240            decoder.debug_check_bounds::<Self>(offset);
2241            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2242                None => return Err(fidl::Error::NotNullable),
2243                Some(len) => len,
2244            };
2245            // Calling decoder.out_of_line_offset(0) is not allowed.
2246            if len == 0 {
2247                return Ok(());
2248            };
2249            depth.increment()?;
2250            let envelope_size = 8;
2251            let bytes_len = len * envelope_size;
2252            let offset = decoder.out_of_line_offset(bytes_len)?;
2253            // Decode the envelope for each type.
2254            let mut _next_ordinal_to_read = 0;
2255            let mut next_offset = offset;
2256            let end_offset = offset + bytes_len;
2257            _next_ordinal_to_read += 1;
2258            if next_offset >= end_offset {
2259                return Ok(());
2260            }
2261
2262            // Decode unknown envelopes for gaps in ordinals.
2263            while _next_ordinal_to_read < 1 {
2264                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2265                _next_ordinal_to_read += 1;
2266                next_offset += envelope_size;
2267            }
2268
2269            let next_out_of_line = decoder.next_out_of_line();
2270            let handles_before = decoder.remaining_handles();
2271            if let Some((inlined, num_bytes, num_handles)) =
2272                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2273            {
2274                let member_inline_size =
2275                    <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2276                if inlined != (member_inline_size <= 4) {
2277                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2278                }
2279                let inner_offset;
2280                let mut inner_depth = depth.clone();
2281                if inlined {
2282                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2283                    inner_offset = next_offset;
2284                } else {
2285                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2286                    inner_depth.increment()?;
2287                }
2288                let val_ref = self.src_port.get_or_insert_with(|| fidl::new_empty!(Port, D));
2289                fidl::decode!(Port, D, val_ref, decoder, inner_offset, inner_depth)?;
2290                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2291                {
2292                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2293                }
2294                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2295                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2296                }
2297            }
2298
2299            next_offset += envelope_size;
2300            _next_ordinal_to_read += 1;
2301            if next_offset >= end_offset {
2302                return Ok(());
2303            }
2304
2305            // Decode unknown envelopes for gaps in ordinals.
2306            while _next_ordinal_to_read < 2 {
2307                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2308                _next_ordinal_to_read += 1;
2309                next_offset += envelope_size;
2310            }
2311
2312            let next_out_of_line = decoder.next_out_of_line();
2313            let handles_before = decoder.remaining_handles();
2314            if let Some((inlined, num_bytes, num_handles)) =
2315                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2316            {
2317                let member_inline_size =
2318                    <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2319                if inlined != (member_inline_size <= 4) {
2320                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2321                }
2322                let inner_offset;
2323                let mut inner_depth = depth.clone();
2324                if inlined {
2325                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2326                    inner_offset = next_offset;
2327                } else {
2328                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2329                    inner_depth.increment()?;
2330                }
2331                let val_ref = self.dst_port.get_or_insert_with(|| fidl::new_empty!(Port, D));
2332                fidl::decode!(Port, D, val_ref, decoder, inner_offset, inner_depth)?;
2333                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2334                {
2335                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2336                }
2337                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2338                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2339                }
2340            }
2341
2342            next_offset += envelope_size;
2343
2344            // Decode the remaining unknown envelopes.
2345            while next_offset < end_offset {
2346                _next_ordinal_to_read += 1;
2347                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2348                next_offset += envelope_size;
2349            }
2350
2351            Ok(())
2352        }
2353    }
2354
2355    impl fidl::encoding::ValueTypeMarker for AddressMatcherType {
2356        type Borrowed<'a> = &'a Self;
2357        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2358            value
2359        }
2360    }
2361
2362    unsafe impl fidl::encoding::TypeMarker for AddressMatcherType {
2363        type Owned = Self;
2364
2365        #[inline(always)]
2366        fn inline_align(_context: fidl::encoding::Context) -> usize {
2367            8
2368        }
2369
2370        #[inline(always)]
2371        fn inline_size(_context: fidl::encoding::Context) -> usize {
2372            16
2373        }
2374    }
2375
2376    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<AddressMatcherType, D>
2377        for &AddressMatcherType
2378    {
2379        #[inline]
2380        unsafe fn encode(
2381            self,
2382            encoder: &mut fidl::encoding::Encoder<'_, D>,
2383            offset: usize,
2384            _depth: fidl::encoding::Depth,
2385        ) -> fidl::Result<()> {
2386            encoder.debug_check_bounds::<AddressMatcherType>(offset);
2387            encoder.write_num::<u64>(self.ordinal(), offset);
2388            match self {
2389                AddressMatcherType::Subnet(ref val) => fidl::encoding::encode_in_envelope::<
2390                    fidl_fuchsia_net__common::Subnet,
2391                    D,
2392                >(
2393                    <fidl_fuchsia_net__common::Subnet as fidl::encoding::ValueTypeMarker>::borrow(
2394                        val,
2395                    ),
2396                    encoder,
2397                    offset + 8,
2398                    _depth,
2399                ),
2400                AddressMatcherType::Range(ref val) => {
2401                    fidl::encoding::encode_in_envelope::<AddressRange, D>(
2402                        <AddressRange as fidl::encoding::ValueTypeMarker>::borrow(val),
2403                        encoder,
2404                        offset + 8,
2405                        _depth,
2406                    )
2407                }
2408                AddressMatcherType::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2409            }
2410        }
2411    }
2412
2413    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for AddressMatcherType {
2414        #[inline(always)]
2415        fn new_empty() -> Self {
2416            Self::__SourceBreaking { unknown_ordinal: 0 }
2417        }
2418
2419        #[inline]
2420        unsafe fn decode(
2421            &mut self,
2422            decoder: &mut fidl::encoding::Decoder<'_, D>,
2423            offset: usize,
2424            mut depth: fidl::encoding::Depth,
2425        ) -> fidl::Result<()> {
2426            decoder.debug_check_bounds::<Self>(offset);
2427            #[allow(unused_variables)]
2428            let next_out_of_line = decoder.next_out_of_line();
2429            let handles_before = decoder.remaining_handles();
2430            let (ordinal, inlined, num_bytes, num_handles) =
2431                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2432
2433            let member_inline_size = match ordinal {
2434                1 => <fidl_fuchsia_net__common::Subnet as fidl::encoding::TypeMarker>::inline_size(
2435                    decoder.context,
2436                ),
2437                2 => <AddressRange as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2438                0 => return Err(fidl::Error::UnknownUnionTag),
2439                _ => num_bytes as usize,
2440            };
2441
2442            if inlined != (member_inline_size <= 4) {
2443                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2444            }
2445            let _inner_offset;
2446            if inlined {
2447                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2448                _inner_offset = offset + 8;
2449            } else {
2450                depth.increment()?;
2451                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2452            }
2453            match ordinal {
2454                1 => {
2455                    #[allow(irrefutable_let_patterns)]
2456                    if let AddressMatcherType::Subnet(_) = self {
2457                        // Do nothing, read the value into the object
2458                    } else {
2459                        // Initialize `self` to the right variant
2460                        *self = AddressMatcherType::Subnet(fidl::new_empty!(
2461                            fidl_fuchsia_net__common::Subnet,
2462                            D
2463                        ));
2464                    }
2465                    #[allow(irrefutable_let_patterns)]
2466                    if let AddressMatcherType::Subnet(ref mut val) = self {
2467                        fidl::decode!(
2468                            fidl_fuchsia_net__common::Subnet,
2469                            D,
2470                            val,
2471                            decoder,
2472                            _inner_offset,
2473                            depth
2474                        )?;
2475                    } else {
2476                        unreachable!()
2477                    }
2478                }
2479                2 => {
2480                    #[allow(irrefutable_let_patterns)]
2481                    if let AddressMatcherType::Range(_) = self {
2482                        // Do nothing, read the value into the object
2483                    } else {
2484                        // Initialize `self` to the right variant
2485                        *self = AddressMatcherType::Range(fidl::new_empty!(AddressRange, D));
2486                    }
2487                    #[allow(irrefutable_let_patterns)]
2488                    if let AddressMatcherType::Range(ref mut val) = self {
2489                        fidl::decode!(AddressRange, D, val, decoder, _inner_offset, depth)?;
2490                    } else {
2491                        unreachable!()
2492                    }
2493                }
2494                #[allow(deprecated)]
2495                ordinal => {
2496                    for _ in 0..num_handles {
2497                        decoder.drop_next_handle()?;
2498                    }
2499                    *self = AddressMatcherType::__SourceBreaking { unknown_ordinal: ordinal };
2500                }
2501            }
2502            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2503                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2504            }
2505            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2506                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2507            }
2508            Ok(())
2509        }
2510    }
2511
2512    impl fidl::encoding::ValueTypeMarker for BoundInterface {
2513        type Borrowed<'a> = &'a Self;
2514        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2515            value
2516        }
2517    }
2518
2519    unsafe impl fidl::encoding::TypeMarker for BoundInterface {
2520        type Owned = Self;
2521
2522        #[inline(always)]
2523        fn inline_align(_context: fidl::encoding::Context) -> usize {
2524            8
2525        }
2526
2527        #[inline(always)]
2528        fn inline_size(_context: fidl::encoding::Context) -> usize {
2529            16
2530        }
2531    }
2532
2533    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BoundInterface, D>
2534        for &BoundInterface
2535    {
2536        #[inline]
2537        unsafe fn encode(
2538            self,
2539            encoder: &mut fidl::encoding::Encoder<'_, D>,
2540            offset: usize,
2541            _depth: fidl::encoding::Depth,
2542        ) -> fidl::Result<()> {
2543            encoder.debug_check_bounds::<BoundInterface>(offset);
2544            encoder.write_num::<u64>(self.ordinal(), offset);
2545            match self {
2546                BoundInterface::Bound(ref val) => {
2547                    fidl::encoding::encode_in_envelope::<Interface, D>(
2548                        <Interface as fidl::encoding::ValueTypeMarker>::borrow(val),
2549                        encoder,
2550                        offset + 8,
2551                        _depth,
2552                    )
2553                }
2554                BoundInterface::Unbound(ref val) => {
2555                    fidl::encoding::encode_in_envelope::<Unbound, D>(
2556                        <Unbound as fidl::encoding::ValueTypeMarker>::borrow(val),
2557                        encoder,
2558                        offset + 8,
2559                        _depth,
2560                    )
2561                }
2562                BoundInterface::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2563            }
2564        }
2565    }
2566
2567    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BoundInterface {
2568        #[inline(always)]
2569        fn new_empty() -> Self {
2570            Self::__SourceBreaking { unknown_ordinal: 0 }
2571        }
2572
2573        #[inline]
2574        unsafe fn decode(
2575            &mut self,
2576            decoder: &mut fidl::encoding::Decoder<'_, D>,
2577            offset: usize,
2578            mut depth: fidl::encoding::Depth,
2579        ) -> fidl::Result<()> {
2580            decoder.debug_check_bounds::<Self>(offset);
2581            #[allow(unused_variables)]
2582            let next_out_of_line = decoder.next_out_of_line();
2583            let handles_before = decoder.remaining_handles();
2584            let (ordinal, inlined, num_bytes, num_handles) =
2585                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2586
2587            let member_inline_size = match ordinal {
2588                1 => <Interface as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2589                2 => <Unbound as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2590                0 => return Err(fidl::Error::UnknownUnionTag),
2591                _ => num_bytes as usize,
2592            };
2593
2594            if inlined != (member_inline_size <= 4) {
2595                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2596            }
2597            let _inner_offset;
2598            if inlined {
2599                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2600                _inner_offset = offset + 8;
2601            } else {
2602                depth.increment()?;
2603                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2604            }
2605            match ordinal {
2606                1 => {
2607                    #[allow(irrefutable_let_patterns)]
2608                    if let BoundInterface::Bound(_) = self {
2609                        // Do nothing, read the value into the object
2610                    } else {
2611                        // Initialize `self` to the right variant
2612                        *self = BoundInterface::Bound(fidl::new_empty!(Interface, D));
2613                    }
2614                    #[allow(irrefutable_let_patterns)]
2615                    if let BoundInterface::Bound(ref mut val) = self {
2616                        fidl::decode!(Interface, D, val, decoder, _inner_offset, depth)?;
2617                    } else {
2618                        unreachable!()
2619                    }
2620                }
2621                2 => {
2622                    #[allow(irrefutable_let_patterns)]
2623                    if let BoundInterface::Unbound(_) = self {
2624                        // Do nothing, read the value into the object
2625                    } else {
2626                        // Initialize `self` to the right variant
2627                        *self = BoundInterface::Unbound(fidl::new_empty!(Unbound, D));
2628                    }
2629                    #[allow(irrefutable_let_patterns)]
2630                    if let BoundInterface::Unbound(ref mut val) = self {
2631                        fidl::decode!(Unbound, D, val, decoder, _inner_offset, depth)?;
2632                    } else {
2633                        unreachable!()
2634                    }
2635                }
2636                #[allow(deprecated)]
2637                ordinal => {
2638                    for _ in 0..num_handles {
2639                        decoder.drop_next_handle()?;
2640                    }
2641                    *self = BoundInterface::__SourceBreaking { unknown_ordinal: ordinal };
2642                }
2643            }
2644            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2645                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2646            }
2647            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2648                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2649            }
2650            Ok(())
2651        }
2652    }
2653
2654    impl fidl::encoding::ValueTypeMarker for Interface {
2655        type Borrowed<'a> = &'a Self;
2656        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2657            value
2658        }
2659    }
2660
2661    unsafe impl fidl::encoding::TypeMarker for Interface {
2662        type Owned = Self;
2663
2664        #[inline(always)]
2665        fn inline_align(_context: fidl::encoding::Context) -> usize {
2666            8
2667        }
2668
2669        #[inline(always)]
2670        fn inline_size(_context: fidl::encoding::Context) -> usize {
2671            16
2672        }
2673    }
2674
2675    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Interface, D>
2676        for &Interface
2677    {
2678        #[inline]
2679        unsafe fn encode(
2680            self,
2681            encoder: &mut fidl::encoding::Encoder<'_, D>,
2682            offset: usize,
2683            _depth: fidl::encoding::Depth,
2684        ) -> fidl::Result<()> {
2685            encoder.debug_check_bounds::<Interface>(offset);
2686            encoder.write_num::<u64>(self.ordinal(), offset);
2687            match self {
2688            Interface::Id(ref val) => {
2689                fidl::encoding::encode_in_envelope::<u64, D>(
2690                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(val),
2691                    encoder, offset + 8, _depth
2692                )
2693            }
2694            Interface::Name(ref val) => {
2695                fidl::encoding::encode_in_envelope::<fidl::encoding::BoundedString<15>, D>(
2696                    <fidl::encoding::BoundedString<15> as fidl::encoding::ValueTypeMarker>::borrow(val),
2697                    encoder, offset + 8, _depth
2698                )
2699            }
2700            Interface::PortClass(ref val) => {
2701                fidl::encoding::encode_in_envelope::<fidl_fuchsia_net_interfaces__common::PortClass, D>(
2702                    <fidl_fuchsia_net_interfaces__common::PortClass as fidl::encoding::ValueTypeMarker>::borrow(val),
2703                    encoder, offset + 8, _depth
2704                )
2705            }
2706            Interface::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2707        }
2708        }
2709    }
2710
2711    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Interface {
2712        #[inline(always)]
2713        fn new_empty() -> Self {
2714            Self::__SourceBreaking { unknown_ordinal: 0 }
2715        }
2716
2717        #[inline]
2718        unsafe fn decode(
2719            &mut self,
2720            decoder: &mut fidl::encoding::Decoder<'_, D>,
2721            offset: usize,
2722            mut depth: fidl::encoding::Depth,
2723        ) -> fidl::Result<()> {
2724            decoder.debug_check_bounds::<Self>(offset);
2725            #[allow(unused_variables)]
2726            let next_out_of_line = decoder.next_out_of_line();
2727            let handles_before = decoder.remaining_handles();
2728            let (ordinal, inlined, num_bytes, num_handles) =
2729                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2730
2731            let member_inline_size = match ordinal {
2732            1 => <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2733            2 => <fidl::encoding::BoundedString<15> as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2734            3 => <fidl_fuchsia_net_interfaces__common::PortClass as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2735            0 => return Err(fidl::Error::UnknownUnionTag),
2736            _ => num_bytes as usize,
2737        };
2738
2739            if inlined != (member_inline_size <= 4) {
2740                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2741            }
2742            let _inner_offset;
2743            if inlined {
2744                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2745                _inner_offset = offset + 8;
2746            } else {
2747                depth.increment()?;
2748                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2749            }
2750            match ordinal {
2751                1 => {
2752                    #[allow(irrefutable_let_patterns)]
2753                    if let Interface::Id(_) = self {
2754                        // Do nothing, read the value into the object
2755                    } else {
2756                        // Initialize `self` to the right variant
2757                        *self = Interface::Id(fidl::new_empty!(u64, D));
2758                    }
2759                    #[allow(irrefutable_let_patterns)]
2760                    if let Interface::Id(ref mut val) = self {
2761                        fidl::decode!(u64, D, val, decoder, _inner_offset, depth)?;
2762                    } else {
2763                        unreachable!()
2764                    }
2765                }
2766                2 => {
2767                    #[allow(irrefutable_let_patterns)]
2768                    if let Interface::Name(_) = self {
2769                        // Do nothing, read the value into the object
2770                    } else {
2771                        // Initialize `self` to the right variant
2772                        *self =
2773                            Interface::Name(fidl::new_empty!(fidl::encoding::BoundedString<15>, D));
2774                    }
2775                    #[allow(irrefutable_let_patterns)]
2776                    if let Interface::Name(ref mut val) = self {
2777                        fidl::decode!(
2778                            fidl::encoding::BoundedString<15>,
2779                            D,
2780                            val,
2781                            decoder,
2782                            _inner_offset,
2783                            depth
2784                        )?;
2785                    } else {
2786                        unreachable!()
2787                    }
2788                }
2789                3 => {
2790                    #[allow(irrefutable_let_patterns)]
2791                    if let Interface::PortClass(_) = self {
2792                        // Do nothing, read the value into the object
2793                    } else {
2794                        // Initialize `self` to the right variant
2795                        *self = Interface::PortClass(fidl::new_empty!(
2796                            fidl_fuchsia_net_interfaces__common::PortClass,
2797                            D
2798                        ));
2799                    }
2800                    #[allow(irrefutable_let_patterns)]
2801                    if let Interface::PortClass(ref mut val) = self {
2802                        fidl::decode!(
2803                            fidl_fuchsia_net_interfaces__common::PortClass,
2804                            D,
2805                            val,
2806                            decoder,
2807                            _inner_offset,
2808                            depth
2809                        )?;
2810                    } else {
2811                        unreachable!()
2812                    }
2813                }
2814                #[allow(deprecated)]
2815                ordinal => {
2816                    for _ in 0..num_handles {
2817                        decoder.drop_next_handle()?;
2818                    }
2819                    *self = Interface::__SourceBreaking { unknown_ordinal: ordinal };
2820                }
2821            }
2822            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2823                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2824            }
2825            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2826                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2827            }
2828            Ok(())
2829        }
2830    }
2831
2832    impl fidl::encoding::ValueTypeMarker for Mark {
2833        type Borrowed<'a> = &'a Self;
2834        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2835            value
2836        }
2837    }
2838
2839    unsafe impl fidl::encoding::TypeMarker for Mark {
2840        type Owned = Self;
2841
2842        #[inline(always)]
2843        fn inline_align(_context: fidl::encoding::Context) -> usize {
2844            8
2845        }
2846
2847        #[inline(always)]
2848        fn inline_size(_context: fidl::encoding::Context) -> usize {
2849            16
2850        }
2851    }
2852
2853    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Mark, D> for &Mark {
2854        #[inline]
2855        unsafe fn encode(
2856            self,
2857            encoder: &mut fidl::encoding::Encoder<'_, D>,
2858            offset: usize,
2859            _depth: fidl::encoding::Depth,
2860        ) -> fidl::Result<()> {
2861            encoder.debug_check_bounds::<Mark>(offset);
2862            encoder.write_num::<u64>(self.ordinal(), offset);
2863            match self {
2864                Mark::Unmarked(ref val) => fidl::encoding::encode_in_envelope::<Unmarked, D>(
2865                    <Unmarked as fidl::encoding::ValueTypeMarker>::borrow(val),
2866                    encoder,
2867                    offset + 8,
2868                    _depth,
2869                ),
2870                Mark::Marked(ref val) => fidl::encoding::encode_in_envelope::<Marked, D>(
2871                    <Marked as fidl::encoding::ValueTypeMarker>::borrow(val),
2872                    encoder,
2873                    offset + 8,
2874                    _depth,
2875                ),
2876                Mark::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2877            }
2878        }
2879    }
2880
2881    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Mark {
2882        #[inline(always)]
2883        fn new_empty() -> Self {
2884            Self::__SourceBreaking { unknown_ordinal: 0 }
2885        }
2886
2887        #[inline]
2888        unsafe fn decode(
2889            &mut self,
2890            decoder: &mut fidl::encoding::Decoder<'_, D>,
2891            offset: usize,
2892            mut depth: fidl::encoding::Depth,
2893        ) -> fidl::Result<()> {
2894            decoder.debug_check_bounds::<Self>(offset);
2895            #[allow(unused_variables)]
2896            let next_out_of_line = decoder.next_out_of_line();
2897            let handles_before = decoder.remaining_handles();
2898            let (ordinal, inlined, num_bytes, num_handles) =
2899                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2900
2901            let member_inline_size = match ordinal {
2902                1 => <Unmarked as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2903                2 => <Marked as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2904                0 => return Err(fidl::Error::UnknownUnionTag),
2905                _ => num_bytes as usize,
2906            };
2907
2908            if inlined != (member_inline_size <= 4) {
2909                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2910            }
2911            let _inner_offset;
2912            if inlined {
2913                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2914                _inner_offset = offset + 8;
2915            } else {
2916                depth.increment()?;
2917                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2918            }
2919            match ordinal {
2920                1 => {
2921                    #[allow(irrefutable_let_patterns)]
2922                    if let Mark::Unmarked(_) = self {
2923                        // Do nothing, read the value into the object
2924                    } else {
2925                        // Initialize `self` to the right variant
2926                        *self = Mark::Unmarked(fidl::new_empty!(Unmarked, D));
2927                    }
2928                    #[allow(irrefutable_let_patterns)]
2929                    if let Mark::Unmarked(ref mut val) = self {
2930                        fidl::decode!(Unmarked, D, val, decoder, _inner_offset, depth)?;
2931                    } else {
2932                        unreachable!()
2933                    }
2934                }
2935                2 => {
2936                    #[allow(irrefutable_let_patterns)]
2937                    if let Mark::Marked(_) = self {
2938                        // Do nothing, read the value into the object
2939                    } else {
2940                        // Initialize `self` to the right variant
2941                        *self = Mark::Marked(fidl::new_empty!(Marked, D));
2942                    }
2943                    #[allow(irrefutable_let_patterns)]
2944                    if let Mark::Marked(ref mut val) = self {
2945                        fidl::decode!(Marked, D, val, decoder, _inner_offset, depth)?;
2946                    } else {
2947                        unreachable!()
2948                    }
2949                }
2950                #[allow(deprecated)]
2951                ordinal => {
2952                    for _ in 0..num_handles {
2953                        decoder.drop_next_handle()?;
2954                    }
2955                    *self = Mark::__SourceBreaking { unknown_ordinal: ordinal };
2956                }
2957            }
2958            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2959                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2960            }
2961            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2962                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2963            }
2964            Ok(())
2965        }
2966    }
2967
2968    impl fidl::encoding::ValueTypeMarker for PacketTransportProtocol {
2969        type Borrowed<'a> = &'a Self;
2970        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2971            value
2972        }
2973    }
2974
2975    unsafe impl fidl::encoding::TypeMarker for PacketTransportProtocol {
2976        type Owned = Self;
2977
2978        #[inline(always)]
2979        fn inline_align(_context: fidl::encoding::Context) -> usize {
2980            8
2981        }
2982
2983        #[inline(always)]
2984        fn inline_size(_context: fidl::encoding::Context) -> usize {
2985            16
2986        }
2987    }
2988
2989    unsafe impl<D: fidl::encoding::ResourceDialect>
2990        fidl::encoding::Encode<PacketTransportProtocol, D> for &PacketTransportProtocol
2991    {
2992        #[inline]
2993        unsafe fn encode(
2994            self,
2995            encoder: &mut fidl::encoding::Encoder<'_, D>,
2996            offset: usize,
2997            _depth: fidl::encoding::Depth,
2998        ) -> fidl::Result<()> {
2999            encoder.debug_check_bounds::<PacketTransportProtocol>(offset);
3000            encoder.write_num::<u64>(self.ordinal(), offset);
3001            match self {
3002                PacketTransportProtocol::Tcp(ref val) => {
3003                    fidl::encoding::encode_in_envelope::<TcpPacket, D>(
3004                        <TcpPacket as fidl::encoding::ValueTypeMarker>::borrow(val),
3005                        encoder,
3006                        offset + 8,
3007                        _depth,
3008                    )
3009                }
3010                PacketTransportProtocol::Udp(ref val) => {
3011                    fidl::encoding::encode_in_envelope::<UdpPacket, D>(
3012                        <UdpPacket as fidl::encoding::ValueTypeMarker>::borrow(val),
3013                        encoder,
3014                        offset + 8,
3015                        _depth,
3016                    )
3017                }
3018                PacketTransportProtocol::Icmp(ref val) => {
3019                    fidl::encoding::encode_in_envelope::<IcmpPacket, D>(
3020                        <IcmpPacket as fidl::encoding::ValueTypeMarker>::borrow(val),
3021                        encoder,
3022                        offset + 8,
3023                        _depth,
3024                    )
3025                }
3026                PacketTransportProtocol::Icmpv6(ref val) => {
3027                    fidl::encoding::encode_in_envelope::<Icmpv6Packet, D>(
3028                        <Icmpv6Packet as fidl::encoding::ValueTypeMarker>::borrow(val),
3029                        encoder,
3030                        offset + 8,
3031                        _depth,
3032                    )
3033                }
3034                PacketTransportProtocol::__SourceBreaking { .. } => {
3035                    Err(fidl::Error::UnknownUnionTag)
3036                }
3037            }
3038        }
3039    }
3040
3041    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3042        for PacketTransportProtocol
3043    {
3044        #[inline(always)]
3045        fn new_empty() -> Self {
3046            Self::__SourceBreaking { unknown_ordinal: 0 }
3047        }
3048
3049        #[inline]
3050        unsafe fn decode(
3051            &mut self,
3052            decoder: &mut fidl::encoding::Decoder<'_, D>,
3053            offset: usize,
3054            mut depth: fidl::encoding::Depth,
3055        ) -> fidl::Result<()> {
3056            decoder.debug_check_bounds::<Self>(offset);
3057            #[allow(unused_variables)]
3058            let next_out_of_line = decoder.next_out_of_line();
3059            let handles_before = decoder.remaining_handles();
3060            let (ordinal, inlined, num_bytes, num_handles) =
3061                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
3062
3063            let member_inline_size = match ordinal {
3064                1 => <TcpPacket as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3065                2 => <UdpPacket as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3066                3 => <IcmpPacket as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3067                4 => <Icmpv6Packet as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3068                0 => return Err(fidl::Error::UnknownUnionTag),
3069                _ => num_bytes as usize,
3070            };
3071
3072            if inlined != (member_inline_size <= 4) {
3073                return Err(fidl::Error::InvalidInlineBitInEnvelope);
3074            }
3075            let _inner_offset;
3076            if inlined {
3077                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
3078                _inner_offset = offset + 8;
3079            } else {
3080                depth.increment()?;
3081                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3082            }
3083            match ordinal {
3084                1 => {
3085                    #[allow(irrefutable_let_patterns)]
3086                    if let PacketTransportProtocol::Tcp(_) = self {
3087                        // Do nothing, read the value into the object
3088                    } else {
3089                        // Initialize `self` to the right variant
3090                        *self = PacketTransportProtocol::Tcp(fidl::new_empty!(TcpPacket, D));
3091                    }
3092                    #[allow(irrefutable_let_patterns)]
3093                    if let PacketTransportProtocol::Tcp(ref mut val) = self {
3094                        fidl::decode!(TcpPacket, D, val, decoder, _inner_offset, depth)?;
3095                    } else {
3096                        unreachable!()
3097                    }
3098                }
3099                2 => {
3100                    #[allow(irrefutable_let_patterns)]
3101                    if let PacketTransportProtocol::Udp(_) = self {
3102                        // Do nothing, read the value into the object
3103                    } else {
3104                        // Initialize `self` to the right variant
3105                        *self = PacketTransportProtocol::Udp(fidl::new_empty!(UdpPacket, D));
3106                    }
3107                    #[allow(irrefutable_let_patterns)]
3108                    if let PacketTransportProtocol::Udp(ref mut val) = self {
3109                        fidl::decode!(UdpPacket, D, val, decoder, _inner_offset, depth)?;
3110                    } else {
3111                        unreachable!()
3112                    }
3113                }
3114                3 => {
3115                    #[allow(irrefutable_let_patterns)]
3116                    if let PacketTransportProtocol::Icmp(_) = self {
3117                        // Do nothing, read the value into the object
3118                    } else {
3119                        // Initialize `self` to the right variant
3120                        *self = PacketTransportProtocol::Icmp(fidl::new_empty!(IcmpPacket, D));
3121                    }
3122                    #[allow(irrefutable_let_patterns)]
3123                    if let PacketTransportProtocol::Icmp(ref mut val) = self {
3124                        fidl::decode!(IcmpPacket, D, val, decoder, _inner_offset, depth)?;
3125                    } else {
3126                        unreachable!()
3127                    }
3128                }
3129                4 => {
3130                    #[allow(irrefutable_let_patterns)]
3131                    if let PacketTransportProtocol::Icmpv6(_) = self {
3132                        // Do nothing, read the value into the object
3133                    } else {
3134                        // Initialize `self` to the right variant
3135                        *self = PacketTransportProtocol::Icmpv6(fidl::new_empty!(Icmpv6Packet, D));
3136                    }
3137                    #[allow(irrefutable_let_patterns)]
3138                    if let PacketTransportProtocol::Icmpv6(ref mut val) = self {
3139                        fidl::decode!(Icmpv6Packet, D, val, decoder, _inner_offset, depth)?;
3140                    } else {
3141                        unreachable!()
3142                    }
3143                }
3144                #[allow(deprecated)]
3145                ordinal => {
3146                    for _ in 0..num_handles {
3147                        decoder.drop_next_handle()?;
3148                    }
3149                    *self = PacketTransportProtocol::__SourceBreaking { unknown_ordinal: ordinal };
3150                }
3151            }
3152            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
3153                return Err(fidl::Error::InvalidNumBytesInEnvelope);
3154            }
3155            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3156                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3157            }
3158            Ok(())
3159        }
3160    }
3161
3162    impl fidl::encoding::ValueTypeMarker for SocketTransportProtocol {
3163        type Borrowed<'a> = &'a Self;
3164        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3165            value
3166        }
3167    }
3168
3169    unsafe impl fidl::encoding::TypeMarker for SocketTransportProtocol {
3170        type Owned = Self;
3171
3172        #[inline(always)]
3173        fn inline_align(_context: fidl::encoding::Context) -> usize {
3174            8
3175        }
3176
3177        #[inline(always)]
3178        fn inline_size(_context: fidl::encoding::Context) -> usize {
3179            16
3180        }
3181    }
3182
3183    unsafe impl<D: fidl::encoding::ResourceDialect>
3184        fidl::encoding::Encode<SocketTransportProtocol, D> for &SocketTransportProtocol
3185    {
3186        #[inline]
3187        unsafe fn encode(
3188            self,
3189            encoder: &mut fidl::encoding::Encoder<'_, D>,
3190            offset: usize,
3191            _depth: fidl::encoding::Depth,
3192        ) -> fidl::Result<()> {
3193            encoder.debug_check_bounds::<SocketTransportProtocol>(offset);
3194            encoder.write_num::<u64>(self.ordinal(), offset);
3195            match self {
3196                SocketTransportProtocol::Tcp(ref val) => {
3197                    fidl::encoding::encode_in_envelope::<TcpSocket, D>(
3198                        <TcpSocket as fidl::encoding::ValueTypeMarker>::borrow(val),
3199                        encoder,
3200                        offset + 8,
3201                        _depth,
3202                    )
3203                }
3204                SocketTransportProtocol::Udp(ref val) => {
3205                    fidl::encoding::encode_in_envelope::<UdpSocket, D>(
3206                        <UdpSocket as fidl::encoding::ValueTypeMarker>::borrow(val),
3207                        encoder,
3208                        offset + 8,
3209                        _depth,
3210                    )
3211                }
3212                SocketTransportProtocol::__SourceBreaking { .. } => {
3213                    Err(fidl::Error::UnknownUnionTag)
3214                }
3215            }
3216        }
3217    }
3218
3219    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
3220        for SocketTransportProtocol
3221    {
3222        #[inline(always)]
3223        fn new_empty() -> Self {
3224            Self::__SourceBreaking { unknown_ordinal: 0 }
3225        }
3226
3227        #[inline]
3228        unsafe fn decode(
3229            &mut self,
3230            decoder: &mut fidl::encoding::Decoder<'_, D>,
3231            offset: usize,
3232            mut depth: fidl::encoding::Depth,
3233        ) -> fidl::Result<()> {
3234            decoder.debug_check_bounds::<Self>(offset);
3235            #[allow(unused_variables)]
3236            let next_out_of_line = decoder.next_out_of_line();
3237            let handles_before = decoder.remaining_handles();
3238            let (ordinal, inlined, num_bytes, num_handles) =
3239                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
3240
3241            let member_inline_size = match ordinal {
3242                1 => <TcpSocket as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3243                2 => <UdpSocket as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3244                0 => return Err(fidl::Error::UnknownUnionTag),
3245                _ => num_bytes as usize,
3246            };
3247
3248            if inlined != (member_inline_size <= 4) {
3249                return Err(fidl::Error::InvalidInlineBitInEnvelope);
3250            }
3251            let _inner_offset;
3252            if inlined {
3253                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
3254                _inner_offset = offset + 8;
3255            } else {
3256                depth.increment()?;
3257                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3258            }
3259            match ordinal {
3260                1 => {
3261                    #[allow(irrefutable_let_patterns)]
3262                    if let SocketTransportProtocol::Tcp(_) = self {
3263                        // Do nothing, read the value into the object
3264                    } else {
3265                        // Initialize `self` to the right variant
3266                        *self = SocketTransportProtocol::Tcp(fidl::new_empty!(TcpSocket, D));
3267                    }
3268                    #[allow(irrefutable_let_patterns)]
3269                    if let SocketTransportProtocol::Tcp(ref mut val) = self {
3270                        fidl::decode!(TcpSocket, D, val, decoder, _inner_offset, depth)?;
3271                    } else {
3272                        unreachable!()
3273                    }
3274                }
3275                2 => {
3276                    #[allow(irrefutable_let_patterns)]
3277                    if let SocketTransportProtocol::Udp(_) = self {
3278                        // Do nothing, read the value into the object
3279                    } else {
3280                        // Initialize `self` to the right variant
3281                        *self = SocketTransportProtocol::Udp(fidl::new_empty!(UdpSocket, D));
3282                    }
3283                    #[allow(irrefutable_let_patterns)]
3284                    if let SocketTransportProtocol::Udp(ref mut val) = self {
3285                        fidl::decode!(UdpSocket, D, val, decoder, _inner_offset, depth)?;
3286                    } else {
3287                        unreachable!()
3288                    }
3289                }
3290                #[allow(deprecated)]
3291                ordinal => {
3292                    for _ in 0..num_handles {
3293                        decoder.drop_next_handle()?;
3294                    }
3295                    *self = SocketTransportProtocol::__SourceBreaking { unknown_ordinal: ordinal };
3296                }
3297            }
3298            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
3299                return Err(fidl::Error::InvalidNumBytesInEnvelope);
3300            }
3301            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3302                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3303            }
3304            Ok(())
3305        }
3306    }
3307
3308    impl fidl::encoding::ValueTypeMarker for TcpSocket {
3309        type Borrowed<'a> = &'a Self;
3310        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3311            value
3312        }
3313    }
3314
3315    unsafe impl fidl::encoding::TypeMarker for TcpSocket {
3316        type Owned = Self;
3317
3318        #[inline(always)]
3319        fn inline_align(_context: fidl::encoding::Context) -> usize {
3320            8
3321        }
3322
3323        #[inline(always)]
3324        fn inline_size(_context: fidl::encoding::Context) -> usize {
3325            16
3326        }
3327    }
3328
3329    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<TcpSocket, D>
3330        for &TcpSocket
3331    {
3332        #[inline]
3333        unsafe fn encode(
3334            self,
3335            encoder: &mut fidl::encoding::Encoder<'_, D>,
3336            offset: usize,
3337            _depth: fidl::encoding::Depth,
3338        ) -> fidl::Result<()> {
3339            encoder.debug_check_bounds::<TcpSocket>(offset);
3340            encoder.write_num::<u64>(self.ordinal(), offset);
3341            match self {
3342                TcpSocket::Empty(ref val) => fidl::encoding::encode_in_envelope::<Empty, D>(
3343                    <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
3344                    encoder,
3345                    offset + 8,
3346                    _depth,
3347                ),
3348                TcpSocket::SrcPort(ref val) => fidl::encoding::encode_in_envelope::<Port, D>(
3349                    <Port as fidl::encoding::ValueTypeMarker>::borrow(val),
3350                    encoder,
3351                    offset + 8,
3352                    _depth,
3353                ),
3354                TcpSocket::DstPort(ref val) => fidl::encoding::encode_in_envelope::<Port, D>(
3355                    <Port as fidl::encoding::ValueTypeMarker>::borrow(val),
3356                    encoder,
3357                    offset + 8,
3358                    _depth,
3359                ),
3360                TcpSocket::States(ref val) => fidl::encoding::encode_in_envelope::<TcpState, D>(
3361                    <TcpState as fidl::encoding::ValueTypeMarker>::borrow(val),
3362                    encoder,
3363                    offset + 8,
3364                    _depth,
3365                ),
3366                TcpSocket::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
3367            }
3368        }
3369    }
3370
3371    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TcpSocket {
3372        #[inline(always)]
3373        fn new_empty() -> Self {
3374            Self::__SourceBreaking { unknown_ordinal: 0 }
3375        }
3376
3377        #[inline]
3378        unsafe fn decode(
3379            &mut self,
3380            decoder: &mut fidl::encoding::Decoder<'_, D>,
3381            offset: usize,
3382            mut depth: fidl::encoding::Depth,
3383        ) -> fidl::Result<()> {
3384            decoder.debug_check_bounds::<Self>(offset);
3385            #[allow(unused_variables)]
3386            let next_out_of_line = decoder.next_out_of_line();
3387            let handles_before = decoder.remaining_handles();
3388            let (ordinal, inlined, num_bytes, num_handles) =
3389                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
3390
3391            let member_inline_size = match ordinal {
3392                1 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3393                2 => <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3394                3 => <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3395                4 => <TcpState as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3396                0 => return Err(fidl::Error::UnknownUnionTag),
3397                _ => num_bytes as usize,
3398            };
3399
3400            if inlined != (member_inline_size <= 4) {
3401                return Err(fidl::Error::InvalidInlineBitInEnvelope);
3402            }
3403            let _inner_offset;
3404            if inlined {
3405                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
3406                _inner_offset = offset + 8;
3407            } else {
3408                depth.increment()?;
3409                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3410            }
3411            match ordinal {
3412                1 => {
3413                    #[allow(irrefutable_let_patterns)]
3414                    if let TcpSocket::Empty(_) = self {
3415                        // Do nothing, read the value into the object
3416                    } else {
3417                        // Initialize `self` to the right variant
3418                        *self = TcpSocket::Empty(fidl::new_empty!(Empty, D));
3419                    }
3420                    #[allow(irrefutable_let_patterns)]
3421                    if let TcpSocket::Empty(ref mut val) = self {
3422                        fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
3423                    } else {
3424                        unreachable!()
3425                    }
3426                }
3427                2 => {
3428                    #[allow(irrefutable_let_patterns)]
3429                    if let TcpSocket::SrcPort(_) = self {
3430                        // Do nothing, read the value into the object
3431                    } else {
3432                        // Initialize `self` to the right variant
3433                        *self = TcpSocket::SrcPort(fidl::new_empty!(Port, D));
3434                    }
3435                    #[allow(irrefutable_let_patterns)]
3436                    if let TcpSocket::SrcPort(ref mut val) = self {
3437                        fidl::decode!(Port, D, val, decoder, _inner_offset, depth)?;
3438                    } else {
3439                        unreachable!()
3440                    }
3441                }
3442                3 => {
3443                    #[allow(irrefutable_let_patterns)]
3444                    if let TcpSocket::DstPort(_) = self {
3445                        // Do nothing, read the value into the object
3446                    } else {
3447                        // Initialize `self` to the right variant
3448                        *self = TcpSocket::DstPort(fidl::new_empty!(Port, D));
3449                    }
3450                    #[allow(irrefutable_let_patterns)]
3451                    if let TcpSocket::DstPort(ref mut val) = self {
3452                        fidl::decode!(Port, D, val, decoder, _inner_offset, depth)?;
3453                    } else {
3454                        unreachable!()
3455                    }
3456                }
3457                4 => {
3458                    #[allow(irrefutable_let_patterns)]
3459                    if let TcpSocket::States(_) = self {
3460                        // Do nothing, read the value into the object
3461                    } else {
3462                        // Initialize `self` to the right variant
3463                        *self = TcpSocket::States(fidl::new_empty!(TcpState, D));
3464                    }
3465                    #[allow(irrefutable_let_patterns)]
3466                    if let TcpSocket::States(ref mut val) = self {
3467                        fidl::decode!(TcpState, D, val, decoder, _inner_offset, depth)?;
3468                    } else {
3469                        unreachable!()
3470                    }
3471                }
3472                #[allow(deprecated)]
3473                ordinal => {
3474                    for _ in 0..num_handles {
3475                        decoder.drop_next_handle()?;
3476                    }
3477                    *self = TcpSocket::__SourceBreaking { unknown_ordinal: ordinal };
3478                }
3479            }
3480            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
3481                return Err(fidl::Error::InvalidNumBytesInEnvelope);
3482            }
3483            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3484                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3485            }
3486            Ok(())
3487        }
3488    }
3489
3490    impl fidl::encoding::ValueTypeMarker for UdpSocket {
3491        type Borrowed<'a> = &'a Self;
3492        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3493            value
3494        }
3495    }
3496
3497    unsafe impl fidl::encoding::TypeMarker for UdpSocket {
3498        type Owned = Self;
3499
3500        #[inline(always)]
3501        fn inline_align(_context: fidl::encoding::Context) -> usize {
3502            8
3503        }
3504
3505        #[inline(always)]
3506        fn inline_size(_context: fidl::encoding::Context) -> usize {
3507            16
3508        }
3509    }
3510
3511    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<UdpSocket, D>
3512        for &UdpSocket
3513    {
3514        #[inline]
3515        unsafe fn encode(
3516            self,
3517            encoder: &mut fidl::encoding::Encoder<'_, D>,
3518            offset: usize,
3519            _depth: fidl::encoding::Depth,
3520        ) -> fidl::Result<()> {
3521            encoder.debug_check_bounds::<UdpSocket>(offset);
3522            encoder.write_num::<u64>(self.ordinal(), offset);
3523            match self {
3524                UdpSocket::Empty(ref val) => fidl::encoding::encode_in_envelope::<Empty, D>(
3525                    <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
3526                    encoder,
3527                    offset + 8,
3528                    _depth,
3529                ),
3530                UdpSocket::SrcPort(ref val) => fidl::encoding::encode_in_envelope::<Port, D>(
3531                    <Port as fidl::encoding::ValueTypeMarker>::borrow(val),
3532                    encoder,
3533                    offset + 8,
3534                    _depth,
3535                ),
3536                UdpSocket::DstPort(ref val) => fidl::encoding::encode_in_envelope::<Port, D>(
3537                    <Port as fidl::encoding::ValueTypeMarker>::borrow(val),
3538                    encoder,
3539                    offset + 8,
3540                    _depth,
3541                ),
3542                UdpSocket::States(ref val) => fidl::encoding::encode_in_envelope::<UdpState, D>(
3543                    <UdpState as fidl::encoding::ValueTypeMarker>::borrow(val),
3544                    encoder,
3545                    offset + 8,
3546                    _depth,
3547                ),
3548                UdpSocket::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
3549            }
3550        }
3551    }
3552
3553    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for UdpSocket {
3554        #[inline(always)]
3555        fn new_empty() -> Self {
3556            Self::__SourceBreaking { unknown_ordinal: 0 }
3557        }
3558
3559        #[inline]
3560        unsafe fn decode(
3561            &mut self,
3562            decoder: &mut fidl::encoding::Decoder<'_, D>,
3563            offset: usize,
3564            mut depth: fidl::encoding::Depth,
3565        ) -> fidl::Result<()> {
3566            decoder.debug_check_bounds::<Self>(offset);
3567            #[allow(unused_variables)]
3568            let next_out_of_line = decoder.next_out_of_line();
3569            let handles_before = decoder.remaining_handles();
3570            let (ordinal, inlined, num_bytes, num_handles) =
3571                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
3572
3573            let member_inline_size = match ordinal {
3574                1 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3575                2 => <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3576                3 => <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3577                4 => <UdpState as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3578                0 => return Err(fidl::Error::UnknownUnionTag),
3579                _ => num_bytes as usize,
3580            };
3581
3582            if inlined != (member_inline_size <= 4) {
3583                return Err(fidl::Error::InvalidInlineBitInEnvelope);
3584            }
3585            let _inner_offset;
3586            if inlined {
3587                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
3588                _inner_offset = offset + 8;
3589            } else {
3590                depth.increment()?;
3591                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3592            }
3593            match ordinal {
3594                1 => {
3595                    #[allow(irrefutable_let_patterns)]
3596                    if let UdpSocket::Empty(_) = self {
3597                        // Do nothing, read the value into the object
3598                    } else {
3599                        // Initialize `self` to the right variant
3600                        *self = UdpSocket::Empty(fidl::new_empty!(Empty, D));
3601                    }
3602                    #[allow(irrefutable_let_patterns)]
3603                    if let UdpSocket::Empty(ref mut val) = self {
3604                        fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
3605                    } else {
3606                        unreachable!()
3607                    }
3608                }
3609                2 => {
3610                    #[allow(irrefutable_let_patterns)]
3611                    if let UdpSocket::SrcPort(_) = self {
3612                        // Do nothing, read the value into the object
3613                    } else {
3614                        // Initialize `self` to the right variant
3615                        *self = UdpSocket::SrcPort(fidl::new_empty!(Port, D));
3616                    }
3617                    #[allow(irrefutable_let_patterns)]
3618                    if let UdpSocket::SrcPort(ref mut val) = self {
3619                        fidl::decode!(Port, D, val, decoder, _inner_offset, depth)?;
3620                    } else {
3621                        unreachable!()
3622                    }
3623                }
3624                3 => {
3625                    #[allow(irrefutable_let_patterns)]
3626                    if let UdpSocket::DstPort(_) = self {
3627                        // Do nothing, read the value into the object
3628                    } else {
3629                        // Initialize `self` to the right variant
3630                        *self = UdpSocket::DstPort(fidl::new_empty!(Port, D));
3631                    }
3632                    #[allow(irrefutable_let_patterns)]
3633                    if let UdpSocket::DstPort(ref mut val) = self {
3634                        fidl::decode!(Port, D, val, decoder, _inner_offset, depth)?;
3635                    } else {
3636                        unreachable!()
3637                    }
3638                }
3639                4 => {
3640                    #[allow(irrefutable_let_patterns)]
3641                    if let UdpSocket::States(_) = self {
3642                        // Do nothing, read the value into the object
3643                    } else {
3644                        // Initialize `self` to the right variant
3645                        *self = UdpSocket::States(fidl::new_empty!(UdpState, D));
3646                    }
3647                    #[allow(irrefutable_let_patterns)]
3648                    if let UdpSocket::States(ref mut val) = self {
3649                        fidl::decode!(UdpState, D, val, decoder, _inner_offset, depth)?;
3650                    } else {
3651                        unreachable!()
3652                    }
3653                }
3654                #[allow(deprecated)]
3655                ordinal => {
3656                    for _ in 0..num_handles {
3657                        decoder.drop_next_handle()?;
3658                    }
3659                    *self = UdpSocket::__SourceBreaking { unknown_ordinal: ordinal };
3660                }
3661            }
3662            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
3663                return Err(fidl::Error::InvalidNumBytesInEnvelope);
3664            }
3665            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3666                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3667            }
3668            Ok(())
3669        }
3670    }
3671}