fidl_fuchsia_net_policy_properties__common/
fidl_fuchsia_net_policy_properties__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 Property {
13    SocketMarks,
14    DnsConfiguration,
15    #[doc(hidden)]
16    __SourceBreaking {
17        unknown_ordinal: u32,
18    },
19}
20
21/// Pattern that matches an unknown `Property` member.
22#[macro_export]
23macro_rules! PropertyUnknown {
24    () => {
25        _
26    };
27}
28
29impl Property {
30    #[inline]
31    pub fn from_primitive(prim: u32) -> Option<Self> {
32        match prim {
33            1 => Some(Self::SocketMarks),
34            2 => Some(Self::DnsConfiguration),
35            _ => None,
36        }
37    }
38
39    #[inline]
40    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
41        match prim {
42            1 => Self::SocketMarks,
43            2 => Self::DnsConfiguration,
44            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
45        }
46    }
47
48    #[inline]
49    pub fn unknown() -> Self {
50        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
51    }
52
53    #[inline]
54    pub const fn into_primitive(self) -> u32 {
55        match self {
56            Self::SocketMarks => 1,
57            Self::DnsConfiguration => 2,
58            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
59        }
60    }
61
62    #[inline]
63    pub fn is_unknown(&self) -> bool {
64        match self {
65            Self::__SourceBreaking { unknown_ordinal: _ } => true,
66            _ => false,
67        }
68    }
69}
70
71#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
72pub enum WatchError {
73    /// The provided `properties` list was empty.
74    NoProperties,
75    /// The provided NetworkToken was either not acquired from
76    /// [`WatchDefault`] or is no longer valid.
77    InvalidNetworkToken,
78    /// When the network represented by `network` no longer exists, a new
79    /// [`NetworkToken`] must be acquired.
80    NetworkGone,
81    /// When the network represented by `network` is no longer the default
82    /// network, a new [`NetworkToken`] must be acquired.
83    DefaultNetworkChanged,
84    /// When there is no longer a default network, a new [`NetworkToken`]
85    /// must be acquired.
86    DefaultNetworkLost,
87    /// An argument marked above as REQUIRED was not provided.
88    MissingRequiredArgument,
89    #[doc(hidden)]
90    __SourceBreaking { unknown_ordinal: u32 },
91}
92
93/// Pattern that matches an unknown `WatchError` member.
94#[macro_export]
95macro_rules! WatchErrorUnknown {
96    () => {
97        _
98    };
99}
100
101impl WatchError {
102    #[inline]
103    pub fn from_primitive(prim: u32) -> Option<Self> {
104        match prim {
105            1 => Some(Self::NoProperties),
106            2 => Some(Self::InvalidNetworkToken),
107            3 => Some(Self::NetworkGone),
108            4 => Some(Self::DefaultNetworkChanged),
109            5 => Some(Self::DefaultNetworkLost),
110            99 => Some(Self::MissingRequiredArgument),
111            _ => None,
112        }
113    }
114
115    #[inline]
116    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
117        match prim {
118            1 => Self::NoProperties,
119            2 => Self::InvalidNetworkToken,
120            3 => Self::NetworkGone,
121            4 => Self::DefaultNetworkChanged,
122            5 => Self::DefaultNetworkLost,
123            99 => Self::MissingRequiredArgument,
124            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
125        }
126    }
127
128    #[inline]
129    pub fn unknown() -> Self {
130        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
131    }
132
133    #[inline]
134    pub const fn into_primitive(self) -> u32 {
135        match self {
136            Self::NoProperties => 1,
137            Self::InvalidNetworkToken => 2,
138            Self::NetworkGone => 3,
139            Self::DefaultNetworkChanged => 4,
140            Self::DefaultNetworkLost => 5,
141            Self::MissingRequiredArgument => 99,
142            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
143        }
144    }
145
146    #[inline]
147    pub fn is_unknown(&self) -> bool {
148        match self {
149            Self::__SourceBreaking { unknown_ordinal: _ } => true,
150            _ => false,
151        }
152    }
153}
154
155#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
156pub struct Empty;
157
158impl fidl::Persistable for Empty {}
159
160#[derive(Clone, Debug, PartialEq)]
161pub struct NetworksWatchPropertiesResponse {
162    /// A list of updates that have happened since the last call to
163    /// `WatchProperties` returned. There is no guarantee of ordering. If a
164    /// property changes multiple times between updates, only the most
165    /// recent version will be reported.
166    pub updates: Vec<PropertyUpdate>,
167}
168
169impl fidl::Persistable for NetworksWatchPropertiesResponse {}
170
171#[derive(Clone, Debug, Default, PartialEq)]
172pub struct DefaultNetworkUpdate {
173    /// The value of the new interface id.
174    /// NOTE: Required if `socket_marks` is set.
175    pub interface_id: Option<u64>,
176    /// The socket marks associated with that interface.
177    /// NOTE: Required if `interface_id` is set.
178    pub socket_marks: Option<fidl_fuchsia_net__common::Marks>,
179    #[doc(hidden)]
180    pub __source_breaking: fidl::marker::SourceBreaking,
181}
182
183impl fidl::Persistable for DefaultNetworkUpdate {}
184
185#[derive(Clone, Debug, Default, PartialEq)]
186pub struct DnsConfiguration {
187    /// A preference ordered list of [`fuchsia.net.name.DnsServer`]s.
188    /// NOTE: Required, this field must always be set.
189    pub servers: Option<Vec<fidl_fuchsia_net_name__common::DnsServer_>>,
190    #[doc(hidden)]
191    pub __source_breaking: fidl::marker::SourceBreaking,
192}
193
194impl fidl::Persistable for DnsConfiguration {}
195
196/// A single update from [`Networks.WatchProperties`].
197#[derive(Clone, Debug)]
198pub enum PropertyUpdate {
199    /// The socket marks associated with this network.
200    SocketMarks(fidl_fuchsia_net__common::Marks),
201    /// The DNS Configuration associated with this network.
202    DnsConfiguration(DnsConfiguration),
203    #[doc(hidden)]
204    __SourceBreaking { unknown_ordinal: u64 },
205}
206
207/// Pattern that matches an unknown `PropertyUpdate` member.
208#[macro_export]
209macro_rules! PropertyUpdateUnknown {
210    () => {
211        _
212    };
213}
214
215// Custom PartialEq so that unknown variants are not equal to themselves.
216impl PartialEq for PropertyUpdate {
217    fn eq(&self, other: &Self) -> bool {
218        match (self, other) {
219            (Self::SocketMarks(x), Self::SocketMarks(y)) => *x == *y,
220            (Self::DnsConfiguration(x), Self::DnsConfiguration(y)) => *x == *y,
221            _ => false,
222        }
223    }
224}
225
226impl PropertyUpdate {
227    #[inline]
228    pub fn ordinal(&self) -> u64 {
229        match *self {
230            Self::SocketMarks(_) => 1,
231            Self::DnsConfiguration(_) => 2,
232            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
233        }
234    }
235
236    #[inline]
237    pub fn unknown_variant_for_testing() -> Self {
238        Self::__SourceBreaking { unknown_ordinal: 0 }
239    }
240
241    #[inline]
242    pub fn is_unknown(&self) -> bool {
243        match self {
244            Self::__SourceBreaking { .. } => true,
245            _ => false,
246        }
247    }
248}
249
250impl fidl::Persistable for PropertyUpdate {}
251
252pub mod default_network_watcher_ordinals {
253    pub const WATCH: u64 = 0x5fa419d19afc90b2;
254}
255
256pub mod networks_ordinals {
257    pub const WATCH_DEFAULT: u64 = 0x346880b2d7db0f98;
258    pub const WATCH_PROPERTIES: u64 = 0x24d2340905f7dcc6;
259}
260
261mod internal {
262    use super::*;
263    unsafe impl fidl::encoding::TypeMarker for Property {
264        type Owned = Self;
265
266        #[inline(always)]
267        fn inline_align(_context: fidl::encoding::Context) -> usize {
268            std::mem::align_of::<u32>()
269        }
270
271        #[inline(always)]
272        fn inline_size(_context: fidl::encoding::Context) -> usize {
273            std::mem::size_of::<u32>()
274        }
275
276        #[inline(always)]
277        fn encode_is_copy() -> bool {
278            false
279        }
280
281        #[inline(always)]
282        fn decode_is_copy() -> bool {
283            false
284        }
285    }
286
287    impl fidl::encoding::ValueTypeMarker for Property {
288        type Borrowed<'a> = Self;
289        #[inline(always)]
290        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
291            *value
292        }
293    }
294
295    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Property {
296        #[inline]
297        unsafe fn encode(
298            self,
299            encoder: &mut fidl::encoding::Encoder<'_, D>,
300            offset: usize,
301            _depth: fidl::encoding::Depth,
302        ) -> fidl::Result<()> {
303            encoder.debug_check_bounds::<Self>(offset);
304            encoder.write_num(self.into_primitive(), offset);
305            Ok(())
306        }
307    }
308
309    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Property {
310        #[inline(always)]
311        fn new_empty() -> Self {
312            Self::unknown()
313        }
314
315        #[inline]
316        unsafe fn decode(
317            &mut self,
318            decoder: &mut fidl::encoding::Decoder<'_, D>,
319            offset: usize,
320            _depth: fidl::encoding::Depth,
321        ) -> fidl::Result<()> {
322            decoder.debug_check_bounds::<Self>(offset);
323            let prim = decoder.read_num::<u32>(offset);
324
325            *self = Self::from_primitive_allow_unknown(prim);
326            Ok(())
327        }
328    }
329    unsafe impl fidl::encoding::TypeMarker for WatchError {
330        type Owned = Self;
331
332        #[inline(always)]
333        fn inline_align(_context: fidl::encoding::Context) -> usize {
334            std::mem::align_of::<u32>()
335        }
336
337        #[inline(always)]
338        fn inline_size(_context: fidl::encoding::Context) -> usize {
339            std::mem::size_of::<u32>()
340        }
341
342        #[inline(always)]
343        fn encode_is_copy() -> bool {
344            false
345        }
346
347        #[inline(always)]
348        fn decode_is_copy() -> bool {
349            false
350        }
351    }
352
353    impl fidl::encoding::ValueTypeMarker for WatchError {
354        type Borrowed<'a> = Self;
355        #[inline(always)]
356        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
357            *value
358        }
359    }
360
361    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for WatchError {
362        #[inline]
363        unsafe fn encode(
364            self,
365            encoder: &mut fidl::encoding::Encoder<'_, D>,
366            offset: usize,
367            _depth: fidl::encoding::Depth,
368        ) -> fidl::Result<()> {
369            encoder.debug_check_bounds::<Self>(offset);
370            encoder.write_num(self.into_primitive(), offset);
371            Ok(())
372        }
373    }
374
375    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WatchError {
376        #[inline(always)]
377        fn new_empty() -> Self {
378            Self::unknown()
379        }
380
381        #[inline]
382        unsafe fn decode(
383            &mut self,
384            decoder: &mut fidl::encoding::Decoder<'_, D>,
385            offset: usize,
386            _depth: fidl::encoding::Depth,
387        ) -> fidl::Result<()> {
388            decoder.debug_check_bounds::<Self>(offset);
389            let prim = decoder.read_num::<u32>(offset);
390
391            *self = Self::from_primitive_allow_unknown(prim);
392            Ok(())
393        }
394    }
395
396    impl fidl::encoding::ValueTypeMarker for Empty {
397        type Borrowed<'a> = &'a Self;
398        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
399            value
400        }
401    }
402
403    unsafe impl fidl::encoding::TypeMarker for Empty {
404        type Owned = Self;
405
406        #[inline(always)]
407        fn inline_align(_context: fidl::encoding::Context) -> usize {
408            1
409        }
410
411        #[inline(always)]
412        fn inline_size(_context: fidl::encoding::Context) -> usize {
413            1
414        }
415    }
416
417    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Empty, D> for &Empty {
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::<Empty>(offset);
426            encoder.write_num(0u8, offset);
427            Ok(())
428        }
429    }
430
431    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Empty {
432        #[inline(always)]
433        fn new_empty() -> Self {
434            Self
435        }
436
437        #[inline]
438        unsafe fn decode(
439            &mut self,
440            decoder: &mut fidl::encoding::Decoder<'_, D>,
441            offset: usize,
442            _depth: fidl::encoding::Depth,
443        ) -> fidl::Result<()> {
444            decoder.debug_check_bounds::<Self>(offset);
445            match decoder.read_num::<u8>(offset) {
446                0 => Ok(()),
447                _ => Err(fidl::Error::Invalid),
448            }
449        }
450    }
451
452    impl fidl::encoding::ValueTypeMarker for NetworksWatchPropertiesResponse {
453        type Borrowed<'a> = &'a Self;
454        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
455            value
456        }
457    }
458
459    unsafe impl fidl::encoding::TypeMarker for NetworksWatchPropertiesResponse {
460        type Owned = Self;
461
462        #[inline(always)]
463        fn inline_align(_context: fidl::encoding::Context) -> usize {
464            8
465        }
466
467        #[inline(always)]
468        fn inline_size(_context: fidl::encoding::Context) -> usize {
469            16
470        }
471    }
472
473    unsafe impl<D: fidl::encoding::ResourceDialect>
474        fidl::encoding::Encode<NetworksWatchPropertiesResponse, D>
475        for &NetworksWatchPropertiesResponse
476    {
477        #[inline]
478        unsafe fn encode(
479            self,
480            encoder: &mut fidl::encoding::Encoder<'_, D>,
481            offset: usize,
482            _depth: fidl::encoding::Depth,
483        ) -> fidl::Result<()> {
484            encoder.debug_check_bounds::<NetworksWatchPropertiesResponse>(offset);
485            // Delegate to tuple encoding.
486            fidl::encoding::Encode::<NetworksWatchPropertiesResponse, D>::encode(
487                (
488                    <fidl::encoding::UnboundedVector<PropertyUpdate> as fidl::encoding::ValueTypeMarker>::borrow(&self.updates),
489                ),
490                encoder, offset, _depth
491            )
492        }
493    }
494    unsafe impl<
495        D: fidl::encoding::ResourceDialect,
496        T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<PropertyUpdate>, D>,
497    > fidl::encoding::Encode<NetworksWatchPropertiesResponse, D> for (T0,)
498    {
499        #[inline]
500        unsafe fn encode(
501            self,
502            encoder: &mut fidl::encoding::Encoder<'_, D>,
503            offset: usize,
504            depth: fidl::encoding::Depth,
505        ) -> fidl::Result<()> {
506            encoder.debug_check_bounds::<NetworksWatchPropertiesResponse>(offset);
507            // Zero out padding regions. There's no need to apply masks
508            // because the unmasked parts will be overwritten by fields.
509            // Write the fields.
510            self.0.encode(encoder, offset + 0, depth)?;
511            Ok(())
512        }
513    }
514
515    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
516        for NetworksWatchPropertiesResponse
517    {
518        #[inline(always)]
519        fn new_empty() -> Self {
520            Self { updates: fidl::new_empty!(fidl::encoding::UnboundedVector<PropertyUpdate>, D) }
521        }
522
523        #[inline]
524        unsafe fn decode(
525            &mut self,
526            decoder: &mut fidl::encoding::Decoder<'_, D>,
527            offset: usize,
528            _depth: fidl::encoding::Depth,
529        ) -> fidl::Result<()> {
530            decoder.debug_check_bounds::<Self>(offset);
531            // Verify that padding bytes are zero.
532            fidl::decode!(
533                fidl::encoding::UnboundedVector<PropertyUpdate>,
534                D,
535                &mut self.updates,
536                decoder,
537                offset + 0,
538                _depth
539            )?;
540            Ok(())
541        }
542    }
543
544    impl DefaultNetworkUpdate {
545        #[inline(always)]
546        fn max_ordinal_present(&self) -> u64 {
547            if let Some(_) = self.socket_marks {
548                return 2;
549            }
550            if let Some(_) = self.interface_id {
551                return 1;
552            }
553            0
554        }
555    }
556
557    impl fidl::encoding::ValueTypeMarker for DefaultNetworkUpdate {
558        type Borrowed<'a> = &'a Self;
559        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
560            value
561        }
562    }
563
564    unsafe impl fidl::encoding::TypeMarker for DefaultNetworkUpdate {
565        type Owned = Self;
566
567        #[inline(always)]
568        fn inline_align(_context: fidl::encoding::Context) -> usize {
569            8
570        }
571
572        #[inline(always)]
573        fn inline_size(_context: fidl::encoding::Context) -> usize {
574            16
575        }
576    }
577
578    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DefaultNetworkUpdate, D>
579        for &DefaultNetworkUpdate
580    {
581        unsafe fn encode(
582            self,
583            encoder: &mut fidl::encoding::Encoder<'_, D>,
584            offset: usize,
585            mut depth: fidl::encoding::Depth,
586        ) -> fidl::Result<()> {
587            encoder.debug_check_bounds::<DefaultNetworkUpdate>(offset);
588            // Vector header
589            let max_ordinal: u64 = self.max_ordinal_present();
590            encoder.write_num(max_ordinal, offset);
591            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
592            // Calling encoder.out_of_line_offset(0) is not allowed.
593            if max_ordinal == 0 {
594                return Ok(());
595            }
596            depth.increment()?;
597            let envelope_size = 8;
598            let bytes_len = max_ordinal as usize * envelope_size;
599            #[allow(unused_variables)]
600            let offset = encoder.out_of_line_offset(bytes_len);
601            let mut _prev_end_offset: usize = 0;
602            if 1 > max_ordinal {
603                return Ok(());
604            }
605
606            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
607            // are envelope_size bytes.
608            let cur_offset: usize = (1 - 1) * envelope_size;
609
610            // Zero reserved fields.
611            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
612
613            // Safety:
614            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
615            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
616            //   envelope_size bytes, there is always sufficient room.
617            fidl::encoding::encode_in_envelope_optional::<u64, D>(
618                self.interface_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
619                encoder,
620                offset + cur_offset,
621                depth,
622            )?;
623
624            _prev_end_offset = cur_offset + envelope_size;
625            if 2 > max_ordinal {
626                return Ok(());
627            }
628
629            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
630            // are envelope_size bytes.
631            let cur_offset: usize = (2 - 1) * envelope_size;
632
633            // Zero reserved fields.
634            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
635
636            // Safety:
637            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
638            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
639            //   envelope_size bytes, there is always sufficient room.
640            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_net__common::Marks, D>(
641                self.socket_marks.as_ref().map(
642                    <fidl_fuchsia_net__common::Marks as fidl::encoding::ValueTypeMarker>::borrow,
643                ),
644                encoder,
645                offset + cur_offset,
646                depth,
647            )?;
648
649            _prev_end_offset = cur_offset + envelope_size;
650
651            Ok(())
652        }
653    }
654
655    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DefaultNetworkUpdate {
656        #[inline(always)]
657        fn new_empty() -> Self {
658            Self::default()
659        }
660
661        unsafe fn decode(
662            &mut self,
663            decoder: &mut fidl::encoding::Decoder<'_, D>,
664            offset: usize,
665            mut depth: fidl::encoding::Depth,
666        ) -> fidl::Result<()> {
667            decoder.debug_check_bounds::<Self>(offset);
668            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
669                None => return Err(fidl::Error::NotNullable),
670                Some(len) => len,
671            };
672            // Calling decoder.out_of_line_offset(0) is not allowed.
673            if len == 0 {
674                return Ok(());
675            };
676            depth.increment()?;
677            let envelope_size = 8;
678            let bytes_len = len * envelope_size;
679            let offset = decoder.out_of_line_offset(bytes_len)?;
680            // Decode the envelope for each type.
681            let mut _next_ordinal_to_read = 0;
682            let mut next_offset = offset;
683            let end_offset = offset + bytes_len;
684            _next_ordinal_to_read += 1;
685            if next_offset >= end_offset {
686                return Ok(());
687            }
688
689            // Decode unknown envelopes for gaps in ordinals.
690            while _next_ordinal_to_read < 1 {
691                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
692                _next_ordinal_to_read += 1;
693                next_offset += envelope_size;
694            }
695
696            let next_out_of_line = decoder.next_out_of_line();
697            let handles_before = decoder.remaining_handles();
698            if let Some((inlined, num_bytes, num_handles)) =
699                fidl::encoding::decode_envelope_header(decoder, next_offset)?
700            {
701                let member_inline_size =
702                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
703                if inlined != (member_inline_size <= 4) {
704                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
705                }
706                let inner_offset;
707                let mut inner_depth = depth.clone();
708                if inlined {
709                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
710                    inner_offset = next_offset;
711                } else {
712                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
713                    inner_depth.increment()?;
714                }
715                let val_ref = self.interface_id.get_or_insert_with(|| fidl::new_empty!(u64, D));
716                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
717                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
718                {
719                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
720                }
721                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
722                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
723                }
724            }
725
726            next_offset += envelope_size;
727            _next_ordinal_to_read += 1;
728            if next_offset >= end_offset {
729                return Ok(());
730            }
731
732            // Decode unknown envelopes for gaps in ordinals.
733            while _next_ordinal_to_read < 2 {
734                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
735                _next_ordinal_to_read += 1;
736                next_offset += envelope_size;
737            }
738
739            let next_out_of_line = decoder.next_out_of_line();
740            let handles_before = decoder.remaining_handles();
741            if let Some((inlined, num_bytes, num_handles)) =
742                fidl::encoding::decode_envelope_header(decoder, next_offset)?
743            {
744                let member_inline_size =
745                    <fidl_fuchsia_net__common::Marks as fidl::encoding::TypeMarker>::inline_size(
746                        decoder.context,
747                    );
748                if inlined != (member_inline_size <= 4) {
749                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
750                }
751                let inner_offset;
752                let mut inner_depth = depth.clone();
753                if inlined {
754                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
755                    inner_offset = next_offset;
756                } else {
757                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
758                    inner_depth.increment()?;
759                }
760                let val_ref = self
761                    .socket_marks
762                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_net__common::Marks, D));
763                fidl::decode!(
764                    fidl_fuchsia_net__common::Marks,
765                    D,
766                    val_ref,
767                    decoder,
768                    inner_offset,
769                    inner_depth
770                )?;
771                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
772                {
773                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
774                }
775                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
776                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
777                }
778            }
779
780            next_offset += envelope_size;
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 DnsConfiguration {
794        #[inline(always)]
795        fn max_ordinal_present(&self) -> u64 {
796            if let Some(_) = self.servers {
797                return 1;
798            }
799            0
800        }
801    }
802
803    impl fidl::encoding::ValueTypeMarker for DnsConfiguration {
804        type Borrowed<'a> = &'a Self;
805        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
806            value
807        }
808    }
809
810    unsafe impl fidl::encoding::TypeMarker for DnsConfiguration {
811        type Owned = Self;
812
813        #[inline(always)]
814        fn inline_align(_context: fidl::encoding::Context) -> usize {
815            8
816        }
817
818        #[inline(always)]
819        fn inline_size(_context: fidl::encoding::Context) -> usize {
820            16
821        }
822    }
823
824    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DnsConfiguration, D>
825        for &DnsConfiguration
826    {
827        unsafe fn encode(
828            self,
829            encoder: &mut fidl::encoding::Encoder<'_, D>,
830            offset: usize,
831            mut depth: fidl::encoding::Depth,
832        ) -> fidl::Result<()> {
833            encoder.debug_check_bounds::<DnsConfiguration>(offset);
834            // Vector header
835            let max_ordinal: u64 = self.max_ordinal_present();
836            encoder.write_num(max_ordinal, offset);
837            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
838            // Calling encoder.out_of_line_offset(0) is not allowed.
839            if max_ordinal == 0 {
840                return Ok(());
841            }
842            depth.increment()?;
843            let envelope_size = 8;
844            let bytes_len = max_ordinal as usize * envelope_size;
845            #[allow(unused_variables)]
846            let offset = encoder.out_of_line_offset(bytes_len);
847            let mut _prev_end_offset: usize = 0;
848            if 1 > max_ordinal {
849                return Ok(());
850            }
851
852            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
853            // are envelope_size bytes.
854            let cur_offset: usize = (1 - 1) * envelope_size;
855
856            // Zero reserved fields.
857            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
858
859            // Safety:
860            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
861            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
862            //   envelope_size bytes, there is always sufficient room.
863            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl_fuchsia_net_name__common::DnsServer_>, D>(
864            self.servers.as_ref().map(<fidl::encoding::UnboundedVector<fidl_fuchsia_net_name__common::DnsServer_> as fidl::encoding::ValueTypeMarker>::borrow),
865            encoder, offset + cur_offset, depth
866        )?;
867
868            _prev_end_offset = cur_offset + envelope_size;
869
870            Ok(())
871        }
872    }
873
874    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DnsConfiguration {
875        #[inline(always)]
876        fn new_empty() -> Self {
877            Self::default()
878        }
879
880        unsafe fn decode(
881            &mut self,
882            decoder: &mut fidl::encoding::Decoder<'_, D>,
883            offset: usize,
884            mut depth: fidl::encoding::Depth,
885        ) -> fidl::Result<()> {
886            decoder.debug_check_bounds::<Self>(offset);
887            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
888                None => return Err(fidl::Error::NotNullable),
889                Some(len) => len,
890            };
891            // Calling decoder.out_of_line_offset(0) is not allowed.
892            if len == 0 {
893                return Ok(());
894            };
895            depth.increment()?;
896            let envelope_size = 8;
897            let bytes_len = len * envelope_size;
898            let offset = decoder.out_of_line_offset(bytes_len)?;
899            // Decode the envelope for each type.
900            let mut _next_ordinal_to_read = 0;
901            let mut next_offset = offset;
902            let end_offset = offset + bytes_len;
903            _next_ordinal_to_read += 1;
904            if next_offset >= end_offset {
905                return Ok(());
906            }
907
908            // Decode unknown envelopes for gaps in ordinals.
909            while _next_ordinal_to_read < 1 {
910                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
911                _next_ordinal_to_read += 1;
912                next_offset += envelope_size;
913            }
914
915            let next_out_of_line = decoder.next_out_of_line();
916            let handles_before = decoder.remaining_handles();
917            if let Some((inlined, num_bytes, num_handles)) =
918                fidl::encoding::decode_envelope_header(decoder, next_offset)?
919            {
920                let member_inline_size = <fidl::encoding::UnboundedVector<
921                    fidl_fuchsia_net_name__common::DnsServer_,
922                > as fidl::encoding::TypeMarker>::inline_size(
923                    decoder.context
924                );
925                if inlined != (member_inline_size <= 4) {
926                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
927                }
928                let inner_offset;
929                let mut inner_depth = depth.clone();
930                if inlined {
931                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
932                    inner_offset = next_offset;
933                } else {
934                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
935                    inner_depth.increment()?;
936                }
937                let val_ref = self.servers.get_or_insert_with(|| {
938                    fidl::new_empty!(
939                        fidl::encoding::UnboundedVector<fidl_fuchsia_net_name__common::DnsServer_>,
940                        D
941                    )
942                });
943                fidl::decode!(
944                    fidl::encoding::UnboundedVector<fidl_fuchsia_net_name__common::DnsServer_>,
945                    D,
946                    val_ref,
947                    decoder,
948                    inner_offset,
949                    inner_depth
950                )?;
951                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
952                {
953                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
954                }
955                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
956                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
957                }
958            }
959
960            next_offset += envelope_size;
961
962            // Decode the remaining unknown envelopes.
963            while next_offset < end_offset {
964                _next_ordinal_to_read += 1;
965                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
966                next_offset += envelope_size;
967            }
968
969            Ok(())
970        }
971    }
972
973    impl fidl::encoding::ValueTypeMarker for PropertyUpdate {
974        type Borrowed<'a> = &'a Self;
975        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
976            value
977        }
978    }
979
980    unsafe impl fidl::encoding::TypeMarker for PropertyUpdate {
981        type Owned = Self;
982
983        #[inline(always)]
984        fn inline_align(_context: fidl::encoding::Context) -> usize {
985            8
986        }
987
988        #[inline(always)]
989        fn inline_size(_context: fidl::encoding::Context) -> usize {
990            16
991        }
992    }
993
994    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PropertyUpdate, D>
995        for &PropertyUpdate
996    {
997        #[inline]
998        unsafe fn encode(
999            self,
1000            encoder: &mut fidl::encoding::Encoder<'_, D>,
1001            offset: usize,
1002            _depth: fidl::encoding::Depth,
1003        ) -> fidl::Result<()> {
1004            encoder.debug_check_bounds::<PropertyUpdate>(offset);
1005            encoder.write_num::<u64>(self.ordinal(), offset);
1006            match self {
1007                PropertyUpdate::SocketMarks(ref val) => fidl::encoding::encode_in_envelope::<
1008                    fidl_fuchsia_net__common::Marks,
1009                    D,
1010                >(
1011                    <fidl_fuchsia_net__common::Marks as fidl::encoding::ValueTypeMarker>::borrow(
1012                        val,
1013                    ),
1014                    encoder,
1015                    offset + 8,
1016                    _depth,
1017                ),
1018                PropertyUpdate::DnsConfiguration(ref val) => {
1019                    fidl::encoding::encode_in_envelope::<DnsConfiguration, D>(
1020                        <DnsConfiguration as fidl::encoding::ValueTypeMarker>::borrow(val),
1021                        encoder,
1022                        offset + 8,
1023                        _depth,
1024                    )
1025                }
1026                PropertyUpdate::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1027            }
1028        }
1029    }
1030
1031    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PropertyUpdate {
1032        #[inline(always)]
1033        fn new_empty() -> Self {
1034            Self::__SourceBreaking { unknown_ordinal: 0 }
1035        }
1036
1037        #[inline]
1038        unsafe fn decode(
1039            &mut self,
1040            decoder: &mut fidl::encoding::Decoder<'_, D>,
1041            offset: usize,
1042            mut depth: fidl::encoding::Depth,
1043        ) -> fidl::Result<()> {
1044            decoder.debug_check_bounds::<Self>(offset);
1045            #[allow(unused_variables)]
1046            let next_out_of_line = decoder.next_out_of_line();
1047            let handles_before = decoder.remaining_handles();
1048            let (ordinal, inlined, num_bytes, num_handles) =
1049                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1050
1051            let member_inline_size = match ordinal {
1052                1 => <fidl_fuchsia_net__common::Marks as fidl::encoding::TypeMarker>::inline_size(
1053                    decoder.context,
1054                ),
1055                2 => <DnsConfiguration as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1056                0 => return Err(fidl::Error::UnknownUnionTag),
1057                _ => num_bytes as usize,
1058            };
1059
1060            if inlined != (member_inline_size <= 4) {
1061                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1062            }
1063            let _inner_offset;
1064            if inlined {
1065                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1066                _inner_offset = offset + 8;
1067            } else {
1068                depth.increment()?;
1069                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1070            }
1071            match ordinal {
1072                1 => {
1073                    #[allow(irrefutable_let_patterns)]
1074                    if let PropertyUpdate::SocketMarks(_) = self {
1075                        // Do nothing, read the value into the object
1076                    } else {
1077                        // Initialize `self` to the right variant
1078                        *self = PropertyUpdate::SocketMarks(fidl::new_empty!(
1079                            fidl_fuchsia_net__common::Marks,
1080                            D
1081                        ));
1082                    }
1083                    #[allow(irrefutable_let_patterns)]
1084                    if let PropertyUpdate::SocketMarks(ref mut val) = self {
1085                        fidl::decode!(
1086                            fidl_fuchsia_net__common::Marks,
1087                            D,
1088                            val,
1089                            decoder,
1090                            _inner_offset,
1091                            depth
1092                        )?;
1093                    } else {
1094                        unreachable!()
1095                    }
1096                }
1097                2 => {
1098                    #[allow(irrefutable_let_patterns)]
1099                    if let PropertyUpdate::DnsConfiguration(_) = self {
1100                        // Do nothing, read the value into the object
1101                    } else {
1102                        // Initialize `self` to the right variant
1103                        *self =
1104                            PropertyUpdate::DnsConfiguration(fidl::new_empty!(DnsConfiguration, D));
1105                    }
1106                    #[allow(irrefutable_let_patterns)]
1107                    if let PropertyUpdate::DnsConfiguration(ref mut val) = self {
1108                        fidl::decode!(DnsConfiguration, D, val, decoder, _inner_offset, depth)?;
1109                    } else {
1110                        unreachable!()
1111                    }
1112                }
1113                #[allow(deprecated)]
1114                ordinal => {
1115                    for _ in 0..num_handles {
1116                        decoder.drop_next_handle()?;
1117                    }
1118                    *self = PropertyUpdate::__SourceBreaking { unknown_ordinal: ordinal };
1119                }
1120            }
1121            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1122                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1123            }
1124            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1125                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1126            }
1127            Ok(())
1128        }
1129    }
1130}