Skip to main content

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