fidl_fuchsia_overnet_protocol__common/
fidl_fuchsia_overnet_protocol__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 transfer key is used when moving a stream endpoint from one node to
12/// another. It identifies a single transfer, should be unique (so, made from
13/// random bytes), and should be discarded at the end of the transfer.
14pub type TransferKey = [u8; 16];
15
16pub const MAX_SERVICE_NAME_LENGTH: u64 = fidl_fuchsia_io__common::MAX_NAME_LENGTH as u64;
17
18/// Length of a transfer key.
19pub const TRANSFER_KEY_LENGTH: u32 = 16;
20
21bitflags! {
22    /// Channel rights.
23    /// Overnet treats rights as per-object type, to reduce the space of things that can be communicated
24    /// over its wire format. Transfer rights are always assumed present.
25    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
26    pub struct ChannelRights: u32 {
27        const READ = 1;
28        const WRITE = 2;
29    }
30}
31
32impl ChannelRights {}
33
34bitflags! {
35    /// EventPair rights.
36    /// Overnet treats rights as per-object type, to reduce the space of things that can be communicated
37    /// over its wire format. Transfer rights are always assumed present.
38    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
39    pub struct EventPairRights: u32 {
40        const DO_NOT_USE = 2147483648;
41    }
42}
43
44impl EventPairRights {}
45
46bitflags! {
47    /// Signals that can be propagated.
48    /// These are deliberately chosen to be different bits than defined in Zircon, to force mapping code
49    /// to exist, and minimize the chance that Zircon ABI accidentally becomes Overnet protocol.
50    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
51    pub struct Signals: u32 {
52        const USER_0 = 1;
53        const USER_1 = 2;
54        const USER_2 = 4;
55        const USER_3 = 8;
56        const USER_4 = 16;
57        const USER_5 = 32;
58        const USER_6 = 64;
59        const USER_7 = 128;
60    }
61}
62
63impl Signals {}
64
65bitflags! {
66    /// Socket rights.
67    /// Overnet treats rights as per-object type, to reduce the space of things that can be communicated
68    /// over its wire format. Transfer rights are always assumed present.
69    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
70    pub struct SocketRights: u32 {
71        const READ = 1;
72        const WRITE = 2;
73    }
74}
75
76impl SocketRights {}
77
78/// The type of socket being communicated via [`fuchsia.overnet.protocol/SocketHandle`].
79#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
80#[repr(u32)]
81pub enum SocketType {
82    /// A datagram oriented socket.
83    Datagram = 0,
84    /// A stream oriented socket.
85    Stream = 1,
86}
87
88impl SocketType {
89    #[inline]
90    pub fn from_primitive(prim: u32) -> Option<Self> {
91        match prim {
92            0 => Some(Self::Datagram),
93            1 => Some(Self::Stream),
94            _ => None,
95        }
96    }
97
98    #[inline]
99    pub const fn into_primitive(self) -> u32 {
100        self as u32
101    }
102}
103
104/// Body for [`fuchsia.overnet.protocol/StreamControl.begin_transfer`].
105#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
106#[repr(C)]
107pub struct BeginTransfer {
108    /// The new owner of this stream endpoint.
109    pub new_destination_node: NodeId,
110    /// A key to identify this transfer of ownership.
111    pub transfer_key: [u8; 16],
112}
113
114impl fidl::Persistable for BeginTransfer {}
115
116/// A proxied channel.
117#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
118pub struct ChannelHandle {
119    /// The handle rights that are given to this handle.
120    pub rights: ChannelRights,
121    /// The Overnet proxy stream that was created to carry this channel.
122    /// The protocol over said stream will be a `ZirconChannel`.
123    pub stream_ref: StreamRef,
124}
125
126impl fidl::Persistable for ChannelHandle {}
127
128/// Create a new stream, labelled `stream_id`, to communicate with the
129/// advertised service `service_name`.
130#[derive(Clone, Debug, PartialEq)]
131pub struct ConnectToService {
132    /// Which service to connect to.
133    pub service_name: String,
134    /// On which QUIC stream will this service connection be formed.
135    pub stream_ref: StreamRef,
136    /// The channel rights for this connection.
137    pub rights: ChannelRights,
138    /// Ancillary options for this connection.
139    pub options: ConnectToServiceOptions,
140}
141
142impl fidl::Persistable for ConnectToService {}
143
144#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
145pub struct Empty;
146
147impl fidl::Persistable for Empty {}
148
149/// A proxied eventpair.
150#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
151pub struct EventPairHandle {
152    /// The handle rights that are given to this handle.
153    pub rights: EventPairRights,
154    /// The Overnet proxy stream that was created to carry this eventpair.
155    /// No payloads will be sent over this stream, however transport and signal control messages
156    /// will be per the normal StreamControl/SignalUpdate protocols used for all handle types.
157    pub stream_ref: StreamRef,
158}
159
160impl fidl::Persistable for EventPairHandle {}
161
162/// Address of a node on the overlay network.
163#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
164#[repr(C)]
165pub struct NodeId {
166    pub id: u64,
167}
168
169impl fidl::Persistable for NodeId {}
170
171/// Create a new stream, labelled `stream_id`, to finalize the transfer
172/// labelled `transfer_key`.
173#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
174#[repr(C)]
175pub struct OpenTransfer {
176    /// On which QUIC stream will this service connection be formed.
177    pub stream_id: StreamId,
178    /// Transfer key tracking the transfer.
179    pub transfer_key: [u8; 16],
180}
181
182impl fidl::Persistable for OpenTransfer {}
183
184/// A proxied socket.
185#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
186pub struct SocketHandle {
187    /// The handle rights that are given to this handle.
188    pub rights: SocketRights,
189    /// The Overnet proxy stream that was created to carry this socket.
190    /// The protocol over said stream will be a `ZirconSocket`.
191    pub stream_ref: StreamRef,
192    /// Socket options, per `zx_socket_create`.
193    pub socket_type: SocketType,
194}
195
196impl fidl::Persistable for SocketHandle {}
197
198/// Identifies a single overnet stream between two processes on the Overnet
199/// mesh.
200#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
201#[repr(C)]
202pub struct StreamId {
203    pub id: u64,
204}
205
206impl fidl::Persistable for StreamId {}
207
208/// Body for [`fuchsia.overnet.protocol/StreamRef.transfer_initiator`].
209#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
210#[repr(C)]
211pub struct TransferInitiator {
212    /// The drain stream for this transfer. Buffered messages from the old
213    /// proxy end will be sent via this unidirectional QUIC stream and should
214    /// be processed *prior* to processing any messages from the new endpoint.
215    pub stream_id: StreamId,
216    /// The peer node id for this proxy that we should reach out to.
217    /// Note that this *may* be the same node that receives this message.
218    pub new_destination_node: NodeId,
219    /// A key to identify this transfer of ownership.
220    pub transfer_key: [u8; 16],
221}
222
223impl fidl::Persistable for TransferInitiator {}
224
225/// Body for [`fuchsia.overnet.protocol/StreamRef.transfer_waiter`].
226#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
227#[repr(C)]
228pub struct TransferWaiter {
229    /// The drain stream for this transfer. Buffered messages from the old
230    /// proxy end will be sent via this unidirectional QUIC stream and should
231    /// be processed *prior* to processing any messages from the new endpoint.
232    pub stream_id: StreamId,
233    /// A key to identify this transfer of ownership.
234    pub transfer_key: [u8; 16],
235}
236
237impl fidl::Persistable for TransferWaiter {}
238
239/// A single message proxied from a Zircon channel over an Overnet stream.
240#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
241pub struct ZirconChannelMessage {
242    /// Bytes part of the payload.
243    pub bytes: Vec<u8>,
244    /// Handles part of the payload.
245    pub handles: Vec<ZirconHandle>,
246}
247
248impl fidl::Persistable for ZirconChannelMessage {}
249
250/// Overall connection configuration request
251#[derive(Clone, Debug, Default, PartialEq)]
252pub struct ConfigRequest {
253    #[doc(hidden)]
254    pub __source_breaking: fidl::marker::SourceBreaking,
255}
256
257impl fidl::Persistable for ConfigRequest {}
258
259/// Overall connection configuration response - sent as the first response
260/// message on the connection stream.
261#[derive(Clone, Debug, Default, PartialEq)]
262pub struct ConfigResponse {
263    #[doc(hidden)]
264    pub __source_breaking: fidl::marker::SourceBreaking,
265}
266
267impl fidl::Persistable for ConfigResponse {}
268
269/// Options for service connection formation.
270#[derive(Clone, Debug, Default, PartialEq)]
271pub struct ConnectToServiceOptions {
272    #[doc(hidden)]
273    pub __source_breaking: fidl::marker::SourceBreaking,
274}
275
276impl fidl::Persistable for ConnectToServiceOptions {}
277
278/// Description of a single node.
279#[derive(Clone, Debug, Default, PartialEq)]
280pub struct PeerDescription {
281    /// The set of services published by this node.
282    pub services: Option<Vec<String>>,
283    #[doc(hidden)]
284    pub __source_breaking: fidl::marker::SourceBreaking,
285}
286
287impl fidl::Persistable for PeerDescription {}
288
289/// Signal state updates.
290/// Transported as a side channel for each handle type, these propagate some signal bits.
291#[derive(Clone, Debug, Default, PartialEq)]
292pub struct SignalUpdate {
293    /// Update some signals
294    pub assert_signals: Option<Signals>,
295    #[doc(hidden)]
296    pub __source_breaking: fidl::marker::SourceBreaking,
297}
298
299impl fidl::Persistable for SignalUpdate {}
300
301/// Peer-to-peer protocol between two Overnet nodes.
302/// Client QUIC connections send this xunion to servers over QUIC stream 0.
303#[derive(Clone, Debug, PartialEq)]
304pub enum PeerMessage {
305    /// Request to create a channel to a service exported by this peer.
306    ConnectToService(ConnectToService),
307    /// Update this peers description on the server.
308    UpdateNodeDescription(PeerDescription),
309    /// Open a transfered stream.
310    OpenTransfer(OpenTransfer),
311}
312
313impl PeerMessage {
314    #[inline]
315    pub fn ordinal(&self) -> u64 {
316        match *self {
317            Self::ConnectToService(_) => 1,
318            Self::UpdateNodeDescription(_) => 2,
319            Self::OpenTransfer(_) => 4,
320        }
321    }
322}
323
324impl fidl::Persistable for PeerMessage {}
325
326/// Reply messages for PeerMessage, where appropriate.
327/// The ConfigResponse message must have been sent already.
328#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
329pub enum PeerReply {
330    /// Acknowledge an UpdateLinkStatus message
331    UpdateLinkStatusAck(Empty),
332}
333
334impl PeerReply {
335    #[inline]
336    pub fn ordinal(&self) -> u64 {
337        match *self {
338            Self::UpdateLinkStatusAck(_) => 1,
339        }
340    }
341}
342
343impl fidl::Persistable for PeerReply {}
344
345/// Stream control message: sent instead of usual stream frames if the frame
346/// type is 1 (StreamControl).
347/// TODO: consider defining the stream framing format in FIDL also.
348#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
349pub enum StreamControl {
350    /// A transfer is beginning: the sending node would like to transfer
351    /// control.
352    BeginTransfer(BeginTransfer),
353    /// Acknowledge a begin_transfer - the sender has seen a previously sent
354    /// begin_transfer, and responded to it.
355    /// This should be the last message sent on a regular stream.
356    AckTransfer(Empty),
357    /// End a transfer - signal that a drain stream has finished draining.
358    /// This should be the last message sent on a drain stream.
359    EndTransfer(Empty),
360    /// Shutdown the stream with some status.
361    Shutdown(i32),
362}
363
364impl StreamControl {
365    #[inline]
366    pub fn ordinal(&self) -> u64 {
367        match *self {
368            Self::BeginTransfer(_) => 1,
369            Self::AckTransfer(_) => 2,
370            Self::EndTransfer(_) => 3,
371            Self::Shutdown(_) => 4,
372        }
373    }
374}
375
376impl fidl::Persistable for StreamControl {}
377
378/// A StreamRef identifies a new proxied stream, and details how that stream
379/// will come to be on the receiving node.
380#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
381pub enum StreamRef {
382    /// A new proxy is being created, and the other end of the proxy is on the
383    /// sending node. This is the simple case, and we just communicate the QUIC
384    /// stream ID that will be used to carry traffic.
385    Creating(StreamId),
386    /// An existing proxy is being transferred to this node. This node should
387    /// initiate communication with the peer.
388    TransferInitiator(TransferInitiator),
389    /// An existing proxy is being transferred to this node. This node should
390    /// await contact from the peer.
391    TransferWaiter(TransferWaiter),
392}
393
394impl StreamRef {
395    #[inline]
396    pub fn ordinal(&self) -> u64 {
397        match *self {
398            Self::Creating(_) => 1,
399            Self::TransferInitiator(_) => 2,
400            Self::TransferWaiter(_) => 3,
401        }
402    }
403}
404
405impl fidl::Persistable for StreamRef {}
406
407/// A single handle to be proxied.
408/// Not all Zircon types are supported.
409#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
410pub enum ZirconHandle {
411    /// A proxied channel.
412    Channel(ChannelHandle),
413    /// A proxied socket.
414    Socket(SocketHandle),
415    /// A proxied eventpair.
416    EventPair(EventPairHandle),
417}
418
419impl ZirconHandle {
420    #[inline]
421    pub fn ordinal(&self) -> u64 {
422        match *self {
423            Self::Channel(_) => 1,
424            Self::Socket(_) => 2,
425            Self::EventPair(_) => 3,
426        }
427    }
428}
429
430impl fidl::Persistable for ZirconHandle {}
431
432mod internal {
433    use super::*;
434    unsafe impl fidl::encoding::TypeMarker for ChannelRights {
435        type Owned = Self;
436
437        #[inline(always)]
438        fn inline_align(_context: fidl::encoding::Context) -> usize {
439            4
440        }
441
442        #[inline(always)]
443        fn inline_size(_context: fidl::encoding::Context) -> usize {
444            4
445        }
446    }
447
448    impl fidl::encoding::ValueTypeMarker for ChannelRights {
449        type Borrowed<'a> = Self;
450        #[inline(always)]
451        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
452            *value
453        }
454    }
455
456    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ChannelRights {
457        #[inline]
458        unsafe fn encode(
459            self,
460            encoder: &mut fidl::encoding::Encoder<'_, D>,
461            offset: usize,
462            _depth: fidl::encoding::Depth,
463        ) -> fidl::Result<()> {
464            encoder.debug_check_bounds::<Self>(offset);
465            if self.bits() & Self::all().bits() != self.bits() {
466                return Err(fidl::Error::InvalidBitsValue);
467            }
468            encoder.write_num(self.bits(), offset);
469            Ok(())
470        }
471    }
472
473    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ChannelRights {
474        #[inline(always)]
475        fn new_empty() -> Self {
476            Self::empty()
477        }
478
479        #[inline]
480        unsafe fn decode(
481            &mut self,
482            decoder: &mut fidl::encoding::Decoder<'_, D>,
483            offset: usize,
484            _depth: fidl::encoding::Depth,
485        ) -> fidl::Result<()> {
486            decoder.debug_check_bounds::<Self>(offset);
487            let prim = decoder.read_num::<u32>(offset);
488            *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
489            Ok(())
490        }
491    }
492    unsafe impl fidl::encoding::TypeMarker for EventPairRights {
493        type Owned = Self;
494
495        #[inline(always)]
496        fn inline_align(_context: fidl::encoding::Context) -> usize {
497            4
498        }
499
500        #[inline(always)]
501        fn inline_size(_context: fidl::encoding::Context) -> usize {
502            4
503        }
504    }
505
506    impl fidl::encoding::ValueTypeMarker for EventPairRights {
507        type Borrowed<'a> = Self;
508        #[inline(always)]
509        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
510            *value
511        }
512    }
513
514    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
515        for EventPairRights
516    {
517        #[inline]
518        unsafe fn encode(
519            self,
520            encoder: &mut fidl::encoding::Encoder<'_, D>,
521            offset: usize,
522            _depth: fidl::encoding::Depth,
523        ) -> fidl::Result<()> {
524            encoder.debug_check_bounds::<Self>(offset);
525            if self.bits() & Self::all().bits() != self.bits() {
526                return Err(fidl::Error::InvalidBitsValue);
527            }
528            encoder.write_num(self.bits(), offset);
529            Ok(())
530        }
531    }
532
533    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for EventPairRights {
534        #[inline(always)]
535        fn new_empty() -> Self {
536            Self::empty()
537        }
538
539        #[inline]
540        unsafe fn decode(
541            &mut self,
542            decoder: &mut fidl::encoding::Decoder<'_, D>,
543            offset: usize,
544            _depth: fidl::encoding::Depth,
545        ) -> fidl::Result<()> {
546            decoder.debug_check_bounds::<Self>(offset);
547            let prim = decoder.read_num::<u32>(offset);
548            *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
549            Ok(())
550        }
551    }
552    unsafe impl fidl::encoding::TypeMarker for Signals {
553        type Owned = Self;
554
555        #[inline(always)]
556        fn inline_align(_context: fidl::encoding::Context) -> usize {
557            4
558        }
559
560        #[inline(always)]
561        fn inline_size(_context: fidl::encoding::Context) -> usize {
562            4
563        }
564    }
565
566    impl fidl::encoding::ValueTypeMarker for Signals {
567        type Borrowed<'a> = Self;
568        #[inline(always)]
569        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
570            *value
571        }
572    }
573
574    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Signals {
575        #[inline]
576        unsafe fn encode(
577            self,
578            encoder: &mut fidl::encoding::Encoder<'_, D>,
579            offset: usize,
580            _depth: fidl::encoding::Depth,
581        ) -> fidl::Result<()> {
582            encoder.debug_check_bounds::<Self>(offset);
583            if self.bits() & Self::all().bits() != self.bits() {
584                return Err(fidl::Error::InvalidBitsValue);
585            }
586            encoder.write_num(self.bits(), offset);
587            Ok(())
588        }
589    }
590
591    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Signals {
592        #[inline(always)]
593        fn new_empty() -> Self {
594            Self::empty()
595        }
596
597        #[inline]
598        unsafe fn decode(
599            &mut self,
600            decoder: &mut fidl::encoding::Decoder<'_, D>,
601            offset: usize,
602            _depth: fidl::encoding::Depth,
603        ) -> fidl::Result<()> {
604            decoder.debug_check_bounds::<Self>(offset);
605            let prim = decoder.read_num::<u32>(offset);
606            *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
607            Ok(())
608        }
609    }
610    unsafe impl fidl::encoding::TypeMarker for SocketRights {
611        type Owned = Self;
612
613        #[inline(always)]
614        fn inline_align(_context: fidl::encoding::Context) -> usize {
615            4
616        }
617
618        #[inline(always)]
619        fn inline_size(_context: fidl::encoding::Context) -> usize {
620            4
621        }
622    }
623
624    impl fidl::encoding::ValueTypeMarker for SocketRights {
625        type Borrowed<'a> = Self;
626        #[inline(always)]
627        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
628            *value
629        }
630    }
631
632    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for SocketRights {
633        #[inline]
634        unsafe fn encode(
635            self,
636            encoder: &mut fidl::encoding::Encoder<'_, D>,
637            offset: usize,
638            _depth: fidl::encoding::Depth,
639        ) -> fidl::Result<()> {
640            encoder.debug_check_bounds::<Self>(offset);
641            if self.bits() & Self::all().bits() != self.bits() {
642                return Err(fidl::Error::InvalidBitsValue);
643            }
644            encoder.write_num(self.bits(), offset);
645            Ok(())
646        }
647    }
648
649    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SocketRights {
650        #[inline(always)]
651        fn new_empty() -> Self {
652            Self::empty()
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 prim = decoder.read_num::<u32>(offset);
664            *self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
665            Ok(())
666        }
667    }
668    unsafe impl fidl::encoding::TypeMarker for SocketType {
669        type Owned = Self;
670
671        #[inline(always)]
672        fn inline_align(_context: fidl::encoding::Context) -> usize {
673            std::mem::align_of::<u32>()
674        }
675
676        #[inline(always)]
677        fn inline_size(_context: fidl::encoding::Context) -> usize {
678            std::mem::size_of::<u32>()
679        }
680
681        #[inline(always)]
682        fn encode_is_copy() -> bool {
683            true
684        }
685
686        #[inline(always)]
687        fn decode_is_copy() -> bool {
688            false
689        }
690    }
691
692    impl fidl::encoding::ValueTypeMarker for SocketType {
693        type Borrowed<'a> = Self;
694        #[inline(always)]
695        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
696            *value
697        }
698    }
699
700    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for SocketType {
701        #[inline]
702        unsafe fn encode(
703            self,
704            encoder: &mut fidl::encoding::Encoder<'_, D>,
705            offset: usize,
706            _depth: fidl::encoding::Depth,
707        ) -> fidl::Result<()> {
708            encoder.debug_check_bounds::<Self>(offset);
709            encoder.write_num(self.into_primitive(), offset);
710            Ok(())
711        }
712    }
713
714    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SocketType {
715        #[inline(always)]
716        fn new_empty() -> Self {
717            Self::Datagram
718        }
719
720        #[inline]
721        unsafe fn decode(
722            &mut self,
723            decoder: &mut fidl::encoding::Decoder<'_, D>,
724            offset: usize,
725            _depth: fidl::encoding::Depth,
726        ) -> fidl::Result<()> {
727            decoder.debug_check_bounds::<Self>(offset);
728            let prim = decoder.read_num::<u32>(offset);
729
730            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
731            Ok(())
732        }
733    }
734
735    impl fidl::encoding::ValueTypeMarker for BeginTransfer {
736        type Borrowed<'a> = &'a Self;
737        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
738            value
739        }
740    }
741
742    unsafe impl fidl::encoding::TypeMarker for BeginTransfer {
743        type Owned = Self;
744
745        #[inline(always)]
746        fn inline_align(_context: fidl::encoding::Context) -> usize {
747            8
748        }
749
750        #[inline(always)]
751        fn inline_size(_context: fidl::encoding::Context) -> usize {
752            24
753        }
754        #[inline(always)]
755        fn encode_is_copy() -> bool {
756            true
757        }
758
759        #[inline(always)]
760        fn decode_is_copy() -> bool {
761            true
762        }
763    }
764
765    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BeginTransfer, D>
766        for &BeginTransfer
767    {
768        #[inline]
769        unsafe fn encode(
770            self,
771            encoder: &mut fidl::encoding::Encoder<'_, D>,
772            offset: usize,
773            _depth: fidl::encoding::Depth,
774        ) -> fidl::Result<()> {
775            encoder.debug_check_bounds::<BeginTransfer>(offset);
776            unsafe {
777                // Copy the object into the buffer.
778                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
779                (buf_ptr as *mut BeginTransfer)
780                    .write_unaligned((self as *const BeginTransfer).read());
781                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
782                // done second because the memcpy will write garbage to these bytes.
783            }
784            Ok(())
785        }
786    }
787    unsafe impl<
788            D: fidl::encoding::ResourceDialect,
789            T0: fidl::encoding::Encode<NodeId, D>,
790            T1: fidl::encoding::Encode<fidl::encoding::Array<u8, 16>, D>,
791        > fidl::encoding::Encode<BeginTransfer, D> for (T0, T1)
792    {
793        #[inline]
794        unsafe fn encode(
795            self,
796            encoder: &mut fidl::encoding::Encoder<'_, D>,
797            offset: usize,
798            depth: fidl::encoding::Depth,
799        ) -> fidl::Result<()> {
800            encoder.debug_check_bounds::<BeginTransfer>(offset);
801            // Zero out padding regions. There's no need to apply masks
802            // because the unmasked parts will be overwritten by fields.
803            // Write the fields.
804            self.0.encode(encoder, offset + 0, depth)?;
805            self.1.encode(encoder, offset + 8, depth)?;
806            Ok(())
807        }
808    }
809
810    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BeginTransfer {
811        #[inline(always)]
812        fn new_empty() -> Self {
813            Self {
814                new_destination_node: fidl::new_empty!(NodeId, D),
815                transfer_key: fidl::new_empty!(fidl::encoding::Array<u8, 16>, D),
816            }
817        }
818
819        #[inline]
820        unsafe fn decode(
821            &mut self,
822            decoder: &mut fidl::encoding::Decoder<'_, D>,
823            offset: usize,
824            _depth: fidl::encoding::Depth,
825        ) -> fidl::Result<()> {
826            decoder.debug_check_bounds::<Self>(offset);
827            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
828            // Verify that padding bytes are zero.
829            // Copy from the buffer into the object.
830            unsafe {
831                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 24);
832            }
833            Ok(())
834        }
835    }
836
837    impl fidl::encoding::ValueTypeMarker for ChannelHandle {
838        type Borrowed<'a> = &'a Self;
839        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
840            value
841        }
842    }
843
844    unsafe impl fidl::encoding::TypeMarker for ChannelHandle {
845        type Owned = Self;
846
847        #[inline(always)]
848        fn inline_align(_context: fidl::encoding::Context) -> usize {
849            8
850        }
851
852        #[inline(always)]
853        fn inline_size(_context: fidl::encoding::Context) -> usize {
854            24
855        }
856    }
857
858    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ChannelHandle, D>
859        for &ChannelHandle
860    {
861        #[inline]
862        unsafe fn encode(
863            self,
864            encoder: &mut fidl::encoding::Encoder<'_, D>,
865            offset: usize,
866            _depth: fidl::encoding::Depth,
867        ) -> fidl::Result<()> {
868            encoder.debug_check_bounds::<ChannelHandle>(offset);
869            // Delegate to tuple encoding.
870            fidl::encoding::Encode::<ChannelHandle, D>::encode(
871                (
872                    <ChannelRights as fidl::encoding::ValueTypeMarker>::borrow(&self.rights),
873                    <StreamRef as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_ref),
874                ),
875                encoder,
876                offset,
877                _depth,
878            )
879        }
880    }
881    unsafe impl<
882            D: fidl::encoding::ResourceDialect,
883            T0: fidl::encoding::Encode<ChannelRights, D>,
884            T1: fidl::encoding::Encode<StreamRef, D>,
885        > fidl::encoding::Encode<ChannelHandle, D> for (T0, T1)
886    {
887        #[inline]
888        unsafe fn encode(
889            self,
890            encoder: &mut fidl::encoding::Encoder<'_, D>,
891            offset: usize,
892            depth: fidl::encoding::Depth,
893        ) -> fidl::Result<()> {
894            encoder.debug_check_bounds::<ChannelHandle>(offset);
895            // Zero out padding regions. There's no need to apply masks
896            // because the unmasked parts will be overwritten by fields.
897            unsafe {
898                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
899                (ptr as *mut u64).write_unaligned(0);
900            }
901            // Write the fields.
902            self.0.encode(encoder, offset + 0, depth)?;
903            self.1.encode(encoder, offset + 8, depth)?;
904            Ok(())
905        }
906    }
907
908    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ChannelHandle {
909        #[inline(always)]
910        fn new_empty() -> Self {
911            Self {
912                rights: fidl::new_empty!(ChannelRights, D),
913                stream_ref: fidl::new_empty!(StreamRef, D),
914            }
915        }
916
917        #[inline]
918        unsafe fn decode(
919            &mut self,
920            decoder: &mut fidl::encoding::Decoder<'_, D>,
921            offset: usize,
922            _depth: fidl::encoding::Depth,
923        ) -> fidl::Result<()> {
924            decoder.debug_check_bounds::<Self>(offset);
925            // Verify that padding bytes are zero.
926            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
927            let padval = unsafe { (ptr as *const u64).read_unaligned() };
928            let mask = 0xffffffff00000000u64;
929            let maskedval = padval & mask;
930            if maskedval != 0 {
931                return Err(fidl::Error::NonZeroPadding {
932                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
933                });
934            }
935            fidl::decode!(ChannelRights, D, &mut self.rights, decoder, offset + 0, _depth)?;
936            fidl::decode!(StreamRef, D, &mut self.stream_ref, decoder, offset + 8, _depth)?;
937            Ok(())
938        }
939    }
940
941    impl fidl::encoding::ValueTypeMarker for ConnectToService {
942        type Borrowed<'a> = &'a Self;
943        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
944            value
945        }
946    }
947
948    unsafe impl fidl::encoding::TypeMarker for ConnectToService {
949        type Owned = Self;
950
951        #[inline(always)]
952        fn inline_align(_context: fidl::encoding::Context) -> usize {
953            8
954        }
955
956        #[inline(always)]
957        fn inline_size(_context: fidl::encoding::Context) -> usize {
958            56
959        }
960    }
961
962    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ConnectToService, D>
963        for &ConnectToService
964    {
965        #[inline]
966        unsafe fn encode(
967            self,
968            encoder: &mut fidl::encoding::Encoder<'_, D>,
969            offset: usize,
970            _depth: fidl::encoding::Depth,
971        ) -> fidl::Result<()> {
972            encoder.debug_check_bounds::<ConnectToService>(offset);
973            // Delegate to tuple encoding.
974            fidl::encoding::Encode::<ConnectToService, D>::encode(
975                (
976                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
977                        &self.service_name,
978                    ),
979                    <StreamRef as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_ref),
980                    <ChannelRights as fidl::encoding::ValueTypeMarker>::borrow(&self.rights),
981                    <ConnectToServiceOptions as fidl::encoding::ValueTypeMarker>::borrow(
982                        &self.options,
983                    ),
984                ),
985                encoder,
986                offset,
987                _depth,
988            )
989        }
990    }
991    unsafe impl<
992            D: fidl::encoding::ResourceDialect,
993            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<255>, D>,
994            T1: fidl::encoding::Encode<StreamRef, D>,
995            T2: fidl::encoding::Encode<ChannelRights, D>,
996            T3: fidl::encoding::Encode<ConnectToServiceOptions, D>,
997        > fidl::encoding::Encode<ConnectToService, D> for (T0, T1, T2, T3)
998    {
999        #[inline]
1000        unsafe fn encode(
1001            self,
1002            encoder: &mut fidl::encoding::Encoder<'_, D>,
1003            offset: usize,
1004            depth: fidl::encoding::Depth,
1005        ) -> fidl::Result<()> {
1006            encoder.debug_check_bounds::<ConnectToService>(offset);
1007            // Zero out padding regions. There's no need to apply masks
1008            // because the unmasked parts will be overwritten by fields.
1009            unsafe {
1010                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
1011                (ptr as *mut u64).write_unaligned(0);
1012            }
1013            // Write the fields.
1014            self.0.encode(encoder, offset + 0, depth)?;
1015            self.1.encode(encoder, offset + 16, depth)?;
1016            self.2.encode(encoder, offset + 32, depth)?;
1017            self.3.encode(encoder, offset + 40, depth)?;
1018            Ok(())
1019        }
1020    }
1021
1022    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ConnectToService {
1023        #[inline(always)]
1024        fn new_empty() -> Self {
1025            Self {
1026                service_name: fidl::new_empty!(fidl::encoding::BoundedString<255>, D),
1027                stream_ref: fidl::new_empty!(StreamRef, D),
1028                rights: fidl::new_empty!(ChannelRights, D),
1029                options: fidl::new_empty!(ConnectToServiceOptions, D),
1030            }
1031        }
1032
1033        #[inline]
1034        unsafe fn decode(
1035            &mut self,
1036            decoder: &mut fidl::encoding::Decoder<'_, D>,
1037            offset: usize,
1038            _depth: fidl::encoding::Depth,
1039        ) -> fidl::Result<()> {
1040            decoder.debug_check_bounds::<Self>(offset);
1041            // Verify that padding bytes are zero.
1042            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
1043            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1044            let mask = 0xffffffff00000000u64;
1045            let maskedval = padval & mask;
1046            if maskedval != 0 {
1047                return Err(fidl::Error::NonZeroPadding {
1048                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
1049                });
1050            }
1051            fidl::decode!(
1052                fidl::encoding::BoundedString<255>,
1053                D,
1054                &mut self.service_name,
1055                decoder,
1056                offset + 0,
1057                _depth
1058            )?;
1059            fidl::decode!(StreamRef, D, &mut self.stream_ref, decoder, offset + 16, _depth)?;
1060            fidl::decode!(ChannelRights, D, &mut self.rights, decoder, offset + 32, _depth)?;
1061            fidl::decode!(
1062                ConnectToServiceOptions,
1063                D,
1064                &mut self.options,
1065                decoder,
1066                offset + 40,
1067                _depth
1068            )?;
1069            Ok(())
1070        }
1071    }
1072
1073    impl fidl::encoding::ValueTypeMarker for Empty {
1074        type Borrowed<'a> = &'a Self;
1075        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1076            value
1077        }
1078    }
1079
1080    unsafe impl fidl::encoding::TypeMarker for Empty {
1081        type Owned = Self;
1082
1083        #[inline(always)]
1084        fn inline_align(_context: fidl::encoding::Context) -> usize {
1085            1
1086        }
1087
1088        #[inline(always)]
1089        fn inline_size(_context: fidl::encoding::Context) -> usize {
1090            1
1091        }
1092    }
1093
1094    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Empty, D> for &Empty {
1095        #[inline]
1096        unsafe fn encode(
1097            self,
1098            encoder: &mut fidl::encoding::Encoder<'_, D>,
1099            offset: usize,
1100            _depth: fidl::encoding::Depth,
1101        ) -> fidl::Result<()> {
1102            encoder.debug_check_bounds::<Empty>(offset);
1103            encoder.write_num(0u8, offset);
1104            Ok(())
1105        }
1106    }
1107
1108    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Empty {
1109        #[inline(always)]
1110        fn new_empty() -> Self {
1111            Self
1112        }
1113
1114        #[inline]
1115        unsafe fn decode(
1116            &mut self,
1117            decoder: &mut fidl::encoding::Decoder<'_, D>,
1118            offset: usize,
1119            _depth: fidl::encoding::Depth,
1120        ) -> fidl::Result<()> {
1121            decoder.debug_check_bounds::<Self>(offset);
1122            match decoder.read_num::<u8>(offset) {
1123                0 => Ok(()),
1124                _ => Err(fidl::Error::Invalid),
1125            }
1126        }
1127    }
1128
1129    impl fidl::encoding::ValueTypeMarker for EventPairHandle {
1130        type Borrowed<'a> = &'a Self;
1131        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1132            value
1133        }
1134    }
1135
1136    unsafe impl fidl::encoding::TypeMarker for EventPairHandle {
1137        type Owned = Self;
1138
1139        #[inline(always)]
1140        fn inline_align(_context: fidl::encoding::Context) -> usize {
1141            8
1142        }
1143
1144        #[inline(always)]
1145        fn inline_size(_context: fidl::encoding::Context) -> usize {
1146            24
1147        }
1148    }
1149
1150    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<EventPairHandle, D>
1151        for &EventPairHandle
1152    {
1153        #[inline]
1154        unsafe fn encode(
1155            self,
1156            encoder: &mut fidl::encoding::Encoder<'_, D>,
1157            offset: usize,
1158            _depth: fidl::encoding::Depth,
1159        ) -> fidl::Result<()> {
1160            encoder.debug_check_bounds::<EventPairHandle>(offset);
1161            // Delegate to tuple encoding.
1162            fidl::encoding::Encode::<EventPairHandle, D>::encode(
1163                (
1164                    <EventPairRights as fidl::encoding::ValueTypeMarker>::borrow(&self.rights),
1165                    <StreamRef as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_ref),
1166                ),
1167                encoder,
1168                offset,
1169                _depth,
1170            )
1171        }
1172    }
1173    unsafe impl<
1174            D: fidl::encoding::ResourceDialect,
1175            T0: fidl::encoding::Encode<EventPairRights, D>,
1176            T1: fidl::encoding::Encode<StreamRef, D>,
1177        > fidl::encoding::Encode<EventPairHandle, D> for (T0, T1)
1178    {
1179        #[inline]
1180        unsafe fn encode(
1181            self,
1182            encoder: &mut fidl::encoding::Encoder<'_, D>,
1183            offset: usize,
1184            depth: fidl::encoding::Depth,
1185        ) -> fidl::Result<()> {
1186            encoder.debug_check_bounds::<EventPairHandle>(offset);
1187            // Zero out padding regions. There's no need to apply masks
1188            // because the unmasked parts will be overwritten by fields.
1189            unsafe {
1190                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1191                (ptr as *mut u64).write_unaligned(0);
1192            }
1193            // Write the fields.
1194            self.0.encode(encoder, offset + 0, depth)?;
1195            self.1.encode(encoder, offset + 8, depth)?;
1196            Ok(())
1197        }
1198    }
1199
1200    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for EventPairHandle {
1201        #[inline(always)]
1202        fn new_empty() -> Self {
1203            Self {
1204                rights: fidl::new_empty!(EventPairRights, D),
1205                stream_ref: fidl::new_empty!(StreamRef, D),
1206            }
1207        }
1208
1209        #[inline]
1210        unsafe fn decode(
1211            &mut self,
1212            decoder: &mut fidl::encoding::Decoder<'_, D>,
1213            offset: usize,
1214            _depth: fidl::encoding::Depth,
1215        ) -> fidl::Result<()> {
1216            decoder.debug_check_bounds::<Self>(offset);
1217            // Verify that padding bytes are zero.
1218            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1219            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1220            let mask = 0xffffffff00000000u64;
1221            let maskedval = padval & mask;
1222            if maskedval != 0 {
1223                return Err(fidl::Error::NonZeroPadding {
1224                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1225                });
1226            }
1227            fidl::decode!(EventPairRights, D, &mut self.rights, decoder, offset + 0, _depth)?;
1228            fidl::decode!(StreamRef, D, &mut self.stream_ref, decoder, offset + 8, _depth)?;
1229            Ok(())
1230        }
1231    }
1232
1233    impl fidl::encoding::ValueTypeMarker for NodeId {
1234        type Borrowed<'a> = &'a Self;
1235        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1236            value
1237        }
1238    }
1239
1240    unsafe impl fidl::encoding::TypeMarker for NodeId {
1241        type Owned = Self;
1242
1243        #[inline(always)]
1244        fn inline_align(_context: fidl::encoding::Context) -> usize {
1245            8
1246        }
1247
1248        #[inline(always)]
1249        fn inline_size(_context: fidl::encoding::Context) -> usize {
1250            8
1251        }
1252        #[inline(always)]
1253        fn encode_is_copy() -> bool {
1254            true
1255        }
1256
1257        #[inline(always)]
1258        fn decode_is_copy() -> bool {
1259            true
1260        }
1261    }
1262
1263    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<NodeId, D> for &NodeId {
1264        #[inline]
1265        unsafe fn encode(
1266            self,
1267            encoder: &mut fidl::encoding::Encoder<'_, D>,
1268            offset: usize,
1269            _depth: fidl::encoding::Depth,
1270        ) -> fidl::Result<()> {
1271            encoder.debug_check_bounds::<NodeId>(offset);
1272            unsafe {
1273                // Copy the object into the buffer.
1274                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1275                (buf_ptr as *mut NodeId).write_unaligned((self as *const NodeId).read());
1276                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1277                // done second because the memcpy will write garbage to these bytes.
1278            }
1279            Ok(())
1280        }
1281    }
1282    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
1283        fidl::encoding::Encode<NodeId, D> for (T0,)
1284    {
1285        #[inline]
1286        unsafe fn encode(
1287            self,
1288            encoder: &mut fidl::encoding::Encoder<'_, D>,
1289            offset: usize,
1290            depth: fidl::encoding::Depth,
1291        ) -> fidl::Result<()> {
1292            encoder.debug_check_bounds::<NodeId>(offset);
1293            // Zero out padding regions. There's no need to apply masks
1294            // because the unmasked parts will be overwritten by fields.
1295            // Write the fields.
1296            self.0.encode(encoder, offset + 0, depth)?;
1297            Ok(())
1298        }
1299    }
1300
1301    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for NodeId {
1302        #[inline(always)]
1303        fn new_empty() -> Self {
1304            Self { id: fidl::new_empty!(u64, D) }
1305        }
1306
1307        #[inline]
1308        unsafe fn decode(
1309            &mut self,
1310            decoder: &mut fidl::encoding::Decoder<'_, D>,
1311            offset: usize,
1312            _depth: fidl::encoding::Depth,
1313        ) -> fidl::Result<()> {
1314            decoder.debug_check_bounds::<Self>(offset);
1315            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1316            // Verify that padding bytes are zero.
1317            // Copy from the buffer into the object.
1318            unsafe {
1319                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
1320            }
1321            Ok(())
1322        }
1323    }
1324
1325    impl fidl::encoding::ValueTypeMarker for OpenTransfer {
1326        type Borrowed<'a> = &'a Self;
1327        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1328            value
1329        }
1330    }
1331
1332    unsafe impl fidl::encoding::TypeMarker for OpenTransfer {
1333        type Owned = Self;
1334
1335        #[inline(always)]
1336        fn inline_align(_context: fidl::encoding::Context) -> usize {
1337            8
1338        }
1339
1340        #[inline(always)]
1341        fn inline_size(_context: fidl::encoding::Context) -> usize {
1342            24
1343        }
1344        #[inline(always)]
1345        fn encode_is_copy() -> bool {
1346            true
1347        }
1348
1349        #[inline(always)]
1350        fn decode_is_copy() -> bool {
1351            true
1352        }
1353    }
1354
1355    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<OpenTransfer, D>
1356        for &OpenTransfer
1357    {
1358        #[inline]
1359        unsafe fn encode(
1360            self,
1361            encoder: &mut fidl::encoding::Encoder<'_, D>,
1362            offset: usize,
1363            _depth: fidl::encoding::Depth,
1364        ) -> fidl::Result<()> {
1365            encoder.debug_check_bounds::<OpenTransfer>(offset);
1366            unsafe {
1367                // Copy the object into the buffer.
1368                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1369                (buf_ptr as *mut OpenTransfer)
1370                    .write_unaligned((self as *const OpenTransfer).read());
1371                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1372                // done second because the memcpy will write garbage to these bytes.
1373            }
1374            Ok(())
1375        }
1376    }
1377    unsafe impl<
1378            D: fidl::encoding::ResourceDialect,
1379            T0: fidl::encoding::Encode<StreamId, D>,
1380            T1: fidl::encoding::Encode<fidl::encoding::Array<u8, 16>, D>,
1381        > fidl::encoding::Encode<OpenTransfer, D> for (T0, T1)
1382    {
1383        #[inline]
1384        unsafe fn encode(
1385            self,
1386            encoder: &mut fidl::encoding::Encoder<'_, D>,
1387            offset: usize,
1388            depth: fidl::encoding::Depth,
1389        ) -> fidl::Result<()> {
1390            encoder.debug_check_bounds::<OpenTransfer>(offset);
1391            // Zero out padding regions. There's no need to apply masks
1392            // because the unmasked parts will be overwritten by fields.
1393            // Write the fields.
1394            self.0.encode(encoder, offset + 0, depth)?;
1395            self.1.encode(encoder, offset + 8, depth)?;
1396            Ok(())
1397        }
1398    }
1399
1400    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OpenTransfer {
1401        #[inline(always)]
1402        fn new_empty() -> Self {
1403            Self {
1404                stream_id: fidl::new_empty!(StreamId, D),
1405                transfer_key: fidl::new_empty!(fidl::encoding::Array<u8, 16>, D),
1406            }
1407        }
1408
1409        #[inline]
1410        unsafe fn decode(
1411            &mut self,
1412            decoder: &mut fidl::encoding::Decoder<'_, D>,
1413            offset: usize,
1414            _depth: fidl::encoding::Depth,
1415        ) -> fidl::Result<()> {
1416            decoder.debug_check_bounds::<Self>(offset);
1417            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1418            // Verify that padding bytes are zero.
1419            // Copy from the buffer into the object.
1420            unsafe {
1421                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 24);
1422            }
1423            Ok(())
1424        }
1425    }
1426
1427    impl fidl::encoding::ValueTypeMarker for SocketHandle {
1428        type Borrowed<'a> = &'a Self;
1429        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1430            value
1431        }
1432    }
1433
1434    unsafe impl fidl::encoding::TypeMarker for SocketHandle {
1435        type Owned = Self;
1436
1437        #[inline(always)]
1438        fn inline_align(_context: fidl::encoding::Context) -> usize {
1439            8
1440        }
1441
1442        #[inline(always)]
1443        fn inline_size(_context: fidl::encoding::Context) -> usize {
1444            32
1445        }
1446    }
1447
1448    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SocketHandle, D>
1449        for &SocketHandle
1450    {
1451        #[inline]
1452        unsafe fn encode(
1453            self,
1454            encoder: &mut fidl::encoding::Encoder<'_, D>,
1455            offset: usize,
1456            _depth: fidl::encoding::Depth,
1457        ) -> fidl::Result<()> {
1458            encoder.debug_check_bounds::<SocketHandle>(offset);
1459            // Delegate to tuple encoding.
1460            fidl::encoding::Encode::<SocketHandle, D>::encode(
1461                (
1462                    <SocketRights as fidl::encoding::ValueTypeMarker>::borrow(&self.rights),
1463                    <StreamRef as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_ref),
1464                    <SocketType as fidl::encoding::ValueTypeMarker>::borrow(&self.socket_type),
1465                ),
1466                encoder,
1467                offset,
1468                _depth,
1469            )
1470        }
1471    }
1472    unsafe impl<
1473            D: fidl::encoding::ResourceDialect,
1474            T0: fidl::encoding::Encode<SocketRights, D>,
1475            T1: fidl::encoding::Encode<StreamRef, D>,
1476            T2: fidl::encoding::Encode<SocketType, D>,
1477        > fidl::encoding::Encode<SocketHandle, D> for (T0, T1, T2)
1478    {
1479        #[inline]
1480        unsafe fn encode(
1481            self,
1482            encoder: &mut fidl::encoding::Encoder<'_, D>,
1483            offset: usize,
1484            depth: fidl::encoding::Depth,
1485        ) -> fidl::Result<()> {
1486            encoder.debug_check_bounds::<SocketHandle>(offset);
1487            // Zero out padding regions. There's no need to apply masks
1488            // because the unmasked parts will be overwritten by fields.
1489            unsafe {
1490                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1491                (ptr as *mut u64).write_unaligned(0);
1492            }
1493            unsafe {
1494                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
1495                (ptr as *mut u64).write_unaligned(0);
1496            }
1497            // Write the fields.
1498            self.0.encode(encoder, offset + 0, depth)?;
1499            self.1.encode(encoder, offset + 8, depth)?;
1500            self.2.encode(encoder, offset + 24, depth)?;
1501            Ok(())
1502        }
1503    }
1504
1505    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SocketHandle {
1506        #[inline(always)]
1507        fn new_empty() -> Self {
1508            Self {
1509                rights: fidl::new_empty!(SocketRights, D),
1510                stream_ref: fidl::new_empty!(StreamRef, D),
1511                socket_type: fidl::new_empty!(SocketType, D),
1512            }
1513        }
1514
1515        #[inline]
1516        unsafe fn decode(
1517            &mut self,
1518            decoder: &mut fidl::encoding::Decoder<'_, D>,
1519            offset: usize,
1520            _depth: fidl::encoding::Depth,
1521        ) -> fidl::Result<()> {
1522            decoder.debug_check_bounds::<Self>(offset);
1523            // Verify that padding bytes are zero.
1524            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1525            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1526            let mask = 0xffffffff00000000u64;
1527            let maskedval = padval & mask;
1528            if maskedval != 0 {
1529                return Err(fidl::Error::NonZeroPadding {
1530                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1531                });
1532            }
1533            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
1534            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1535            let mask = 0xffffffff00000000u64;
1536            let maskedval = padval & mask;
1537            if maskedval != 0 {
1538                return Err(fidl::Error::NonZeroPadding {
1539                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
1540                });
1541            }
1542            fidl::decode!(SocketRights, D, &mut self.rights, decoder, offset + 0, _depth)?;
1543            fidl::decode!(StreamRef, D, &mut self.stream_ref, decoder, offset + 8, _depth)?;
1544            fidl::decode!(SocketType, D, &mut self.socket_type, decoder, offset + 24, _depth)?;
1545            Ok(())
1546        }
1547    }
1548
1549    impl fidl::encoding::ValueTypeMarker for StreamId {
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 StreamId {
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            8
1567        }
1568        #[inline(always)]
1569        fn encode_is_copy() -> bool {
1570            true
1571        }
1572
1573        #[inline(always)]
1574        fn decode_is_copy() -> bool {
1575            true
1576        }
1577    }
1578
1579    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<StreamId, D> for &StreamId {
1580        #[inline]
1581        unsafe fn encode(
1582            self,
1583            encoder: &mut fidl::encoding::Encoder<'_, D>,
1584            offset: usize,
1585            _depth: fidl::encoding::Depth,
1586        ) -> fidl::Result<()> {
1587            encoder.debug_check_bounds::<StreamId>(offset);
1588            unsafe {
1589                // Copy the object into the buffer.
1590                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1591                (buf_ptr as *mut StreamId).write_unaligned((self as *const StreamId).read());
1592                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1593                // done second because the memcpy will write garbage to these bytes.
1594            }
1595            Ok(())
1596        }
1597    }
1598    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
1599        fidl::encoding::Encode<StreamId, D> for (T0,)
1600    {
1601        #[inline]
1602        unsafe fn encode(
1603            self,
1604            encoder: &mut fidl::encoding::Encoder<'_, D>,
1605            offset: usize,
1606            depth: fidl::encoding::Depth,
1607        ) -> fidl::Result<()> {
1608            encoder.debug_check_bounds::<StreamId>(offset);
1609            // Zero out padding regions. There's no need to apply masks
1610            // because the unmasked parts will be overwritten by fields.
1611            // Write the fields.
1612            self.0.encode(encoder, offset + 0, depth)?;
1613            Ok(())
1614        }
1615    }
1616
1617    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StreamId {
1618        #[inline(always)]
1619        fn new_empty() -> Self {
1620            Self { id: fidl::new_empty!(u64, D) }
1621        }
1622
1623        #[inline]
1624        unsafe fn decode(
1625            &mut self,
1626            decoder: &mut fidl::encoding::Decoder<'_, D>,
1627            offset: usize,
1628            _depth: fidl::encoding::Depth,
1629        ) -> fidl::Result<()> {
1630            decoder.debug_check_bounds::<Self>(offset);
1631            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1632            // Verify that padding bytes are zero.
1633            // Copy from the buffer into the object.
1634            unsafe {
1635                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
1636            }
1637            Ok(())
1638        }
1639    }
1640
1641    impl fidl::encoding::ValueTypeMarker for TransferInitiator {
1642        type Borrowed<'a> = &'a Self;
1643        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1644            value
1645        }
1646    }
1647
1648    unsafe impl fidl::encoding::TypeMarker for TransferInitiator {
1649        type Owned = Self;
1650
1651        #[inline(always)]
1652        fn inline_align(_context: fidl::encoding::Context) -> usize {
1653            8
1654        }
1655
1656        #[inline(always)]
1657        fn inline_size(_context: fidl::encoding::Context) -> usize {
1658            32
1659        }
1660        #[inline(always)]
1661        fn encode_is_copy() -> bool {
1662            true
1663        }
1664
1665        #[inline(always)]
1666        fn decode_is_copy() -> bool {
1667            true
1668        }
1669    }
1670
1671    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<TransferInitiator, D>
1672        for &TransferInitiator
1673    {
1674        #[inline]
1675        unsafe fn encode(
1676            self,
1677            encoder: &mut fidl::encoding::Encoder<'_, D>,
1678            offset: usize,
1679            _depth: fidl::encoding::Depth,
1680        ) -> fidl::Result<()> {
1681            encoder.debug_check_bounds::<TransferInitiator>(offset);
1682            unsafe {
1683                // Copy the object into the buffer.
1684                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1685                (buf_ptr as *mut TransferInitiator)
1686                    .write_unaligned((self as *const TransferInitiator).read());
1687                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1688                // done second because the memcpy will write garbage to these bytes.
1689            }
1690            Ok(())
1691        }
1692    }
1693    unsafe impl<
1694            D: fidl::encoding::ResourceDialect,
1695            T0: fidl::encoding::Encode<StreamId, D>,
1696            T1: fidl::encoding::Encode<NodeId, D>,
1697            T2: fidl::encoding::Encode<fidl::encoding::Array<u8, 16>, D>,
1698        > fidl::encoding::Encode<TransferInitiator, D> for (T0, T1, T2)
1699    {
1700        #[inline]
1701        unsafe fn encode(
1702            self,
1703            encoder: &mut fidl::encoding::Encoder<'_, D>,
1704            offset: usize,
1705            depth: fidl::encoding::Depth,
1706        ) -> fidl::Result<()> {
1707            encoder.debug_check_bounds::<TransferInitiator>(offset);
1708            // Zero out padding regions. There's no need to apply masks
1709            // because the unmasked parts will be overwritten by fields.
1710            // Write the fields.
1711            self.0.encode(encoder, offset + 0, depth)?;
1712            self.1.encode(encoder, offset + 8, depth)?;
1713            self.2.encode(encoder, offset + 16, depth)?;
1714            Ok(())
1715        }
1716    }
1717
1718    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TransferInitiator {
1719        #[inline(always)]
1720        fn new_empty() -> Self {
1721            Self {
1722                stream_id: fidl::new_empty!(StreamId, D),
1723                new_destination_node: fidl::new_empty!(NodeId, D),
1724                transfer_key: fidl::new_empty!(fidl::encoding::Array<u8, 16>, D),
1725            }
1726        }
1727
1728        #[inline]
1729        unsafe fn decode(
1730            &mut self,
1731            decoder: &mut fidl::encoding::Decoder<'_, D>,
1732            offset: usize,
1733            _depth: fidl::encoding::Depth,
1734        ) -> fidl::Result<()> {
1735            decoder.debug_check_bounds::<Self>(offset);
1736            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1737            // Verify that padding bytes are zero.
1738            // Copy from the buffer into the object.
1739            unsafe {
1740                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 32);
1741            }
1742            Ok(())
1743        }
1744    }
1745
1746    impl fidl::encoding::ValueTypeMarker for TransferWaiter {
1747        type Borrowed<'a> = &'a Self;
1748        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1749            value
1750        }
1751    }
1752
1753    unsafe impl fidl::encoding::TypeMarker for TransferWaiter {
1754        type Owned = Self;
1755
1756        #[inline(always)]
1757        fn inline_align(_context: fidl::encoding::Context) -> usize {
1758            8
1759        }
1760
1761        #[inline(always)]
1762        fn inline_size(_context: fidl::encoding::Context) -> usize {
1763            24
1764        }
1765        #[inline(always)]
1766        fn encode_is_copy() -> bool {
1767            true
1768        }
1769
1770        #[inline(always)]
1771        fn decode_is_copy() -> bool {
1772            true
1773        }
1774    }
1775
1776    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<TransferWaiter, D>
1777        for &TransferWaiter
1778    {
1779        #[inline]
1780        unsafe fn encode(
1781            self,
1782            encoder: &mut fidl::encoding::Encoder<'_, D>,
1783            offset: usize,
1784            _depth: fidl::encoding::Depth,
1785        ) -> fidl::Result<()> {
1786            encoder.debug_check_bounds::<TransferWaiter>(offset);
1787            unsafe {
1788                // Copy the object into the buffer.
1789                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1790                (buf_ptr as *mut TransferWaiter)
1791                    .write_unaligned((self as *const TransferWaiter).read());
1792                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
1793                // done second because the memcpy will write garbage to these bytes.
1794            }
1795            Ok(())
1796        }
1797    }
1798    unsafe impl<
1799            D: fidl::encoding::ResourceDialect,
1800            T0: fidl::encoding::Encode<StreamId, D>,
1801            T1: fidl::encoding::Encode<fidl::encoding::Array<u8, 16>, D>,
1802        > fidl::encoding::Encode<TransferWaiter, D> for (T0, T1)
1803    {
1804        #[inline]
1805        unsafe fn encode(
1806            self,
1807            encoder: &mut fidl::encoding::Encoder<'_, D>,
1808            offset: usize,
1809            depth: fidl::encoding::Depth,
1810        ) -> fidl::Result<()> {
1811            encoder.debug_check_bounds::<TransferWaiter>(offset);
1812            // Zero out padding regions. There's no need to apply masks
1813            // because the unmasked parts will be overwritten by fields.
1814            // Write the fields.
1815            self.0.encode(encoder, offset + 0, depth)?;
1816            self.1.encode(encoder, offset + 8, depth)?;
1817            Ok(())
1818        }
1819    }
1820
1821    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TransferWaiter {
1822        #[inline(always)]
1823        fn new_empty() -> Self {
1824            Self {
1825                stream_id: fidl::new_empty!(StreamId, D),
1826                transfer_key: fidl::new_empty!(fidl::encoding::Array<u8, 16>, D),
1827            }
1828        }
1829
1830        #[inline]
1831        unsafe fn decode(
1832            &mut self,
1833            decoder: &mut fidl::encoding::Decoder<'_, D>,
1834            offset: usize,
1835            _depth: fidl::encoding::Depth,
1836        ) -> fidl::Result<()> {
1837            decoder.debug_check_bounds::<Self>(offset);
1838            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1839            // Verify that padding bytes are zero.
1840            // Copy from the buffer into the object.
1841            unsafe {
1842                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 24);
1843            }
1844            Ok(())
1845        }
1846    }
1847
1848    impl fidl::encoding::ValueTypeMarker for ZirconChannelMessage {
1849        type Borrowed<'a> = &'a Self;
1850        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1851            value
1852        }
1853    }
1854
1855    unsafe impl fidl::encoding::TypeMarker for ZirconChannelMessage {
1856        type Owned = Self;
1857
1858        #[inline(always)]
1859        fn inline_align(_context: fidl::encoding::Context) -> usize {
1860            8
1861        }
1862
1863        #[inline(always)]
1864        fn inline_size(_context: fidl::encoding::Context) -> usize {
1865            32
1866        }
1867    }
1868
1869    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ZirconChannelMessage, D>
1870        for &ZirconChannelMessage
1871    {
1872        #[inline]
1873        unsafe fn encode(
1874            self,
1875            encoder: &mut fidl::encoding::Encoder<'_, D>,
1876            offset: usize,
1877            _depth: fidl::encoding::Depth,
1878        ) -> fidl::Result<()> {
1879            encoder.debug_check_bounds::<ZirconChannelMessage>(offset);
1880            // Delegate to tuple encoding.
1881            fidl::encoding::Encode::<ZirconChannelMessage, D>::encode(
1882                (
1883                    <fidl::encoding::Vector<u8, 65536> as fidl::encoding::ValueTypeMarker>::borrow(&self.bytes),
1884                    <fidl::encoding::Vector<ZirconHandle, 64> as fidl::encoding::ValueTypeMarker>::borrow(&self.handles),
1885                ),
1886                encoder, offset, _depth
1887            )
1888        }
1889    }
1890    unsafe impl<
1891            D: fidl::encoding::ResourceDialect,
1892            T0: fidl::encoding::Encode<fidl::encoding::Vector<u8, 65536>, D>,
1893            T1: fidl::encoding::Encode<fidl::encoding::Vector<ZirconHandle, 64>, D>,
1894        > fidl::encoding::Encode<ZirconChannelMessage, D> for (T0, T1)
1895    {
1896        #[inline]
1897        unsafe fn encode(
1898            self,
1899            encoder: &mut fidl::encoding::Encoder<'_, D>,
1900            offset: usize,
1901            depth: fidl::encoding::Depth,
1902        ) -> fidl::Result<()> {
1903            encoder.debug_check_bounds::<ZirconChannelMessage>(offset);
1904            // Zero out padding regions. There's no need to apply masks
1905            // because the unmasked parts will be overwritten by fields.
1906            // Write the fields.
1907            self.0.encode(encoder, offset + 0, depth)?;
1908            self.1.encode(encoder, offset + 16, depth)?;
1909            Ok(())
1910        }
1911    }
1912
1913    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ZirconChannelMessage {
1914        #[inline(always)]
1915        fn new_empty() -> Self {
1916            Self {
1917                bytes: fidl::new_empty!(fidl::encoding::Vector<u8, 65536>, D),
1918                handles: fidl::new_empty!(fidl::encoding::Vector<ZirconHandle, 64>, D),
1919            }
1920        }
1921
1922        #[inline]
1923        unsafe fn decode(
1924            &mut self,
1925            decoder: &mut fidl::encoding::Decoder<'_, D>,
1926            offset: usize,
1927            _depth: fidl::encoding::Depth,
1928        ) -> fidl::Result<()> {
1929            decoder.debug_check_bounds::<Self>(offset);
1930            // Verify that padding bytes are zero.
1931            fidl::decode!(fidl::encoding::Vector<u8, 65536>, D, &mut self.bytes, decoder, offset + 0, _depth)?;
1932            fidl::decode!(fidl::encoding::Vector<ZirconHandle, 64>, D, &mut self.handles, decoder, offset + 16, _depth)?;
1933            Ok(())
1934        }
1935    }
1936
1937    impl ConfigRequest {
1938        #[inline(always)]
1939        fn max_ordinal_present(&self) -> u64 {
1940            0
1941        }
1942    }
1943
1944    impl fidl::encoding::ValueTypeMarker for ConfigRequest {
1945        type Borrowed<'a> = &'a Self;
1946        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1947            value
1948        }
1949    }
1950
1951    unsafe impl fidl::encoding::TypeMarker for ConfigRequest {
1952        type Owned = Self;
1953
1954        #[inline(always)]
1955        fn inline_align(_context: fidl::encoding::Context) -> usize {
1956            8
1957        }
1958
1959        #[inline(always)]
1960        fn inline_size(_context: fidl::encoding::Context) -> usize {
1961            16
1962        }
1963    }
1964
1965    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ConfigRequest, D>
1966        for &ConfigRequest
1967    {
1968        unsafe fn encode(
1969            self,
1970            encoder: &mut fidl::encoding::Encoder<'_, D>,
1971            offset: usize,
1972            mut depth: fidl::encoding::Depth,
1973        ) -> fidl::Result<()> {
1974            encoder.debug_check_bounds::<ConfigRequest>(offset);
1975            // Vector header
1976            let max_ordinal: u64 = self.max_ordinal_present();
1977            encoder.write_num(max_ordinal, offset);
1978            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1979            // Calling encoder.out_of_line_offset(0) is not allowed.
1980            if max_ordinal == 0 {
1981                return Ok(());
1982            }
1983            depth.increment()?;
1984            let envelope_size = 8;
1985            let bytes_len = max_ordinal as usize * envelope_size;
1986            #[allow(unused_variables)]
1987            let offset = encoder.out_of_line_offset(bytes_len);
1988            let mut _prev_end_offset: usize = 0;
1989
1990            Ok(())
1991        }
1992    }
1993
1994    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ConfigRequest {
1995        #[inline(always)]
1996        fn new_empty() -> Self {
1997            Self::default()
1998        }
1999
2000        unsafe fn decode(
2001            &mut self,
2002            decoder: &mut fidl::encoding::Decoder<'_, D>,
2003            offset: usize,
2004            mut depth: fidl::encoding::Depth,
2005        ) -> fidl::Result<()> {
2006            decoder.debug_check_bounds::<Self>(offset);
2007            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2008                None => return Err(fidl::Error::NotNullable),
2009                Some(len) => len,
2010            };
2011            // Calling decoder.out_of_line_offset(0) is not allowed.
2012            if len == 0 {
2013                return Ok(());
2014            };
2015            depth.increment()?;
2016            let envelope_size = 8;
2017            let bytes_len = len * envelope_size;
2018            let offset = decoder.out_of_line_offset(bytes_len)?;
2019            // Decode the envelope for each type.
2020            let mut _next_ordinal_to_read = 0;
2021            let mut next_offset = offset;
2022            let end_offset = offset + bytes_len;
2023
2024            // Decode the remaining unknown envelopes.
2025            while next_offset < end_offset {
2026                _next_ordinal_to_read += 1;
2027                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2028                next_offset += envelope_size;
2029            }
2030
2031            Ok(())
2032        }
2033    }
2034
2035    impl ConfigResponse {
2036        #[inline(always)]
2037        fn max_ordinal_present(&self) -> u64 {
2038            0
2039        }
2040    }
2041
2042    impl fidl::encoding::ValueTypeMarker for ConfigResponse {
2043        type Borrowed<'a> = &'a Self;
2044        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2045            value
2046        }
2047    }
2048
2049    unsafe impl fidl::encoding::TypeMarker for ConfigResponse {
2050        type Owned = Self;
2051
2052        #[inline(always)]
2053        fn inline_align(_context: fidl::encoding::Context) -> usize {
2054            8
2055        }
2056
2057        #[inline(always)]
2058        fn inline_size(_context: fidl::encoding::Context) -> usize {
2059            16
2060        }
2061    }
2062
2063    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ConfigResponse, D>
2064        for &ConfigResponse
2065    {
2066        unsafe fn encode(
2067            self,
2068            encoder: &mut fidl::encoding::Encoder<'_, D>,
2069            offset: usize,
2070            mut depth: fidl::encoding::Depth,
2071        ) -> fidl::Result<()> {
2072            encoder.debug_check_bounds::<ConfigResponse>(offset);
2073            // Vector header
2074            let max_ordinal: u64 = self.max_ordinal_present();
2075            encoder.write_num(max_ordinal, offset);
2076            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2077            // Calling encoder.out_of_line_offset(0) is not allowed.
2078            if max_ordinal == 0 {
2079                return Ok(());
2080            }
2081            depth.increment()?;
2082            let envelope_size = 8;
2083            let bytes_len = max_ordinal as usize * envelope_size;
2084            #[allow(unused_variables)]
2085            let offset = encoder.out_of_line_offset(bytes_len);
2086            let mut _prev_end_offset: usize = 0;
2087
2088            Ok(())
2089        }
2090    }
2091
2092    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ConfigResponse {
2093        #[inline(always)]
2094        fn new_empty() -> Self {
2095            Self::default()
2096        }
2097
2098        unsafe fn decode(
2099            &mut self,
2100            decoder: &mut fidl::encoding::Decoder<'_, D>,
2101            offset: usize,
2102            mut depth: fidl::encoding::Depth,
2103        ) -> fidl::Result<()> {
2104            decoder.debug_check_bounds::<Self>(offset);
2105            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2106                None => return Err(fidl::Error::NotNullable),
2107                Some(len) => len,
2108            };
2109            // Calling decoder.out_of_line_offset(0) is not allowed.
2110            if len == 0 {
2111                return Ok(());
2112            };
2113            depth.increment()?;
2114            let envelope_size = 8;
2115            let bytes_len = len * envelope_size;
2116            let offset = decoder.out_of_line_offset(bytes_len)?;
2117            // Decode the envelope for each type.
2118            let mut _next_ordinal_to_read = 0;
2119            let mut next_offset = offset;
2120            let end_offset = offset + bytes_len;
2121
2122            // Decode the remaining unknown envelopes.
2123            while next_offset < end_offset {
2124                _next_ordinal_to_read += 1;
2125                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2126                next_offset += envelope_size;
2127            }
2128
2129            Ok(())
2130        }
2131    }
2132
2133    impl ConnectToServiceOptions {
2134        #[inline(always)]
2135        fn max_ordinal_present(&self) -> u64 {
2136            0
2137        }
2138    }
2139
2140    impl fidl::encoding::ValueTypeMarker for ConnectToServiceOptions {
2141        type Borrowed<'a> = &'a Self;
2142        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2143            value
2144        }
2145    }
2146
2147    unsafe impl fidl::encoding::TypeMarker for ConnectToServiceOptions {
2148        type Owned = Self;
2149
2150        #[inline(always)]
2151        fn inline_align(_context: fidl::encoding::Context) -> usize {
2152            8
2153        }
2154
2155        #[inline(always)]
2156        fn inline_size(_context: fidl::encoding::Context) -> usize {
2157            16
2158        }
2159    }
2160
2161    unsafe impl<D: fidl::encoding::ResourceDialect>
2162        fidl::encoding::Encode<ConnectToServiceOptions, D> for &ConnectToServiceOptions
2163    {
2164        unsafe fn encode(
2165            self,
2166            encoder: &mut fidl::encoding::Encoder<'_, D>,
2167            offset: usize,
2168            mut depth: fidl::encoding::Depth,
2169        ) -> fidl::Result<()> {
2170            encoder.debug_check_bounds::<ConnectToServiceOptions>(offset);
2171            // Vector header
2172            let max_ordinal: u64 = self.max_ordinal_present();
2173            encoder.write_num(max_ordinal, offset);
2174            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2175            // Calling encoder.out_of_line_offset(0) is not allowed.
2176            if max_ordinal == 0 {
2177                return Ok(());
2178            }
2179            depth.increment()?;
2180            let envelope_size = 8;
2181            let bytes_len = max_ordinal as usize * envelope_size;
2182            #[allow(unused_variables)]
2183            let offset = encoder.out_of_line_offset(bytes_len);
2184            let mut _prev_end_offset: usize = 0;
2185
2186            Ok(())
2187        }
2188    }
2189
2190    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2191        for ConnectToServiceOptions
2192    {
2193        #[inline(always)]
2194        fn new_empty() -> Self {
2195            Self::default()
2196        }
2197
2198        unsafe fn decode(
2199            &mut self,
2200            decoder: &mut fidl::encoding::Decoder<'_, D>,
2201            offset: usize,
2202            mut depth: fidl::encoding::Depth,
2203        ) -> fidl::Result<()> {
2204            decoder.debug_check_bounds::<Self>(offset);
2205            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2206                None => return Err(fidl::Error::NotNullable),
2207                Some(len) => len,
2208            };
2209            // Calling decoder.out_of_line_offset(0) is not allowed.
2210            if len == 0 {
2211                return Ok(());
2212            };
2213            depth.increment()?;
2214            let envelope_size = 8;
2215            let bytes_len = len * envelope_size;
2216            let offset = decoder.out_of_line_offset(bytes_len)?;
2217            // Decode the envelope for each type.
2218            let mut _next_ordinal_to_read = 0;
2219            let mut next_offset = offset;
2220            let end_offset = offset + bytes_len;
2221
2222            // Decode the remaining unknown envelopes.
2223            while next_offset < end_offset {
2224                _next_ordinal_to_read += 1;
2225                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2226                next_offset += envelope_size;
2227            }
2228
2229            Ok(())
2230        }
2231    }
2232
2233    impl PeerDescription {
2234        #[inline(always)]
2235        fn max_ordinal_present(&self) -> u64 {
2236            if let Some(_) = self.services {
2237                return 1;
2238            }
2239            0
2240        }
2241    }
2242
2243    impl fidl::encoding::ValueTypeMarker for PeerDescription {
2244        type Borrowed<'a> = &'a Self;
2245        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2246            value
2247        }
2248    }
2249
2250    unsafe impl fidl::encoding::TypeMarker for PeerDescription {
2251        type Owned = Self;
2252
2253        #[inline(always)]
2254        fn inline_align(_context: fidl::encoding::Context) -> usize {
2255            8
2256        }
2257
2258        #[inline(always)]
2259        fn inline_size(_context: fidl::encoding::Context) -> usize {
2260            16
2261        }
2262    }
2263
2264    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PeerDescription, D>
2265        for &PeerDescription
2266    {
2267        unsafe fn encode(
2268            self,
2269            encoder: &mut fidl::encoding::Encoder<'_, D>,
2270            offset: usize,
2271            mut depth: fidl::encoding::Depth,
2272        ) -> fidl::Result<()> {
2273            encoder.debug_check_bounds::<PeerDescription>(offset);
2274            // Vector header
2275            let max_ordinal: u64 = self.max_ordinal_present();
2276            encoder.write_num(max_ordinal, offset);
2277            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2278            // Calling encoder.out_of_line_offset(0) is not allowed.
2279            if max_ordinal == 0 {
2280                return Ok(());
2281            }
2282            depth.increment()?;
2283            let envelope_size = 8;
2284            let bytes_len = max_ordinal as usize * envelope_size;
2285            #[allow(unused_variables)]
2286            let offset = encoder.out_of_line_offset(bytes_len);
2287            let mut _prev_end_offset: usize = 0;
2288            if 1 > max_ordinal {
2289                return Ok(());
2290            }
2291
2292            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2293            // are envelope_size bytes.
2294            let cur_offset: usize = (1 - 1) * envelope_size;
2295
2296            // Zero reserved fields.
2297            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2298
2299            // Safety:
2300            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2301            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2302            //   envelope_size bytes, there is always sufficient room.
2303            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<255>>, D>(
2304            self.services.as_ref().map(<fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<255>> as fidl::encoding::ValueTypeMarker>::borrow),
2305            encoder, offset + cur_offset, depth
2306        )?;
2307
2308            _prev_end_offset = cur_offset + envelope_size;
2309
2310            Ok(())
2311        }
2312    }
2313
2314    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PeerDescription {
2315        #[inline(always)]
2316        fn new_empty() -> Self {
2317            Self::default()
2318        }
2319
2320        unsafe fn decode(
2321            &mut self,
2322            decoder: &mut fidl::encoding::Decoder<'_, D>,
2323            offset: usize,
2324            mut depth: fidl::encoding::Depth,
2325        ) -> fidl::Result<()> {
2326            decoder.debug_check_bounds::<Self>(offset);
2327            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2328                None => return Err(fidl::Error::NotNullable),
2329                Some(len) => len,
2330            };
2331            // Calling decoder.out_of_line_offset(0) is not allowed.
2332            if len == 0 {
2333                return Ok(());
2334            };
2335            depth.increment()?;
2336            let envelope_size = 8;
2337            let bytes_len = len * envelope_size;
2338            let offset = decoder.out_of_line_offset(bytes_len)?;
2339            // Decode the envelope for each type.
2340            let mut _next_ordinal_to_read = 0;
2341            let mut next_offset = offset;
2342            let end_offset = offset + bytes_len;
2343            _next_ordinal_to_read += 1;
2344            if next_offset >= end_offset {
2345                return Ok(());
2346            }
2347
2348            // Decode unknown envelopes for gaps in ordinals.
2349            while _next_ordinal_to_read < 1 {
2350                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2351                _next_ordinal_to_read += 1;
2352                next_offset += envelope_size;
2353            }
2354
2355            let next_out_of_line = decoder.next_out_of_line();
2356            let handles_before = decoder.remaining_handles();
2357            if let Some((inlined, num_bytes, num_handles)) =
2358                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2359            {
2360                let member_inline_size = <fidl::encoding::UnboundedVector<
2361                    fidl::encoding::BoundedString<255>,
2362                > as fidl::encoding::TypeMarker>::inline_size(
2363                    decoder.context
2364                );
2365                if inlined != (member_inline_size <= 4) {
2366                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2367                }
2368                let inner_offset;
2369                let mut inner_depth = depth.clone();
2370                if inlined {
2371                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2372                    inner_offset = next_offset;
2373                } else {
2374                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2375                    inner_depth.increment()?;
2376                }
2377                let val_ref = self.services.get_or_insert_with(|| {
2378                    fidl::new_empty!(
2379                        fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<255>>,
2380                        D
2381                    )
2382                });
2383                fidl::decode!(
2384                    fidl::encoding::UnboundedVector<fidl::encoding::BoundedString<255>>,
2385                    D,
2386                    val_ref,
2387                    decoder,
2388                    inner_offset,
2389                    inner_depth
2390                )?;
2391                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2392                {
2393                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2394                }
2395                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2396                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2397                }
2398            }
2399
2400            next_offset += envelope_size;
2401
2402            // Decode the remaining unknown envelopes.
2403            while next_offset < end_offset {
2404                _next_ordinal_to_read += 1;
2405                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2406                next_offset += envelope_size;
2407            }
2408
2409            Ok(())
2410        }
2411    }
2412
2413    impl SignalUpdate {
2414        #[inline(always)]
2415        fn max_ordinal_present(&self) -> u64 {
2416            if let Some(_) = self.assert_signals {
2417                return 1;
2418            }
2419            0
2420        }
2421    }
2422
2423    impl fidl::encoding::ValueTypeMarker for SignalUpdate {
2424        type Borrowed<'a> = &'a Self;
2425        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2426            value
2427        }
2428    }
2429
2430    unsafe impl fidl::encoding::TypeMarker for SignalUpdate {
2431        type Owned = Self;
2432
2433        #[inline(always)]
2434        fn inline_align(_context: fidl::encoding::Context) -> usize {
2435            8
2436        }
2437
2438        #[inline(always)]
2439        fn inline_size(_context: fidl::encoding::Context) -> usize {
2440            16
2441        }
2442    }
2443
2444    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SignalUpdate, D>
2445        for &SignalUpdate
2446    {
2447        unsafe fn encode(
2448            self,
2449            encoder: &mut fidl::encoding::Encoder<'_, D>,
2450            offset: usize,
2451            mut depth: fidl::encoding::Depth,
2452        ) -> fidl::Result<()> {
2453            encoder.debug_check_bounds::<SignalUpdate>(offset);
2454            // Vector header
2455            let max_ordinal: u64 = self.max_ordinal_present();
2456            encoder.write_num(max_ordinal, offset);
2457            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2458            // Calling encoder.out_of_line_offset(0) is not allowed.
2459            if max_ordinal == 0 {
2460                return Ok(());
2461            }
2462            depth.increment()?;
2463            let envelope_size = 8;
2464            let bytes_len = max_ordinal as usize * envelope_size;
2465            #[allow(unused_variables)]
2466            let offset = encoder.out_of_line_offset(bytes_len);
2467            let mut _prev_end_offset: usize = 0;
2468            if 1 > max_ordinal {
2469                return Ok(());
2470            }
2471
2472            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2473            // are envelope_size bytes.
2474            let cur_offset: usize = (1 - 1) * envelope_size;
2475
2476            // Zero reserved fields.
2477            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2478
2479            // Safety:
2480            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2481            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2482            //   envelope_size bytes, there is always sufficient room.
2483            fidl::encoding::encode_in_envelope_optional::<Signals, D>(
2484                self.assert_signals
2485                    .as_ref()
2486                    .map(<Signals as fidl::encoding::ValueTypeMarker>::borrow),
2487                encoder,
2488                offset + cur_offset,
2489                depth,
2490            )?;
2491
2492            _prev_end_offset = cur_offset + envelope_size;
2493
2494            Ok(())
2495        }
2496    }
2497
2498    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SignalUpdate {
2499        #[inline(always)]
2500        fn new_empty() -> Self {
2501            Self::default()
2502        }
2503
2504        unsafe fn decode(
2505            &mut self,
2506            decoder: &mut fidl::encoding::Decoder<'_, D>,
2507            offset: usize,
2508            mut depth: fidl::encoding::Depth,
2509        ) -> fidl::Result<()> {
2510            decoder.debug_check_bounds::<Self>(offset);
2511            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2512                None => return Err(fidl::Error::NotNullable),
2513                Some(len) => len,
2514            };
2515            // Calling decoder.out_of_line_offset(0) is not allowed.
2516            if len == 0 {
2517                return Ok(());
2518            };
2519            depth.increment()?;
2520            let envelope_size = 8;
2521            let bytes_len = len * envelope_size;
2522            let offset = decoder.out_of_line_offset(bytes_len)?;
2523            // Decode the envelope for each type.
2524            let mut _next_ordinal_to_read = 0;
2525            let mut next_offset = offset;
2526            let end_offset = offset + bytes_len;
2527            _next_ordinal_to_read += 1;
2528            if next_offset >= end_offset {
2529                return Ok(());
2530            }
2531
2532            // Decode unknown envelopes for gaps in ordinals.
2533            while _next_ordinal_to_read < 1 {
2534                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2535                _next_ordinal_to_read += 1;
2536                next_offset += envelope_size;
2537            }
2538
2539            let next_out_of_line = decoder.next_out_of_line();
2540            let handles_before = decoder.remaining_handles();
2541            if let Some((inlined, num_bytes, num_handles)) =
2542                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2543            {
2544                let member_inline_size =
2545                    <Signals as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2546                if inlined != (member_inline_size <= 4) {
2547                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2548                }
2549                let inner_offset;
2550                let mut inner_depth = depth.clone();
2551                if inlined {
2552                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2553                    inner_offset = next_offset;
2554                } else {
2555                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2556                    inner_depth.increment()?;
2557                }
2558                let val_ref =
2559                    self.assert_signals.get_or_insert_with(|| fidl::new_empty!(Signals, D));
2560                fidl::decode!(Signals, D, val_ref, decoder, inner_offset, inner_depth)?;
2561                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2562                {
2563                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2564                }
2565                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2566                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2567                }
2568            }
2569
2570            next_offset += envelope_size;
2571
2572            // Decode the remaining unknown envelopes.
2573            while next_offset < end_offset {
2574                _next_ordinal_to_read += 1;
2575                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2576                next_offset += envelope_size;
2577            }
2578
2579            Ok(())
2580        }
2581    }
2582
2583    impl fidl::encoding::ValueTypeMarker for PeerMessage {
2584        type Borrowed<'a> = &'a Self;
2585        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2586            value
2587        }
2588    }
2589
2590    unsafe impl fidl::encoding::TypeMarker for PeerMessage {
2591        type Owned = Self;
2592
2593        #[inline(always)]
2594        fn inline_align(_context: fidl::encoding::Context) -> usize {
2595            8
2596        }
2597
2598        #[inline(always)]
2599        fn inline_size(_context: fidl::encoding::Context) -> usize {
2600            16
2601        }
2602    }
2603
2604    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PeerMessage, D>
2605        for &PeerMessage
2606    {
2607        #[inline]
2608        unsafe fn encode(
2609            self,
2610            encoder: &mut fidl::encoding::Encoder<'_, D>,
2611            offset: usize,
2612            _depth: fidl::encoding::Depth,
2613        ) -> fidl::Result<()> {
2614            encoder.debug_check_bounds::<PeerMessage>(offset);
2615            encoder.write_num::<u64>(self.ordinal(), offset);
2616            match self {
2617                PeerMessage::ConnectToService(ref val) => {
2618                    fidl::encoding::encode_in_envelope::<ConnectToService, D>(
2619                        <ConnectToService as fidl::encoding::ValueTypeMarker>::borrow(val),
2620                        encoder,
2621                        offset + 8,
2622                        _depth,
2623                    )
2624                }
2625                PeerMessage::UpdateNodeDescription(ref val) => {
2626                    fidl::encoding::encode_in_envelope::<PeerDescription, D>(
2627                        <PeerDescription as fidl::encoding::ValueTypeMarker>::borrow(val),
2628                        encoder,
2629                        offset + 8,
2630                        _depth,
2631                    )
2632                }
2633                PeerMessage::OpenTransfer(ref val) => {
2634                    fidl::encoding::encode_in_envelope::<OpenTransfer, D>(
2635                        <OpenTransfer as fidl::encoding::ValueTypeMarker>::borrow(val),
2636                        encoder,
2637                        offset + 8,
2638                        _depth,
2639                    )
2640                }
2641            }
2642        }
2643    }
2644
2645    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PeerMessage {
2646        #[inline(always)]
2647        fn new_empty() -> Self {
2648            Self::ConnectToService(fidl::new_empty!(ConnectToService, D))
2649        }
2650
2651        #[inline]
2652        unsafe fn decode(
2653            &mut self,
2654            decoder: &mut fidl::encoding::Decoder<'_, D>,
2655            offset: usize,
2656            mut depth: fidl::encoding::Depth,
2657        ) -> fidl::Result<()> {
2658            decoder.debug_check_bounds::<Self>(offset);
2659            #[allow(unused_variables)]
2660            let next_out_of_line = decoder.next_out_of_line();
2661            let handles_before = decoder.remaining_handles();
2662            let (ordinal, inlined, num_bytes, num_handles) =
2663                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2664
2665            let member_inline_size = match ordinal {
2666                1 => <ConnectToService as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2667                2 => <PeerDescription as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2668                4 => <OpenTransfer as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2669                _ => return Err(fidl::Error::UnknownUnionTag),
2670            };
2671
2672            if inlined != (member_inline_size <= 4) {
2673                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2674            }
2675            let _inner_offset;
2676            if inlined {
2677                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2678                _inner_offset = offset + 8;
2679            } else {
2680                depth.increment()?;
2681                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2682            }
2683            match ordinal {
2684                1 => {
2685                    #[allow(irrefutable_let_patterns)]
2686                    if let PeerMessage::ConnectToService(_) = self {
2687                        // Do nothing, read the value into the object
2688                    } else {
2689                        // Initialize `self` to the right variant
2690                        *self =
2691                            PeerMessage::ConnectToService(fidl::new_empty!(ConnectToService, D));
2692                    }
2693                    #[allow(irrefutable_let_patterns)]
2694                    if let PeerMessage::ConnectToService(ref mut val) = self {
2695                        fidl::decode!(ConnectToService, D, val, decoder, _inner_offset, depth)?;
2696                    } else {
2697                        unreachable!()
2698                    }
2699                }
2700                2 => {
2701                    #[allow(irrefutable_let_patterns)]
2702                    if let PeerMessage::UpdateNodeDescription(_) = self {
2703                        // Do nothing, read the value into the object
2704                    } else {
2705                        // Initialize `self` to the right variant
2706                        *self = PeerMessage::UpdateNodeDescription(fidl::new_empty!(
2707                            PeerDescription,
2708                            D
2709                        ));
2710                    }
2711                    #[allow(irrefutable_let_patterns)]
2712                    if let PeerMessage::UpdateNodeDescription(ref mut val) = self {
2713                        fidl::decode!(PeerDescription, D, val, decoder, _inner_offset, depth)?;
2714                    } else {
2715                        unreachable!()
2716                    }
2717                }
2718                4 => {
2719                    #[allow(irrefutable_let_patterns)]
2720                    if let PeerMessage::OpenTransfer(_) = self {
2721                        // Do nothing, read the value into the object
2722                    } else {
2723                        // Initialize `self` to the right variant
2724                        *self = PeerMessage::OpenTransfer(fidl::new_empty!(OpenTransfer, D));
2725                    }
2726                    #[allow(irrefutable_let_patterns)]
2727                    if let PeerMessage::OpenTransfer(ref mut val) = self {
2728                        fidl::decode!(OpenTransfer, D, val, decoder, _inner_offset, depth)?;
2729                    } else {
2730                        unreachable!()
2731                    }
2732                }
2733                ordinal => panic!("unexpected ordinal {:?}", ordinal),
2734            }
2735            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2736                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2737            }
2738            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2739                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2740            }
2741            Ok(())
2742        }
2743    }
2744
2745    impl fidl::encoding::ValueTypeMarker for PeerReply {
2746        type Borrowed<'a> = &'a Self;
2747        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2748            value
2749        }
2750    }
2751
2752    unsafe impl fidl::encoding::TypeMarker for PeerReply {
2753        type Owned = Self;
2754
2755        #[inline(always)]
2756        fn inline_align(_context: fidl::encoding::Context) -> usize {
2757            8
2758        }
2759
2760        #[inline(always)]
2761        fn inline_size(_context: fidl::encoding::Context) -> usize {
2762            16
2763        }
2764    }
2765
2766    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PeerReply, D>
2767        for &PeerReply
2768    {
2769        #[inline]
2770        unsafe fn encode(
2771            self,
2772            encoder: &mut fidl::encoding::Encoder<'_, D>,
2773            offset: usize,
2774            _depth: fidl::encoding::Depth,
2775        ) -> fidl::Result<()> {
2776            encoder.debug_check_bounds::<PeerReply>(offset);
2777            encoder.write_num::<u64>(self.ordinal(), offset);
2778            match self {
2779                PeerReply::UpdateLinkStatusAck(ref val) => {
2780                    fidl::encoding::encode_in_envelope::<Empty, D>(
2781                        <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
2782                        encoder,
2783                        offset + 8,
2784                        _depth,
2785                    )
2786                }
2787            }
2788        }
2789    }
2790
2791    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PeerReply {
2792        #[inline(always)]
2793        fn new_empty() -> Self {
2794            Self::UpdateLinkStatusAck(fidl::new_empty!(Empty, D))
2795        }
2796
2797        #[inline]
2798        unsafe fn decode(
2799            &mut self,
2800            decoder: &mut fidl::encoding::Decoder<'_, D>,
2801            offset: usize,
2802            mut depth: fidl::encoding::Depth,
2803        ) -> fidl::Result<()> {
2804            decoder.debug_check_bounds::<Self>(offset);
2805            #[allow(unused_variables)]
2806            let next_out_of_line = decoder.next_out_of_line();
2807            let handles_before = decoder.remaining_handles();
2808            let (ordinal, inlined, num_bytes, num_handles) =
2809                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2810
2811            let member_inline_size = match ordinal {
2812                1 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2813                _ => return Err(fidl::Error::UnknownUnionTag),
2814            };
2815
2816            if inlined != (member_inline_size <= 4) {
2817                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2818            }
2819            let _inner_offset;
2820            if inlined {
2821                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2822                _inner_offset = offset + 8;
2823            } else {
2824                depth.increment()?;
2825                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2826            }
2827            match ordinal {
2828                1 => {
2829                    #[allow(irrefutable_let_patterns)]
2830                    if let PeerReply::UpdateLinkStatusAck(_) = self {
2831                        // Do nothing, read the value into the object
2832                    } else {
2833                        // Initialize `self` to the right variant
2834                        *self = PeerReply::UpdateLinkStatusAck(fidl::new_empty!(Empty, D));
2835                    }
2836                    #[allow(irrefutable_let_patterns)]
2837                    if let PeerReply::UpdateLinkStatusAck(ref mut val) = self {
2838                        fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
2839                    } else {
2840                        unreachable!()
2841                    }
2842                }
2843                ordinal => panic!("unexpected ordinal {:?}", ordinal),
2844            }
2845            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2846                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2847            }
2848            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2849                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2850            }
2851            Ok(())
2852        }
2853    }
2854
2855    impl fidl::encoding::ValueTypeMarker for StreamControl {
2856        type Borrowed<'a> = &'a Self;
2857        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2858            value
2859        }
2860    }
2861
2862    unsafe impl fidl::encoding::TypeMarker for StreamControl {
2863        type Owned = Self;
2864
2865        #[inline(always)]
2866        fn inline_align(_context: fidl::encoding::Context) -> usize {
2867            8
2868        }
2869
2870        #[inline(always)]
2871        fn inline_size(_context: fidl::encoding::Context) -> usize {
2872            16
2873        }
2874    }
2875
2876    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<StreamControl, D>
2877        for &StreamControl
2878    {
2879        #[inline]
2880        unsafe fn encode(
2881            self,
2882            encoder: &mut fidl::encoding::Encoder<'_, D>,
2883            offset: usize,
2884            _depth: fidl::encoding::Depth,
2885        ) -> fidl::Result<()> {
2886            encoder.debug_check_bounds::<StreamControl>(offset);
2887            encoder.write_num::<u64>(self.ordinal(), offset);
2888            match self {
2889                StreamControl::BeginTransfer(ref val) => {
2890                    fidl::encoding::encode_in_envelope::<BeginTransfer, D>(
2891                        <BeginTransfer as fidl::encoding::ValueTypeMarker>::borrow(val),
2892                        encoder,
2893                        offset + 8,
2894                        _depth,
2895                    )
2896                }
2897                StreamControl::AckTransfer(ref val) => {
2898                    fidl::encoding::encode_in_envelope::<Empty, D>(
2899                        <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
2900                        encoder,
2901                        offset + 8,
2902                        _depth,
2903                    )
2904                }
2905                StreamControl::EndTransfer(ref val) => {
2906                    fidl::encoding::encode_in_envelope::<Empty, D>(
2907                        <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
2908                        encoder,
2909                        offset + 8,
2910                        _depth,
2911                    )
2912                }
2913                StreamControl::Shutdown(ref val) => fidl::encoding::encode_in_envelope::<i32, D>(
2914                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
2915                    encoder,
2916                    offset + 8,
2917                    _depth,
2918                ),
2919            }
2920        }
2921    }
2922
2923    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StreamControl {
2924        #[inline(always)]
2925        fn new_empty() -> Self {
2926            Self::BeginTransfer(fidl::new_empty!(BeginTransfer, D))
2927        }
2928
2929        #[inline]
2930        unsafe fn decode(
2931            &mut self,
2932            decoder: &mut fidl::encoding::Decoder<'_, D>,
2933            offset: usize,
2934            mut depth: fidl::encoding::Depth,
2935        ) -> fidl::Result<()> {
2936            decoder.debug_check_bounds::<Self>(offset);
2937            #[allow(unused_variables)]
2938            let next_out_of_line = decoder.next_out_of_line();
2939            let handles_before = decoder.remaining_handles();
2940            let (ordinal, inlined, num_bytes, num_handles) =
2941                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2942
2943            let member_inline_size = match ordinal {
2944                1 => <BeginTransfer as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2945                2 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2946                3 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2947                4 => <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2948                _ => return Err(fidl::Error::UnknownUnionTag),
2949            };
2950
2951            if inlined != (member_inline_size <= 4) {
2952                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2953            }
2954            let _inner_offset;
2955            if inlined {
2956                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2957                _inner_offset = offset + 8;
2958            } else {
2959                depth.increment()?;
2960                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2961            }
2962            match ordinal {
2963                1 => {
2964                    #[allow(irrefutable_let_patterns)]
2965                    if let StreamControl::BeginTransfer(_) = self {
2966                        // Do nothing, read the value into the object
2967                    } else {
2968                        // Initialize `self` to the right variant
2969                        *self = StreamControl::BeginTransfer(fidl::new_empty!(BeginTransfer, D));
2970                    }
2971                    #[allow(irrefutable_let_patterns)]
2972                    if let StreamControl::BeginTransfer(ref mut val) = self {
2973                        fidl::decode!(BeginTransfer, D, val, decoder, _inner_offset, depth)?;
2974                    } else {
2975                        unreachable!()
2976                    }
2977                }
2978                2 => {
2979                    #[allow(irrefutable_let_patterns)]
2980                    if let StreamControl::AckTransfer(_) = self {
2981                        // Do nothing, read the value into the object
2982                    } else {
2983                        // Initialize `self` to the right variant
2984                        *self = StreamControl::AckTransfer(fidl::new_empty!(Empty, D));
2985                    }
2986                    #[allow(irrefutable_let_patterns)]
2987                    if let StreamControl::AckTransfer(ref mut val) = self {
2988                        fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
2989                    } else {
2990                        unreachable!()
2991                    }
2992                }
2993                3 => {
2994                    #[allow(irrefutable_let_patterns)]
2995                    if let StreamControl::EndTransfer(_) = self {
2996                        // Do nothing, read the value into the object
2997                    } else {
2998                        // Initialize `self` to the right variant
2999                        *self = StreamControl::EndTransfer(fidl::new_empty!(Empty, D));
3000                    }
3001                    #[allow(irrefutable_let_patterns)]
3002                    if let StreamControl::EndTransfer(ref mut val) = self {
3003                        fidl::decode!(Empty, D, val, decoder, _inner_offset, depth)?;
3004                    } else {
3005                        unreachable!()
3006                    }
3007                }
3008                4 => {
3009                    #[allow(irrefutable_let_patterns)]
3010                    if let StreamControl::Shutdown(_) = self {
3011                        // Do nothing, read the value into the object
3012                    } else {
3013                        // Initialize `self` to the right variant
3014                        *self = StreamControl::Shutdown(fidl::new_empty!(i32, D));
3015                    }
3016                    #[allow(irrefutable_let_patterns)]
3017                    if let StreamControl::Shutdown(ref mut val) = self {
3018                        fidl::decode!(i32, D, val, decoder, _inner_offset, depth)?;
3019                    } else {
3020                        unreachable!()
3021                    }
3022                }
3023                ordinal => panic!("unexpected ordinal {:?}", ordinal),
3024            }
3025            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
3026                return Err(fidl::Error::InvalidNumBytesInEnvelope);
3027            }
3028            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3029                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3030            }
3031            Ok(())
3032        }
3033    }
3034
3035    impl fidl::encoding::ValueTypeMarker for StreamRef {
3036        type Borrowed<'a> = &'a Self;
3037        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3038            value
3039        }
3040    }
3041
3042    unsafe impl fidl::encoding::TypeMarker for StreamRef {
3043        type Owned = Self;
3044
3045        #[inline(always)]
3046        fn inline_align(_context: fidl::encoding::Context) -> usize {
3047            8
3048        }
3049
3050        #[inline(always)]
3051        fn inline_size(_context: fidl::encoding::Context) -> usize {
3052            16
3053        }
3054    }
3055
3056    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<StreamRef, D>
3057        for &StreamRef
3058    {
3059        #[inline]
3060        unsafe fn encode(
3061            self,
3062            encoder: &mut fidl::encoding::Encoder<'_, D>,
3063            offset: usize,
3064            _depth: fidl::encoding::Depth,
3065        ) -> fidl::Result<()> {
3066            encoder.debug_check_bounds::<StreamRef>(offset);
3067            encoder.write_num::<u64>(self.ordinal(), offset);
3068            match self {
3069                StreamRef::Creating(ref val) => fidl::encoding::encode_in_envelope::<StreamId, D>(
3070                    <StreamId as fidl::encoding::ValueTypeMarker>::borrow(val),
3071                    encoder,
3072                    offset + 8,
3073                    _depth,
3074                ),
3075                StreamRef::TransferInitiator(ref val) => {
3076                    fidl::encoding::encode_in_envelope::<TransferInitiator, D>(
3077                        <TransferInitiator as fidl::encoding::ValueTypeMarker>::borrow(val),
3078                        encoder,
3079                        offset + 8,
3080                        _depth,
3081                    )
3082                }
3083                StreamRef::TransferWaiter(ref val) => {
3084                    fidl::encoding::encode_in_envelope::<TransferWaiter, D>(
3085                        <TransferWaiter as fidl::encoding::ValueTypeMarker>::borrow(val),
3086                        encoder,
3087                        offset + 8,
3088                        _depth,
3089                    )
3090                }
3091            }
3092        }
3093    }
3094
3095    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StreamRef {
3096        #[inline(always)]
3097        fn new_empty() -> Self {
3098            Self::Creating(fidl::new_empty!(StreamId, D))
3099        }
3100
3101        #[inline]
3102        unsafe fn decode(
3103            &mut self,
3104            decoder: &mut fidl::encoding::Decoder<'_, D>,
3105            offset: usize,
3106            mut depth: fidl::encoding::Depth,
3107        ) -> fidl::Result<()> {
3108            decoder.debug_check_bounds::<Self>(offset);
3109            #[allow(unused_variables)]
3110            let next_out_of_line = decoder.next_out_of_line();
3111            let handles_before = decoder.remaining_handles();
3112            let (ordinal, inlined, num_bytes, num_handles) =
3113                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
3114
3115            let member_inline_size = match ordinal {
3116                1 => <StreamId as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3117                2 => {
3118                    <TransferInitiator as fidl::encoding::TypeMarker>::inline_size(decoder.context)
3119                }
3120                3 => <TransferWaiter as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3121                _ => return Err(fidl::Error::UnknownUnionTag),
3122            };
3123
3124            if inlined != (member_inline_size <= 4) {
3125                return Err(fidl::Error::InvalidInlineBitInEnvelope);
3126            }
3127            let _inner_offset;
3128            if inlined {
3129                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
3130                _inner_offset = offset + 8;
3131            } else {
3132                depth.increment()?;
3133                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3134            }
3135            match ordinal {
3136                1 => {
3137                    #[allow(irrefutable_let_patterns)]
3138                    if let StreamRef::Creating(_) = self {
3139                        // Do nothing, read the value into the object
3140                    } else {
3141                        // Initialize `self` to the right variant
3142                        *self = StreamRef::Creating(fidl::new_empty!(StreamId, D));
3143                    }
3144                    #[allow(irrefutable_let_patterns)]
3145                    if let StreamRef::Creating(ref mut val) = self {
3146                        fidl::decode!(StreamId, D, val, decoder, _inner_offset, depth)?;
3147                    } else {
3148                        unreachable!()
3149                    }
3150                }
3151                2 => {
3152                    #[allow(irrefutable_let_patterns)]
3153                    if let StreamRef::TransferInitiator(_) = self {
3154                        // Do nothing, read the value into the object
3155                    } else {
3156                        // Initialize `self` to the right variant
3157                        *self =
3158                            StreamRef::TransferInitiator(fidl::new_empty!(TransferInitiator, D));
3159                    }
3160                    #[allow(irrefutable_let_patterns)]
3161                    if let StreamRef::TransferInitiator(ref mut val) = self {
3162                        fidl::decode!(TransferInitiator, D, val, decoder, _inner_offset, depth)?;
3163                    } else {
3164                        unreachable!()
3165                    }
3166                }
3167                3 => {
3168                    #[allow(irrefutable_let_patterns)]
3169                    if let StreamRef::TransferWaiter(_) = self {
3170                        // Do nothing, read the value into the object
3171                    } else {
3172                        // Initialize `self` to the right variant
3173                        *self = StreamRef::TransferWaiter(fidl::new_empty!(TransferWaiter, D));
3174                    }
3175                    #[allow(irrefutable_let_patterns)]
3176                    if let StreamRef::TransferWaiter(ref mut val) = self {
3177                        fidl::decode!(TransferWaiter, D, val, decoder, _inner_offset, depth)?;
3178                    } else {
3179                        unreachable!()
3180                    }
3181                }
3182                ordinal => panic!("unexpected ordinal {:?}", ordinal),
3183            }
3184            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
3185                return Err(fidl::Error::InvalidNumBytesInEnvelope);
3186            }
3187            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3188                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3189            }
3190            Ok(())
3191        }
3192    }
3193
3194    impl fidl::encoding::ValueTypeMarker for ZirconHandle {
3195        type Borrowed<'a> = &'a Self;
3196        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
3197            value
3198        }
3199    }
3200
3201    unsafe impl fidl::encoding::TypeMarker for ZirconHandle {
3202        type Owned = Self;
3203
3204        #[inline(always)]
3205        fn inline_align(_context: fidl::encoding::Context) -> usize {
3206            8
3207        }
3208
3209        #[inline(always)]
3210        fn inline_size(_context: fidl::encoding::Context) -> usize {
3211            16
3212        }
3213    }
3214
3215    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ZirconHandle, D>
3216        for &ZirconHandle
3217    {
3218        #[inline]
3219        unsafe fn encode(
3220            self,
3221            encoder: &mut fidl::encoding::Encoder<'_, D>,
3222            offset: usize,
3223            _depth: fidl::encoding::Depth,
3224        ) -> fidl::Result<()> {
3225            encoder.debug_check_bounds::<ZirconHandle>(offset);
3226            encoder.write_num::<u64>(self.ordinal(), offset);
3227            match self {
3228                ZirconHandle::Channel(ref val) => {
3229                    fidl::encoding::encode_in_envelope::<ChannelHandle, D>(
3230                        <ChannelHandle as fidl::encoding::ValueTypeMarker>::borrow(val),
3231                        encoder,
3232                        offset + 8,
3233                        _depth,
3234                    )
3235                }
3236                ZirconHandle::Socket(ref val) => {
3237                    fidl::encoding::encode_in_envelope::<SocketHandle, D>(
3238                        <SocketHandle as fidl::encoding::ValueTypeMarker>::borrow(val),
3239                        encoder,
3240                        offset + 8,
3241                        _depth,
3242                    )
3243                }
3244                ZirconHandle::EventPair(ref val) => {
3245                    fidl::encoding::encode_in_envelope::<EventPairHandle, D>(
3246                        <EventPairHandle as fidl::encoding::ValueTypeMarker>::borrow(val),
3247                        encoder,
3248                        offset + 8,
3249                        _depth,
3250                    )
3251                }
3252            }
3253        }
3254    }
3255
3256    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ZirconHandle {
3257        #[inline(always)]
3258        fn new_empty() -> Self {
3259            Self::Channel(fidl::new_empty!(ChannelHandle, D))
3260        }
3261
3262        #[inline]
3263        unsafe fn decode(
3264            &mut self,
3265            decoder: &mut fidl::encoding::Decoder<'_, D>,
3266            offset: usize,
3267            mut depth: fidl::encoding::Depth,
3268        ) -> fidl::Result<()> {
3269            decoder.debug_check_bounds::<Self>(offset);
3270            #[allow(unused_variables)]
3271            let next_out_of_line = decoder.next_out_of_line();
3272            let handles_before = decoder.remaining_handles();
3273            let (ordinal, inlined, num_bytes, num_handles) =
3274                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
3275
3276            let member_inline_size = match ordinal {
3277                1 => <ChannelHandle as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3278                2 => <SocketHandle as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3279                3 => <EventPairHandle as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3280                _ => return Err(fidl::Error::UnknownUnionTag),
3281            };
3282
3283            if inlined != (member_inline_size <= 4) {
3284                return Err(fidl::Error::InvalidInlineBitInEnvelope);
3285            }
3286            let _inner_offset;
3287            if inlined {
3288                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
3289                _inner_offset = offset + 8;
3290            } else {
3291                depth.increment()?;
3292                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3293            }
3294            match ordinal {
3295                1 => {
3296                    #[allow(irrefutable_let_patterns)]
3297                    if let ZirconHandle::Channel(_) = self {
3298                        // Do nothing, read the value into the object
3299                    } else {
3300                        // Initialize `self` to the right variant
3301                        *self = ZirconHandle::Channel(fidl::new_empty!(ChannelHandle, D));
3302                    }
3303                    #[allow(irrefutable_let_patterns)]
3304                    if let ZirconHandle::Channel(ref mut val) = self {
3305                        fidl::decode!(ChannelHandle, D, val, decoder, _inner_offset, depth)?;
3306                    } else {
3307                        unreachable!()
3308                    }
3309                }
3310                2 => {
3311                    #[allow(irrefutable_let_patterns)]
3312                    if let ZirconHandle::Socket(_) = self {
3313                        // Do nothing, read the value into the object
3314                    } else {
3315                        // Initialize `self` to the right variant
3316                        *self = ZirconHandle::Socket(fidl::new_empty!(SocketHandle, D));
3317                    }
3318                    #[allow(irrefutable_let_patterns)]
3319                    if let ZirconHandle::Socket(ref mut val) = self {
3320                        fidl::decode!(SocketHandle, D, val, decoder, _inner_offset, depth)?;
3321                    } else {
3322                        unreachable!()
3323                    }
3324                }
3325                3 => {
3326                    #[allow(irrefutable_let_patterns)]
3327                    if let ZirconHandle::EventPair(_) = self {
3328                        // Do nothing, read the value into the object
3329                    } else {
3330                        // Initialize `self` to the right variant
3331                        *self = ZirconHandle::EventPair(fidl::new_empty!(EventPairHandle, D));
3332                    }
3333                    #[allow(irrefutable_let_patterns)]
3334                    if let ZirconHandle::EventPair(ref mut val) = self {
3335                        fidl::decode!(EventPairHandle, D, val, decoder, _inner_offset, depth)?;
3336                    } else {
3337                        unreachable!()
3338                    }
3339                }
3340                ordinal => panic!("unexpected ordinal {:?}", ordinal),
3341            }
3342            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
3343                return Err(fidl::Error::InvalidNumBytesInEnvelope);
3344            }
3345            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3346                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3347            }
3348            Ok(())
3349        }
3350    }
3351}