Skip to main content

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