fidl_fuchsia_net_virtualization__common/
fidl_fuchsia_net_virtualization__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#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
12pub enum InterfaceRemovalReason {
13    /// Failed to create the network because the network supports only
14    /// a single port.
15    OnlyOnePortSupported,
16    #[doc(hidden)]
17    __SourceBreaking { unknown_ordinal: u32 },
18}
19
20/// Pattern that matches an unknown `InterfaceRemovalReason` member.
21#[macro_export]
22macro_rules! InterfaceRemovalReasonUnknown {
23    () => {
24        _
25    };
26}
27
28impl InterfaceRemovalReason {
29    #[inline]
30    pub fn from_primitive(prim: u32) -> Option<Self> {
31        match prim {
32            1 => Some(Self::OnlyOnePortSupported),
33            _ => None,
34        }
35    }
36
37    #[inline]
38    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
39        match prim {
40            1 => Self::OnlyOnePortSupported,
41            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
42        }
43    }
44
45    #[inline]
46    pub fn unknown() -> Self {
47        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
48    }
49
50    #[inline]
51    pub const fn into_primitive(self) -> u32 {
52        match self {
53            Self::OnlyOnePortSupported => 1,
54            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
55        }
56    }
57
58    #[inline]
59    pub fn is_unknown(&self) -> bool {
60        match self {
61            Self::__SourceBreaking { unknown_ordinal: _ } => true,
62            _ => false,
63        }
64    }
65}
66
67#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
68pub enum NetworkRemovalReason {
69    /// Failed to create the network due to invalid configuration.
70    InvalidConfig,
71    #[doc(hidden)]
72    __SourceBreaking { unknown_ordinal: u32 },
73}
74
75/// Pattern that matches an unknown `NetworkRemovalReason` member.
76#[macro_export]
77macro_rules! NetworkRemovalReasonUnknown {
78    () => {
79        _
80    };
81}
82
83impl NetworkRemovalReason {
84    #[inline]
85    pub fn from_primitive(prim: u32) -> Option<Self> {
86        match prim {
87            1 => Some(Self::InvalidConfig),
88            _ => None,
89        }
90    }
91
92    #[inline]
93    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
94        match prim {
95            1 => Self::InvalidConfig,
96            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
97        }
98    }
99
100    #[inline]
101    pub fn unknown() -> Self {
102        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
103    }
104
105    #[inline]
106    pub const fn into_primitive(self) -> u32 {
107        match self {
108            Self::InvalidConfig => 1,
109            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
110        }
111    }
112
113    #[inline]
114    pub fn is_unknown(&self) -> bool {
115        match self {
116            Self::__SourceBreaking { unknown_ordinal: _ } => true,
117            _ => false,
118        }
119    }
120}
121
122#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
123pub struct InterfaceOnRemovedRequest {
124    pub reason: InterfaceRemovalReason,
125}
126
127impl fidl::Persistable for InterfaceOnRemovedRequest {}
128
129#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
130pub struct NetworkOnRemovedRequest {
131    pub reason: NetworkRemovalReason,
132}
133
134impl fidl::Persistable for NetworkOnRemovedRequest {}
135
136#[derive(Clone, Debug, Default, PartialEq)]
137pub struct Bridged {
138    #[doc(hidden)]
139    pub __source_breaking: fidl::marker::SourceBreaking,
140}
141
142impl fidl::Persistable for Bridged {}
143
144#[derive(Clone, Debug, Default, PartialEq)]
145pub struct IPv4NatConfig {
146    #[doc(hidden)]
147    pub __source_breaking: fidl::marker::SourceBreaking,
148}
149
150impl fidl::Persistable for IPv4NatConfig {}
151
152#[derive(Clone, Debug, Default, PartialEq)]
153pub struct Ipv4Config {
154    /// IPv4 address configuration options.
155    ///
156    /// If not present, no addresses will be assigned.
157    pub addr_config: Option<Ipv4AddressConfig>,
158    /// IPv4 connectivity type.
159    ///
160    /// If present, IPv4 unicast packet forwarding will be enabled for this
161    /// network; otherwise, guests on the network will only be able to
162    /// communicate with each other and the host OS.
163    pub connectivity: Option<Ipv4Connectivity>,
164    #[doc(hidden)]
165    pub __source_breaking: fidl::marker::SourceBreaking,
166}
167
168impl fidl::Persistable for Ipv4Config {}
169
170#[derive(Clone, Debug, Default, PartialEq)]
171pub struct Ipv4RoutedConfig {
172    /// NAT configuration.
173    ///
174    /// If present, perform IPv4 masquerading for packets originating
175    /// from the subnet configured through [`Ipv4Config.addr_config`]
176    /// going out all upstream-providing interfaces.
177    pub nat: Option<IPv4NatConfig>,
178    #[doc(hidden)]
179    pub __source_breaking: fidl::marker::SourceBreaking,
180}
181
182impl fidl::Persistable for Ipv4RoutedConfig {}
183
184#[derive(Clone, Debug, Default, PartialEq)]
185pub struct Networked {
186    /// IPv4 configuration.
187    ///
188    /// Invalid if `connectivity` is `Ipv4Connectivity.routed`,
189    /// but `addr_config` is not present.
190    ///
191    /// If not present, interpreted as the empty table.
192    pub ipv4: Option<Ipv4Config>,
193    #[doc(hidden)]
194    pub __source_breaking: fidl::marker::SourceBreaking,
195}
196
197impl fidl::Persistable for Networked {}
198
199#[derive(Clone, Debug)]
200pub enum Config {
201    /// Create a bridged network.
202    ///
203    /// The server will attempt to find a suitable interface to
204    /// attach to the bridge for providing upstream connectivity. The
205    /// selection process will be repeated to find a replacement
206    /// iff the interface attached to the bridge with Internet
207    /// connectivity is removed.
208    Bridged(Bridged),
209    /// Create a network that interacts with the host OS at the network
210    /// layer.
211    Networked(Networked),
212    #[doc(hidden)]
213    __SourceBreaking { unknown_ordinal: u64 },
214}
215
216/// Pattern that matches an unknown `Config` member.
217#[macro_export]
218macro_rules! ConfigUnknown {
219    () => {
220        _
221    };
222}
223
224// Custom PartialEq so that unknown variants are not equal to themselves.
225impl PartialEq for Config {
226    fn eq(&self, other: &Self) -> bool {
227        match (self, other) {
228            (Self::Bridged(x), Self::Bridged(y)) => *x == *y,
229            (Self::Networked(x), Self::Networked(y)) => *x == *y,
230            _ => false,
231        }
232    }
233}
234
235impl Config {
236    #[inline]
237    pub fn ordinal(&self) -> u64 {
238        match *self {
239            Self::Bridged(_) => 1,
240            Self::Networked(_) => 2,
241            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
242        }
243    }
244
245    #[inline]
246    pub fn unknown_variant_for_testing() -> Self {
247        Self::__SourceBreaking { unknown_ordinal: 0 }
248    }
249
250    #[inline]
251    pub fn is_unknown(&self) -> bool {
252        match self {
253            Self::__SourceBreaking { .. } => true,
254            _ => false,
255        }
256    }
257}
258
259impl fidl::Persistable for Config {}
260
261#[derive(Clone, Debug)]
262pub enum Ipv4AddressConfig {
263    /// Static address configuration.
264    ///
265    /// The address and a subnet route will be configured.
266    Static_(fidl_fuchsia_net__common::Ipv4AddressWithPrefix),
267    #[doc(hidden)]
268    __SourceBreaking { unknown_ordinal: u64 },
269}
270
271/// Pattern that matches an unknown `Ipv4AddressConfig` member.
272#[macro_export]
273macro_rules! Ipv4AddressConfigUnknown {
274    () => {
275        _
276    };
277}
278
279// Custom PartialEq so that unknown variants are not equal to themselves.
280impl PartialEq for Ipv4AddressConfig {
281    fn eq(&self, other: &Self) -> bool {
282        match (self, other) {
283            (Self::Static_(x), Self::Static_(y)) => *x == *y,
284            _ => false,
285        }
286    }
287}
288
289impl Ipv4AddressConfig {
290    #[inline]
291    pub fn ordinal(&self) -> u64 {
292        match *self {
293            Self::Static_(_) => 1,
294            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
295        }
296    }
297
298    #[inline]
299    pub fn unknown_variant_for_testing() -> Self {
300        Self::__SourceBreaking { unknown_ordinal: 0 }
301    }
302
303    #[inline]
304    pub fn is_unknown(&self) -> bool {
305        match self {
306            Self::__SourceBreaking { .. } => true,
307            _ => false,
308        }
309    }
310}
311
312impl fidl::Persistable for Ipv4AddressConfig {}
313
314#[derive(Clone, Debug)]
315pub enum Ipv4Connectivity {
316    /// IPv4 routing configuration.
317    ///
318    /// If present, a route to the subnet configured through
319    /// `Ipv4Config.addr_config` will be added.
320    Routed(Ipv4RoutedConfig),
321    #[doc(hidden)]
322    __SourceBreaking { unknown_ordinal: u64 },
323}
324
325/// Pattern that matches an unknown `Ipv4Connectivity` member.
326#[macro_export]
327macro_rules! Ipv4ConnectivityUnknown {
328    () => {
329        _
330    };
331}
332
333// Custom PartialEq so that unknown variants are not equal to themselves.
334impl PartialEq for Ipv4Connectivity {
335    fn eq(&self, other: &Self) -> bool {
336        match (self, other) {
337            (Self::Routed(x), Self::Routed(y)) => *x == *y,
338            _ => false,
339        }
340    }
341}
342
343impl Ipv4Connectivity {
344    #[inline]
345    pub fn ordinal(&self) -> u64 {
346        match *self {
347            Self::Routed(_) => 1,
348            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
349        }
350    }
351
352    #[inline]
353    pub fn unknown_variant_for_testing() -> Self {
354        Self::__SourceBreaking { unknown_ordinal: 0 }
355    }
356
357    #[inline]
358    pub fn is_unknown(&self) -> bool {
359        match self {
360            Self::__SourceBreaking { .. } => true,
361            _ => false,
362        }
363    }
364}
365
366impl fidl::Persistable for Ipv4Connectivity {}
367
368pub mod control_ordinals {
369    pub const CREATE_NETWORK: u64 = 0x4e5909b506960eaf;
370}
371
372pub mod interface_ordinals {
373    pub const ON_REMOVED: u64 = 0x4785571ae39a2617;
374}
375
376pub mod network_ordinals {
377    pub const ADD_PORT: u64 = 0x7ad6a60c931a3f4e;
378    pub const ON_REMOVED: u64 = 0xfe80656d1e5ec4a;
379}
380
381mod internal {
382    use super::*;
383    unsafe impl fidl::encoding::TypeMarker for InterfaceRemovalReason {
384        type Owned = Self;
385
386        #[inline(always)]
387        fn inline_align(_context: fidl::encoding::Context) -> usize {
388            std::mem::align_of::<u32>()
389        }
390
391        #[inline(always)]
392        fn inline_size(_context: fidl::encoding::Context) -> usize {
393            std::mem::size_of::<u32>()
394        }
395
396        #[inline(always)]
397        fn encode_is_copy() -> bool {
398            false
399        }
400
401        #[inline(always)]
402        fn decode_is_copy() -> bool {
403            false
404        }
405    }
406
407    impl fidl::encoding::ValueTypeMarker for InterfaceRemovalReason {
408        type Borrowed<'a> = Self;
409        #[inline(always)]
410        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
411            *value
412        }
413    }
414
415    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
416        for InterfaceRemovalReason
417    {
418        #[inline]
419        unsafe fn encode(
420            self,
421            encoder: &mut fidl::encoding::Encoder<'_, D>,
422            offset: usize,
423            _depth: fidl::encoding::Depth,
424        ) -> fidl::Result<()> {
425            encoder.debug_check_bounds::<Self>(offset);
426            encoder.write_num(self.into_primitive(), offset);
427            Ok(())
428        }
429    }
430
431    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
432        for InterfaceRemovalReason
433    {
434        #[inline(always)]
435        fn new_empty() -> Self {
436            Self::unknown()
437        }
438
439        #[inline]
440        unsafe fn decode(
441            &mut self,
442            decoder: &mut fidl::encoding::Decoder<'_, D>,
443            offset: usize,
444            _depth: fidl::encoding::Depth,
445        ) -> fidl::Result<()> {
446            decoder.debug_check_bounds::<Self>(offset);
447            let prim = decoder.read_num::<u32>(offset);
448
449            *self = Self::from_primitive_allow_unknown(prim);
450            Ok(())
451        }
452    }
453    unsafe impl fidl::encoding::TypeMarker for NetworkRemovalReason {
454        type Owned = Self;
455
456        #[inline(always)]
457        fn inline_align(_context: fidl::encoding::Context) -> usize {
458            std::mem::align_of::<u32>()
459        }
460
461        #[inline(always)]
462        fn inline_size(_context: fidl::encoding::Context) -> usize {
463            std::mem::size_of::<u32>()
464        }
465
466        #[inline(always)]
467        fn encode_is_copy() -> bool {
468            false
469        }
470
471        #[inline(always)]
472        fn decode_is_copy() -> bool {
473            false
474        }
475    }
476
477    impl fidl::encoding::ValueTypeMarker for NetworkRemovalReason {
478        type Borrowed<'a> = Self;
479        #[inline(always)]
480        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
481            *value
482        }
483    }
484
485    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
486        for NetworkRemovalReason
487    {
488        #[inline]
489        unsafe fn encode(
490            self,
491            encoder: &mut fidl::encoding::Encoder<'_, D>,
492            offset: usize,
493            _depth: fidl::encoding::Depth,
494        ) -> fidl::Result<()> {
495            encoder.debug_check_bounds::<Self>(offset);
496            encoder.write_num(self.into_primitive(), offset);
497            Ok(())
498        }
499    }
500
501    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for NetworkRemovalReason {
502        #[inline(always)]
503        fn new_empty() -> Self {
504            Self::unknown()
505        }
506
507        #[inline]
508        unsafe fn decode(
509            &mut self,
510            decoder: &mut fidl::encoding::Decoder<'_, D>,
511            offset: usize,
512            _depth: fidl::encoding::Depth,
513        ) -> fidl::Result<()> {
514            decoder.debug_check_bounds::<Self>(offset);
515            let prim = decoder.read_num::<u32>(offset);
516
517            *self = Self::from_primitive_allow_unknown(prim);
518            Ok(())
519        }
520    }
521
522    impl fidl::encoding::ValueTypeMarker for InterfaceOnRemovedRequest {
523        type Borrowed<'a> = &'a Self;
524        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
525            value
526        }
527    }
528
529    unsafe impl fidl::encoding::TypeMarker for InterfaceOnRemovedRequest {
530        type Owned = Self;
531
532        #[inline(always)]
533        fn inline_align(_context: fidl::encoding::Context) -> usize {
534            4
535        }
536
537        #[inline(always)]
538        fn inline_size(_context: fidl::encoding::Context) -> usize {
539            4
540        }
541    }
542
543    unsafe impl<D: fidl::encoding::ResourceDialect>
544        fidl::encoding::Encode<InterfaceOnRemovedRequest, D> for &InterfaceOnRemovedRequest
545    {
546        #[inline]
547        unsafe fn encode(
548            self,
549            encoder: &mut fidl::encoding::Encoder<'_, D>,
550            offset: usize,
551            _depth: fidl::encoding::Depth,
552        ) -> fidl::Result<()> {
553            encoder.debug_check_bounds::<InterfaceOnRemovedRequest>(offset);
554            // Delegate to tuple encoding.
555            fidl::encoding::Encode::<InterfaceOnRemovedRequest, D>::encode(
556                (<InterfaceRemovalReason as fidl::encoding::ValueTypeMarker>::borrow(&self.reason),),
557                encoder,
558                offset,
559                _depth,
560            )
561        }
562    }
563    unsafe impl<
564            D: fidl::encoding::ResourceDialect,
565            T0: fidl::encoding::Encode<InterfaceRemovalReason, D>,
566        > fidl::encoding::Encode<InterfaceOnRemovedRequest, D> for (T0,)
567    {
568        #[inline]
569        unsafe fn encode(
570            self,
571            encoder: &mut fidl::encoding::Encoder<'_, D>,
572            offset: usize,
573            depth: fidl::encoding::Depth,
574        ) -> fidl::Result<()> {
575            encoder.debug_check_bounds::<InterfaceOnRemovedRequest>(offset);
576            // Zero out padding regions. There's no need to apply masks
577            // because the unmasked parts will be overwritten by fields.
578            // Write the fields.
579            self.0.encode(encoder, offset + 0, depth)?;
580            Ok(())
581        }
582    }
583
584    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
585        for InterfaceOnRemovedRequest
586    {
587        #[inline(always)]
588        fn new_empty() -> Self {
589            Self { reason: fidl::new_empty!(InterfaceRemovalReason, D) }
590        }
591
592        #[inline]
593        unsafe fn decode(
594            &mut self,
595            decoder: &mut fidl::encoding::Decoder<'_, D>,
596            offset: usize,
597            _depth: fidl::encoding::Depth,
598        ) -> fidl::Result<()> {
599            decoder.debug_check_bounds::<Self>(offset);
600            // Verify that padding bytes are zero.
601            fidl::decode!(
602                InterfaceRemovalReason,
603                D,
604                &mut self.reason,
605                decoder,
606                offset + 0,
607                _depth
608            )?;
609            Ok(())
610        }
611    }
612
613    impl fidl::encoding::ValueTypeMarker for NetworkOnRemovedRequest {
614        type Borrowed<'a> = &'a Self;
615        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
616            value
617        }
618    }
619
620    unsafe impl fidl::encoding::TypeMarker for NetworkOnRemovedRequest {
621        type Owned = Self;
622
623        #[inline(always)]
624        fn inline_align(_context: fidl::encoding::Context) -> usize {
625            4
626        }
627
628        #[inline(always)]
629        fn inline_size(_context: fidl::encoding::Context) -> usize {
630            4
631        }
632    }
633
634    unsafe impl<D: fidl::encoding::ResourceDialect>
635        fidl::encoding::Encode<NetworkOnRemovedRequest, D> for &NetworkOnRemovedRequest
636    {
637        #[inline]
638        unsafe fn encode(
639            self,
640            encoder: &mut fidl::encoding::Encoder<'_, D>,
641            offset: usize,
642            _depth: fidl::encoding::Depth,
643        ) -> fidl::Result<()> {
644            encoder.debug_check_bounds::<NetworkOnRemovedRequest>(offset);
645            // Delegate to tuple encoding.
646            fidl::encoding::Encode::<NetworkOnRemovedRequest, D>::encode(
647                (<NetworkRemovalReason as fidl::encoding::ValueTypeMarker>::borrow(&self.reason),),
648                encoder,
649                offset,
650                _depth,
651            )
652        }
653    }
654    unsafe impl<
655            D: fidl::encoding::ResourceDialect,
656            T0: fidl::encoding::Encode<NetworkRemovalReason, D>,
657        > fidl::encoding::Encode<NetworkOnRemovedRequest, D> for (T0,)
658    {
659        #[inline]
660        unsafe fn encode(
661            self,
662            encoder: &mut fidl::encoding::Encoder<'_, D>,
663            offset: usize,
664            depth: fidl::encoding::Depth,
665        ) -> fidl::Result<()> {
666            encoder.debug_check_bounds::<NetworkOnRemovedRequest>(offset);
667            // Zero out padding regions. There's no need to apply masks
668            // because the unmasked parts will be overwritten by fields.
669            // Write the fields.
670            self.0.encode(encoder, offset + 0, depth)?;
671            Ok(())
672        }
673    }
674
675    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
676        for NetworkOnRemovedRequest
677    {
678        #[inline(always)]
679        fn new_empty() -> Self {
680            Self { reason: fidl::new_empty!(NetworkRemovalReason, D) }
681        }
682
683        #[inline]
684        unsafe fn decode(
685            &mut self,
686            decoder: &mut fidl::encoding::Decoder<'_, D>,
687            offset: usize,
688            _depth: fidl::encoding::Depth,
689        ) -> fidl::Result<()> {
690            decoder.debug_check_bounds::<Self>(offset);
691            // Verify that padding bytes are zero.
692            fidl::decode!(NetworkRemovalReason, D, &mut self.reason, decoder, offset + 0, _depth)?;
693            Ok(())
694        }
695    }
696
697    impl Bridged {
698        #[inline(always)]
699        fn max_ordinal_present(&self) -> u64 {
700            0
701        }
702    }
703
704    impl fidl::encoding::ValueTypeMarker for Bridged {
705        type Borrowed<'a> = &'a Self;
706        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
707            value
708        }
709    }
710
711    unsafe impl fidl::encoding::TypeMarker for Bridged {
712        type Owned = Self;
713
714        #[inline(always)]
715        fn inline_align(_context: fidl::encoding::Context) -> usize {
716            8
717        }
718
719        #[inline(always)]
720        fn inline_size(_context: fidl::encoding::Context) -> usize {
721            16
722        }
723    }
724
725    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Bridged, D> for &Bridged {
726        unsafe fn encode(
727            self,
728            encoder: &mut fidl::encoding::Encoder<'_, D>,
729            offset: usize,
730            mut depth: fidl::encoding::Depth,
731        ) -> fidl::Result<()> {
732            encoder.debug_check_bounds::<Bridged>(offset);
733            // Vector header
734            let max_ordinal: u64 = self.max_ordinal_present();
735            encoder.write_num(max_ordinal, offset);
736            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
737            // Calling encoder.out_of_line_offset(0) is not allowed.
738            if max_ordinal == 0 {
739                return Ok(());
740            }
741            depth.increment()?;
742            let envelope_size = 8;
743            let bytes_len = max_ordinal as usize * envelope_size;
744            #[allow(unused_variables)]
745            let offset = encoder.out_of_line_offset(bytes_len);
746            let mut _prev_end_offset: usize = 0;
747
748            Ok(())
749        }
750    }
751
752    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Bridged {
753        #[inline(always)]
754        fn new_empty() -> Self {
755            Self::default()
756        }
757
758        unsafe fn decode(
759            &mut self,
760            decoder: &mut fidl::encoding::Decoder<'_, D>,
761            offset: usize,
762            mut depth: fidl::encoding::Depth,
763        ) -> fidl::Result<()> {
764            decoder.debug_check_bounds::<Self>(offset);
765            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
766                None => return Err(fidl::Error::NotNullable),
767                Some(len) => len,
768            };
769            // Calling decoder.out_of_line_offset(0) is not allowed.
770            if len == 0 {
771                return Ok(());
772            };
773            depth.increment()?;
774            let envelope_size = 8;
775            let bytes_len = len * envelope_size;
776            let offset = decoder.out_of_line_offset(bytes_len)?;
777            // Decode the envelope for each type.
778            let mut _next_ordinal_to_read = 0;
779            let mut next_offset = offset;
780            let end_offset = offset + bytes_len;
781
782            // Decode the remaining unknown envelopes.
783            while next_offset < end_offset {
784                _next_ordinal_to_read += 1;
785                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
786                next_offset += envelope_size;
787            }
788
789            Ok(())
790        }
791    }
792
793    impl IPv4NatConfig {
794        #[inline(always)]
795        fn max_ordinal_present(&self) -> u64 {
796            0
797        }
798    }
799
800    impl fidl::encoding::ValueTypeMarker for IPv4NatConfig {
801        type Borrowed<'a> = &'a Self;
802        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
803            value
804        }
805    }
806
807    unsafe impl fidl::encoding::TypeMarker for IPv4NatConfig {
808        type Owned = Self;
809
810        #[inline(always)]
811        fn inline_align(_context: fidl::encoding::Context) -> usize {
812            8
813        }
814
815        #[inline(always)]
816        fn inline_size(_context: fidl::encoding::Context) -> usize {
817            16
818        }
819    }
820
821    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<IPv4NatConfig, D>
822        for &IPv4NatConfig
823    {
824        unsafe fn encode(
825            self,
826            encoder: &mut fidl::encoding::Encoder<'_, D>,
827            offset: usize,
828            mut depth: fidl::encoding::Depth,
829        ) -> fidl::Result<()> {
830            encoder.debug_check_bounds::<IPv4NatConfig>(offset);
831            // Vector header
832            let max_ordinal: u64 = self.max_ordinal_present();
833            encoder.write_num(max_ordinal, offset);
834            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
835            // Calling encoder.out_of_line_offset(0) is not allowed.
836            if max_ordinal == 0 {
837                return Ok(());
838            }
839            depth.increment()?;
840            let envelope_size = 8;
841            let bytes_len = max_ordinal as usize * envelope_size;
842            #[allow(unused_variables)]
843            let offset = encoder.out_of_line_offset(bytes_len);
844            let mut _prev_end_offset: usize = 0;
845
846            Ok(())
847        }
848    }
849
850    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for IPv4NatConfig {
851        #[inline(always)]
852        fn new_empty() -> Self {
853            Self::default()
854        }
855
856        unsafe fn decode(
857            &mut self,
858            decoder: &mut fidl::encoding::Decoder<'_, D>,
859            offset: usize,
860            mut depth: fidl::encoding::Depth,
861        ) -> fidl::Result<()> {
862            decoder.debug_check_bounds::<Self>(offset);
863            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
864                None => return Err(fidl::Error::NotNullable),
865                Some(len) => len,
866            };
867            // Calling decoder.out_of_line_offset(0) is not allowed.
868            if len == 0 {
869                return Ok(());
870            };
871            depth.increment()?;
872            let envelope_size = 8;
873            let bytes_len = len * envelope_size;
874            let offset = decoder.out_of_line_offset(bytes_len)?;
875            // Decode the envelope for each type.
876            let mut _next_ordinal_to_read = 0;
877            let mut next_offset = offset;
878            let end_offset = offset + bytes_len;
879
880            // Decode the remaining unknown envelopes.
881            while next_offset < end_offset {
882                _next_ordinal_to_read += 1;
883                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
884                next_offset += envelope_size;
885            }
886
887            Ok(())
888        }
889    }
890
891    impl Ipv4Config {
892        #[inline(always)]
893        fn max_ordinal_present(&self) -> u64 {
894            if let Some(_) = self.connectivity {
895                return 2;
896            }
897            if let Some(_) = self.addr_config {
898                return 1;
899            }
900            0
901        }
902    }
903
904    impl fidl::encoding::ValueTypeMarker for Ipv4Config {
905        type Borrowed<'a> = &'a Self;
906        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
907            value
908        }
909    }
910
911    unsafe impl fidl::encoding::TypeMarker for Ipv4Config {
912        type Owned = Self;
913
914        #[inline(always)]
915        fn inline_align(_context: fidl::encoding::Context) -> usize {
916            8
917        }
918
919        #[inline(always)]
920        fn inline_size(_context: fidl::encoding::Context) -> usize {
921            16
922        }
923    }
924
925    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Ipv4Config, D>
926        for &Ipv4Config
927    {
928        unsafe fn encode(
929            self,
930            encoder: &mut fidl::encoding::Encoder<'_, D>,
931            offset: usize,
932            mut depth: fidl::encoding::Depth,
933        ) -> fidl::Result<()> {
934            encoder.debug_check_bounds::<Ipv4Config>(offset);
935            // Vector header
936            let max_ordinal: u64 = self.max_ordinal_present();
937            encoder.write_num(max_ordinal, offset);
938            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
939            // Calling encoder.out_of_line_offset(0) is not allowed.
940            if max_ordinal == 0 {
941                return Ok(());
942            }
943            depth.increment()?;
944            let envelope_size = 8;
945            let bytes_len = max_ordinal as usize * envelope_size;
946            #[allow(unused_variables)]
947            let offset = encoder.out_of_line_offset(bytes_len);
948            let mut _prev_end_offset: usize = 0;
949            if 1 > max_ordinal {
950                return Ok(());
951            }
952
953            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
954            // are envelope_size bytes.
955            let cur_offset: usize = (1 - 1) * envelope_size;
956
957            // Zero reserved fields.
958            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
959
960            // Safety:
961            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
962            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
963            //   envelope_size bytes, there is always sufficient room.
964            fidl::encoding::encode_in_envelope_optional::<Ipv4AddressConfig, D>(
965                self.addr_config
966                    .as_ref()
967                    .map(<Ipv4AddressConfig as fidl::encoding::ValueTypeMarker>::borrow),
968                encoder,
969                offset + cur_offset,
970                depth,
971            )?;
972
973            _prev_end_offset = cur_offset + envelope_size;
974            if 2 > max_ordinal {
975                return Ok(());
976            }
977
978            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
979            // are envelope_size bytes.
980            let cur_offset: usize = (2 - 1) * envelope_size;
981
982            // Zero reserved fields.
983            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
984
985            // Safety:
986            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
987            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
988            //   envelope_size bytes, there is always sufficient room.
989            fidl::encoding::encode_in_envelope_optional::<Ipv4Connectivity, D>(
990                self.connectivity
991                    .as_ref()
992                    .map(<Ipv4Connectivity as fidl::encoding::ValueTypeMarker>::borrow),
993                encoder,
994                offset + cur_offset,
995                depth,
996            )?;
997
998            _prev_end_offset = cur_offset + envelope_size;
999
1000            Ok(())
1001        }
1002    }
1003
1004    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Ipv4Config {
1005        #[inline(always)]
1006        fn new_empty() -> Self {
1007            Self::default()
1008        }
1009
1010        unsafe fn decode(
1011            &mut self,
1012            decoder: &mut fidl::encoding::Decoder<'_, D>,
1013            offset: usize,
1014            mut depth: fidl::encoding::Depth,
1015        ) -> fidl::Result<()> {
1016            decoder.debug_check_bounds::<Self>(offset);
1017            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1018                None => return Err(fidl::Error::NotNullable),
1019                Some(len) => len,
1020            };
1021            // Calling decoder.out_of_line_offset(0) is not allowed.
1022            if len == 0 {
1023                return Ok(());
1024            };
1025            depth.increment()?;
1026            let envelope_size = 8;
1027            let bytes_len = len * envelope_size;
1028            let offset = decoder.out_of_line_offset(bytes_len)?;
1029            // Decode the envelope for each type.
1030            let mut _next_ordinal_to_read = 0;
1031            let mut next_offset = offset;
1032            let end_offset = offset + bytes_len;
1033            _next_ordinal_to_read += 1;
1034            if next_offset >= end_offset {
1035                return Ok(());
1036            }
1037
1038            // Decode unknown envelopes for gaps in ordinals.
1039            while _next_ordinal_to_read < 1 {
1040                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1041                _next_ordinal_to_read += 1;
1042                next_offset += envelope_size;
1043            }
1044
1045            let next_out_of_line = decoder.next_out_of_line();
1046            let handles_before = decoder.remaining_handles();
1047            if let Some((inlined, num_bytes, num_handles)) =
1048                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1049            {
1050                let member_inline_size =
1051                    <Ipv4AddressConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1052                if inlined != (member_inline_size <= 4) {
1053                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1054                }
1055                let inner_offset;
1056                let mut inner_depth = depth.clone();
1057                if inlined {
1058                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1059                    inner_offset = next_offset;
1060                } else {
1061                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1062                    inner_depth.increment()?;
1063                }
1064                let val_ref =
1065                    self.addr_config.get_or_insert_with(|| fidl::new_empty!(Ipv4AddressConfig, D));
1066                fidl::decode!(Ipv4AddressConfig, D, val_ref, decoder, inner_offset, inner_depth)?;
1067                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1068                {
1069                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1070                }
1071                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1072                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1073                }
1074            }
1075
1076            next_offset += envelope_size;
1077            _next_ordinal_to_read += 1;
1078            if next_offset >= end_offset {
1079                return Ok(());
1080            }
1081
1082            // Decode unknown envelopes for gaps in ordinals.
1083            while _next_ordinal_to_read < 2 {
1084                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1085                _next_ordinal_to_read += 1;
1086                next_offset += envelope_size;
1087            }
1088
1089            let next_out_of_line = decoder.next_out_of_line();
1090            let handles_before = decoder.remaining_handles();
1091            if let Some((inlined, num_bytes, num_handles)) =
1092                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1093            {
1094                let member_inline_size =
1095                    <Ipv4Connectivity as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1096                if inlined != (member_inline_size <= 4) {
1097                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1098                }
1099                let inner_offset;
1100                let mut inner_depth = depth.clone();
1101                if inlined {
1102                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1103                    inner_offset = next_offset;
1104                } else {
1105                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1106                    inner_depth.increment()?;
1107                }
1108                let val_ref =
1109                    self.connectivity.get_or_insert_with(|| fidl::new_empty!(Ipv4Connectivity, D));
1110                fidl::decode!(Ipv4Connectivity, D, val_ref, decoder, inner_offset, inner_depth)?;
1111                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1112                {
1113                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1114                }
1115                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1116                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1117                }
1118            }
1119
1120            next_offset += envelope_size;
1121
1122            // Decode the remaining unknown envelopes.
1123            while next_offset < end_offset {
1124                _next_ordinal_to_read += 1;
1125                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1126                next_offset += envelope_size;
1127            }
1128
1129            Ok(())
1130        }
1131    }
1132
1133    impl Ipv4RoutedConfig {
1134        #[inline(always)]
1135        fn max_ordinal_present(&self) -> u64 {
1136            if let Some(_) = self.nat {
1137                return 1;
1138            }
1139            0
1140        }
1141    }
1142
1143    impl fidl::encoding::ValueTypeMarker for Ipv4RoutedConfig {
1144        type Borrowed<'a> = &'a Self;
1145        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1146            value
1147        }
1148    }
1149
1150    unsafe impl fidl::encoding::TypeMarker for Ipv4RoutedConfig {
1151        type Owned = Self;
1152
1153        #[inline(always)]
1154        fn inline_align(_context: fidl::encoding::Context) -> usize {
1155            8
1156        }
1157
1158        #[inline(always)]
1159        fn inline_size(_context: fidl::encoding::Context) -> usize {
1160            16
1161        }
1162    }
1163
1164    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Ipv4RoutedConfig, D>
1165        for &Ipv4RoutedConfig
1166    {
1167        unsafe fn encode(
1168            self,
1169            encoder: &mut fidl::encoding::Encoder<'_, D>,
1170            offset: usize,
1171            mut depth: fidl::encoding::Depth,
1172        ) -> fidl::Result<()> {
1173            encoder.debug_check_bounds::<Ipv4RoutedConfig>(offset);
1174            // Vector header
1175            let max_ordinal: u64 = self.max_ordinal_present();
1176            encoder.write_num(max_ordinal, offset);
1177            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1178            // Calling encoder.out_of_line_offset(0) is not allowed.
1179            if max_ordinal == 0 {
1180                return Ok(());
1181            }
1182            depth.increment()?;
1183            let envelope_size = 8;
1184            let bytes_len = max_ordinal as usize * envelope_size;
1185            #[allow(unused_variables)]
1186            let offset = encoder.out_of_line_offset(bytes_len);
1187            let mut _prev_end_offset: usize = 0;
1188            if 1 > max_ordinal {
1189                return Ok(());
1190            }
1191
1192            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1193            // are envelope_size bytes.
1194            let cur_offset: usize = (1 - 1) * envelope_size;
1195
1196            // Zero reserved fields.
1197            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1198
1199            // Safety:
1200            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1201            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1202            //   envelope_size bytes, there is always sufficient room.
1203            fidl::encoding::encode_in_envelope_optional::<IPv4NatConfig, D>(
1204                self.nat.as_ref().map(<IPv4NatConfig as fidl::encoding::ValueTypeMarker>::borrow),
1205                encoder,
1206                offset + cur_offset,
1207                depth,
1208            )?;
1209
1210            _prev_end_offset = cur_offset + envelope_size;
1211
1212            Ok(())
1213        }
1214    }
1215
1216    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Ipv4RoutedConfig {
1217        #[inline(always)]
1218        fn new_empty() -> Self {
1219            Self::default()
1220        }
1221
1222        unsafe fn decode(
1223            &mut self,
1224            decoder: &mut fidl::encoding::Decoder<'_, D>,
1225            offset: usize,
1226            mut depth: fidl::encoding::Depth,
1227        ) -> fidl::Result<()> {
1228            decoder.debug_check_bounds::<Self>(offset);
1229            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1230                None => return Err(fidl::Error::NotNullable),
1231                Some(len) => len,
1232            };
1233            // Calling decoder.out_of_line_offset(0) is not allowed.
1234            if len == 0 {
1235                return Ok(());
1236            };
1237            depth.increment()?;
1238            let envelope_size = 8;
1239            let bytes_len = len * envelope_size;
1240            let offset = decoder.out_of_line_offset(bytes_len)?;
1241            // Decode the envelope for each type.
1242            let mut _next_ordinal_to_read = 0;
1243            let mut next_offset = offset;
1244            let end_offset = offset + bytes_len;
1245            _next_ordinal_to_read += 1;
1246            if next_offset >= end_offset {
1247                return Ok(());
1248            }
1249
1250            // Decode unknown envelopes for gaps in ordinals.
1251            while _next_ordinal_to_read < 1 {
1252                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1253                _next_ordinal_to_read += 1;
1254                next_offset += envelope_size;
1255            }
1256
1257            let next_out_of_line = decoder.next_out_of_line();
1258            let handles_before = decoder.remaining_handles();
1259            if let Some((inlined, num_bytes, num_handles)) =
1260                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1261            {
1262                let member_inline_size =
1263                    <IPv4NatConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1264                if inlined != (member_inline_size <= 4) {
1265                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1266                }
1267                let inner_offset;
1268                let mut inner_depth = depth.clone();
1269                if inlined {
1270                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1271                    inner_offset = next_offset;
1272                } else {
1273                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1274                    inner_depth.increment()?;
1275                }
1276                let val_ref = self.nat.get_or_insert_with(|| fidl::new_empty!(IPv4NatConfig, D));
1277                fidl::decode!(IPv4NatConfig, D, val_ref, decoder, inner_offset, inner_depth)?;
1278                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1279                {
1280                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1281                }
1282                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1283                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1284                }
1285            }
1286
1287            next_offset += envelope_size;
1288
1289            // Decode the remaining unknown envelopes.
1290            while next_offset < end_offset {
1291                _next_ordinal_to_read += 1;
1292                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1293                next_offset += envelope_size;
1294            }
1295
1296            Ok(())
1297        }
1298    }
1299
1300    impl Networked {
1301        #[inline(always)]
1302        fn max_ordinal_present(&self) -> u64 {
1303            if let Some(_) = self.ipv4 {
1304                return 1;
1305            }
1306            0
1307        }
1308    }
1309
1310    impl fidl::encoding::ValueTypeMarker for Networked {
1311        type Borrowed<'a> = &'a Self;
1312        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1313            value
1314        }
1315    }
1316
1317    unsafe impl fidl::encoding::TypeMarker for Networked {
1318        type Owned = Self;
1319
1320        #[inline(always)]
1321        fn inline_align(_context: fidl::encoding::Context) -> usize {
1322            8
1323        }
1324
1325        #[inline(always)]
1326        fn inline_size(_context: fidl::encoding::Context) -> usize {
1327            16
1328        }
1329    }
1330
1331    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Networked, D>
1332        for &Networked
1333    {
1334        unsafe fn encode(
1335            self,
1336            encoder: &mut fidl::encoding::Encoder<'_, D>,
1337            offset: usize,
1338            mut depth: fidl::encoding::Depth,
1339        ) -> fidl::Result<()> {
1340            encoder.debug_check_bounds::<Networked>(offset);
1341            // Vector header
1342            let max_ordinal: u64 = self.max_ordinal_present();
1343            encoder.write_num(max_ordinal, offset);
1344            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1345            // Calling encoder.out_of_line_offset(0) is not allowed.
1346            if max_ordinal == 0 {
1347                return Ok(());
1348            }
1349            depth.increment()?;
1350            let envelope_size = 8;
1351            let bytes_len = max_ordinal as usize * envelope_size;
1352            #[allow(unused_variables)]
1353            let offset = encoder.out_of_line_offset(bytes_len);
1354            let mut _prev_end_offset: usize = 0;
1355            if 1 > max_ordinal {
1356                return Ok(());
1357            }
1358
1359            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1360            // are envelope_size bytes.
1361            let cur_offset: usize = (1 - 1) * envelope_size;
1362
1363            // Zero reserved fields.
1364            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1365
1366            // Safety:
1367            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1368            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1369            //   envelope_size bytes, there is always sufficient room.
1370            fidl::encoding::encode_in_envelope_optional::<Ipv4Config, D>(
1371                self.ipv4.as_ref().map(<Ipv4Config as fidl::encoding::ValueTypeMarker>::borrow),
1372                encoder,
1373                offset + cur_offset,
1374                depth,
1375            )?;
1376
1377            _prev_end_offset = cur_offset + envelope_size;
1378
1379            Ok(())
1380        }
1381    }
1382
1383    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Networked {
1384        #[inline(always)]
1385        fn new_empty() -> Self {
1386            Self::default()
1387        }
1388
1389        unsafe fn decode(
1390            &mut self,
1391            decoder: &mut fidl::encoding::Decoder<'_, D>,
1392            offset: usize,
1393            mut depth: fidl::encoding::Depth,
1394        ) -> fidl::Result<()> {
1395            decoder.debug_check_bounds::<Self>(offset);
1396            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1397                None => return Err(fidl::Error::NotNullable),
1398                Some(len) => len,
1399            };
1400            // Calling decoder.out_of_line_offset(0) is not allowed.
1401            if len == 0 {
1402                return Ok(());
1403            };
1404            depth.increment()?;
1405            let envelope_size = 8;
1406            let bytes_len = len * envelope_size;
1407            let offset = decoder.out_of_line_offset(bytes_len)?;
1408            // Decode the envelope for each type.
1409            let mut _next_ordinal_to_read = 0;
1410            let mut next_offset = offset;
1411            let end_offset = offset + bytes_len;
1412            _next_ordinal_to_read += 1;
1413            if next_offset >= end_offset {
1414                return Ok(());
1415            }
1416
1417            // Decode unknown envelopes for gaps in ordinals.
1418            while _next_ordinal_to_read < 1 {
1419                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1420                _next_ordinal_to_read += 1;
1421                next_offset += envelope_size;
1422            }
1423
1424            let next_out_of_line = decoder.next_out_of_line();
1425            let handles_before = decoder.remaining_handles();
1426            if let Some((inlined, num_bytes, num_handles)) =
1427                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1428            {
1429                let member_inline_size =
1430                    <Ipv4Config as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1431                if inlined != (member_inline_size <= 4) {
1432                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1433                }
1434                let inner_offset;
1435                let mut inner_depth = depth.clone();
1436                if inlined {
1437                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1438                    inner_offset = next_offset;
1439                } else {
1440                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1441                    inner_depth.increment()?;
1442                }
1443                let val_ref = self.ipv4.get_or_insert_with(|| fidl::new_empty!(Ipv4Config, D));
1444                fidl::decode!(Ipv4Config, D, val_ref, decoder, inner_offset, inner_depth)?;
1445                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1446                {
1447                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1448                }
1449                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1450                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1451                }
1452            }
1453
1454            next_offset += envelope_size;
1455
1456            // Decode the remaining unknown envelopes.
1457            while next_offset < end_offset {
1458                _next_ordinal_to_read += 1;
1459                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1460                next_offset += envelope_size;
1461            }
1462
1463            Ok(())
1464        }
1465    }
1466
1467    impl fidl::encoding::ValueTypeMarker for Config {
1468        type Borrowed<'a> = &'a Self;
1469        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1470            value
1471        }
1472    }
1473
1474    unsafe impl fidl::encoding::TypeMarker for Config {
1475        type Owned = Self;
1476
1477        #[inline(always)]
1478        fn inline_align(_context: fidl::encoding::Context) -> usize {
1479            8
1480        }
1481
1482        #[inline(always)]
1483        fn inline_size(_context: fidl::encoding::Context) -> usize {
1484            16
1485        }
1486    }
1487
1488    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Config, D> for &Config {
1489        #[inline]
1490        unsafe fn encode(
1491            self,
1492            encoder: &mut fidl::encoding::Encoder<'_, D>,
1493            offset: usize,
1494            _depth: fidl::encoding::Depth,
1495        ) -> fidl::Result<()> {
1496            encoder.debug_check_bounds::<Config>(offset);
1497            encoder.write_num::<u64>(self.ordinal(), offset);
1498            match self {
1499                Config::Bridged(ref val) => fidl::encoding::encode_in_envelope::<Bridged, D>(
1500                    <Bridged as fidl::encoding::ValueTypeMarker>::borrow(val),
1501                    encoder,
1502                    offset + 8,
1503                    _depth,
1504                ),
1505                Config::Networked(ref val) => fidl::encoding::encode_in_envelope::<Networked, D>(
1506                    <Networked as fidl::encoding::ValueTypeMarker>::borrow(val),
1507                    encoder,
1508                    offset + 8,
1509                    _depth,
1510                ),
1511                Config::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1512            }
1513        }
1514    }
1515
1516    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
1517        #[inline(always)]
1518        fn new_empty() -> Self {
1519            Self::__SourceBreaking { unknown_ordinal: 0 }
1520        }
1521
1522        #[inline]
1523        unsafe fn decode(
1524            &mut self,
1525            decoder: &mut fidl::encoding::Decoder<'_, D>,
1526            offset: usize,
1527            mut depth: fidl::encoding::Depth,
1528        ) -> fidl::Result<()> {
1529            decoder.debug_check_bounds::<Self>(offset);
1530            #[allow(unused_variables)]
1531            let next_out_of_line = decoder.next_out_of_line();
1532            let handles_before = decoder.remaining_handles();
1533            let (ordinal, inlined, num_bytes, num_handles) =
1534                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1535
1536            let member_inline_size = match ordinal {
1537                1 => <Bridged as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1538                2 => <Networked as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1539                0 => return Err(fidl::Error::UnknownUnionTag),
1540                _ => num_bytes as usize,
1541            };
1542
1543            if inlined != (member_inline_size <= 4) {
1544                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1545            }
1546            let _inner_offset;
1547            if inlined {
1548                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1549                _inner_offset = offset + 8;
1550            } else {
1551                depth.increment()?;
1552                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1553            }
1554            match ordinal {
1555                1 => {
1556                    #[allow(irrefutable_let_patterns)]
1557                    if let Config::Bridged(_) = self {
1558                        // Do nothing, read the value into the object
1559                    } else {
1560                        // Initialize `self` to the right variant
1561                        *self = Config::Bridged(fidl::new_empty!(Bridged, D));
1562                    }
1563                    #[allow(irrefutable_let_patterns)]
1564                    if let Config::Bridged(ref mut val) = self {
1565                        fidl::decode!(Bridged, D, val, decoder, _inner_offset, depth)?;
1566                    } else {
1567                        unreachable!()
1568                    }
1569                }
1570                2 => {
1571                    #[allow(irrefutable_let_patterns)]
1572                    if let Config::Networked(_) = self {
1573                        // Do nothing, read the value into the object
1574                    } else {
1575                        // Initialize `self` to the right variant
1576                        *self = Config::Networked(fidl::new_empty!(Networked, D));
1577                    }
1578                    #[allow(irrefutable_let_patterns)]
1579                    if let Config::Networked(ref mut val) = self {
1580                        fidl::decode!(Networked, D, val, decoder, _inner_offset, depth)?;
1581                    } else {
1582                        unreachable!()
1583                    }
1584                }
1585                #[allow(deprecated)]
1586                ordinal => {
1587                    for _ in 0..num_handles {
1588                        decoder.drop_next_handle()?;
1589                    }
1590                    *self = Config::__SourceBreaking { unknown_ordinal: ordinal };
1591                }
1592            }
1593            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1594                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1595            }
1596            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1597                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1598            }
1599            Ok(())
1600        }
1601    }
1602
1603    impl fidl::encoding::ValueTypeMarker for Ipv4AddressConfig {
1604        type Borrowed<'a> = &'a Self;
1605        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1606            value
1607        }
1608    }
1609
1610    unsafe impl fidl::encoding::TypeMarker for Ipv4AddressConfig {
1611        type Owned = Self;
1612
1613        #[inline(always)]
1614        fn inline_align(_context: fidl::encoding::Context) -> usize {
1615            8
1616        }
1617
1618        #[inline(always)]
1619        fn inline_size(_context: fidl::encoding::Context) -> usize {
1620            16
1621        }
1622    }
1623
1624    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Ipv4AddressConfig, D>
1625        for &Ipv4AddressConfig
1626    {
1627        #[inline]
1628        unsafe fn encode(
1629            self,
1630            encoder: &mut fidl::encoding::Encoder<'_, D>,
1631            offset: usize,
1632            _depth: fidl::encoding::Depth,
1633        ) -> fidl::Result<()> {
1634            encoder.debug_check_bounds::<Ipv4AddressConfig>(offset);
1635            encoder.write_num::<u64>(self.ordinal(), offset);
1636            match self {
1637            Ipv4AddressConfig::Static_(ref val) => {
1638                fidl::encoding::encode_in_envelope::<fidl_fuchsia_net__common::Ipv4AddressWithPrefix, D>(
1639                    <fidl_fuchsia_net__common::Ipv4AddressWithPrefix as fidl::encoding::ValueTypeMarker>::borrow(val),
1640                    encoder, offset + 8, _depth
1641                )
1642            }
1643            Ipv4AddressConfig::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1644        }
1645        }
1646    }
1647
1648    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Ipv4AddressConfig {
1649        #[inline(always)]
1650        fn new_empty() -> Self {
1651            Self::__SourceBreaking { unknown_ordinal: 0 }
1652        }
1653
1654        #[inline]
1655        unsafe fn decode(
1656            &mut self,
1657            decoder: &mut fidl::encoding::Decoder<'_, D>,
1658            offset: usize,
1659            mut depth: fidl::encoding::Depth,
1660        ) -> fidl::Result<()> {
1661            decoder.debug_check_bounds::<Self>(offset);
1662            #[allow(unused_variables)]
1663            let next_out_of_line = decoder.next_out_of_line();
1664            let handles_before = decoder.remaining_handles();
1665            let (ordinal, inlined, num_bytes, num_handles) =
1666                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1667
1668            let member_inline_size = match ordinal {
1669            1 => <fidl_fuchsia_net__common::Ipv4AddressWithPrefix as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1670            0 => return Err(fidl::Error::UnknownUnionTag),
1671            _ => num_bytes as usize,
1672        };
1673
1674            if inlined != (member_inline_size <= 4) {
1675                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1676            }
1677            let _inner_offset;
1678            if inlined {
1679                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1680                _inner_offset = offset + 8;
1681            } else {
1682                depth.increment()?;
1683                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1684            }
1685            match ordinal {
1686                1 => {
1687                    #[allow(irrefutable_let_patterns)]
1688                    if let Ipv4AddressConfig::Static_(_) = self {
1689                        // Do nothing, read the value into the object
1690                    } else {
1691                        // Initialize `self` to the right variant
1692                        *self = Ipv4AddressConfig::Static_(fidl::new_empty!(
1693                            fidl_fuchsia_net__common::Ipv4AddressWithPrefix,
1694                            D
1695                        ));
1696                    }
1697                    #[allow(irrefutable_let_patterns)]
1698                    if let Ipv4AddressConfig::Static_(ref mut val) = self {
1699                        fidl::decode!(
1700                            fidl_fuchsia_net__common::Ipv4AddressWithPrefix,
1701                            D,
1702                            val,
1703                            decoder,
1704                            _inner_offset,
1705                            depth
1706                        )?;
1707                    } else {
1708                        unreachable!()
1709                    }
1710                }
1711                #[allow(deprecated)]
1712                ordinal => {
1713                    for _ in 0..num_handles {
1714                        decoder.drop_next_handle()?;
1715                    }
1716                    *self = Ipv4AddressConfig::__SourceBreaking { unknown_ordinal: ordinal };
1717                }
1718            }
1719            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1720                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1721            }
1722            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1723                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1724            }
1725            Ok(())
1726        }
1727    }
1728
1729    impl fidl::encoding::ValueTypeMarker for Ipv4Connectivity {
1730        type Borrowed<'a> = &'a Self;
1731        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1732            value
1733        }
1734    }
1735
1736    unsafe impl fidl::encoding::TypeMarker for Ipv4Connectivity {
1737        type Owned = Self;
1738
1739        #[inline(always)]
1740        fn inline_align(_context: fidl::encoding::Context) -> usize {
1741            8
1742        }
1743
1744        #[inline(always)]
1745        fn inline_size(_context: fidl::encoding::Context) -> usize {
1746            16
1747        }
1748    }
1749
1750    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Ipv4Connectivity, D>
1751        for &Ipv4Connectivity
1752    {
1753        #[inline]
1754        unsafe fn encode(
1755            self,
1756            encoder: &mut fidl::encoding::Encoder<'_, D>,
1757            offset: usize,
1758            _depth: fidl::encoding::Depth,
1759        ) -> fidl::Result<()> {
1760            encoder.debug_check_bounds::<Ipv4Connectivity>(offset);
1761            encoder.write_num::<u64>(self.ordinal(), offset);
1762            match self {
1763                Ipv4Connectivity::Routed(ref val) => {
1764                    fidl::encoding::encode_in_envelope::<Ipv4RoutedConfig, D>(
1765                        <Ipv4RoutedConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
1766                        encoder,
1767                        offset + 8,
1768                        _depth,
1769                    )
1770                }
1771                Ipv4Connectivity::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1772            }
1773        }
1774    }
1775
1776    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Ipv4Connectivity {
1777        #[inline(always)]
1778        fn new_empty() -> Self {
1779            Self::__SourceBreaking { unknown_ordinal: 0 }
1780        }
1781
1782        #[inline]
1783        unsafe fn decode(
1784            &mut self,
1785            decoder: &mut fidl::encoding::Decoder<'_, D>,
1786            offset: usize,
1787            mut depth: fidl::encoding::Depth,
1788        ) -> fidl::Result<()> {
1789            decoder.debug_check_bounds::<Self>(offset);
1790            #[allow(unused_variables)]
1791            let next_out_of_line = decoder.next_out_of_line();
1792            let handles_before = decoder.remaining_handles();
1793            let (ordinal, inlined, num_bytes, num_handles) =
1794                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1795
1796            let member_inline_size = match ordinal {
1797                1 => <Ipv4RoutedConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1798                0 => return Err(fidl::Error::UnknownUnionTag),
1799                _ => num_bytes as usize,
1800            };
1801
1802            if inlined != (member_inline_size <= 4) {
1803                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1804            }
1805            let _inner_offset;
1806            if inlined {
1807                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1808                _inner_offset = offset + 8;
1809            } else {
1810                depth.increment()?;
1811                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1812            }
1813            match ordinal {
1814                1 => {
1815                    #[allow(irrefutable_let_patterns)]
1816                    if let Ipv4Connectivity::Routed(_) = self {
1817                        // Do nothing, read the value into the object
1818                    } else {
1819                        // Initialize `self` to the right variant
1820                        *self = Ipv4Connectivity::Routed(fidl::new_empty!(Ipv4RoutedConfig, D));
1821                    }
1822                    #[allow(irrefutable_let_patterns)]
1823                    if let Ipv4Connectivity::Routed(ref mut val) = self {
1824                        fidl::decode!(Ipv4RoutedConfig, D, val, decoder, _inner_offset, depth)?;
1825                    } else {
1826                        unreachable!()
1827                    }
1828                }
1829                #[allow(deprecated)]
1830                ordinal => {
1831                    for _ in 0..num_handles {
1832                        decoder.drop_next_handle()?;
1833                    }
1834                    *self = Ipv4Connectivity::__SourceBreaking { unknown_ordinal: ordinal };
1835                }
1836            }
1837            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1838                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1839            }
1840            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1841                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1842            }
1843            Ok(())
1844        }
1845    }
1846}