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