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