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