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