fidl_fuchsia_net_sockets__common/
fidl_fuchsia_net_sockets__common.rs

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