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