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
432pub mod base_route_table_ordinals {
433    pub const GET_TABLE_ID: u64 = 0x7eab30c55edbfc15;
434    pub const DETACH: u64 = 0x2853ab157285b384;
435    pub const REMOVE: u64 = 0xc42e58a5fc79426;
436    pub const GET_AUTHORIZATION_FOR_ROUTE_TABLE: u64 = 0x56a48c921ff3b6eb;
437}
438
439pub mod base_rule_set_ordinals {
440    pub const AUTHENTICATE_FOR_ROUTE_TABLE: u64 = 0x6fd845360ed9bc8f;
441    pub const REMOVE_RULE: u64 = 0x2ae3d7e817cbff90;
442    pub const CLOSE: u64 = 0x457e1753672d4073;
443}
444
445pub mod route_set_v4_ordinals {
446    pub const AUTHENTICATE_FOR_INTERFACE: u64 = 0x74841ceef127518e;
447    pub const ADD_ROUTE: u64 = 0x4bd69e45539e8ec0;
448    pub const REMOVE_ROUTE: u64 = 0x514f6880232f1665;
449}
450
451pub mod route_set_v6_ordinals {
452    pub const AUTHENTICATE_FOR_INTERFACE: u64 = 0x7d63a6a7aed6f640;
453    pub const ADD_ROUTE: u64 = 0x67a2bd2ee34ace2e;
454    pub const REMOVE_ROUTE: u64 = 0x4e5b7d4b1112cd82;
455}
456
457pub mod route_table_provider_v4_ordinals {
458    pub const NEW_ROUTE_TABLE: u64 = 0x703bc0eaf98f07cf;
459}
460
461pub mod route_table_provider_v6_ordinals {
462    pub const NEW_ROUTE_TABLE: u64 = 0x152b67b397a31ca;
463}
464
465pub mod route_table_v4_ordinals {
466    pub const GET_TABLE_ID: u64 = 0x7eab30c55edbfc15;
467    pub const DETACH: u64 = 0x2853ab157285b384;
468    pub const REMOVE: u64 = 0xc42e58a5fc79426;
469    pub const GET_AUTHORIZATION_FOR_ROUTE_TABLE: u64 = 0x56a48c921ff3b6eb;
470    pub const NEW_ROUTE_SET: u64 = 0x6aeb6d05698abedb;
471}
472
473pub mod route_table_v6_ordinals {
474    pub const GET_TABLE_ID: u64 = 0x7eab30c55edbfc15;
475    pub const DETACH: u64 = 0x2853ab157285b384;
476    pub const REMOVE: u64 = 0xc42e58a5fc79426;
477    pub const GET_AUTHORIZATION_FOR_ROUTE_TABLE: u64 = 0x56a48c921ff3b6eb;
478    pub const NEW_ROUTE_SET: u64 = 0x479aeaf9ad470141;
479}
480
481pub mod rule_set_v4_ordinals {
482    pub const AUTHENTICATE_FOR_ROUTE_TABLE: u64 = 0x6fd845360ed9bc8f;
483    pub const REMOVE_RULE: u64 = 0x2ae3d7e817cbff90;
484    pub const CLOSE: u64 = 0x457e1753672d4073;
485    pub const ADD_RULE: u64 = 0x7f68325de94e80;
486}
487
488pub mod rule_set_v6_ordinals {
489    pub const AUTHENTICATE_FOR_ROUTE_TABLE: u64 = 0x6fd845360ed9bc8f;
490    pub const REMOVE_RULE: u64 = 0x2ae3d7e817cbff90;
491    pub const CLOSE: u64 = 0x457e1753672d4073;
492    pub const ADD_RULE: u64 = 0x946cad8f8a726b3;
493}
494
495pub mod rule_table_v4_ordinals {
496    pub const NEW_RULE_SET: u64 = 0xa32a9097da46f3a;
497}
498
499pub mod rule_table_v6_ordinals {
500    pub const NEW_RULE_SET: u64 = 0x2261cc6eee9726a0;
501}
502
503mod internal {
504    use super::*;
505    unsafe impl fidl::encoding::TypeMarker for AuthenticateForInterfaceError {
506        type Owned = Self;
507
508        #[inline(always)]
509        fn inline_align(_context: fidl::encoding::Context) -> usize {
510            std::mem::align_of::<u32>()
511        }
512
513        #[inline(always)]
514        fn inline_size(_context: fidl::encoding::Context) -> usize {
515            std::mem::size_of::<u32>()
516        }
517
518        #[inline(always)]
519        fn encode_is_copy() -> bool {
520            false
521        }
522
523        #[inline(always)]
524        fn decode_is_copy() -> bool {
525            false
526        }
527    }
528
529    impl fidl::encoding::ValueTypeMarker for AuthenticateForInterfaceError {
530        type Borrowed<'a> = Self;
531        #[inline(always)]
532        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
533            *value
534        }
535    }
536
537    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
538        for AuthenticateForInterfaceError
539    {
540        #[inline]
541        unsafe fn encode(
542            self,
543            encoder: &mut fidl::encoding::Encoder<'_, D>,
544            offset: usize,
545            _depth: fidl::encoding::Depth,
546        ) -> fidl::Result<()> {
547            encoder.debug_check_bounds::<Self>(offset);
548            encoder.write_num(self.into_primitive(), offset);
549            Ok(())
550        }
551    }
552
553    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
554        for AuthenticateForInterfaceError
555    {
556        #[inline(always)]
557        fn new_empty() -> Self {
558            Self::unknown()
559        }
560
561        #[inline]
562        unsafe fn decode(
563            &mut self,
564            decoder: &mut fidl::encoding::Decoder<'_, D>,
565            offset: usize,
566            _depth: fidl::encoding::Depth,
567        ) -> fidl::Result<()> {
568            decoder.debug_check_bounds::<Self>(offset);
569            let prim = decoder.read_num::<u32>(offset);
570
571            *self = Self::from_primitive_allow_unknown(prim);
572            Ok(())
573        }
574    }
575    unsafe impl fidl::encoding::TypeMarker for AuthenticateForRouteTableError {
576        type Owned = Self;
577
578        #[inline(always)]
579        fn inline_align(_context: fidl::encoding::Context) -> usize {
580            std::mem::align_of::<u32>()
581        }
582
583        #[inline(always)]
584        fn inline_size(_context: fidl::encoding::Context) -> usize {
585            std::mem::size_of::<u32>()
586        }
587
588        #[inline(always)]
589        fn encode_is_copy() -> bool {
590            false
591        }
592
593        #[inline(always)]
594        fn decode_is_copy() -> bool {
595            false
596        }
597    }
598
599    impl fidl::encoding::ValueTypeMarker for AuthenticateForRouteTableError {
600        type Borrowed<'a> = Self;
601        #[inline(always)]
602        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
603            *value
604        }
605    }
606
607    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
608        for AuthenticateForRouteTableError
609    {
610        #[inline]
611        unsafe fn encode(
612            self,
613            encoder: &mut fidl::encoding::Encoder<'_, D>,
614            offset: usize,
615            _depth: fidl::encoding::Depth,
616        ) -> fidl::Result<()> {
617            encoder.debug_check_bounds::<Self>(offset);
618            encoder.write_num(self.into_primitive(), offset);
619            Ok(())
620        }
621    }
622
623    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
624        for AuthenticateForRouteTableError
625    {
626        #[inline(always)]
627        fn new_empty() -> Self {
628            Self::unknown()
629        }
630
631        #[inline]
632        unsafe fn decode(
633            &mut self,
634            decoder: &mut fidl::encoding::Decoder<'_, D>,
635            offset: usize,
636            _depth: fidl::encoding::Depth,
637        ) -> fidl::Result<()> {
638            decoder.debug_check_bounds::<Self>(offset);
639            let prim = decoder.read_num::<u32>(offset);
640
641            *self = Self::from_primitive_allow_unknown(prim);
642            Ok(())
643        }
644    }
645    unsafe impl fidl::encoding::TypeMarker for BaseRouteTableRemoveError {
646        type Owned = Self;
647
648        #[inline(always)]
649        fn inline_align(_context: fidl::encoding::Context) -> usize {
650            std::mem::align_of::<u32>()
651        }
652
653        #[inline(always)]
654        fn inline_size(_context: fidl::encoding::Context) -> usize {
655            std::mem::size_of::<u32>()
656        }
657
658        #[inline(always)]
659        fn encode_is_copy() -> bool {
660            false
661        }
662
663        #[inline(always)]
664        fn decode_is_copy() -> bool {
665            false
666        }
667    }
668
669    impl fidl::encoding::ValueTypeMarker for BaseRouteTableRemoveError {
670        type Borrowed<'a> = Self;
671        #[inline(always)]
672        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
673            *value
674        }
675    }
676
677    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
678        for BaseRouteTableRemoveError
679    {
680        #[inline]
681        unsafe fn encode(
682            self,
683            encoder: &mut fidl::encoding::Encoder<'_, D>,
684            offset: usize,
685            _depth: fidl::encoding::Depth,
686        ) -> fidl::Result<()> {
687            encoder.debug_check_bounds::<Self>(offset);
688            encoder.write_num(self.into_primitive(), offset);
689            Ok(())
690        }
691    }
692
693    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
694        for BaseRouteTableRemoveError
695    {
696        #[inline(always)]
697        fn new_empty() -> Self {
698            Self::unknown()
699        }
700
701        #[inline]
702        unsafe fn decode(
703            &mut self,
704            decoder: &mut fidl::encoding::Decoder<'_, D>,
705            offset: usize,
706            _depth: fidl::encoding::Depth,
707        ) -> fidl::Result<()> {
708            decoder.debug_check_bounds::<Self>(offset);
709            let prim = decoder.read_num::<u32>(offset);
710
711            *self = Self::from_primitive_allow_unknown(prim);
712            Ok(())
713        }
714    }
715    unsafe impl fidl::encoding::TypeMarker for RouteSetError {
716        type Owned = Self;
717
718        #[inline(always)]
719        fn inline_align(_context: fidl::encoding::Context) -> usize {
720            std::mem::align_of::<u32>()
721        }
722
723        #[inline(always)]
724        fn inline_size(_context: fidl::encoding::Context) -> usize {
725            std::mem::size_of::<u32>()
726        }
727
728        #[inline(always)]
729        fn encode_is_copy() -> bool {
730            false
731        }
732
733        #[inline(always)]
734        fn decode_is_copy() -> bool {
735            false
736        }
737    }
738
739    impl fidl::encoding::ValueTypeMarker for RouteSetError {
740        type Borrowed<'a> = Self;
741        #[inline(always)]
742        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
743            *value
744        }
745    }
746
747    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for RouteSetError {
748        #[inline]
749        unsafe fn encode(
750            self,
751            encoder: &mut fidl::encoding::Encoder<'_, D>,
752            offset: usize,
753            _depth: fidl::encoding::Depth,
754        ) -> fidl::Result<()> {
755            encoder.debug_check_bounds::<Self>(offset);
756            encoder.write_num(self.into_primitive(), offset);
757            Ok(())
758        }
759    }
760
761    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RouteSetError {
762        #[inline(always)]
763        fn new_empty() -> Self {
764            Self::unknown()
765        }
766
767        #[inline]
768        unsafe fn decode(
769            &mut self,
770            decoder: &mut fidl::encoding::Decoder<'_, D>,
771            offset: usize,
772            _depth: fidl::encoding::Depth,
773        ) -> fidl::Result<()> {
774            decoder.debug_check_bounds::<Self>(offset);
775            let prim = decoder.read_num::<u32>(offset);
776
777            *self = Self::from_primitive_allow_unknown(prim);
778            Ok(())
779        }
780    }
781    unsafe impl fidl::encoding::TypeMarker for RuleSetError {
782        type Owned = Self;
783
784        #[inline(always)]
785        fn inline_align(_context: fidl::encoding::Context) -> usize {
786            std::mem::align_of::<u32>()
787        }
788
789        #[inline(always)]
790        fn inline_size(_context: fidl::encoding::Context) -> usize {
791            std::mem::size_of::<u32>()
792        }
793
794        #[inline(always)]
795        fn encode_is_copy() -> bool {
796            false
797        }
798
799        #[inline(always)]
800        fn decode_is_copy() -> bool {
801            false
802        }
803    }
804
805    impl fidl::encoding::ValueTypeMarker for RuleSetError {
806        type Borrowed<'a> = Self;
807        #[inline(always)]
808        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
809            *value
810        }
811    }
812
813    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for RuleSetError {
814        #[inline]
815        unsafe fn encode(
816            self,
817            encoder: &mut fidl::encoding::Encoder<'_, D>,
818            offset: usize,
819            _depth: fidl::encoding::Depth,
820        ) -> fidl::Result<()> {
821            encoder.debug_check_bounds::<Self>(offset);
822            encoder.write_num(self.into_primitive(), offset);
823            Ok(())
824        }
825    }
826
827    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RuleSetError {
828        #[inline(always)]
829        fn new_empty() -> Self {
830            Self::unknown()
831        }
832
833        #[inline]
834        unsafe fn decode(
835            &mut self,
836            decoder: &mut fidl::encoding::Decoder<'_, D>,
837            offset: usize,
838            _depth: fidl::encoding::Depth,
839        ) -> fidl::Result<()> {
840            decoder.debug_check_bounds::<Self>(offset);
841            let prim = decoder.read_num::<u32>(offset);
842
843            *self = Self::from_primitive_allow_unknown(prim);
844            Ok(())
845        }
846    }
847
848    impl fidl::encoding::ValueTypeMarker for BaseRouteTableGetTableIdResponse {
849        type Borrowed<'a> = &'a Self;
850        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
851            value
852        }
853    }
854
855    unsafe impl fidl::encoding::TypeMarker for BaseRouteTableGetTableIdResponse {
856        type Owned = Self;
857
858        #[inline(always)]
859        fn inline_align(_context: fidl::encoding::Context) -> usize {
860            4
861        }
862
863        #[inline(always)]
864        fn inline_size(_context: fidl::encoding::Context) -> usize {
865            4
866        }
867        #[inline(always)]
868        fn encode_is_copy() -> bool {
869            true
870        }
871
872        #[inline(always)]
873        fn decode_is_copy() -> bool {
874            true
875        }
876    }
877
878    unsafe impl<D: fidl::encoding::ResourceDialect>
879        fidl::encoding::Encode<BaseRouteTableGetTableIdResponse, D>
880        for &BaseRouteTableGetTableIdResponse
881    {
882        #[inline]
883        unsafe fn encode(
884            self,
885            encoder: &mut fidl::encoding::Encoder<'_, D>,
886            offset: usize,
887            _depth: fidl::encoding::Depth,
888        ) -> fidl::Result<()> {
889            encoder.debug_check_bounds::<BaseRouteTableGetTableIdResponse>(offset);
890            unsafe {
891                // Copy the object into the buffer.
892                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
893                (buf_ptr as *mut BaseRouteTableGetTableIdResponse)
894                    .write_unaligned((self as *const BaseRouteTableGetTableIdResponse).read());
895                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
896                // done second because the memcpy will write garbage to these bytes.
897            }
898            Ok(())
899        }
900    }
901    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
902        fidl::encoding::Encode<BaseRouteTableGetTableIdResponse, D> for (T0,)
903    {
904        #[inline]
905        unsafe fn encode(
906            self,
907            encoder: &mut fidl::encoding::Encoder<'_, D>,
908            offset: usize,
909            depth: fidl::encoding::Depth,
910        ) -> fidl::Result<()> {
911            encoder.debug_check_bounds::<BaseRouteTableGetTableIdResponse>(offset);
912            // Zero out padding regions. There's no need to apply masks
913            // because the unmasked parts will be overwritten by fields.
914            // Write the fields.
915            self.0.encode(encoder, offset + 0, depth)?;
916            Ok(())
917        }
918    }
919
920    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
921        for BaseRouteTableGetTableIdResponse
922    {
923        #[inline(always)]
924        fn new_empty() -> Self {
925            Self { table_id: fidl::new_empty!(u32, D) }
926        }
927
928        #[inline]
929        unsafe fn decode(
930            &mut self,
931            decoder: &mut fidl::encoding::Decoder<'_, D>,
932            offset: usize,
933            _depth: fidl::encoding::Depth,
934        ) -> fidl::Result<()> {
935            decoder.debug_check_bounds::<Self>(offset);
936            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
937            // Verify that padding bytes are zero.
938            // Copy from the buffer into the object.
939            unsafe {
940                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
941            }
942            Ok(())
943        }
944    }
945
946    impl fidl::encoding::ValueTypeMarker for BaseRuleSetRemoveRuleRequest {
947        type Borrowed<'a> = &'a Self;
948        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
949            value
950        }
951    }
952
953    unsafe impl fidl::encoding::TypeMarker for BaseRuleSetRemoveRuleRequest {
954        type Owned = Self;
955
956        #[inline(always)]
957        fn inline_align(_context: fidl::encoding::Context) -> usize {
958            4
959        }
960
961        #[inline(always)]
962        fn inline_size(_context: fidl::encoding::Context) -> usize {
963            4
964        }
965        #[inline(always)]
966        fn encode_is_copy() -> bool {
967            true
968        }
969
970        #[inline(always)]
971        fn decode_is_copy() -> bool {
972            true
973        }
974    }
975
976    unsafe impl<D: fidl::encoding::ResourceDialect>
977        fidl::encoding::Encode<BaseRuleSetRemoveRuleRequest, D> for &BaseRuleSetRemoveRuleRequest
978    {
979        #[inline]
980        unsafe fn encode(
981            self,
982            encoder: &mut fidl::encoding::Encoder<'_, D>,
983            offset: usize,
984            _depth: fidl::encoding::Depth,
985        ) -> fidl::Result<()> {
986            encoder.debug_check_bounds::<BaseRuleSetRemoveRuleRequest>(offset);
987            unsafe {
988                // Copy the object into the buffer.
989                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
990                (buf_ptr as *mut BaseRuleSetRemoveRuleRequest)
991                    .write_unaligned((self as *const BaseRuleSetRemoveRuleRequest).read());
992                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
993                // done second because the memcpy will write garbage to these bytes.
994            }
995            Ok(())
996        }
997    }
998    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
999        fidl::encoding::Encode<BaseRuleSetRemoveRuleRequest, D> for (T0,)
1000    {
1001        #[inline]
1002        unsafe fn encode(
1003            self,
1004            encoder: &mut fidl::encoding::Encoder<'_, D>,
1005            offset: usize,
1006            depth: fidl::encoding::Depth,
1007        ) -> fidl::Result<()> {
1008            encoder.debug_check_bounds::<BaseRuleSetRemoveRuleRequest>(offset);
1009            // Zero out padding regions. There's no need to apply masks
1010            // because the unmasked parts will be overwritten by fields.
1011            // Write the fields.
1012            self.0.encode(encoder, offset + 0, depth)?;
1013            Ok(())
1014        }
1015    }
1016
1017    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1018        for BaseRuleSetRemoveRuleRequest
1019    {
1020        #[inline(always)]
1021        fn new_empty() -> Self {
1022            Self { index: fidl::new_empty!(u32, D) }
1023        }
1024
1025        #[inline]
1026        unsafe fn decode(
1027            &mut self,
1028            decoder: &mut fidl::encoding::Decoder<'_, D>,
1029            offset: usize,
1030            _depth: fidl::encoding::Depth,
1031        ) -> fidl::Result<()> {
1032            decoder.debug_check_bounds::<Self>(offset);
1033            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1034            // Verify that padding bytes are zero.
1035            // Copy from the buffer into the object.
1036            unsafe {
1037                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1038            }
1039            Ok(())
1040        }
1041    }
1042
1043    impl fidl::encoding::ValueTypeMarker for RouteSetV4AddRouteResponse {
1044        type Borrowed<'a> = &'a Self;
1045        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1046            value
1047        }
1048    }
1049
1050    unsafe impl fidl::encoding::TypeMarker for RouteSetV4AddRouteResponse {
1051        type Owned = Self;
1052
1053        #[inline(always)]
1054        fn inline_align(_context: fidl::encoding::Context) -> usize {
1055            1
1056        }
1057
1058        #[inline(always)]
1059        fn inline_size(_context: fidl::encoding::Context) -> usize {
1060            1
1061        }
1062    }
1063
1064    unsafe impl<D: fidl::encoding::ResourceDialect>
1065        fidl::encoding::Encode<RouteSetV4AddRouteResponse, D> for &RouteSetV4AddRouteResponse
1066    {
1067        #[inline]
1068        unsafe fn encode(
1069            self,
1070            encoder: &mut fidl::encoding::Encoder<'_, D>,
1071            offset: usize,
1072            _depth: fidl::encoding::Depth,
1073        ) -> fidl::Result<()> {
1074            encoder.debug_check_bounds::<RouteSetV4AddRouteResponse>(offset);
1075            // Delegate to tuple encoding.
1076            fidl::encoding::Encode::<RouteSetV4AddRouteResponse, D>::encode(
1077                (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.did_add),),
1078                encoder,
1079                offset,
1080                _depth,
1081            )
1082        }
1083    }
1084    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
1085        fidl::encoding::Encode<RouteSetV4AddRouteResponse, D> for (T0,)
1086    {
1087        #[inline]
1088        unsafe fn encode(
1089            self,
1090            encoder: &mut fidl::encoding::Encoder<'_, D>,
1091            offset: usize,
1092            depth: fidl::encoding::Depth,
1093        ) -> fidl::Result<()> {
1094            encoder.debug_check_bounds::<RouteSetV4AddRouteResponse>(offset);
1095            // Zero out padding regions. There's no need to apply masks
1096            // because the unmasked parts will be overwritten by fields.
1097            // Write the fields.
1098            self.0.encode(encoder, offset + 0, depth)?;
1099            Ok(())
1100        }
1101    }
1102
1103    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1104        for RouteSetV4AddRouteResponse
1105    {
1106        #[inline(always)]
1107        fn new_empty() -> Self {
1108            Self { did_add: fidl::new_empty!(bool, D) }
1109        }
1110
1111        #[inline]
1112        unsafe fn decode(
1113            &mut self,
1114            decoder: &mut fidl::encoding::Decoder<'_, D>,
1115            offset: usize,
1116            _depth: fidl::encoding::Depth,
1117        ) -> fidl::Result<()> {
1118            decoder.debug_check_bounds::<Self>(offset);
1119            // Verify that padding bytes are zero.
1120            fidl::decode!(bool, D, &mut self.did_add, decoder, offset + 0, _depth)?;
1121            Ok(())
1122        }
1123    }
1124
1125    impl fidl::encoding::ValueTypeMarker for RouteSetV4RemoveRouteResponse {
1126        type Borrowed<'a> = &'a Self;
1127        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1128            value
1129        }
1130    }
1131
1132    unsafe impl fidl::encoding::TypeMarker for RouteSetV4RemoveRouteResponse {
1133        type Owned = Self;
1134
1135        #[inline(always)]
1136        fn inline_align(_context: fidl::encoding::Context) -> usize {
1137            1
1138        }
1139
1140        #[inline(always)]
1141        fn inline_size(_context: fidl::encoding::Context) -> usize {
1142            1
1143        }
1144    }
1145
1146    unsafe impl<D: fidl::encoding::ResourceDialect>
1147        fidl::encoding::Encode<RouteSetV4RemoveRouteResponse, D>
1148        for &RouteSetV4RemoveRouteResponse
1149    {
1150        #[inline]
1151        unsafe fn encode(
1152            self,
1153            encoder: &mut fidl::encoding::Encoder<'_, D>,
1154            offset: usize,
1155            _depth: fidl::encoding::Depth,
1156        ) -> fidl::Result<()> {
1157            encoder.debug_check_bounds::<RouteSetV4RemoveRouteResponse>(offset);
1158            // Delegate to tuple encoding.
1159            fidl::encoding::Encode::<RouteSetV4RemoveRouteResponse, D>::encode(
1160                (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.did_remove),),
1161                encoder,
1162                offset,
1163                _depth,
1164            )
1165        }
1166    }
1167    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
1168        fidl::encoding::Encode<RouteSetV4RemoveRouteResponse, D> for (T0,)
1169    {
1170        #[inline]
1171        unsafe fn encode(
1172            self,
1173            encoder: &mut fidl::encoding::Encoder<'_, D>,
1174            offset: usize,
1175            depth: fidl::encoding::Depth,
1176        ) -> fidl::Result<()> {
1177            encoder.debug_check_bounds::<RouteSetV4RemoveRouteResponse>(offset);
1178            // Zero out padding regions. There's no need to apply masks
1179            // because the unmasked parts will be overwritten by fields.
1180            // Write the fields.
1181            self.0.encode(encoder, offset + 0, depth)?;
1182            Ok(())
1183        }
1184    }
1185
1186    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1187        for RouteSetV4RemoveRouteResponse
1188    {
1189        #[inline(always)]
1190        fn new_empty() -> Self {
1191            Self { did_remove: fidl::new_empty!(bool, D) }
1192        }
1193
1194        #[inline]
1195        unsafe fn decode(
1196            &mut self,
1197            decoder: &mut fidl::encoding::Decoder<'_, D>,
1198            offset: usize,
1199            _depth: fidl::encoding::Depth,
1200        ) -> fidl::Result<()> {
1201            decoder.debug_check_bounds::<Self>(offset);
1202            // Verify that padding bytes are zero.
1203            fidl::decode!(bool, D, &mut self.did_remove, decoder, offset + 0, _depth)?;
1204            Ok(())
1205        }
1206    }
1207
1208    impl fidl::encoding::ValueTypeMarker for RouteSetV6AddRouteResponse {
1209        type Borrowed<'a> = &'a Self;
1210        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1211            value
1212        }
1213    }
1214
1215    unsafe impl fidl::encoding::TypeMarker for RouteSetV6AddRouteResponse {
1216        type Owned = Self;
1217
1218        #[inline(always)]
1219        fn inline_align(_context: fidl::encoding::Context) -> usize {
1220            1
1221        }
1222
1223        #[inline(always)]
1224        fn inline_size(_context: fidl::encoding::Context) -> usize {
1225            1
1226        }
1227    }
1228
1229    unsafe impl<D: fidl::encoding::ResourceDialect>
1230        fidl::encoding::Encode<RouteSetV6AddRouteResponse, D> for &RouteSetV6AddRouteResponse
1231    {
1232        #[inline]
1233        unsafe fn encode(
1234            self,
1235            encoder: &mut fidl::encoding::Encoder<'_, D>,
1236            offset: usize,
1237            _depth: fidl::encoding::Depth,
1238        ) -> fidl::Result<()> {
1239            encoder.debug_check_bounds::<RouteSetV6AddRouteResponse>(offset);
1240            // Delegate to tuple encoding.
1241            fidl::encoding::Encode::<RouteSetV6AddRouteResponse, D>::encode(
1242                (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.did_add),),
1243                encoder,
1244                offset,
1245                _depth,
1246            )
1247        }
1248    }
1249    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
1250        fidl::encoding::Encode<RouteSetV6AddRouteResponse, D> for (T0,)
1251    {
1252        #[inline]
1253        unsafe fn encode(
1254            self,
1255            encoder: &mut fidl::encoding::Encoder<'_, D>,
1256            offset: usize,
1257            depth: fidl::encoding::Depth,
1258        ) -> fidl::Result<()> {
1259            encoder.debug_check_bounds::<RouteSetV6AddRouteResponse>(offset);
1260            // Zero out padding regions. There's no need to apply masks
1261            // because the unmasked parts will be overwritten by fields.
1262            // Write the fields.
1263            self.0.encode(encoder, offset + 0, depth)?;
1264            Ok(())
1265        }
1266    }
1267
1268    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1269        for RouteSetV6AddRouteResponse
1270    {
1271        #[inline(always)]
1272        fn new_empty() -> Self {
1273            Self { did_add: fidl::new_empty!(bool, D) }
1274        }
1275
1276        #[inline]
1277        unsafe fn decode(
1278            &mut self,
1279            decoder: &mut fidl::encoding::Decoder<'_, D>,
1280            offset: usize,
1281            _depth: fidl::encoding::Depth,
1282        ) -> fidl::Result<()> {
1283            decoder.debug_check_bounds::<Self>(offset);
1284            // Verify that padding bytes are zero.
1285            fidl::decode!(bool, D, &mut self.did_add, decoder, offset + 0, _depth)?;
1286            Ok(())
1287        }
1288    }
1289
1290    impl fidl::encoding::ValueTypeMarker for RouteSetV6RemoveRouteResponse {
1291        type Borrowed<'a> = &'a Self;
1292        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1293            value
1294        }
1295    }
1296
1297    unsafe impl fidl::encoding::TypeMarker for RouteSetV6RemoveRouteResponse {
1298        type Owned = Self;
1299
1300        #[inline(always)]
1301        fn inline_align(_context: fidl::encoding::Context) -> usize {
1302            1
1303        }
1304
1305        #[inline(always)]
1306        fn inline_size(_context: fidl::encoding::Context) -> usize {
1307            1
1308        }
1309    }
1310
1311    unsafe impl<D: fidl::encoding::ResourceDialect>
1312        fidl::encoding::Encode<RouteSetV6RemoveRouteResponse, D>
1313        for &RouteSetV6RemoveRouteResponse
1314    {
1315        #[inline]
1316        unsafe fn encode(
1317            self,
1318            encoder: &mut fidl::encoding::Encoder<'_, D>,
1319            offset: usize,
1320            _depth: fidl::encoding::Depth,
1321        ) -> fidl::Result<()> {
1322            encoder.debug_check_bounds::<RouteSetV6RemoveRouteResponse>(offset);
1323            // Delegate to tuple encoding.
1324            fidl::encoding::Encode::<RouteSetV6RemoveRouteResponse, D>::encode(
1325                (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.did_remove),),
1326                encoder,
1327                offset,
1328                _depth,
1329            )
1330        }
1331    }
1332    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
1333        fidl::encoding::Encode<RouteSetV6RemoveRouteResponse, D> for (T0,)
1334    {
1335        #[inline]
1336        unsafe fn encode(
1337            self,
1338            encoder: &mut fidl::encoding::Encoder<'_, D>,
1339            offset: usize,
1340            depth: fidl::encoding::Depth,
1341        ) -> fidl::Result<()> {
1342            encoder.debug_check_bounds::<RouteSetV6RemoveRouteResponse>(offset);
1343            // Zero out padding regions. There's no need to apply masks
1344            // because the unmasked parts will be overwritten by fields.
1345            // Write the fields.
1346            self.0.encode(encoder, offset + 0, depth)?;
1347            Ok(())
1348        }
1349    }
1350
1351    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1352        for RouteSetV6RemoveRouteResponse
1353    {
1354        #[inline(always)]
1355        fn new_empty() -> Self {
1356            Self { did_remove: fidl::new_empty!(bool, D) }
1357        }
1358
1359        #[inline]
1360        unsafe fn decode(
1361            &mut self,
1362            decoder: &mut fidl::encoding::Decoder<'_, D>,
1363            offset: usize,
1364            _depth: fidl::encoding::Depth,
1365        ) -> fidl::Result<()> {
1366            decoder.debug_check_bounds::<Self>(offset);
1367            // Verify that padding bytes are zero.
1368            fidl::decode!(bool, D, &mut self.did_remove, decoder, offset + 0, _depth)?;
1369            Ok(())
1370        }
1371    }
1372
1373    impl RouteTableOptionsV4 {
1374        #[inline(always)]
1375        fn max_ordinal_present(&self) -> u64 {
1376            if let Some(_) = self.name {
1377                return 1;
1378            }
1379            0
1380        }
1381    }
1382
1383    impl fidl::encoding::ValueTypeMarker for RouteTableOptionsV4 {
1384        type Borrowed<'a> = &'a Self;
1385        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1386            value
1387        }
1388    }
1389
1390    unsafe impl fidl::encoding::TypeMarker for RouteTableOptionsV4 {
1391        type Owned = Self;
1392
1393        #[inline(always)]
1394        fn inline_align(_context: fidl::encoding::Context) -> usize {
1395            8
1396        }
1397
1398        #[inline(always)]
1399        fn inline_size(_context: fidl::encoding::Context) -> usize {
1400            16
1401        }
1402    }
1403
1404    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RouteTableOptionsV4, D>
1405        for &RouteTableOptionsV4
1406    {
1407        unsafe fn encode(
1408            self,
1409            encoder: &mut fidl::encoding::Encoder<'_, D>,
1410            offset: usize,
1411            mut depth: fidl::encoding::Depth,
1412        ) -> fidl::Result<()> {
1413            encoder.debug_check_bounds::<RouteTableOptionsV4>(offset);
1414            // Vector header
1415            let max_ordinal: u64 = self.max_ordinal_present();
1416            encoder.write_num(max_ordinal, offset);
1417            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1418            // Calling encoder.out_of_line_offset(0) is not allowed.
1419            if max_ordinal == 0 {
1420                return Ok(());
1421            }
1422            depth.increment()?;
1423            let envelope_size = 8;
1424            let bytes_len = max_ordinal as usize * envelope_size;
1425            #[allow(unused_variables)]
1426            let offset = encoder.out_of_line_offset(bytes_len);
1427            let mut _prev_end_offset: usize = 0;
1428            if 1 > max_ordinal {
1429                return Ok(());
1430            }
1431
1432            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1433            // are envelope_size bytes.
1434            let cur_offset: usize = (1 - 1) * envelope_size;
1435
1436            // Zero reserved fields.
1437            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1438
1439            // Safety:
1440            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1441            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1442            //   envelope_size bytes, there is always sufficient room.
1443            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<255>, D>(
1444                self.name.as_ref().map(
1445                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow,
1446                ),
1447                encoder,
1448                offset + cur_offset,
1449                depth,
1450            )?;
1451
1452            _prev_end_offset = cur_offset + envelope_size;
1453
1454            Ok(())
1455        }
1456    }
1457
1458    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RouteTableOptionsV4 {
1459        #[inline(always)]
1460        fn new_empty() -> Self {
1461            Self::default()
1462        }
1463
1464        unsafe fn decode(
1465            &mut self,
1466            decoder: &mut fidl::encoding::Decoder<'_, D>,
1467            offset: usize,
1468            mut depth: fidl::encoding::Depth,
1469        ) -> fidl::Result<()> {
1470            decoder.debug_check_bounds::<Self>(offset);
1471            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1472                None => return Err(fidl::Error::NotNullable),
1473                Some(len) => len,
1474            };
1475            // Calling decoder.out_of_line_offset(0) is not allowed.
1476            if len == 0 {
1477                return Ok(());
1478            };
1479            depth.increment()?;
1480            let envelope_size = 8;
1481            let bytes_len = len * envelope_size;
1482            let offset = decoder.out_of_line_offset(bytes_len)?;
1483            // Decode the envelope for each type.
1484            let mut _next_ordinal_to_read = 0;
1485            let mut next_offset = offset;
1486            let end_offset = offset + bytes_len;
1487            _next_ordinal_to_read += 1;
1488            if next_offset >= end_offset {
1489                return Ok(());
1490            }
1491
1492            // Decode unknown envelopes for gaps in ordinals.
1493            while _next_ordinal_to_read < 1 {
1494                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1495                _next_ordinal_to_read += 1;
1496                next_offset += envelope_size;
1497            }
1498
1499            let next_out_of_line = decoder.next_out_of_line();
1500            let handles_before = decoder.remaining_handles();
1501            if let Some((inlined, num_bytes, num_handles)) =
1502                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1503            {
1504                let member_inline_size =
1505                    <fidl::encoding::BoundedString<255> as fidl::encoding::TypeMarker>::inline_size(
1506                        decoder.context,
1507                    );
1508                if inlined != (member_inline_size <= 4) {
1509                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1510                }
1511                let inner_offset;
1512                let mut inner_depth = depth.clone();
1513                if inlined {
1514                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1515                    inner_offset = next_offset;
1516                } else {
1517                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1518                    inner_depth.increment()?;
1519                }
1520                let val_ref = self
1521                    .name
1522                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<255>, D));
1523                fidl::decode!(
1524                    fidl::encoding::BoundedString<255>,
1525                    D,
1526                    val_ref,
1527                    decoder,
1528                    inner_offset,
1529                    inner_depth
1530                )?;
1531                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1532                {
1533                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1534                }
1535                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1536                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1537                }
1538            }
1539
1540            next_offset += envelope_size;
1541
1542            // Decode the remaining unknown envelopes.
1543            while next_offset < end_offset {
1544                _next_ordinal_to_read += 1;
1545                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1546                next_offset += envelope_size;
1547            }
1548
1549            Ok(())
1550        }
1551    }
1552
1553    impl RouteTableOptionsV6 {
1554        #[inline(always)]
1555        fn max_ordinal_present(&self) -> u64 {
1556            if let Some(_) = self.name {
1557                return 1;
1558            }
1559            0
1560        }
1561    }
1562
1563    impl fidl::encoding::ValueTypeMarker for RouteTableOptionsV6 {
1564        type Borrowed<'a> = &'a Self;
1565        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1566            value
1567        }
1568    }
1569
1570    unsafe impl fidl::encoding::TypeMarker for RouteTableOptionsV6 {
1571        type Owned = Self;
1572
1573        #[inline(always)]
1574        fn inline_align(_context: fidl::encoding::Context) -> usize {
1575            8
1576        }
1577
1578        #[inline(always)]
1579        fn inline_size(_context: fidl::encoding::Context) -> usize {
1580            16
1581        }
1582    }
1583
1584    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RouteTableOptionsV6, D>
1585        for &RouteTableOptionsV6
1586    {
1587        unsafe fn encode(
1588            self,
1589            encoder: &mut fidl::encoding::Encoder<'_, D>,
1590            offset: usize,
1591            mut depth: fidl::encoding::Depth,
1592        ) -> fidl::Result<()> {
1593            encoder.debug_check_bounds::<RouteTableOptionsV6>(offset);
1594            // Vector header
1595            let max_ordinal: u64 = self.max_ordinal_present();
1596            encoder.write_num(max_ordinal, offset);
1597            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1598            // Calling encoder.out_of_line_offset(0) is not allowed.
1599            if max_ordinal == 0 {
1600                return Ok(());
1601            }
1602            depth.increment()?;
1603            let envelope_size = 8;
1604            let bytes_len = max_ordinal as usize * envelope_size;
1605            #[allow(unused_variables)]
1606            let offset = encoder.out_of_line_offset(bytes_len);
1607            let mut _prev_end_offset: usize = 0;
1608            if 1 > max_ordinal {
1609                return Ok(());
1610            }
1611
1612            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1613            // are envelope_size bytes.
1614            let cur_offset: usize = (1 - 1) * envelope_size;
1615
1616            // Zero reserved fields.
1617            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1618
1619            // Safety:
1620            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1621            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1622            //   envelope_size bytes, there is always sufficient room.
1623            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<255>, D>(
1624                self.name.as_ref().map(
1625                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow,
1626                ),
1627                encoder,
1628                offset + cur_offset,
1629                depth,
1630            )?;
1631
1632            _prev_end_offset = cur_offset + envelope_size;
1633
1634            Ok(())
1635        }
1636    }
1637
1638    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RouteTableOptionsV6 {
1639        #[inline(always)]
1640        fn new_empty() -> Self {
1641            Self::default()
1642        }
1643
1644        unsafe fn decode(
1645            &mut self,
1646            decoder: &mut fidl::encoding::Decoder<'_, D>,
1647            offset: usize,
1648            mut depth: fidl::encoding::Depth,
1649        ) -> fidl::Result<()> {
1650            decoder.debug_check_bounds::<Self>(offset);
1651            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1652                None => return Err(fidl::Error::NotNullable),
1653                Some(len) => len,
1654            };
1655            // Calling decoder.out_of_line_offset(0) is not allowed.
1656            if len == 0 {
1657                return Ok(());
1658            };
1659            depth.increment()?;
1660            let envelope_size = 8;
1661            let bytes_len = len * envelope_size;
1662            let offset = decoder.out_of_line_offset(bytes_len)?;
1663            // Decode the envelope for each type.
1664            let mut _next_ordinal_to_read = 0;
1665            let mut next_offset = offset;
1666            let end_offset = offset + bytes_len;
1667            _next_ordinal_to_read += 1;
1668            if next_offset >= end_offset {
1669                return Ok(());
1670            }
1671
1672            // Decode unknown envelopes for gaps in ordinals.
1673            while _next_ordinal_to_read < 1 {
1674                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1675                _next_ordinal_to_read += 1;
1676                next_offset += envelope_size;
1677            }
1678
1679            let next_out_of_line = decoder.next_out_of_line();
1680            let handles_before = decoder.remaining_handles();
1681            if let Some((inlined, num_bytes, num_handles)) =
1682                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1683            {
1684                let member_inline_size =
1685                    <fidl::encoding::BoundedString<255> as fidl::encoding::TypeMarker>::inline_size(
1686                        decoder.context,
1687                    );
1688                if inlined != (member_inline_size <= 4) {
1689                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1690                }
1691                let inner_offset;
1692                let mut inner_depth = depth.clone();
1693                if inlined {
1694                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1695                    inner_offset = next_offset;
1696                } else {
1697                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1698                    inner_depth.increment()?;
1699                }
1700                let val_ref = self
1701                    .name
1702                    .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<255>, D));
1703                fidl::decode!(
1704                    fidl::encoding::BoundedString<255>,
1705                    D,
1706                    val_ref,
1707                    decoder,
1708                    inner_offset,
1709                    inner_depth
1710                )?;
1711                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1712                {
1713                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1714                }
1715                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1716                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1717                }
1718            }
1719
1720            next_offset += envelope_size;
1721
1722            // Decode the remaining unknown envelopes.
1723            while next_offset < end_offset {
1724                _next_ordinal_to_read += 1;
1725                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1726                next_offset += envelope_size;
1727            }
1728
1729            Ok(())
1730        }
1731    }
1732}