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