Skip to main content

fidl_fuchsia_hardware_network/
fidl_fuchsia_hardware_network.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 _};
10pub use fidl_fuchsia_hardware_network__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DeviceCloneRequest {
16    pub device: fidl::endpoints::ServerEnd<DeviceMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceCloneRequest {}
20
21#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
22pub struct DeviceGetPortRequest {
23    pub id: PortId,
24    pub port: fidl::endpoints::ServerEnd<PortMarker>,
25}
26
27impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceGetPortRequest {}
28
29#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
30pub struct DeviceGetPortWatcherRequest {
31    pub watcher: fidl::endpoints::ServerEnd<PortWatcherMarker>,
32}
33
34impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
35    for DeviceGetPortWatcherRequest
36{
37}
38
39#[derive(Debug, PartialEq)]
40pub struct DeviceOpenSessionRequest {
41    pub session_name: String,
42    pub session_info: SessionInfo,
43}
44
45impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceOpenSessionRequest {}
46
47#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
48pub struct DeviceOpenSessionResponse {
49    pub session: fidl::endpoints::ClientEnd<SessionMarker>,
50    pub fifos: Fifos,
51}
52
53impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceOpenSessionResponse {}
54
55/// Data-plane FIFOs.
56#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
57pub struct Fifos {
58    /// Handle for the rx FIFO.
59    ///
60    /// Clients must write 16-bit descriptor indexes to this FIFO to be able to
61    /// receive frames.
62    pub rx: fidl::Fifo,
63    /// Handle for the tx FIFO.
64    ///
65    /// Clients write 16-bit descriptor indexes to this FIFO to enqueue outgoing
66    /// frames.
67    pub tx: fidl::Fifo,
68}
69
70impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Fifos {}
71
72#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
73pub struct PortCloneRequest {
74    pub port: fidl::endpoints::ServerEnd<PortMarker>,
75}
76
77impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PortCloneRequest {}
78
79#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
80pub struct PortGetDeviceRequest {
81    pub device: fidl::endpoints::ServerEnd<DeviceMarker>,
82}
83
84impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PortGetDeviceRequest {}
85
86#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
87pub struct PortGetDiagnosticsRequest {
88    pub diagnostics: fidl::endpoints::ServerEnd<DiagnosticsMarker>,
89}
90
91impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PortGetDiagnosticsRequest {}
92
93#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
94pub struct PortGetIdentityResponse {
95    pub event: fidl::Event,
96}
97
98impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PortGetIdentityResponse {}
99
100#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
101pub struct PortGetMacRequest {
102    pub mac: fidl::endpoints::ServerEnd<MacAddressingMarker>,
103}
104
105impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PortGetMacRequest {}
106
107#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
108pub struct PortGetStatusWatcherRequest {
109    pub watcher: fidl::endpoints::ServerEnd<StatusWatcherMarker>,
110    pub buffer: u32,
111}
112
113impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
114    for PortGetStatusWatcherRequest
115{
116}
117
118#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
119pub struct SessionRegisterForTxRequest {
120    pub vmos: Vec<u8>,
121}
122
123impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
124    for SessionRegisterForTxRequest
125{
126}
127
128#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
129pub struct SessionUnregisterForTxRequest {
130    pub vmos: Vec<u8>,
131}
132
133impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
134    for SessionUnregisterForTxRequest
135{
136}
137
138#[derive(Debug, PartialEq)]
139pub struct SessionWatchDelegatedRxLeaseResponse {
140    pub lease: DelegatedRxLease,
141}
142
143impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
144    for SessionWatchDelegatedRxLeaseResponse
145{
146}
147
148/// A VMO that can be used for data-plane operations.
149#[derive(Debug, Default, PartialEq)]
150pub struct DataVmo {
151    pub id: Option<u8>,
152    pub vmo: Option<fidl::Vmo>,
153    /// Netdevice needs this information to decide when to safely unregister and
154    /// decommit.
155    pub num_rx_buffers: Option<u16>,
156    #[doc(hidden)]
157    pub __source_breaking: fidl::marker::SourceBreaking,
158}
159
160impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DataVmo {}
161
162/// An acquired lease that is propagated up to applications.
163#[derive(Debug, Default, PartialEq)]
164pub struct DelegatedRxLease {
165    /// The frame after which the lease in `handle` can be released.
166    ///
167    /// Agents observing leases must keep track of received frames with an
168    /// increasing counter to be able to properly relinquish leases after the
169    /// frame `hold_until_frame` is fully processed.
170    ///
171    /// This value can be interpreted as either the 1-based index of a given
172    /// frame or as the total number of exchanged frames so far, which are
173    /// mathematically equivalent.
174    ///
175    /// This mechanism allows for wake lease handles from received frames to be
176    /// passed up and keep the system from suspension until the frame is fully
177    /// processed.
178    ///
179    /// Required.
180    pub hold_until_frame: Option<u64>,
181    /// A handle representing the held lease.
182    ///
183    /// Required.
184    pub handle: Option<DelegatedRxLeaseHandle>,
185    #[doc(hidden)]
186    pub __source_breaking: fidl::marker::SourceBreaking,
187}
188
189impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DelegatedRxLease {}
190
191/// Session configuration.
192#[derive(Debug, Default, PartialEq)]
193pub struct SessionInfo {
194    /// VMO containing the descriptors. Required.
195    ///
196    /// 16-bit indices transmitted over the FIFOs index a descriptor in this VMO
197    /// (byte offset = descriptor_length * 8 * index).
198    pub descriptors: Option<fidl::Vmo>,
199    /// VMOs containing frame data. Required
200    ///
201    /// Descriptors contain byte-offsets and vmo ids that are used to index regions
202    /// in data VMOs.
203    pub data: Option<Vec<DataVmo>>,
204    /// Requested descriptor version. Required.
205    ///
206    /// If the network device does not support the requested descriptor version,
207    /// [`Device.OpenSession`] fails with `ZX_ERR_NOT_SUPPORTED`.
208    pub descriptor_version: Option<u8>,
209    /// Descriptor length, in 64-bit words. Required.
210    ///
211    /// The length of each descriptor in the `descriptors` VMO. This is used as
212    /// a multiplier to find byte offsets in `descriptors` given a descriptor
213    /// index passed through the rx or tx FIFOs.
214    pub descriptor_length: Option<u8>,
215    /// Total number of descriptors that can be used by this session. Required.
216    ///
217    /// Descriptor indices transferred through either the rx or tx FIFO must be
218    /// in the range [0, `descriptor_count`).
219    pub descriptor_count: Option<u16>,
220    /// Extra options. Interpreted as empty bitmask if absent.
221    pub options: Option<SessionFlags>,
222    #[doc(hidden)]
223    pub __source_breaking: fidl::marker::SourceBreaking,
224}
225
226impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SessionInfo {}
227
228#[derive(Debug)]
229pub enum DelegatedRxLeaseHandle {
230    /// An untyped channel representing a lease.
231    ///
232    /// Close the channel to release the lease.
233    Channel(fidl::Channel),
234    /// An eventpair representing a lease.
235    ///
236    /// Close the eventpair to release the lease.
237    Eventpair(fidl::EventPair),
238    #[doc(hidden)]
239    __SourceBreaking { unknown_ordinal: u64 },
240}
241
242/// Pattern that matches an unknown `DelegatedRxLeaseHandle` member.
243#[macro_export]
244macro_rules! DelegatedRxLeaseHandleUnknown {
245    () => {
246        _
247    };
248}
249
250// Custom PartialEq so that unknown variants are not equal to themselves.
251impl PartialEq for DelegatedRxLeaseHandle {
252    fn eq(&self, other: &Self) -> bool {
253        match (self, other) {
254            (Self::Channel(x), Self::Channel(y)) => *x == *y,
255            (Self::Eventpair(x), Self::Eventpair(y)) => *x == *y,
256            _ => false,
257        }
258    }
259}
260
261impl DelegatedRxLeaseHandle {
262    #[inline]
263    pub fn ordinal(&self) -> u64 {
264        match *self {
265            Self::Channel(_) => 1,
266            Self::Eventpair(_) => 2,
267            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
268        }
269    }
270
271    #[inline]
272    pub fn unknown_variant_for_testing() -> Self {
273        Self::__SourceBreaking { unknown_ordinal: 0 }
274    }
275
276    #[inline]
277    pub fn is_unknown(&self) -> bool {
278        match self {
279            Self::__SourceBreaking { .. } => true,
280            _ => false,
281        }
282    }
283}
284
285impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DelegatedRxLeaseHandle {}
286
287#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
288pub struct DeviceMarker;
289
290impl fidl::endpoints::ProtocolMarker for DeviceMarker {
291    type Proxy = DeviceProxy;
292    type RequestStream = DeviceRequestStream;
293    #[cfg(target_os = "fuchsia")]
294    type SynchronousProxy = DeviceSynchronousProxy;
295
296    const DEBUG_NAME: &'static str = "(anonymous) Device";
297}
298pub type DeviceOpenSessionResult = Result<(fidl::endpoints::ClientEnd<SessionMarker>, Fifos), i32>;
299
300pub trait DeviceProxyInterface: Send + Sync {
301    type GetInfoResponseFut: std::future::Future<Output = Result<DeviceInfo, fidl::Error>> + Send;
302    fn r#get_info(&self) -> Self::GetInfoResponseFut;
303    type OpenSessionResponseFut: std::future::Future<Output = Result<DeviceOpenSessionResult, fidl::Error>>
304        + Send;
305    fn r#open_session(
306        &self,
307        session_name: &str,
308        session_info: SessionInfo,
309    ) -> Self::OpenSessionResponseFut;
310    fn r#get_port(
311        &self,
312        id: &PortId,
313        port: fidl::endpoints::ServerEnd<PortMarker>,
314    ) -> Result<(), fidl::Error>;
315    fn r#get_port_watcher(
316        &self,
317        watcher: fidl::endpoints::ServerEnd<PortWatcherMarker>,
318    ) -> Result<(), fidl::Error>;
319    fn r#clone(&self, device: fidl::endpoints::ServerEnd<DeviceMarker>) -> Result<(), fidl::Error>;
320}
321#[derive(Debug)]
322#[cfg(target_os = "fuchsia")]
323pub struct DeviceSynchronousProxy {
324    client: fidl::client::sync::Client,
325}
326
327#[cfg(target_os = "fuchsia")]
328impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
329    type Proxy = DeviceProxy;
330    type Protocol = DeviceMarker;
331
332    fn from_channel(inner: fidl::Channel) -> Self {
333        Self::new(inner)
334    }
335
336    fn into_channel(self) -> fidl::Channel {
337        self.client.into_channel()
338    }
339
340    fn as_channel(&self) -> &fidl::Channel {
341        self.client.as_channel()
342    }
343}
344
345#[cfg(target_os = "fuchsia")]
346impl DeviceSynchronousProxy {
347    pub fn new(channel: fidl::Channel) -> Self {
348        Self { client: fidl::client::sync::Client::new(channel) }
349    }
350
351    pub fn into_channel(self) -> fidl::Channel {
352        self.client.into_channel()
353    }
354
355    /// Waits until an event arrives and returns it. It is safe for other
356    /// threads to make concurrent requests while waiting for an event.
357    pub fn wait_for_event(
358        &self,
359        deadline: zx::MonotonicInstant,
360    ) -> Result<DeviceEvent, fidl::Error> {
361        DeviceEvent::decode(self.client.wait_for_event::<DeviceMarker>(deadline)?)
362    }
363
364    /// Obtain information about device
365    ///
366    /// - response `info` device information.
367    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<DeviceInfo, fidl::Error> {
368        let _response = self
369            .client
370            .send_query::<fidl::encoding::EmptyPayload, DeviceGetInfoResponse, DeviceMarker>(
371                (),
372                0x3c500ca9341e8f56,
373                fidl::encoding::DynamicFlags::empty(),
374                ___deadline,
375            )?;
376        Ok(_response.info)
377    }
378
379    /// Opens a new session with the network device.
380    ///
381    /// + request `session_name` is used as a debugging label attached to this
382    /// session.
383    /// + request `session_info` contains the necessary information to setup the
384    /// session's data exchange.
385    /// - response `session` a handle to control the session.
386    /// - response `fifos` data-plane FIFOs attached to the session.
387    /// * error `ZX_ERR_NOT_SUPPORTED` if `session_info` contains not supported
388    /// frame types or descriptors set up.
389    /// * error `ZX_ERR_INVALID_ARGS` if `session_info` is missing fields or
390    /// contains invalid information.
391    /// * error `ZX_ERR_INTERNAL` if the data VMO is rejected by the underlying
392    /// device.
393    pub fn r#open_session(
394        &self,
395        mut session_name: &str,
396        mut session_info: SessionInfo,
397        ___deadline: zx::MonotonicInstant,
398    ) -> Result<DeviceOpenSessionResult, fidl::Error> {
399        let _response = self.client.send_query::<
400            DeviceOpenSessionRequest,
401            fidl::encoding::ResultType<DeviceOpenSessionResponse, i32>,
402            DeviceMarker,
403        >(
404            (session_name, &mut session_info,),
405            0x25940b82146dcf67,
406            fidl::encoding::DynamicFlags::empty(),
407            ___deadline,
408        )?;
409        Ok(_response.map(|x| (x.session, x.fifos)))
410    }
411
412    /// Connects to a port the given `id`.
413    ///
414    /// + request `id` port to connect to.
415    /// + request `port` server end of port channel.
416    ///
417    /// `port` is closed with a `ZX_ERR_NOT_FOUND` epitaph if no port with `id`
418    /// exists.
419    pub fn r#get_port(
420        &self,
421        mut id: &PortId,
422        mut port: fidl::endpoints::ServerEnd<PortMarker>,
423    ) -> Result<(), fidl::Error> {
424        self.client.send::<DeviceGetPortRequest>(
425            (id, port),
426            0x340a852c955ba2a6,
427            fidl::encoding::DynamicFlags::empty(),
428        )
429    }
430
431    /// Connects a [`PortWatcher`] to this device.
432    ///
433    /// + request `watcher` server end of watcher channel.
434    pub fn r#get_port_watcher(
435        &self,
436        mut watcher: fidl::endpoints::ServerEnd<PortWatcherMarker>,
437    ) -> Result<(), fidl::Error> {
438        self.client.send::<DeviceGetPortWatcherRequest>(
439            (watcher,),
440            0x104f43c937c39f0c,
441            fidl::encoding::DynamicFlags::empty(),
442        )
443    }
444
445    /// Establishes a new connection to this device.
446    ///
447    /// + request `device` the server end for the new connection.
448    pub fn r#clone(
449        &self,
450        mut device: fidl::endpoints::ServerEnd<DeviceMarker>,
451    ) -> Result<(), fidl::Error> {
452        self.client.send::<DeviceCloneRequest>(
453            (device,),
454            0x5882ea09b3809af4,
455            fidl::encoding::DynamicFlags::empty(),
456        )
457    }
458}
459
460#[cfg(target_os = "fuchsia")]
461impl From<DeviceSynchronousProxy> for zx::NullableHandle {
462    fn from(value: DeviceSynchronousProxy) -> Self {
463        value.into_channel().into()
464    }
465}
466
467#[cfg(target_os = "fuchsia")]
468impl From<fidl::Channel> for DeviceSynchronousProxy {
469    fn from(value: fidl::Channel) -> Self {
470        Self::new(value)
471    }
472}
473
474#[cfg(target_os = "fuchsia")]
475impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
476    type Protocol = DeviceMarker;
477
478    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
479        Self::new(value.into_channel())
480    }
481}
482
483#[derive(Debug, Clone)]
484pub struct DeviceProxy {
485    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
486}
487
488impl fidl::endpoints::Proxy for DeviceProxy {
489    type Protocol = DeviceMarker;
490
491    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
492        Self::new(inner)
493    }
494
495    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
496        self.client.into_channel().map_err(|client| Self { client })
497    }
498
499    fn as_channel(&self) -> &::fidl::AsyncChannel {
500        self.client.as_channel()
501    }
502}
503
504impl DeviceProxy {
505    /// Create a new Proxy for fuchsia.hardware.network/Device.
506    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
507        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
508        Self { client: fidl::client::Client::new(channel, protocol_name) }
509    }
510
511    /// Get a Stream of events from the remote end of the protocol.
512    ///
513    /// # Panics
514    ///
515    /// Panics if the event stream was already taken.
516    pub fn take_event_stream(&self) -> DeviceEventStream {
517        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
518    }
519
520    /// Obtain information about device
521    ///
522    /// - response `info` device information.
523    pub fn r#get_info(
524        &self,
525    ) -> fidl::client::QueryResponseFut<DeviceInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
526    {
527        DeviceProxyInterface::r#get_info(self)
528    }
529
530    /// Opens a new session with the network device.
531    ///
532    /// + request `session_name` is used as a debugging label attached to this
533    /// session.
534    /// + request `session_info` contains the necessary information to setup the
535    /// session's data exchange.
536    /// - response `session` a handle to control the session.
537    /// - response `fifos` data-plane FIFOs attached to the session.
538    /// * error `ZX_ERR_NOT_SUPPORTED` if `session_info` contains not supported
539    /// frame types or descriptors set up.
540    /// * error `ZX_ERR_INVALID_ARGS` if `session_info` is missing fields or
541    /// contains invalid information.
542    /// * error `ZX_ERR_INTERNAL` if the data VMO is rejected by the underlying
543    /// device.
544    pub fn r#open_session(
545        &self,
546        mut session_name: &str,
547        mut session_info: SessionInfo,
548    ) -> fidl::client::QueryResponseFut<
549        DeviceOpenSessionResult,
550        fidl::encoding::DefaultFuchsiaResourceDialect,
551    > {
552        DeviceProxyInterface::r#open_session(self, session_name, session_info)
553    }
554
555    /// Connects to a port the given `id`.
556    ///
557    /// + request `id` port to connect to.
558    /// + request `port` server end of port channel.
559    ///
560    /// `port` is closed with a `ZX_ERR_NOT_FOUND` epitaph if no port with `id`
561    /// exists.
562    pub fn r#get_port(
563        &self,
564        mut id: &PortId,
565        mut port: fidl::endpoints::ServerEnd<PortMarker>,
566    ) -> Result<(), fidl::Error> {
567        DeviceProxyInterface::r#get_port(self, id, port)
568    }
569
570    /// Connects a [`PortWatcher`] to this device.
571    ///
572    /// + request `watcher` server end of watcher channel.
573    pub fn r#get_port_watcher(
574        &self,
575        mut watcher: fidl::endpoints::ServerEnd<PortWatcherMarker>,
576    ) -> Result<(), fidl::Error> {
577        DeviceProxyInterface::r#get_port_watcher(self, watcher)
578    }
579
580    /// Establishes a new connection to this device.
581    ///
582    /// + request `device` the server end for the new connection.
583    pub fn r#clone(
584        &self,
585        mut device: fidl::endpoints::ServerEnd<DeviceMarker>,
586    ) -> Result<(), fidl::Error> {
587        DeviceProxyInterface::r#clone(self, device)
588    }
589}
590
591impl DeviceProxyInterface for DeviceProxy {
592    type GetInfoResponseFut =
593        fidl::client::QueryResponseFut<DeviceInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
594    fn r#get_info(&self) -> Self::GetInfoResponseFut {
595        fn _decode(
596            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
597        ) -> Result<DeviceInfo, fidl::Error> {
598            let _response = fidl::client::decode_transaction_body::<
599                DeviceGetInfoResponse,
600                fidl::encoding::DefaultFuchsiaResourceDialect,
601                0x3c500ca9341e8f56,
602            >(_buf?)?;
603            Ok(_response.info)
604        }
605        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceInfo>(
606            (),
607            0x3c500ca9341e8f56,
608            fidl::encoding::DynamicFlags::empty(),
609            _decode,
610        )
611    }
612
613    type OpenSessionResponseFut = fidl::client::QueryResponseFut<
614        DeviceOpenSessionResult,
615        fidl::encoding::DefaultFuchsiaResourceDialect,
616    >;
617    fn r#open_session(
618        &self,
619        mut session_name: &str,
620        mut session_info: SessionInfo,
621    ) -> Self::OpenSessionResponseFut {
622        fn _decode(
623            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
624        ) -> Result<DeviceOpenSessionResult, fidl::Error> {
625            let _response = fidl::client::decode_transaction_body::<
626                fidl::encoding::ResultType<DeviceOpenSessionResponse, i32>,
627                fidl::encoding::DefaultFuchsiaResourceDialect,
628                0x25940b82146dcf67,
629            >(_buf?)?;
630            Ok(_response.map(|x| (x.session, x.fifos)))
631        }
632        self.client.send_query_and_decode::<DeviceOpenSessionRequest, DeviceOpenSessionResult>(
633            (session_name, &mut session_info),
634            0x25940b82146dcf67,
635            fidl::encoding::DynamicFlags::empty(),
636            _decode,
637        )
638    }
639
640    fn r#get_port(
641        &self,
642        mut id: &PortId,
643        mut port: fidl::endpoints::ServerEnd<PortMarker>,
644    ) -> Result<(), fidl::Error> {
645        self.client.send::<DeviceGetPortRequest>(
646            (id, port),
647            0x340a852c955ba2a6,
648            fidl::encoding::DynamicFlags::empty(),
649        )
650    }
651
652    fn r#get_port_watcher(
653        &self,
654        mut watcher: fidl::endpoints::ServerEnd<PortWatcherMarker>,
655    ) -> Result<(), fidl::Error> {
656        self.client.send::<DeviceGetPortWatcherRequest>(
657            (watcher,),
658            0x104f43c937c39f0c,
659            fidl::encoding::DynamicFlags::empty(),
660        )
661    }
662
663    fn r#clone(
664        &self,
665        mut device: fidl::endpoints::ServerEnd<DeviceMarker>,
666    ) -> Result<(), fidl::Error> {
667        self.client.send::<DeviceCloneRequest>(
668            (device,),
669            0x5882ea09b3809af4,
670            fidl::encoding::DynamicFlags::empty(),
671        )
672    }
673}
674
675pub struct DeviceEventStream {
676    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
677}
678
679impl std::marker::Unpin for DeviceEventStream {}
680
681impl futures::stream::FusedStream for DeviceEventStream {
682    fn is_terminated(&self) -> bool {
683        self.event_receiver.is_terminated()
684    }
685}
686
687impl futures::Stream for DeviceEventStream {
688    type Item = Result<DeviceEvent, fidl::Error>;
689
690    fn poll_next(
691        mut self: std::pin::Pin<&mut Self>,
692        cx: &mut std::task::Context<'_>,
693    ) -> std::task::Poll<Option<Self::Item>> {
694        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
695            &mut self.event_receiver,
696            cx
697        )?) {
698            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
699            None => std::task::Poll::Ready(None),
700        }
701    }
702}
703
704#[derive(Debug)]
705pub enum DeviceEvent {}
706
707impl DeviceEvent {
708    /// Decodes a message buffer as a [`DeviceEvent`].
709    fn decode(
710        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
711    ) -> Result<DeviceEvent, fidl::Error> {
712        let (bytes, _handles) = buf.split_mut();
713        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
714        debug_assert_eq!(tx_header.tx_id, 0);
715        match tx_header.ordinal {
716            _ => Err(fidl::Error::UnknownOrdinal {
717                ordinal: tx_header.ordinal,
718                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
719            }),
720        }
721    }
722}
723
724/// A Stream of incoming requests for fuchsia.hardware.network/Device.
725pub struct DeviceRequestStream {
726    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
727    is_terminated: bool,
728}
729
730impl std::marker::Unpin for DeviceRequestStream {}
731
732impl futures::stream::FusedStream for DeviceRequestStream {
733    fn is_terminated(&self) -> bool {
734        self.is_terminated
735    }
736}
737
738impl fidl::endpoints::RequestStream for DeviceRequestStream {
739    type Protocol = DeviceMarker;
740    type ControlHandle = DeviceControlHandle;
741
742    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
743        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
744    }
745
746    fn control_handle(&self) -> Self::ControlHandle {
747        DeviceControlHandle { inner: self.inner.clone() }
748    }
749
750    fn into_inner(
751        self,
752    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
753    {
754        (self.inner, self.is_terminated)
755    }
756
757    fn from_inner(
758        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
759        is_terminated: bool,
760    ) -> Self {
761        Self { inner, is_terminated }
762    }
763}
764
765impl futures::Stream for DeviceRequestStream {
766    type Item = Result<DeviceRequest, fidl::Error>;
767
768    fn poll_next(
769        mut self: std::pin::Pin<&mut Self>,
770        cx: &mut std::task::Context<'_>,
771    ) -> std::task::Poll<Option<Self::Item>> {
772        let this = &mut *self;
773        if this.inner.check_shutdown(cx) {
774            this.is_terminated = true;
775            return std::task::Poll::Ready(None);
776        }
777        if this.is_terminated {
778            panic!("polled DeviceRequestStream after completion");
779        }
780        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
781            |bytes, handles| {
782                match this.inner.channel().read_etc(cx, bytes, handles) {
783                    std::task::Poll::Ready(Ok(())) => {}
784                    std::task::Poll::Pending => return std::task::Poll::Pending,
785                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
786                        this.is_terminated = true;
787                        return std::task::Poll::Ready(None);
788                    }
789                    std::task::Poll::Ready(Err(e)) => {
790                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
791                            e.into(),
792                        ))));
793                    }
794                }
795
796                // A message has been received from the channel
797                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
798
799                std::task::Poll::Ready(Some(match header.ordinal {
800                    0x3c500ca9341e8f56 => {
801                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
802                        let mut req = fidl::new_empty!(
803                            fidl::encoding::EmptyPayload,
804                            fidl::encoding::DefaultFuchsiaResourceDialect
805                        );
806                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
807                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
808                        Ok(DeviceRequest::GetInfo {
809                            responder: DeviceGetInfoResponder {
810                                control_handle: std::mem::ManuallyDrop::new(control_handle),
811                                tx_id: header.tx_id,
812                            },
813                        })
814                    }
815                    0x25940b82146dcf67 => {
816                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
817                        let mut req = fidl::new_empty!(
818                            DeviceOpenSessionRequest,
819                            fidl::encoding::DefaultFuchsiaResourceDialect
820                        );
821                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceOpenSessionRequest>(&header, _body_bytes, handles, &mut req)?;
822                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
823                        Ok(DeviceRequest::OpenSession {
824                            session_name: req.session_name,
825                            session_info: req.session_info,
826
827                            responder: DeviceOpenSessionResponder {
828                                control_handle: std::mem::ManuallyDrop::new(control_handle),
829                                tx_id: header.tx_id,
830                            },
831                        })
832                    }
833                    0x340a852c955ba2a6 => {
834                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
835                        let mut req = fidl::new_empty!(
836                            DeviceGetPortRequest,
837                            fidl::encoding::DefaultFuchsiaResourceDialect
838                        );
839                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetPortRequest>(&header, _body_bytes, handles, &mut req)?;
840                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
841                        Ok(DeviceRequest::GetPort { id: req.id, port: req.port, control_handle })
842                    }
843                    0x104f43c937c39f0c => {
844                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
845                        let mut req = fidl::new_empty!(
846                            DeviceGetPortWatcherRequest,
847                            fidl::encoding::DefaultFuchsiaResourceDialect
848                        );
849                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetPortWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
850                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
851                        Ok(DeviceRequest::GetPortWatcher { watcher: req.watcher, control_handle })
852                    }
853                    0x5882ea09b3809af4 => {
854                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
855                        let mut req = fidl::new_empty!(
856                            DeviceCloneRequest,
857                            fidl::encoding::DefaultFuchsiaResourceDialect
858                        );
859                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceCloneRequest>(&header, _body_bytes, handles, &mut req)?;
860                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
861                        Ok(DeviceRequest::Clone { device: req.device, control_handle })
862                    }
863                    _ => Err(fidl::Error::UnknownOrdinal {
864                        ordinal: header.ordinal,
865                        protocol_name:
866                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
867                    }),
868                }))
869            },
870        )
871    }
872}
873
874/// A Network Device.
875#[derive(Debug)]
876pub enum DeviceRequest {
877    /// Obtain information about device
878    ///
879    /// - response `info` device information.
880    GetInfo { responder: DeviceGetInfoResponder },
881    /// Opens a new session with the network device.
882    ///
883    /// + request `session_name` is used as a debugging label attached to this
884    /// session.
885    /// + request `session_info` contains the necessary information to setup the
886    /// session's data exchange.
887    /// - response `session` a handle to control the session.
888    /// - response `fifos` data-plane FIFOs attached to the session.
889    /// * error `ZX_ERR_NOT_SUPPORTED` if `session_info` contains not supported
890    /// frame types or descriptors set up.
891    /// * error `ZX_ERR_INVALID_ARGS` if `session_info` is missing fields or
892    /// contains invalid information.
893    /// * error `ZX_ERR_INTERNAL` if the data VMO is rejected by the underlying
894    /// device.
895    OpenSession {
896        session_name: String,
897        session_info: SessionInfo,
898        responder: DeviceOpenSessionResponder,
899    },
900    /// Connects to a port the given `id`.
901    ///
902    /// + request `id` port to connect to.
903    /// + request `port` server end of port channel.
904    ///
905    /// `port` is closed with a `ZX_ERR_NOT_FOUND` epitaph if no port with `id`
906    /// exists.
907    GetPort {
908        id: PortId,
909        port: fidl::endpoints::ServerEnd<PortMarker>,
910        control_handle: DeviceControlHandle,
911    },
912    /// Connects a [`PortWatcher`] to this device.
913    ///
914    /// + request `watcher` server end of watcher channel.
915    GetPortWatcher {
916        watcher: fidl::endpoints::ServerEnd<PortWatcherMarker>,
917        control_handle: DeviceControlHandle,
918    },
919    /// Establishes a new connection to this device.
920    ///
921    /// + request `device` the server end for the new connection.
922    Clone { device: fidl::endpoints::ServerEnd<DeviceMarker>, control_handle: DeviceControlHandle },
923}
924
925impl DeviceRequest {
926    #[allow(irrefutable_let_patterns)]
927    pub fn into_get_info(self) -> Option<(DeviceGetInfoResponder)> {
928        if let DeviceRequest::GetInfo { responder } = self { Some((responder)) } else { None }
929    }
930
931    #[allow(irrefutable_let_patterns)]
932    pub fn into_open_session(self) -> Option<(String, SessionInfo, DeviceOpenSessionResponder)> {
933        if let DeviceRequest::OpenSession { session_name, session_info, responder } = self {
934            Some((session_name, session_info, responder))
935        } else {
936            None
937        }
938    }
939
940    #[allow(irrefutable_let_patterns)]
941    pub fn into_get_port(
942        self,
943    ) -> Option<(PortId, fidl::endpoints::ServerEnd<PortMarker>, DeviceControlHandle)> {
944        if let DeviceRequest::GetPort { id, port, control_handle } = self {
945            Some((id, port, control_handle))
946        } else {
947            None
948        }
949    }
950
951    #[allow(irrefutable_let_patterns)]
952    pub fn into_get_port_watcher(
953        self,
954    ) -> Option<(fidl::endpoints::ServerEnd<PortWatcherMarker>, DeviceControlHandle)> {
955        if let DeviceRequest::GetPortWatcher { watcher, control_handle } = self {
956            Some((watcher, control_handle))
957        } else {
958            None
959        }
960    }
961
962    #[allow(irrefutable_let_patterns)]
963    pub fn into_clone(
964        self,
965    ) -> Option<(fidl::endpoints::ServerEnd<DeviceMarker>, DeviceControlHandle)> {
966        if let DeviceRequest::Clone { device, control_handle } = self {
967            Some((device, control_handle))
968        } else {
969            None
970        }
971    }
972
973    /// Name of the method defined in FIDL
974    pub fn method_name(&self) -> &'static str {
975        match *self {
976            DeviceRequest::GetInfo { .. } => "get_info",
977            DeviceRequest::OpenSession { .. } => "open_session",
978            DeviceRequest::GetPort { .. } => "get_port",
979            DeviceRequest::GetPortWatcher { .. } => "get_port_watcher",
980            DeviceRequest::Clone { .. } => "clone",
981        }
982    }
983}
984
985#[derive(Debug, Clone)]
986pub struct DeviceControlHandle {
987    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
988}
989
990impl fidl::endpoints::ControlHandle for DeviceControlHandle {
991    fn shutdown(&self) {
992        self.inner.shutdown()
993    }
994
995    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
996        self.inner.shutdown_with_epitaph(status)
997    }
998
999    fn is_closed(&self) -> bool {
1000        self.inner.channel().is_closed()
1001    }
1002    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1003        self.inner.channel().on_closed()
1004    }
1005
1006    #[cfg(target_os = "fuchsia")]
1007    fn signal_peer(
1008        &self,
1009        clear_mask: zx::Signals,
1010        set_mask: zx::Signals,
1011    ) -> Result<(), zx_status::Status> {
1012        use fidl::Peered;
1013        self.inner.channel().signal_peer(clear_mask, set_mask)
1014    }
1015}
1016
1017impl DeviceControlHandle {}
1018
1019#[must_use = "FIDL methods require a response to be sent"]
1020#[derive(Debug)]
1021pub struct DeviceGetInfoResponder {
1022    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1023    tx_id: u32,
1024}
1025
1026/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1027/// if the responder is dropped without sending a response, so that the client
1028/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1029impl std::ops::Drop for DeviceGetInfoResponder {
1030    fn drop(&mut self) {
1031        self.control_handle.shutdown();
1032        // Safety: drops once, never accessed again
1033        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1034    }
1035}
1036
1037impl fidl::endpoints::Responder for DeviceGetInfoResponder {
1038    type ControlHandle = DeviceControlHandle;
1039
1040    fn control_handle(&self) -> &DeviceControlHandle {
1041        &self.control_handle
1042    }
1043
1044    fn drop_without_shutdown(mut self) {
1045        // Safety: drops once, never accessed again due to mem::forget
1046        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1047        // Prevent Drop from running (which would shut down the channel)
1048        std::mem::forget(self);
1049    }
1050}
1051
1052impl DeviceGetInfoResponder {
1053    /// Sends a response to the FIDL transaction.
1054    ///
1055    /// Sets the channel to shutdown if an error occurs.
1056    pub fn send(self, mut info: &DeviceInfo) -> Result<(), fidl::Error> {
1057        let _result = self.send_raw(info);
1058        if _result.is_err() {
1059            self.control_handle.shutdown();
1060        }
1061        self.drop_without_shutdown();
1062        _result
1063    }
1064
1065    /// Similar to "send" but does not shutdown the channel if an error occurs.
1066    pub fn send_no_shutdown_on_err(self, mut info: &DeviceInfo) -> Result<(), fidl::Error> {
1067        let _result = self.send_raw(info);
1068        self.drop_without_shutdown();
1069        _result
1070    }
1071
1072    fn send_raw(&self, mut info: &DeviceInfo) -> Result<(), fidl::Error> {
1073        self.control_handle.inner.send::<DeviceGetInfoResponse>(
1074            (info,),
1075            self.tx_id,
1076            0x3c500ca9341e8f56,
1077            fidl::encoding::DynamicFlags::empty(),
1078        )
1079    }
1080}
1081
1082#[must_use = "FIDL methods require a response to be sent"]
1083#[derive(Debug)]
1084pub struct DeviceOpenSessionResponder {
1085    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1086    tx_id: u32,
1087}
1088
1089/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1090/// if the responder is dropped without sending a response, so that the client
1091/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1092impl std::ops::Drop for DeviceOpenSessionResponder {
1093    fn drop(&mut self) {
1094        self.control_handle.shutdown();
1095        // Safety: drops once, never accessed again
1096        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1097    }
1098}
1099
1100impl fidl::endpoints::Responder for DeviceOpenSessionResponder {
1101    type ControlHandle = DeviceControlHandle;
1102
1103    fn control_handle(&self) -> &DeviceControlHandle {
1104        &self.control_handle
1105    }
1106
1107    fn drop_without_shutdown(mut self) {
1108        // Safety: drops once, never accessed again due to mem::forget
1109        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1110        // Prevent Drop from running (which would shut down the channel)
1111        std::mem::forget(self);
1112    }
1113}
1114
1115impl DeviceOpenSessionResponder {
1116    /// Sends a response to the FIDL transaction.
1117    ///
1118    /// Sets the channel to shutdown if an error occurs.
1119    pub fn send(
1120        self,
1121        mut result: Result<(fidl::endpoints::ClientEnd<SessionMarker>, Fifos), i32>,
1122    ) -> Result<(), fidl::Error> {
1123        let _result = self.send_raw(result);
1124        if _result.is_err() {
1125            self.control_handle.shutdown();
1126        }
1127        self.drop_without_shutdown();
1128        _result
1129    }
1130
1131    /// Similar to "send" but does not shutdown the channel if an error occurs.
1132    pub fn send_no_shutdown_on_err(
1133        self,
1134        mut result: Result<(fidl::endpoints::ClientEnd<SessionMarker>, Fifos), i32>,
1135    ) -> Result<(), fidl::Error> {
1136        let _result = self.send_raw(result);
1137        self.drop_without_shutdown();
1138        _result
1139    }
1140
1141    fn send_raw(
1142        &self,
1143        mut result: Result<(fidl::endpoints::ClientEnd<SessionMarker>, Fifos), i32>,
1144    ) -> Result<(), fidl::Error> {
1145        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceOpenSessionResponse, i32>>(
1146            result.as_mut().map_err(|e| *e).map(|(session, fifos)| (std::mem::replace(session, <<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::Handle as fidl::encoding::HandleFor<fidl::encoding::DefaultFuchsiaResourceDialect>>::invalid().into()), fifos,)),
1147            self.tx_id,
1148            0x25940b82146dcf67,
1149            fidl::encoding::DynamicFlags::empty()
1150        )
1151    }
1152}
1153
1154#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1155pub struct DiagnosticsMarker;
1156
1157impl fidl::endpoints::ProtocolMarker for DiagnosticsMarker {
1158    type Proxy = DiagnosticsProxy;
1159    type RequestStream = DiagnosticsRequestStream;
1160    #[cfg(target_os = "fuchsia")]
1161    type SynchronousProxy = DiagnosticsSynchronousProxy;
1162
1163    const DEBUG_NAME: &'static str = "(anonymous) Diagnostics";
1164}
1165
1166pub trait DiagnosticsProxyInterface: Send + Sync {
1167    type LogDebugInfoToSyslogResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
1168        + Send;
1169    fn r#log_debug_info_to_syslog(&self) -> Self::LogDebugInfoToSyslogResponseFut;
1170}
1171#[derive(Debug)]
1172#[cfg(target_os = "fuchsia")]
1173pub struct DiagnosticsSynchronousProxy {
1174    client: fidl::client::sync::Client,
1175}
1176
1177#[cfg(target_os = "fuchsia")]
1178impl fidl::endpoints::SynchronousProxy for DiagnosticsSynchronousProxy {
1179    type Proxy = DiagnosticsProxy;
1180    type Protocol = DiagnosticsMarker;
1181
1182    fn from_channel(inner: fidl::Channel) -> Self {
1183        Self::new(inner)
1184    }
1185
1186    fn into_channel(self) -> fidl::Channel {
1187        self.client.into_channel()
1188    }
1189
1190    fn as_channel(&self) -> &fidl::Channel {
1191        self.client.as_channel()
1192    }
1193}
1194
1195#[cfg(target_os = "fuchsia")]
1196impl DiagnosticsSynchronousProxy {
1197    pub fn new(channel: fidl::Channel) -> Self {
1198        Self { client: fidl::client::sync::Client::new(channel) }
1199    }
1200
1201    pub fn into_channel(self) -> fidl::Channel {
1202        self.client.into_channel()
1203    }
1204
1205    /// Waits until an event arrives and returns it. It is safe for other
1206    /// threads to make concurrent requests while waiting for an event.
1207    pub fn wait_for_event(
1208        &self,
1209        deadline: zx::MonotonicInstant,
1210    ) -> Result<DiagnosticsEvent, fidl::Error> {
1211        DiagnosticsEvent::decode(self.client.wait_for_event::<DiagnosticsMarker>(deadline)?)
1212    }
1213
1214    /// Requests that the device produces debugging information in the system
1215    /// logs.
1216    ///
1217    /// The call returns once device debug information has been produced.
1218    pub fn r#log_debug_info_to_syslog(
1219        &self,
1220        ___deadline: zx::MonotonicInstant,
1221    ) -> Result<(), fidl::Error> {
1222        let _response = self.client.send_query::<
1223            fidl::encoding::EmptyPayload,
1224            fidl::encoding::EmptyPayload,
1225            DiagnosticsMarker,
1226        >(
1227            (),
1228            0x4222897dfe1f4b4a,
1229            fidl::encoding::DynamicFlags::empty(),
1230            ___deadline,
1231        )?;
1232        Ok(_response)
1233    }
1234}
1235
1236#[cfg(target_os = "fuchsia")]
1237impl From<DiagnosticsSynchronousProxy> for zx::NullableHandle {
1238    fn from(value: DiagnosticsSynchronousProxy) -> Self {
1239        value.into_channel().into()
1240    }
1241}
1242
1243#[cfg(target_os = "fuchsia")]
1244impl From<fidl::Channel> for DiagnosticsSynchronousProxy {
1245    fn from(value: fidl::Channel) -> Self {
1246        Self::new(value)
1247    }
1248}
1249
1250#[cfg(target_os = "fuchsia")]
1251impl fidl::endpoints::FromClient for DiagnosticsSynchronousProxy {
1252    type Protocol = DiagnosticsMarker;
1253
1254    fn from_client(value: fidl::endpoints::ClientEnd<DiagnosticsMarker>) -> Self {
1255        Self::new(value.into_channel())
1256    }
1257}
1258
1259#[derive(Debug, Clone)]
1260pub struct DiagnosticsProxy {
1261    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1262}
1263
1264impl fidl::endpoints::Proxy for DiagnosticsProxy {
1265    type Protocol = DiagnosticsMarker;
1266
1267    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1268        Self::new(inner)
1269    }
1270
1271    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1272        self.client.into_channel().map_err(|client| Self { client })
1273    }
1274
1275    fn as_channel(&self) -> &::fidl::AsyncChannel {
1276        self.client.as_channel()
1277    }
1278}
1279
1280impl DiagnosticsProxy {
1281    /// Create a new Proxy for fuchsia.hardware.network/Diagnostics.
1282    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1283        let protocol_name = <DiagnosticsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1284        Self { client: fidl::client::Client::new(channel, protocol_name) }
1285    }
1286
1287    /// Get a Stream of events from the remote end of the protocol.
1288    ///
1289    /// # Panics
1290    ///
1291    /// Panics if the event stream was already taken.
1292    pub fn take_event_stream(&self) -> DiagnosticsEventStream {
1293        DiagnosticsEventStream { event_receiver: self.client.take_event_receiver() }
1294    }
1295
1296    /// Requests that the device produces debugging information in the system
1297    /// logs.
1298    ///
1299    /// The call returns once device debug information has been produced.
1300    pub fn r#log_debug_info_to_syslog(
1301        &self,
1302    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1303        DiagnosticsProxyInterface::r#log_debug_info_to_syslog(self)
1304    }
1305}
1306
1307impl DiagnosticsProxyInterface for DiagnosticsProxy {
1308    type LogDebugInfoToSyslogResponseFut =
1309        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1310    fn r#log_debug_info_to_syslog(&self) -> Self::LogDebugInfoToSyslogResponseFut {
1311        fn _decode(
1312            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1313        ) -> Result<(), fidl::Error> {
1314            let _response = fidl::client::decode_transaction_body::<
1315                fidl::encoding::EmptyPayload,
1316                fidl::encoding::DefaultFuchsiaResourceDialect,
1317                0x4222897dfe1f4b4a,
1318            >(_buf?)?;
1319            Ok(_response)
1320        }
1321        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1322            (),
1323            0x4222897dfe1f4b4a,
1324            fidl::encoding::DynamicFlags::empty(),
1325            _decode,
1326        )
1327    }
1328}
1329
1330pub struct DiagnosticsEventStream {
1331    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1332}
1333
1334impl std::marker::Unpin for DiagnosticsEventStream {}
1335
1336impl futures::stream::FusedStream for DiagnosticsEventStream {
1337    fn is_terminated(&self) -> bool {
1338        self.event_receiver.is_terminated()
1339    }
1340}
1341
1342impl futures::Stream for DiagnosticsEventStream {
1343    type Item = Result<DiagnosticsEvent, fidl::Error>;
1344
1345    fn poll_next(
1346        mut self: std::pin::Pin<&mut Self>,
1347        cx: &mut std::task::Context<'_>,
1348    ) -> std::task::Poll<Option<Self::Item>> {
1349        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1350            &mut self.event_receiver,
1351            cx
1352        )?) {
1353            Some(buf) => std::task::Poll::Ready(Some(DiagnosticsEvent::decode(buf))),
1354            None => std::task::Poll::Ready(None),
1355        }
1356    }
1357}
1358
1359#[derive(Debug)]
1360pub enum DiagnosticsEvent {}
1361
1362impl DiagnosticsEvent {
1363    /// Decodes a message buffer as a [`DiagnosticsEvent`].
1364    fn decode(
1365        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1366    ) -> Result<DiagnosticsEvent, fidl::Error> {
1367        let (bytes, _handles) = buf.split_mut();
1368        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1369        debug_assert_eq!(tx_header.tx_id, 0);
1370        match tx_header.ordinal {
1371            _ => Err(fidl::Error::UnknownOrdinal {
1372                ordinal: tx_header.ordinal,
1373                protocol_name: <DiagnosticsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1374            }),
1375        }
1376    }
1377}
1378
1379/// A Stream of incoming requests for fuchsia.hardware.network/Diagnostics.
1380pub struct DiagnosticsRequestStream {
1381    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1382    is_terminated: bool,
1383}
1384
1385impl std::marker::Unpin for DiagnosticsRequestStream {}
1386
1387impl futures::stream::FusedStream for DiagnosticsRequestStream {
1388    fn is_terminated(&self) -> bool {
1389        self.is_terminated
1390    }
1391}
1392
1393impl fidl::endpoints::RequestStream for DiagnosticsRequestStream {
1394    type Protocol = DiagnosticsMarker;
1395    type ControlHandle = DiagnosticsControlHandle;
1396
1397    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1398        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1399    }
1400
1401    fn control_handle(&self) -> Self::ControlHandle {
1402        DiagnosticsControlHandle { inner: self.inner.clone() }
1403    }
1404
1405    fn into_inner(
1406        self,
1407    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1408    {
1409        (self.inner, self.is_terminated)
1410    }
1411
1412    fn from_inner(
1413        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1414        is_terminated: bool,
1415    ) -> Self {
1416        Self { inner, is_terminated }
1417    }
1418}
1419
1420impl futures::Stream for DiagnosticsRequestStream {
1421    type Item = Result<DiagnosticsRequest, fidl::Error>;
1422
1423    fn poll_next(
1424        mut self: std::pin::Pin<&mut Self>,
1425        cx: &mut std::task::Context<'_>,
1426    ) -> std::task::Poll<Option<Self::Item>> {
1427        let this = &mut *self;
1428        if this.inner.check_shutdown(cx) {
1429            this.is_terminated = true;
1430            return std::task::Poll::Ready(None);
1431        }
1432        if this.is_terminated {
1433            panic!("polled DiagnosticsRequestStream after completion");
1434        }
1435        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1436            |bytes, handles| {
1437                match this.inner.channel().read_etc(cx, bytes, handles) {
1438                    std::task::Poll::Ready(Ok(())) => {}
1439                    std::task::Poll::Pending => return std::task::Poll::Pending,
1440                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1441                        this.is_terminated = true;
1442                        return std::task::Poll::Ready(None);
1443                    }
1444                    std::task::Poll::Ready(Err(e)) => {
1445                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1446                            e.into(),
1447                        ))));
1448                    }
1449                }
1450
1451                // A message has been received from the channel
1452                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1453
1454                std::task::Poll::Ready(Some(match header.ordinal {
1455                    0x4222897dfe1f4b4a => {
1456                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1457                        let mut req = fidl::new_empty!(
1458                            fidl::encoding::EmptyPayload,
1459                            fidl::encoding::DefaultFuchsiaResourceDialect
1460                        );
1461                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1462                        let control_handle = DiagnosticsControlHandle { inner: this.inner.clone() };
1463                        Ok(DiagnosticsRequest::LogDebugInfoToSyslog {
1464                            responder: DiagnosticsLogDebugInfoToSyslogResponder {
1465                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1466                                tx_id: header.tx_id,
1467                            },
1468                        })
1469                    }
1470                    _ => Err(fidl::Error::UnknownOrdinal {
1471                        ordinal: header.ordinal,
1472                        protocol_name:
1473                            <DiagnosticsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1474                    }),
1475                }))
1476            },
1477        )
1478    }
1479}
1480
1481/// Provides two way communications between device and upper layers to exchange
1482/// device health information.
1483#[derive(Debug)]
1484pub enum DiagnosticsRequest {
1485    /// Requests that the device produces debugging information in the system
1486    /// logs.
1487    ///
1488    /// The call returns once device debug information has been produced.
1489    LogDebugInfoToSyslog { responder: DiagnosticsLogDebugInfoToSyslogResponder },
1490}
1491
1492impl DiagnosticsRequest {
1493    #[allow(irrefutable_let_patterns)]
1494    pub fn into_log_debug_info_to_syslog(
1495        self,
1496    ) -> Option<(DiagnosticsLogDebugInfoToSyslogResponder)> {
1497        if let DiagnosticsRequest::LogDebugInfoToSyslog { responder } = self {
1498            Some((responder))
1499        } else {
1500            None
1501        }
1502    }
1503
1504    /// Name of the method defined in FIDL
1505    pub fn method_name(&self) -> &'static str {
1506        match *self {
1507            DiagnosticsRequest::LogDebugInfoToSyslog { .. } => "log_debug_info_to_syslog",
1508        }
1509    }
1510}
1511
1512#[derive(Debug, Clone)]
1513pub struct DiagnosticsControlHandle {
1514    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1515}
1516
1517impl fidl::endpoints::ControlHandle for DiagnosticsControlHandle {
1518    fn shutdown(&self) {
1519        self.inner.shutdown()
1520    }
1521
1522    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1523        self.inner.shutdown_with_epitaph(status)
1524    }
1525
1526    fn is_closed(&self) -> bool {
1527        self.inner.channel().is_closed()
1528    }
1529    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1530        self.inner.channel().on_closed()
1531    }
1532
1533    #[cfg(target_os = "fuchsia")]
1534    fn signal_peer(
1535        &self,
1536        clear_mask: zx::Signals,
1537        set_mask: zx::Signals,
1538    ) -> Result<(), zx_status::Status> {
1539        use fidl::Peered;
1540        self.inner.channel().signal_peer(clear_mask, set_mask)
1541    }
1542}
1543
1544impl DiagnosticsControlHandle {}
1545
1546#[must_use = "FIDL methods require a response to be sent"]
1547#[derive(Debug)]
1548pub struct DiagnosticsLogDebugInfoToSyslogResponder {
1549    control_handle: std::mem::ManuallyDrop<DiagnosticsControlHandle>,
1550    tx_id: u32,
1551}
1552
1553/// Set the the channel to be shutdown (see [`DiagnosticsControlHandle::shutdown`])
1554/// if the responder is dropped without sending a response, so that the client
1555/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1556impl std::ops::Drop for DiagnosticsLogDebugInfoToSyslogResponder {
1557    fn drop(&mut self) {
1558        self.control_handle.shutdown();
1559        // Safety: drops once, never accessed again
1560        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1561    }
1562}
1563
1564impl fidl::endpoints::Responder for DiagnosticsLogDebugInfoToSyslogResponder {
1565    type ControlHandle = DiagnosticsControlHandle;
1566
1567    fn control_handle(&self) -> &DiagnosticsControlHandle {
1568        &self.control_handle
1569    }
1570
1571    fn drop_without_shutdown(mut self) {
1572        // Safety: drops once, never accessed again due to mem::forget
1573        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1574        // Prevent Drop from running (which would shut down the channel)
1575        std::mem::forget(self);
1576    }
1577}
1578
1579impl DiagnosticsLogDebugInfoToSyslogResponder {
1580    /// Sends a response to the FIDL transaction.
1581    ///
1582    /// Sets the channel to shutdown if an error occurs.
1583    pub fn send(self) -> Result<(), fidl::Error> {
1584        let _result = self.send_raw();
1585        if _result.is_err() {
1586            self.control_handle.shutdown();
1587        }
1588        self.drop_without_shutdown();
1589        _result
1590    }
1591
1592    /// Similar to "send" but does not shutdown the channel if an error occurs.
1593    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1594        let _result = self.send_raw();
1595        self.drop_without_shutdown();
1596        _result
1597    }
1598
1599    fn send_raw(&self) -> Result<(), fidl::Error> {
1600        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1601            (),
1602            self.tx_id,
1603            0x4222897dfe1f4b4a,
1604            fidl::encoding::DynamicFlags::empty(),
1605        )
1606    }
1607}
1608
1609#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1610pub struct MacAddressingMarker;
1611
1612impl fidl::endpoints::ProtocolMarker for MacAddressingMarker {
1613    type Proxy = MacAddressingProxy;
1614    type RequestStream = MacAddressingRequestStream;
1615    #[cfg(target_os = "fuchsia")]
1616    type SynchronousProxy = MacAddressingSynchronousProxy;
1617
1618    const DEBUG_NAME: &'static str = "(anonymous) MacAddressing";
1619}
1620
1621pub trait MacAddressingProxyInterface: Send + Sync {
1622    type GetUnicastAddressResponseFut: std::future::Future<Output = Result<fidl_fuchsia_net::MacAddress, fidl::Error>>
1623        + Send;
1624    fn r#get_unicast_address(&self) -> Self::GetUnicastAddressResponseFut;
1625    type SetModeResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
1626    fn r#set_mode(&self, mode: MacFilterMode) -> Self::SetModeResponseFut;
1627    type AddMulticastAddressResponseFut: std::future::Future<Output = Result<i32, fidl::Error>>
1628        + Send;
1629    fn r#add_multicast_address(
1630        &self,
1631        address: &fidl_fuchsia_net::MacAddress,
1632    ) -> Self::AddMulticastAddressResponseFut;
1633    type RemoveMulticastAddressResponseFut: std::future::Future<Output = Result<i32, fidl::Error>>
1634        + Send;
1635    fn r#remove_multicast_address(
1636        &self,
1637        address: &fidl_fuchsia_net::MacAddress,
1638    ) -> Self::RemoveMulticastAddressResponseFut;
1639}
1640#[derive(Debug)]
1641#[cfg(target_os = "fuchsia")]
1642pub struct MacAddressingSynchronousProxy {
1643    client: fidl::client::sync::Client,
1644}
1645
1646#[cfg(target_os = "fuchsia")]
1647impl fidl::endpoints::SynchronousProxy for MacAddressingSynchronousProxy {
1648    type Proxy = MacAddressingProxy;
1649    type Protocol = MacAddressingMarker;
1650
1651    fn from_channel(inner: fidl::Channel) -> Self {
1652        Self::new(inner)
1653    }
1654
1655    fn into_channel(self) -> fidl::Channel {
1656        self.client.into_channel()
1657    }
1658
1659    fn as_channel(&self) -> &fidl::Channel {
1660        self.client.as_channel()
1661    }
1662}
1663
1664#[cfg(target_os = "fuchsia")]
1665impl MacAddressingSynchronousProxy {
1666    pub fn new(channel: fidl::Channel) -> Self {
1667        Self { client: fidl::client::sync::Client::new(channel) }
1668    }
1669
1670    pub fn into_channel(self) -> fidl::Channel {
1671        self.client.into_channel()
1672    }
1673
1674    /// Waits until an event arrives and returns it. It is safe for other
1675    /// threads to make concurrent requests while waiting for an event.
1676    pub fn wait_for_event(
1677        &self,
1678        deadline: zx::MonotonicInstant,
1679    ) -> Result<MacAddressingEvent, fidl::Error> {
1680        MacAddressingEvent::decode(self.client.wait_for_event::<MacAddressingMarker>(deadline)?)
1681    }
1682
1683    /// Gets the Device's current unicast MAC address.
1684    ///
1685    /// Implementers of this API do not need to return a uniquely identifiable
1686    /// MAC; the unicast address returned is the one that is *currently* in use
1687    /// to filter unicast frames, or that identifies the device on a link it's
1688    /// *currently* on. Users of this API must not rely on the stability or
1689    /// uniqueness of the returned value to identify or disambiguate device
1690    /// instances.
1691    ///
1692    /// - response `address` device's unicast MAC address.
1693    pub fn r#get_unicast_address(
1694        &self,
1695        ___deadline: zx::MonotonicInstant,
1696    ) -> Result<fidl_fuchsia_net::MacAddress, fidl::Error> {
1697        let _response = self.client.send_query::<
1698            fidl::encoding::EmptyPayload,
1699            MacAddressingGetUnicastAddressResponse,
1700            MacAddressingMarker,
1701        >(
1702            (),
1703            0x2c60b82a4ecfaebe,
1704            fidl::encoding::DynamicFlags::empty(),
1705            ___deadline,
1706        )?;
1707        Ok(_response.address)
1708    }
1709
1710    /// Sets requested operating mode of this device to `mode`.
1711    ///
1712    /// The requested mode is attached to the current client connection to the
1713    /// device. Because multiple clients can be attached to the same device at
1714    /// once, the mode with the least restrictions is the one actively put into
1715    /// effect into the underlying device implementation.
1716    ///
1717    /// If the device does not support the requested mode, but supports a mode
1718    /// that is more open than the requested one, `SetMode` succeeds regardless.
1719    /// Otherwise, if the device only supports *more restrictive* modes than the
1720    /// one requested, `SetMode` returns `ZX_ERR_NOT_SUPPORTED`.
1721    ///
1722    /// Clients must be aware that the resource being accessed is shared, and
1723    /// that the device may be effectively operating at a more open level than
1724    /// the one that was requested (although never at one more restrictive).
1725    ///
1726    /// + request `mode` request mode to attach to.
1727    /// - response `status` `ZX_ERR_NOT_SUPPORTED` it the device only supports
1728    /// mode more restrictive than the one requested.
1729    pub fn r#set_mode(
1730        &self,
1731        mut mode: MacFilterMode,
1732        ___deadline: zx::MonotonicInstant,
1733    ) -> Result<i32, fidl::Error> {
1734        let _response = self.client.send_query::<
1735            MacAddressingSetModeRequest,
1736            MacAddressingSetModeResponse,
1737            MacAddressingMarker,
1738        >(
1739            (mode,),
1740            0x6297b8dbf03c58c,
1741            fidl::encoding::DynamicFlags::empty(),
1742            ___deadline,
1743        )?;
1744        Ok(_response.status)
1745    }
1746
1747    /// Adds multicast address to the list of multicast groups.
1748    ///
1749    /// The list of multicast addresses kept is untouched by calls to `SetMode`.
1750    /// If the device's mode is not `MULTICAST_FILTER`, the list of multicast
1751    /// addresses is ignored.
1752    ///
1753    /// + request `address` multicast address to add to the list.
1754    /// - response `status` `ZX_ERR_INVALID_ARGS` if `address` is not a
1755    /// multicast address.
1756    /// - response `status` `ZX_ERR_NO_RESOURCES` if there are more than
1757    /// `MAX_MAC_FILTER` addresses installed.
1758    pub fn r#add_multicast_address(
1759        &self,
1760        mut address: &fidl_fuchsia_net::MacAddress,
1761        ___deadline: zx::MonotonicInstant,
1762    ) -> Result<i32, fidl::Error> {
1763        let _response = self.client.send_query::<
1764            MacAddressingAddMulticastAddressRequest,
1765            MacAddressingAddMulticastAddressResponse,
1766            MacAddressingMarker,
1767        >(
1768            (address,),
1769            0xf5637ff11cf0c25,
1770            fidl::encoding::DynamicFlags::empty(),
1771            ___deadline,
1772        )?;
1773        Ok(_response.status)
1774    }
1775
1776    /// Removes multicast address from the list of multicast groups.
1777    ///
1778    /// + request `address` multicast address to remove from the list.
1779    /// - response `status` `ZX_ERR_INVALID_ARGS` if `address` is not a
1780    /// multicast address.
1781    pub fn r#remove_multicast_address(
1782        &self,
1783        mut address: &fidl_fuchsia_net::MacAddress,
1784        ___deadline: zx::MonotonicInstant,
1785    ) -> Result<i32, fidl::Error> {
1786        let _response = self.client.send_query::<
1787            MacAddressingRemoveMulticastAddressRequest,
1788            MacAddressingRemoveMulticastAddressResponse,
1789            MacAddressingMarker,
1790        >(
1791            (address,),
1792            0x5dddf4e3ba4e2560,
1793            fidl::encoding::DynamicFlags::empty(),
1794            ___deadline,
1795        )?;
1796        Ok(_response.status)
1797    }
1798}
1799
1800#[cfg(target_os = "fuchsia")]
1801impl From<MacAddressingSynchronousProxy> for zx::NullableHandle {
1802    fn from(value: MacAddressingSynchronousProxy) -> Self {
1803        value.into_channel().into()
1804    }
1805}
1806
1807#[cfg(target_os = "fuchsia")]
1808impl From<fidl::Channel> for MacAddressingSynchronousProxy {
1809    fn from(value: fidl::Channel) -> Self {
1810        Self::new(value)
1811    }
1812}
1813
1814#[cfg(target_os = "fuchsia")]
1815impl fidl::endpoints::FromClient for MacAddressingSynchronousProxy {
1816    type Protocol = MacAddressingMarker;
1817
1818    fn from_client(value: fidl::endpoints::ClientEnd<MacAddressingMarker>) -> Self {
1819        Self::new(value.into_channel())
1820    }
1821}
1822
1823#[derive(Debug, Clone)]
1824pub struct MacAddressingProxy {
1825    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1826}
1827
1828impl fidl::endpoints::Proxy for MacAddressingProxy {
1829    type Protocol = MacAddressingMarker;
1830
1831    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1832        Self::new(inner)
1833    }
1834
1835    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1836        self.client.into_channel().map_err(|client| Self { client })
1837    }
1838
1839    fn as_channel(&self) -> &::fidl::AsyncChannel {
1840        self.client.as_channel()
1841    }
1842}
1843
1844impl MacAddressingProxy {
1845    /// Create a new Proxy for fuchsia.hardware.network/MacAddressing.
1846    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1847        let protocol_name = <MacAddressingMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1848        Self { client: fidl::client::Client::new(channel, protocol_name) }
1849    }
1850
1851    /// Get a Stream of events from the remote end of the protocol.
1852    ///
1853    /// # Panics
1854    ///
1855    /// Panics if the event stream was already taken.
1856    pub fn take_event_stream(&self) -> MacAddressingEventStream {
1857        MacAddressingEventStream { event_receiver: self.client.take_event_receiver() }
1858    }
1859
1860    /// Gets the Device's current unicast MAC address.
1861    ///
1862    /// Implementers of this API do not need to return a uniquely identifiable
1863    /// MAC; the unicast address returned is the one that is *currently* in use
1864    /// to filter unicast frames, or that identifies the device on a link it's
1865    /// *currently* on. Users of this API must not rely on the stability or
1866    /// uniqueness of the returned value to identify or disambiguate device
1867    /// instances.
1868    ///
1869    /// - response `address` device's unicast MAC address.
1870    pub fn r#get_unicast_address(
1871        &self,
1872    ) -> fidl::client::QueryResponseFut<
1873        fidl_fuchsia_net::MacAddress,
1874        fidl::encoding::DefaultFuchsiaResourceDialect,
1875    > {
1876        MacAddressingProxyInterface::r#get_unicast_address(self)
1877    }
1878
1879    /// Sets requested operating mode of this device to `mode`.
1880    ///
1881    /// The requested mode is attached to the current client connection to the
1882    /// device. Because multiple clients can be attached to the same device at
1883    /// once, the mode with the least restrictions is the one actively put into
1884    /// effect into the underlying device implementation.
1885    ///
1886    /// If the device does not support the requested mode, but supports a mode
1887    /// that is more open than the requested one, `SetMode` succeeds regardless.
1888    /// Otherwise, if the device only supports *more restrictive* modes than the
1889    /// one requested, `SetMode` returns `ZX_ERR_NOT_SUPPORTED`.
1890    ///
1891    /// Clients must be aware that the resource being accessed is shared, and
1892    /// that the device may be effectively operating at a more open level than
1893    /// the one that was requested (although never at one more restrictive).
1894    ///
1895    /// + request `mode` request mode to attach to.
1896    /// - response `status` `ZX_ERR_NOT_SUPPORTED` it the device only supports
1897    /// mode more restrictive than the one requested.
1898    pub fn r#set_mode(
1899        &self,
1900        mut mode: MacFilterMode,
1901    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
1902        MacAddressingProxyInterface::r#set_mode(self, mode)
1903    }
1904
1905    /// Adds multicast address to the list of multicast groups.
1906    ///
1907    /// The list of multicast addresses kept is untouched by calls to `SetMode`.
1908    /// If the device's mode is not `MULTICAST_FILTER`, the list of multicast
1909    /// addresses is ignored.
1910    ///
1911    /// + request `address` multicast address to add to the list.
1912    /// - response `status` `ZX_ERR_INVALID_ARGS` if `address` is not a
1913    /// multicast address.
1914    /// - response `status` `ZX_ERR_NO_RESOURCES` if there are more than
1915    /// `MAX_MAC_FILTER` addresses installed.
1916    pub fn r#add_multicast_address(
1917        &self,
1918        mut address: &fidl_fuchsia_net::MacAddress,
1919    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
1920        MacAddressingProxyInterface::r#add_multicast_address(self, address)
1921    }
1922
1923    /// Removes multicast address from the list of multicast groups.
1924    ///
1925    /// + request `address` multicast address to remove from the list.
1926    /// - response `status` `ZX_ERR_INVALID_ARGS` if `address` is not a
1927    /// multicast address.
1928    pub fn r#remove_multicast_address(
1929        &self,
1930        mut address: &fidl_fuchsia_net::MacAddress,
1931    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
1932        MacAddressingProxyInterface::r#remove_multicast_address(self, address)
1933    }
1934}
1935
1936impl MacAddressingProxyInterface for MacAddressingProxy {
1937    type GetUnicastAddressResponseFut = fidl::client::QueryResponseFut<
1938        fidl_fuchsia_net::MacAddress,
1939        fidl::encoding::DefaultFuchsiaResourceDialect,
1940    >;
1941    fn r#get_unicast_address(&self) -> Self::GetUnicastAddressResponseFut {
1942        fn _decode(
1943            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1944        ) -> Result<fidl_fuchsia_net::MacAddress, fidl::Error> {
1945            let _response = fidl::client::decode_transaction_body::<
1946                MacAddressingGetUnicastAddressResponse,
1947                fidl::encoding::DefaultFuchsiaResourceDialect,
1948                0x2c60b82a4ecfaebe,
1949            >(_buf?)?;
1950            Ok(_response.address)
1951        }
1952        self.client
1953            .send_query_and_decode::<fidl::encoding::EmptyPayload, fidl_fuchsia_net::MacAddress>(
1954                (),
1955                0x2c60b82a4ecfaebe,
1956                fidl::encoding::DynamicFlags::empty(),
1957                _decode,
1958            )
1959    }
1960
1961    type SetModeResponseFut =
1962        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
1963    fn r#set_mode(&self, mut mode: MacFilterMode) -> Self::SetModeResponseFut {
1964        fn _decode(
1965            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1966        ) -> Result<i32, fidl::Error> {
1967            let _response = fidl::client::decode_transaction_body::<
1968                MacAddressingSetModeResponse,
1969                fidl::encoding::DefaultFuchsiaResourceDialect,
1970                0x6297b8dbf03c58c,
1971            >(_buf?)?;
1972            Ok(_response.status)
1973        }
1974        self.client.send_query_and_decode::<MacAddressingSetModeRequest, i32>(
1975            (mode,),
1976            0x6297b8dbf03c58c,
1977            fidl::encoding::DynamicFlags::empty(),
1978            _decode,
1979        )
1980    }
1981
1982    type AddMulticastAddressResponseFut =
1983        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
1984    fn r#add_multicast_address(
1985        &self,
1986        mut address: &fidl_fuchsia_net::MacAddress,
1987    ) -> Self::AddMulticastAddressResponseFut {
1988        fn _decode(
1989            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1990        ) -> Result<i32, fidl::Error> {
1991            let _response = fidl::client::decode_transaction_body::<
1992                MacAddressingAddMulticastAddressResponse,
1993                fidl::encoding::DefaultFuchsiaResourceDialect,
1994                0xf5637ff11cf0c25,
1995            >(_buf?)?;
1996            Ok(_response.status)
1997        }
1998        self.client.send_query_and_decode::<MacAddressingAddMulticastAddressRequest, i32>(
1999            (address,),
2000            0xf5637ff11cf0c25,
2001            fidl::encoding::DynamicFlags::empty(),
2002            _decode,
2003        )
2004    }
2005
2006    type RemoveMulticastAddressResponseFut =
2007        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
2008    fn r#remove_multicast_address(
2009        &self,
2010        mut address: &fidl_fuchsia_net::MacAddress,
2011    ) -> Self::RemoveMulticastAddressResponseFut {
2012        fn _decode(
2013            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2014        ) -> Result<i32, fidl::Error> {
2015            let _response = fidl::client::decode_transaction_body::<
2016                MacAddressingRemoveMulticastAddressResponse,
2017                fidl::encoding::DefaultFuchsiaResourceDialect,
2018                0x5dddf4e3ba4e2560,
2019            >(_buf?)?;
2020            Ok(_response.status)
2021        }
2022        self.client.send_query_and_decode::<MacAddressingRemoveMulticastAddressRequest, i32>(
2023            (address,),
2024            0x5dddf4e3ba4e2560,
2025            fidl::encoding::DynamicFlags::empty(),
2026            _decode,
2027        )
2028    }
2029}
2030
2031pub struct MacAddressingEventStream {
2032    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2033}
2034
2035impl std::marker::Unpin for MacAddressingEventStream {}
2036
2037impl futures::stream::FusedStream for MacAddressingEventStream {
2038    fn is_terminated(&self) -> bool {
2039        self.event_receiver.is_terminated()
2040    }
2041}
2042
2043impl futures::Stream for MacAddressingEventStream {
2044    type Item = Result<MacAddressingEvent, fidl::Error>;
2045
2046    fn poll_next(
2047        mut self: std::pin::Pin<&mut Self>,
2048        cx: &mut std::task::Context<'_>,
2049    ) -> std::task::Poll<Option<Self::Item>> {
2050        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2051            &mut self.event_receiver,
2052            cx
2053        )?) {
2054            Some(buf) => std::task::Poll::Ready(Some(MacAddressingEvent::decode(buf))),
2055            None => std::task::Poll::Ready(None),
2056        }
2057    }
2058}
2059
2060#[derive(Debug)]
2061pub enum MacAddressingEvent {}
2062
2063impl MacAddressingEvent {
2064    /// Decodes a message buffer as a [`MacAddressingEvent`].
2065    fn decode(
2066        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2067    ) -> Result<MacAddressingEvent, fidl::Error> {
2068        let (bytes, _handles) = buf.split_mut();
2069        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2070        debug_assert_eq!(tx_header.tx_id, 0);
2071        match tx_header.ordinal {
2072            _ => Err(fidl::Error::UnknownOrdinal {
2073                ordinal: tx_header.ordinal,
2074                protocol_name: <MacAddressingMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2075            }),
2076        }
2077    }
2078}
2079
2080/// A Stream of incoming requests for fuchsia.hardware.network/MacAddressing.
2081pub struct MacAddressingRequestStream {
2082    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2083    is_terminated: bool,
2084}
2085
2086impl std::marker::Unpin for MacAddressingRequestStream {}
2087
2088impl futures::stream::FusedStream for MacAddressingRequestStream {
2089    fn is_terminated(&self) -> bool {
2090        self.is_terminated
2091    }
2092}
2093
2094impl fidl::endpoints::RequestStream for MacAddressingRequestStream {
2095    type Protocol = MacAddressingMarker;
2096    type ControlHandle = MacAddressingControlHandle;
2097
2098    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2099        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2100    }
2101
2102    fn control_handle(&self) -> Self::ControlHandle {
2103        MacAddressingControlHandle { inner: self.inner.clone() }
2104    }
2105
2106    fn into_inner(
2107        self,
2108    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2109    {
2110        (self.inner, self.is_terminated)
2111    }
2112
2113    fn from_inner(
2114        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2115        is_terminated: bool,
2116    ) -> Self {
2117        Self { inner, is_terminated }
2118    }
2119}
2120
2121impl futures::Stream for MacAddressingRequestStream {
2122    type Item = Result<MacAddressingRequest, fidl::Error>;
2123
2124    fn poll_next(
2125        mut self: std::pin::Pin<&mut Self>,
2126        cx: &mut std::task::Context<'_>,
2127    ) -> std::task::Poll<Option<Self::Item>> {
2128        let this = &mut *self;
2129        if this.inner.check_shutdown(cx) {
2130            this.is_terminated = true;
2131            return std::task::Poll::Ready(None);
2132        }
2133        if this.is_terminated {
2134            panic!("polled MacAddressingRequestStream after completion");
2135        }
2136        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2137            |bytes, handles| {
2138                match this.inner.channel().read_etc(cx, bytes, handles) {
2139                    std::task::Poll::Ready(Ok(())) => {}
2140                    std::task::Poll::Pending => return std::task::Poll::Pending,
2141                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2142                        this.is_terminated = true;
2143                        return std::task::Poll::Ready(None);
2144                    }
2145                    std::task::Poll::Ready(Err(e)) => {
2146                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2147                            e.into(),
2148                        ))));
2149                    }
2150                }
2151
2152                // A message has been received from the channel
2153                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2154
2155                std::task::Poll::Ready(Some(match header.ordinal {
2156                    0x2c60b82a4ecfaebe => {
2157                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2158                        let mut req = fidl::new_empty!(
2159                            fidl::encoding::EmptyPayload,
2160                            fidl::encoding::DefaultFuchsiaResourceDialect
2161                        );
2162                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2163                        let control_handle =
2164                            MacAddressingControlHandle { inner: this.inner.clone() };
2165                        Ok(MacAddressingRequest::GetUnicastAddress {
2166                            responder: MacAddressingGetUnicastAddressResponder {
2167                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2168                                tx_id: header.tx_id,
2169                            },
2170                        })
2171                    }
2172                    0x6297b8dbf03c58c => {
2173                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2174                        let mut req = fidl::new_empty!(
2175                            MacAddressingSetModeRequest,
2176                            fidl::encoding::DefaultFuchsiaResourceDialect
2177                        );
2178                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MacAddressingSetModeRequest>(&header, _body_bytes, handles, &mut req)?;
2179                        let control_handle =
2180                            MacAddressingControlHandle { inner: this.inner.clone() };
2181                        Ok(MacAddressingRequest::SetMode {
2182                            mode: req.mode,
2183
2184                            responder: MacAddressingSetModeResponder {
2185                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2186                                tx_id: header.tx_id,
2187                            },
2188                        })
2189                    }
2190                    0xf5637ff11cf0c25 => {
2191                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2192                        let mut req = fidl::new_empty!(
2193                            MacAddressingAddMulticastAddressRequest,
2194                            fidl::encoding::DefaultFuchsiaResourceDialect
2195                        );
2196                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MacAddressingAddMulticastAddressRequest>(&header, _body_bytes, handles, &mut req)?;
2197                        let control_handle =
2198                            MacAddressingControlHandle { inner: this.inner.clone() };
2199                        Ok(MacAddressingRequest::AddMulticastAddress {
2200                            address: req.address,
2201
2202                            responder: MacAddressingAddMulticastAddressResponder {
2203                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2204                                tx_id: header.tx_id,
2205                            },
2206                        })
2207                    }
2208                    0x5dddf4e3ba4e2560 => {
2209                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2210                        let mut req = fidl::new_empty!(
2211                            MacAddressingRemoveMulticastAddressRequest,
2212                            fidl::encoding::DefaultFuchsiaResourceDialect
2213                        );
2214                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MacAddressingRemoveMulticastAddressRequest>(&header, _body_bytes, handles, &mut req)?;
2215                        let control_handle =
2216                            MacAddressingControlHandle { inner: this.inner.clone() };
2217                        Ok(MacAddressingRequest::RemoveMulticastAddress {
2218                            address: req.address,
2219
2220                            responder: MacAddressingRemoveMulticastAddressResponder {
2221                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2222                                tx_id: header.tx_id,
2223                            },
2224                        })
2225                    }
2226                    _ => Err(fidl::Error::UnknownOrdinal {
2227                        ordinal: header.ordinal,
2228                        protocol_name:
2229                            <MacAddressingMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2230                    }),
2231                }))
2232            },
2233        )
2234    }
2235}
2236
2237#[derive(Debug)]
2238pub enum MacAddressingRequest {
2239    /// Gets the Device's current unicast MAC address.
2240    ///
2241    /// Implementers of this API do not need to return a uniquely identifiable
2242    /// MAC; the unicast address returned is the one that is *currently* in use
2243    /// to filter unicast frames, or that identifies the device on a link it's
2244    /// *currently* on. Users of this API must not rely on the stability or
2245    /// uniqueness of the returned value to identify or disambiguate device
2246    /// instances.
2247    ///
2248    /// - response `address` device's unicast MAC address.
2249    GetUnicastAddress { responder: MacAddressingGetUnicastAddressResponder },
2250    /// Sets requested operating mode of this device to `mode`.
2251    ///
2252    /// The requested mode is attached to the current client connection to the
2253    /// device. Because multiple clients can be attached to the same device at
2254    /// once, the mode with the least restrictions is the one actively put into
2255    /// effect into the underlying device implementation.
2256    ///
2257    /// If the device does not support the requested mode, but supports a mode
2258    /// that is more open than the requested one, `SetMode` succeeds regardless.
2259    /// Otherwise, if the device only supports *more restrictive* modes than the
2260    /// one requested, `SetMode` returns `ZX_ERR_NOT_SUPPORTED`.
2261    ///
2262    /// Clients must be aware that the resource being accessed is shared, and
2263    /// that the device may be effectively operating at a more open level than
2264    /// the one that was requested (although never at one more restrictive).
2265    ///
2266    /// + request `mode` request mode to attach to.
2267    /// - response `status` `ZX_ERR_NOT_SUPPORTED` it the device only supports
2268    /// mode more restrictive than the one requested.
2269    SetMode { mode: MacFilterMode, responder: MacAddressingSetModeResponder },
2270    /// Adds multicast address to the list of multicast groups.
2271    ///
2272    /// The list of multicast addresses kept is untouched by calls to `SetMode`.
2273    /// If the device's mode is not `MULTICAST_FILTER`, the list of multicast
2274    /// addresses is ignored.
2275    ///
2276    /// + request `address` multicast address to add to the list.
2277    /// - response `status` `ZX_ERR_INVALID_ARGS` if `address` is not a
2278    /// multicast address.
2279    /// - response `status` `ZX_ERR_NO_RESOURCES` if there are more than
2280    /// `MAX_MAC_FILTER` addresses installed.
2281    AddMulticastAddress {
2282        address: fidl_fuchsia_net::MacAddress,
2283        responder: MacAddressingAddMulticastAddressResponder,
2284    },
2285    /// Removes multicast address from the list of multicast groups.
2286    ///
2287    /// + request `address` multicast address to remove from the list.
2288    /// - response `status` `ZX_ERR_INVALID_ARGS` if `address` is not a
2289    /// multicast address.
2290    RemoveMulticastAddress {
2291        address: fidl_fuchsia_net::MacAddress,
2292        responder: MacAddressingRemoveMulticastAddressResponder,
2293    },
2294}
2295
2296impl MacAddressingRequest {
2297    #[allow(irrefutable_let_patterns)]
2298    pub fn into_get_unicast_address(self) -> Option<(MacAddressingGetUnicastAddressResponder)> {
2299        if let MacAddressingRequest::GetUnicastAddress { responder } = self {
2300            Some((responder))
2301        } else {
2302            None
2303        }
2304    }
2305
2306    #[allow(irrefutable_let_patterns)]
2307    pub fn into_set_mode(self) -> Option<(MacFilterMode, MacAddressingSetModeResponder)> {
2308        if let MacAddressingRequest::SetMode { mode, responder } = self {
2309            Some((mode, responder))
2310        } else {
2311            None
2312        }
2313    }
2314
2315    #[allow(irrefutable_let_patterns)]
2316    pub fn into_add_multicast_address(
2317        self,
2318    ) -> Option<(fidl_fuchsia_net::MacAddress, MacAddressingAddMulticastAddressResponder)> {
2319        if let MacAddressingRequest::AddMulticastAddress { address, responder } = self {
2320            Some((address, responder))
2321        } else {
2322            None
2323        }
2324    }
2325
2326    #[allow(irrefutable_let_patterns)]
2327    pub fn into_remove_multicast_address(
2328        self,
2329    ) -> Option<(fidl_fuchsia_net::MacAddress, MacAddressingRemoveMulticastAddressResponder)> {
2330        if let MacAddressingRequest::RemoveMulticastAddress { address, responder } = self {
2331            Some((address, responder))
2332        } else {
2333            None
2334        }
2335    }
2336
2337    /// Name of the method defined in FIDL
2338    pub fn method_name(&self) -> &'static str {
2339        match *self {
2340            MacAddressingRequest::GetUnicastAddress { .. } => "get_unicast_address",
2341            MacAddressingRequest::SetMode { .. } => "set_mode",
2342            MacAddressingRequest::AddMulticastAddress { .. } => "add_multicast_address",
2343            MacAddressingRequest::RemoveMulticastAddress { .. } => "remove_multicast_address",
2344        }
2345    }
2346}
2347
2348#[derive(Debug, Clone)]
2349pub struct MacAddressingControlHandle {
2350    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2351}
2352
2353impl fidl::endpoints::ControlHandle for MacAddressingControlHandle {
2354    fn shutdown(&self) {
2355        self.inner.shutdown()
2356    }
2357
2358    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2359        self.inner.shutdown_with_epitaph(status)
2360    }
2361
2362    fn is_closed(&self) -> bool {
2363        self.inner.channel().is_closed()
2364    }
2365    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2366        self.inner.channel().on_closed()
2367    }
2368
2369    #[cfg(target_os = "fuchsia")]
2370    fn signal_peer(
2371        &self,
2372        clear_mask: zx::Signals,
2373        set_mask: zx::Signals,
2374    ) -> Result<(), zx_status::Status> {
2375        use fidl::Peered;
2376        self.inner.channel().signal_peer(clear_mask, set_mask)
2377    }
2378}
2379
2380impl MacAddressingControlHandle {}
2381
2382#[must_use = "FIDL methods require a response to be sent"]
2383#[derive(Debug)]
2384pub struct MacAddressingGetUnicastAddressResponder {
2385    control_handle: std::mem::ManuallyDrop<MacAddressingControlHandle>,
2386    tx_id: u32,
2387}
2388
2389/// Set the the channel to be shutdown (see [`MacAddressingControlHandle::shutdown`])
2390/// if the responder is dropped without sending a response, so that the client
2391/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2392impl std::ops::Drop for MacAddressingGetUnicastAddressResponder {
2393    fn drop(&mut self) {
2394        self.control_handle.shutdown();
2395        // Safety: drops once, never accessed again
2396        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2397    }
2398}
2399
2400impl fidl::endpoints::Responder for MacAddressingGetUnicastAddressResponder {
2401    type ControlHandle = MacAddressingControlHandle;
2402
2403    fn control_handle(&self) -> &MacAddressingControlHandle {
2404        &self.control_handle
2405    }
2406
2407    fn drop_without_shutdown(mut self) {
2408        // Safety: drops once, never accessed again due to mem::forget
2409        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2410        // Prevent Drop from running (which would shut down the channel)
2411        std::mem::forget(self);
2412    }
2413}
2414
2415impl MacAddressingGetUnicastAddressResponder {
2416    /// Sends a response to the FIDL transaction.
2417    ///
2418    /// Sets the channel to shutdown if an error occurs.
2419    pub fn send(self, mut address: &fidl_fuchsia_net::MacAddress) -> Result<(), fidl::Error> {
2420        let _result = self.send_raw(address);
2421        if _result.is_err() {
2422            self.control_handle.shutdown();
2423        }
2424        self.drop_without_shutdown();
2425        _result
2426    }
2427
2428    /// Similar to "send" but does not shutdown the channel if an error occurs.
2429    pub fn send_no_shutdown_on_err(
2430        self,
2431        mut address: &fidl_fuchsia_net::MacAddress,
2432    ) -> Result<(), fidl::Error> {
2433        let _result = self.send_raw(address);
2434        self.drop_without_shutdown();
2435        _result
2436    }
2437
2438    fn send_raw(&self, mut address: &fidl_fuchsia_net::MacAddress) -> Result<(), fidl::Error> {
2439        self.control_handle.inner.send::<MacAddressingGetUnicastAddressResponse>(
2440            (address,),
2441            self.tx_id,
2442            0x2c60b82a4ecfaebe,
2443            fidl::encoding::DynamicFlags::empty(),
2444        )
2445    }
2446}
2447
2448#[must_use = "FIDL methods require a response to be sent"]
2449#[derive(Debug)]
2450pub struct MacAddressingSetModeResponder {
2451    control_handle: std::mem::ManuallyDrop<MacAddressingControlHandle>,
2452    tx_id: u32,
2453}
2454
2455/// Set the the channel to be shutdown (see [`MacAddressingControlHandle::shutdown`])
2456/// if the responder is dropped without sending a response, so that the client
2457/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2458impl std::ops::Drop for MacAddressingSetModeResponder {
2459    fn drop(&mut self) {
2460        self.control_handle.shutdown();
2461        // Safety: drops once, never accessed again
2462        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2463    }
2464}
2465
2466impl fidl::endpoints::Responder for MacAddressingSetModeResponder {
2467    type ControlHandle = MacAddressingControlHandle;
2468
2469    fn control_handle(&self) -> &MacAddressingControlHandle {
2470        &self.control_handle
2471    }
2472
2473    fn drop_without_shutdown(mut self) {
2474        // Safety: drops once, never accessed again due to mem::forget
2475        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2476        // Prevent Drop from running (which would shut down the channel)
2477        std::mem::forget(self);
2478    }
2479}
2480
2481impl MacAddressingSetModeResponder {
2482    /// Sends a response to the FIDL transaction.
2483    ///
2484    /// Sets the channel to shutdown if an error occurs.
2485    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
2486        let _result = self.send_raw(status);
2487        if _result.is_err() {
2488            self.control_handle.shutdown();
2489        }
2490        self.drop_without_shutdown();
2491        _result
2492    }
2493
2494    /// Similar to "send" but does not shutdown the channel if an error occurs.
2495    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
2496        let _result = self.send_raw(status);
2497        self.drop_without_shutdown();
2498        _result
2499    }
2500
2501    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
2502        self.control_handle.inner.send::<MacAddressingSetModeResponse>(
2503            (status,),
2504            self.tx_id,
2505            0x6297b8dbf03c58c,
2506            fidl::encoding::DynamicFlags::empty(),
2507        )
2508    }
2509}
2510
2511#[must_use = "FIDL methods require a response to be sent"]
2512#[derive(Debug)]
2513pub struct MacAddressingAddMulticastAddressResponder {
2514    control_handle: std::mem::ManuallyDrop<MacAddressingControlHandle>,
2515    tx_id: u32,
2516}
2517
2518/// Set the the channel to be shutdown (see [`MacAddressingControlHandle::shutdown`])
2519/// if the responder is dropped without sending a response, so that the client
2520/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2521impl std::ops::Drop for MacAddressingAddMulticastAddressResponder {
2522    fn drop(&mut self) {
2523        self.control_handle.shutdown();
2524        // Safety: drops once, never accessed again
2525        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2526    }
2527}
2528
2529impl fidl::endpoints::Responder for MacAddressingAddMulticastAddressResponder {
2530    type ControlHandle = MacAddressingControlHandle;
2531
2532    fn control_handle(&self) -> &MacAddressingControlHandle {
2533        &self.control_handle
2534    }
2535
2536    fn drop_without_shutdown(mut self) {
2537        // Safety: drops once, never accessed again due to mem::forget
2538        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2539        // Prevent Drop from running (which would shut down the channel)
2540        std::mem::forget(self);
2541    }
2542}
2543
2544impl MacAddressingAddMulticastAddressResponder {
2545    /// Sends a response to the FIDL transaction.
2546    ///
2547    /// Sets the channel to shutdown if an error occurs.
2548    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
2549        let _result = self.send_raw(status);
2550        if _result.is_err() {
2551            self.control_handle.shutdown();
2552        }
2553        self.drop_without_shutdown();
2554        _result
2555    }
2556
2557    /// Similar to "send" but does not shutdown the channel if an error occurs.
2558    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
2559        let _result = self.send_raw(status);
2560        self.drop_without_shutdown();
2561        _result
2562    }
2563
2564    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
2565        self.control_handle.inner.send::<MacAddressingAddMulticastAddressResponse>(
2566            (status,),
2567            self.tx_id,
2568            0xf5637ff11cf0c25,
2569            fidl::encoding::DynamicFlags::empty(),
2570        )
2571    }
2572}
2573
2574#[must_use = "FIDL methods require a response to be sent"]
2575#[derive(Debug)]
2576pub struct MacAddressingRemoveMulticastAddressResponder {
2577    control_handle: std::mem::ManuallyDrop<MacAddressingControlHandle>,
2578    tx_id: u32,
2579}
2580
2581/// Set the the channel to be shutdown (see [`MacAddressingControlHandle::shutdown`])
2582/// if the responder is dropped without sending a response, so that the client
2583/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2584impl std::ops::Drop for MacAddressingRemoveMulticastAddressResponder {
2585    fn drop(&mut self) {
2586        self.control_handle.shutdown();
2587        // Safety: drops once, never accessed again
2588        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2589    }
2590}
2591
2592impl fidl::endpoints::Responder for MacAddressingRemoveMulticastAddressResponder {
2593    type ControlHandle = MacAddressingControlHandle;
2594
2595    fn control_handle(&self) -> &MacAddressingControlHandle {
2596        &self.control_handle
2597    }
2598
2599    fn drop_without_shutdown(mut self) {
2600        // Safety: drops once, never accessed again due to mem::forget
2601        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2602        // Prevent Drop from running (which would shut down the channel)
2603        std::mem::forget(self);
2604    }
2605}
2606
2607impl MacAddressingRemoveMulticastAddressResponder {
2608    /// Sends a response to the FIDL transaction.
2609    ///
2610    /// Sets the channel to shutdown if an error occurs.
2611    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
2612        let _result = self.send_raw(status);
2613        if _result.is_err() {
2614            self.control_handle.shutdown();
2615        }
2616        self.drop_without_shutdown();
2617        _result
2618    }
2619
2620    /// Similar to "send" but does not shutdown the channel if an error occurs.
2621    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
2622        let _result = self.send_raw(status);
2623        self.drop_without_shutdown();
2624        _result
2625    }
2626
2627    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
2628        self.control_handle.inner.send::<MacAddressingRemoveMulticastAddressResponse>(
2629            (status,),
2630            self.tx_id,
2631            0x5dddf4e3ba4e2560,
2632            fidl::encoding::DynamicFlags::empty(),
2633        )
2634    }
2635}
2636
2637#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2638pub struct PortMarker;
2639
2640impl fidl::endpoints::ProtocolMarker for PortMarker {
2641    type Proxy = PortProxy;
2642    type RequestStream = PortRequestStream;
2643    #[cfg(target_os = "fuchsia")]
2644    type SynchronousProxy = PortSynchronousProxy;
2645
2646    const DEBUG_NAME: &'static str = "(anonymous) Port";
2647}
2648
2649pub trait PortProxyInterface: Send + Sync {
2650    type GetInfoResponseFut: std::future::Future<Output = Result<PortInfo, fidl::Error>> + Send;
2651    fn r#get_info(&self) -> Self::GetInfoResponseFut;
2652    type GetStatusResponseFut: std::future::Future<Output = Result<PortStatus, fidl::Error>> + Send;
2653    fn r#get_status(&self) -> Self::GetStatusResponseFut;
2654    fn r#get_status_watcher(
2655        &self,
2656        watcher: fidl::endpoints::ServerEnd<StatusWatcherMarker>,
2657        buffer: u32,
2658    ) -> Result<(), fidl::Error>;
2659    fn r#get_mac(
2660        &self,
2661        mac: fidl::endpoints::ServerEnd<MacAddressingMarker>,
2662    ) -> Result<(), fidl::Error>;
2663    fn r#get_device(
2664        &self,
2665        device: fidl::endpoints::ServerEnd<DeviceMarker>,
2666    ) -> Result<(), fidl::Error>;
2667    fn r#clone(&self, port: fidl::endpoints::ServerEnd<PortMarker>) -> Result<(), fidl::Error>;
2668    type GetCountersResponseFut: std::future::Future<Output = Result<PortGetCountersResponse, fidl::Error>>
2669        + Send;
2670    fn r#get_counters(&self) -> Self::GetCountersResponseFut;
2671    fn r#get_diagnostics(
2672        &self,
2673        diagnostics: fidl::endpoints::ServerEnd<DiagnosticsMarker>,
2674    ) -> Result<(), fidl::Error>;
2675    type GetIdentityResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>>
2676        + Send;
2677    fn r#get_identity(&self) -> Self::GetIdentityResponseFut;
2678}
2679#[derive(Debug)]
2680#[cfg(target_os = "fuchsia")]
2681pub struct PortSynchronousProxy {
2682    client: fidl::client::sync::Client,
2683}
2684
2685#[cfg(target_os = "fuchsia")]
2686impl fidl::endpoints::SynchronousProxy for PortSynchronousProxy {
2687    type Proxy = PortProxy;
2688    type Protocol = PortMarker;
2689
2690    fn from_channel(inner: fidl::Channel) -> Self {
2691        Self::new(inner)
2692    }
2693
2694    fn into_channel(self) -> fidl::Channel {
2695        self.client.into_channel()
2696    }
2697
2698    fn as_channel(&self) -> &fidl::Channel {
2699        self.client.as_channel()
2700    }
2701}
2702
2703#[cfg(target_os = "fuchsia")]
2704impl PortSynchronousProxy {
2705    pub fn new(channel: fidl::Channel) -> Self {
2706        Self { client: fidl::client::sync::Client::new(channel) }
2707    }
2708
2709    pub fn into_channel(self) -> fidl::Channel {
2710        self.client.into_channel()
2711    }
2712
2713    /// Waits until an event arrives and returns it. It is safe for other
2714    /// threads to make concurrent requests while waiting for an event.
2715    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<PortEvent, fidl::Error> {
2716        PortEvent::decode(self.client.wait_for_event::<PortMarker>(deadline)?)
2717    }
2718
2719    /// Obtain information about port.
2720    ///
2721    /// - response `info` port information.
2722    pub fn r#get_info(&self, ___deadline: zx::MonotonicInstant) -> Result<PortInfo, fidl::Error> {
2723        let _response = self
2724            .client
2725            .send_query::<fidl::encoding::EmptyPayload, PortGetInfoResponse, PortMarker>(
2726                (),
2727                0x276cf65feb554ebd,
2728                fidl::encoding::DynamicFlags::empty(),
2729                ___deadline,
2730            )?;
2731        Ok(_response.info)
2732    }
2733
2734    /// Obtain the operating port status.
2735    ///
2736    /// - response `status` snapshot of port's current status.
2737    pub fn r#get_status(
2738        &self,
2739        ___deadline: zx::MonotonicInstant,
2740    ) -> Result<PortStatus, fidl::Error> {
2741        let _response = self
2742            .client
2743            .send_query::<fidl::encoding::EmptyPayload, PortGetStatusResponse, PortMarker>(
2744                (),
2745                0x4235650aacca60b2,
2746                fidl::encoding::DynamicFlags::empty(),
2747                ___deadline,
2748            )?;
2749        Ok(_response.status)
2750    }
2751
2752    /// Connects to a [`StatusWatcher`] to observe port status changes.
2753    ///
2754    /// + request `watcher` handle to the status watcher.
2755    /// + request `buffer` the number of status changes that the client requests
2756    /// to be stored by `StatusWatcher`. Values are capped at
2757    /// [`MAX_STATUS_BUFFER`]. A value of 0 or 1 causes the `StatusWatcher` to
2758    /// not keep any buffers on status changed. Clients that need to observe all
2759    /// changes to status (as opposed to only the current state) are encouraged
2760    /// to set a buffer value larger than 1, so that all edges can be observed.
2761    /// If `StatusWatcher`'s internal queue is filled and new status changes
2762    /// occur, the oldest samples will be dropped to make room for new ones.
2763    pub fn r#get_status_watcher(
2764        &self,
2765        mut watcher: fidl::endpoints::ServerEnd<StatusWatcherMarker>,
2766        mut buffer: u32,
2767    ) -> Result<(), fidl::Error> {
2768        self.client.send::<PortGetStatusWatcherRequest>(
2769            (watcher, buffer),
2770            0x65511ab81c1bd8d4,
2771            fidl::encoding::DynamicFlags::empty(),
2772        )
2773    }
2774
2775    /// Connects to a [`MacAddressing`] associated with the port.
2776    ///
2777    /// + request `mac` mac handle. Closed with `ZX_ERR_NOT_SUPPORTED` if this
2778    /// port does not support mac addressing.
2779    pub fn r#get_mac(
2780        &self,
2781        mut mac: fidl::endpoints::ServerEnd<MacAddressingMarker>,
2782    ) -> Result<(), fidl::Error> {
2783        self.client.send::<PortGetMacRequest>(
2784            (mac,),
2785            0x2c6ec2988aefc0f6,
2786            fidl::encoding::DynamicFlags::empty(),
2787        )
2788    }
2789
2790    /// Connects to the [`Device`] this port belongs to.
2791    ///
2792    /// + request `device` grants access to the parent device.
2793    pub fn r#get_device(
2794        &self,
2795        mut device: fidl::endpoints::ServerEnd<DeviceMarker>,
2796    ) -> Result<(), fidl::Error> {
2797        self.client.send::<PortGetDeviceRequest>(
2798            (device,),
2799            0x7de34747235d2d80,
2800            fidl::encoding::DynamicFlags::empty(),
2801        )
2802    }
2803
2804    /// Establishes a new connection to this port.
2805    ///
2806    /// + request `port` the server end for the new connection.
2807    pub fn r#clone(
2808        &self,
2809        mut port: fidl::endpoints::ServerEnd<PortMarker>,
2810    ) -> Result<(), fidl::Error> {
2811        self.client.send::<PortCloneRequest>(
2812            (port,),
2813            0x4e4764150b4942d3,
2814            fidl::encoding::DynamicFlags::empty(),
2815        )
2816    }
2817
2818    /// Retrieves a snapshot of traffic counters on this port.
2819    pub fn r#get_counters(
2820        &self,
2821        ___deadline: zx::MonotonicInstant,
2822    ) -> Result<PortGetCountersResponse, fidl::Error> {
2823        let _response = self
2824            .client
2825            .send_query::<fidl::encoding::EmptyPayload, PortGetCountersResponse, PortMarker>(
2826                (),
2827                0x6a213b03c4fcbbac,
2828                fidl::encoding::DynamicFlags::empty(),
2829                ___deadline,
2830            )?;
2831        Ok(_response)
2832    }
2833
2834    /// Grants access to [`Diagnostics`] for this port.
2835    ///
2836    /// + request `diagnostics` grants access to diagnostics information.
2837    pub fn r#get_diagnostics(
2838        &self,
2839        mut diagnostics: fidl::endpoints::ServerEnd<DiagnosticsMarker>,
2840    ) -> Result<(), fidl::Error> {
2841        self.client.send::<PortGetDiagnosticsRequest>(
2842            (diagnostics,),
2843            0x381faa4ed75e399c,
2844            fidl::encoding::DynamicFlags::empty(),
2845        )
2846    }
2847
2848    /// Retrieves a unique event handle that is always associated only with
2849    /// this port.
2850    ///
2851    /// This event may be used to uniquely identify a specific port instance
2852    /// across different APIs in the system.
2853    pub fn r#get_identity(
2854        &self,
2855        ___deadline: zx::MonotonicInstant,
2856    ) -> Result<fidl::Event, fidl::Error> {
2857        let _response = self
2858            .client
2859            .send_query::<fidl::encoding::EmptyPayload, PortGetIdentityResponse, PortMarker>(
2860                (),
2861                0x75134ce0bc114e5a,
2862                fidl::encoding::DynamicFlags::empty(),
2863                ___deadline,
2864            )?;
2865        Ok(_response.event)
2866    }
2867}
2868
2869#[cfg(target_os = "fuchsia")]
2870impl From<PortSynchronousProxy> for zx::NullableHandle {
2871    fn from(value: PortSynchronousProxy) -> Self {
2872        value.into_channel().into()
2873    }
2874}
2875
2876#[cfg(target_os = "fuchsia")]
2877impl From<fidl::Channel> for PortSynchronousProxy {
2878    fn from(value: fidl::Channel) -> Self {
2879        Self::new(value)
2880    }
2881}
2882
2883#[cfg(target_os = "fuchsia")]
2884impl fidl::endpoints::FromClient for PortSynchronousProxy {
2885    type Protocol = PortMarker;
2886
2887    fn from_client(value: fidl::endpoints::ClientEnd<PortMarker>) -> Self {
2888        Self::new(value.into_channel())
2889    }
2890}
2891
2892#[derive(Debug, Clone)]
2893pub struct PortProxy {
2894    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2895}
2896
2897impl fidl::endpoints::Proxy for PortProxy {
2898    type Protocol = PortMarker;
2899
2900    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2901        Self::new(inner)
2902    }
2903
2904    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2905        self.client.into_channel().map_err(|client| Self { client })
2906    }
2907
2908    fn as_channel(&self) -> &::fidl::AsyncChannel {
2909        self.client.as_channel()
2910    }
2911}
2912
2913impl PortProxy {
2914    /// Create a new Proxy for fuchsia.hardware.network/Port.
2915    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2916        let protocol_name = <PortMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2917        Self { client: fidl::client::Client::new(channel, protocol_name) }
2918    }
2919
2920    /// Get a Stream of events from the remote end of the protocol.
2921    ///
2922    /// # Panics
2923    ///
2924    /// Panics if the event stream was already taken.
2925    pub fn take_event_stream(&self) -> PortEventStream {
2926        PortEventStream { event_receiver: self.client.take_event_receiver() }
2927    }
2928
2929    /// Obtain information about port.
2930    ///
2931    /// - response `info` port information.
2932    pub fn r#get_info(
2933        &self,
2934    ) -> fidl::client::QueryResponseFut<PortInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
2935    {
2936        PortProxyInterface::r#get_info(self)
2937    }
2938
2939    /// Obtain the operating port status.
2940    ///
2941    /// - response `status` snapshot of port's current status.
2942    pub fn r#get_status(
2943        &self,
2944    ) -> fidl::client::QueryResponseFut<PortStatus, fidl::encoding::DefaultFuchsiaResourceDialect>
2945    {
2946        PortProxyInterface::r#get_status(self)
2947    }
2948
2949    /// Connects to a [`StatusWatcher`] to observe port status changes.
2950    ///
2951    /// + request `watcher` handle to the status watcher.
2952    /// + request `buffer` the number of status changes that the client requests
2953    /// to be stored by `StatusWatcher`. Values are capped at
2954    /// [`MAX_STATUS_BUFFER`]. A value of 0 or 1 causes the `StatusWatcher` to
2955    /// not keep any buffers on status changed. Clients that need to observe all
2956    /// changes to status (as opposed to only the current state) are encouraged
2957    /// to set a buffer value larger than 1, so that all edges can be observed.
2958    /// If `StatusWatcher`'s internal queue is filled and new status changes
2959    /// occur, the oldest samples will be dropped to make room for new ones.
2960    pub fn r#get_status_watcher(
2961        &self,
2962        mut watcher: fidl::endpoints::ServerEnd<StatusWatcherMarker>,
2963        mut buffer: u32,
2964    ) -> Result<(), fidl::Error> {
2965        PortProxyInterface::r#get_status_watcher(self, watcher, buffer)
2966    }
2967
2968    /// Connects to a [`MacAddressing`] associated with the port.
2969    ///
2970    /// + request `mac` mac handle. Closed with `ZX_ERR_NOT_SUPPORTED` if this
2971    /// port does not support mac addressing.
2972    pub fn r#get_mac(
2973        &self,
2974        mut mac: fidl::endpoints::ServerEnd<MacAddressingMarker>,
2975    ) -> Result<(), fidl::Error> {
2976        PortProxyInterface::r#get_mac(self, mac)
2977    }
2978
2979    /// Connects to the [`Device`] this port belongs to.
2980    ///
2981    /// + request `device` grants access to the parent device.
2982    pub fn r#get_device(
2983        &self,
2984        mut device: fidl::endpoints::ServerEnd<DeviceMarker>,
2985    ) -> Result<(), fidl::Error> {
2986        PortProxyInterface::r#get_device(self, device)
2987    }
2988
2989    /// Establishes a new connection to this port.
2990    ///
2991    /// + request `port` the server end for the new connection.
2992    pub fn r#clone(
2993        &self,
2994        mut port: fidl::endpoints::ServerEnd<PortMarker>,
2995    ) -> Result<(), fidl::Error> {
2996        PortProxyInterface::r#clone(self, port)
2997    }
2998
2999    /// Retrieves a snapshot of traffic counters on this port.
3000    pub fn r#get_counters(
3001        &self,
3002    ) -> fidl::client::QueryResponseFut<
3003        PortGetCountersResponse,
3004        fidl::encoding::DefaultFuchsiaResourceDialect,
3005    > {
3006        PortProxyInterface::r#get_counters(self)
3007    }
3008
3009    /// Grants access to [`Diagnostics`] for this port.
3010    ///
3011    /// + request `diagnostics` grants access to diagnostics information.
3012    pub fn r#get_diagnostics(
3013        &self,
3014        mut diagnostics: fidl::endpoints::ServerEnd<DiagnosticsMarker>,
3015    ) -> Result<(), fidl::Error> {
3016        PortProxyInterface::r#get_diagnostics(self, diagnostics)
3017    }
3018
3019    /// Retrieves a unique event handle that is always associated only with
3020    /// this port.
3021    ///
3022    /// This event may be used to uniquely identify a specific port instance
3023    /// across different APIs in the system.
3024    pub fn r#get_identity(
3025        &self,
3026    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
3027    {
3028        PortProxyInterface::r#get_identity(self)
3029    }
3030}
3031
3032impl PortProxyInterface for PortProxy {
3033    type GetInfoResponseFut =
3034        fidl::client::QueryResponseFut<PortInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
3035    fn r#get_info(&self) -> Self::GetInfoResponseFut {
3036        fn _decode(
3037            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3038        ) -> Result<PortInfo, fidl::Error> {
3039            let _response = fidl::client::decode_transaction_body::<
3040                PortGetInfoResponse,
3041                fidl::encoding::DefaultFuchsiaResourceDialect,
3042                0x276cf65feb554ebd,
3043            >(_buf?)?;
3044            Ok(_response.info)
3045        }
3046        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PortInfo>(
3047            (),
3048            0x276cf65feb554ebd,
3049            fidl::encoding::DynamicFlags::empty(),
3050            _decode,
3051        )
3052    }
3053
3054    type GetStatusResponseFut =
3055        fidl::client::QueryResponseFut<PortStatus, fidl::encoding::DefaultFuchsiaResourceDialect>;
3056    fn r#get_status(&self) -> Self::GetStatusResponseFut {
3057        fn _decode(
3058            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3059        ) -> Result<PortStatus, fidl::Error> {
3060            let _response = fidl::client::decode_transaction_body::<
3061                PortGetStatusResponse,
3062                fidl::encoding::DefaultFuchsiaResourceDialect,
3063                0x4235650aacca60b2,
3064            >(_buf?)?;
3065            Ok(_response.status)
3066        }
3067        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PortStatus>(
3068            (),
3069            0x4235650aacca60b2,
3070            fidl::encoding::DynamicFlags::empty(),
3071            _decode,
3072        )
3073    }
3074
3075    fn r#get_status_watcher(
3076        &self,
3077        mut watcher: fidl::endpoints::ServerEnd<StatusWatcherMarker>,
3078        mut buffer: u32,
3079    ) -> Result<(), fidl::Error> {
3080        self.client.send::<PortGetStatusWatcherRequest>(
3081            (watcher, buffer),
3082            0x65511ab81c1bd8d4,
3083            fidl::encoding::DynamicFlags::empty(),
3084        )
3085    }
3086
3087    fn r#get_mac(
3088        &self,
3089        mut mac: fidl::endpoints::ServerEnd<MacAddressingMarker>,
3090    ) -> Result<(), fidl::Error> {
3091        self.client.send::<PortGetMacRequest>(
3092            (mac,),
3093            0x2c6ec2988aefc0f6,
3094            fidl::encoding::DynamicFlags::empty(),
3095        )
3096    }
3097
3098    fn r#get_device(
3099        &self,
3100        mut device: fidl::endpoints::ServerEnd<DeviceMarker>,
3101    ) -> Result<(), fidl::Error> {
3102        self.client.send::<PortGetDeviceRequest>(
3103            (device,),
3104            0x7de34747235d2d80,
3105            fidl::encoding::DynamicFlags::empty(),
3106        )
3107    }
3108
3109    fn r#clone(&self, mut port: fidl::endpoints::ServerEnd<PortMarker>) -> Result<(), fidl::Error> {
3110        self.client.send::<PortCloneRequest>(
3111            (port,),
3112            0x4e4764150b4942d3,
3113            fidl::encoding::DynamicFlags::empty(),
3114        )
3115    }
3116
3117    type GetCountersResponseFut = fidl::client::QueryResponseFut<
3118        PortGetCountersResponse,
3119        fidl::encoding::DefaultFuchsiaResourceDialect,
3120    >;
3121    fn r#get_counters(&self) -> Self::GetCountersResponseFut {
3122        fn _decode(
3123            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3124        ) -> Result<PortGetCountersResponse, fidl::Error> {
3125            let _response = fidl::client::decode_transaction_body::<
3126                PortGetCountersResponse,
3127                fidl::encoding::DefaultFuchsiaResourceDialect,
3128                0x6a213b03c4fcbbac,
3129            >(_buf?)?;
3130            Ok(_response)
3131        }
3132        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PortGetCountersResponse>(
3133            (),
3134            0x6a213b03c4fcbbac,
3135            fidl::encoding::DynamicFlags::empty(),
3136            _decode,
3137        )
3138    }
3139
3140    fn r#get_diagnostics(
3141        &self,
3142        mut diagnostics: fidl::endpoints::ServerEnd<DiagnosticsMarker>,
3143    ) -> Result<(), fidl::Error> {
3144        self.client.send::<PortGetDiagnosticsRequest>(
3145            (diagnostics,),
3146            0x381faa4ed75e399c,
3147            fidl::encoding::DynamicFlags::empty(),
3148        )
3149    }
3150
3151    type GetIdentityResponseFut =
3152        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
3153    fn r#get_identity(&self) -> Self::GetIdentityResponseFut {
3154        fn _decode(
3155            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3156        ) -> Result<fidl::Event, fidl::Error> {
3157            let _response = fidl::client::decode_transaction_body::<
3158                PortGetIdentityResponse,
3159                fidl::encoding::DefaultFuchsiaResourceDialect,
3160                0x75134ce0bc114e5a,
3161            >(_buf?)?;
3162            Ok(_response.event)
3163        }
3164        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
3165            (),
3166            0x75134ce0bc114e5a,
3167            fidl::encoding::DynamicFlags::empty(),
3168            _decode,
3169        )
3170    }
3171}
3172
3173pub struct PortEventStream {
3174    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3175}
3176
3177impl std::marker::Unpin for PortEventStream {}
3178
3179impl futures::stream::FusedStream for PortEventStream {
3180    fn is_terminated(&self) -> bool {
3181        self.event_receiver.is_terminated()
3182    }
3183}
3184
3185impl futures::Stream for PortEventStream {
3186    type Item = Result<PortEvent, fidl::Error>;
3187
3188    fn poll_next(
3189        mut self: std::pin::Pin<&mut Self>,
3190        cx: &mut std::task::Context<'_>,
3191    ) -> std::task::Poll<Option<Self::Item>> {
3192        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3193            &mut self.event_receiver,
3194            cx
3195        )?) {
3196            Some(buf) => std::task::Poll::Ready(Some(PortEvent::decode(buf))),
3197            None => std::task::Poll::Ready(None),
3198        }
3199    }
3200}
3201
3202#[derive(Debug)]
3203pub enum PortEvent {}
3204
3205impl PortEvent {
3206    /// Decodes a message buffer as a [`PortEvent`].
3207    fn decode(
3208        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3209    ) -> Result<PortEvent, fidl::Error> {
3210        let (bytes, _handles) = buf.split_mut();
3211        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3212        debug_assert_eq!(tx_header.tx_id, 0);
3213        match tx_header.ordinal {
3214            _ => Err(fidl::Error::UnknownOrdinal {
3215                ordinal: tx_header.ordinal,
3216                protocol_name: <PortMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3217            }),
3218        }
3219    }
3220}
3221
3222/// A Stream of incoming requests for fuchsia.hardware.network/Port.
3223pub struct PortRequestStream {
3224    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3225    is_terminated: bool,
3226}
3227
3228impl std::marker::Unpin for PortRequestStream {}
3229
3230impl futures::stream::FusedStream for PortRequestStream {
3231    fn is_terminated(&self) -> bool {
3232        self.is_terminated
3233    }
3234}
3235
3236impl fidl::endpoints::RequestStream for PortRequestStream {
3237    type Protocol = PortMarker;
3238    type ControlHandle = PortControlHandle;
3239
3240    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3241        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3242    }
3243
3244    fn control_handle(&self) -> Self::ControlHandle {
3245        PortControlHandle { inner: self.inner.clone() }
3246    }
3247
3248    fn into_inner(
3249        self,
3250    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3251    {
3252        (self.inner, self.is_terminated)
3253    }
3254
3255    fn from_inner(
3256        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3257        is_terminated: bool,
3258    ) -> Self {
3259        Self { inner, is_terminated }
3260    }
3261}
3262
3263impl futures::Stream for PortRequestStream {
3264    type Item = Result<PortRequest, fidl::Error>;
3265
3266    fn poll_next(
3267        mut self: std::pin::Pin<&mut Self>,
3268        cx: &mut std::task::Context<'_>,
3269    ) -> std::task::Poll<Option<Self::Item>> {
3270        let this = &mut *self;
3271        if this.inner.check_shutdown(cx) {
3272            this.is_terminated = true;
3273            return std::task::Poll::Ready(None);
3274        }
3275        if this.is_terminated {
3276            panic!("polled PortRequestStream after completion");
3277        }
3278        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3279            |bytes, handles| {
3280                match this.inner.channel().read_etc(cx, bytes, handles) {
3281                    std::task::Poll::Ready(Ok(())) => {}
3282                    std::task::Poll::Pending => return std::task::Poll::Pending,
3283                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3284                        this.is_terminated = true;
3285                        return std::task::Poll::Ready(None);
3286                    }
3287                    std::task::Poll::Ready(Err(e)) => {
3288                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3289                            e.into(),
3290                        ))));
3291                    }
3292                }
3293
3294                // A message has been received from the channel
3295                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3296
3297                std::task::Poll::Ready(Some(match header.ordinal {
3298                    0x276cf65feb554ebd => {
3299                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3300                        let mut req = fidl::new_empty!(
3301                            fidl::encoding::EmptyPayload,
3302                            fidl::encoding::DefaultFuchsiaResourceDialect
3303                        );
3304                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3305                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3306                        Ok(PortRequest::GetInfo {
3307                            responder: PortGetInfoResponder {
3308                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3309                                tx_id: header.tx_id,
3310                            },
3311                        })
3312                    }
3313                    0x4235650aacca60b2 => {
3314                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3315                        let mut req = fidl::new_empty!(
3316                            fidl::encoding::EmptyPayload,
3317                            fidl::encoding::DefaultFuchsiaResourceDialect
3318                        );
3319                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3320                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3321                        Ok(PortRequest::GetStatus {
3322                            responder: PortGetStatusResponder {
3323                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3324                                tx_id: header.tx_id,
3325                            },
3326                        })
3327                    }
3328                    0x65511ab81c1bd8d4 => {
3329                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3330                        let mut req = fidl::new_empty!(
3331                            PortGetStatusWatcherRequest,
3332                            fidl::encoding::DefaultFuchsiaResourceDialect
3333                        );
3334                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PortGetStatusWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
3335                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3336                        Ok(PortRequest::GetStatusWatcher {
3337                            watcher: req.watcher,
3338                            buffer: req.buffer,
3339
3340                            control_handle,
3341                        })
3342                    }
3343                    0x2c6ec2988aefc0f6 => {
3344                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3345                        let mut req = fidl::new_empty!(
3346                            PortGetMacRequest,
3347                            fidl::encoding::DefaultFuchsiaResourceDialect
3348                        );
3349                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PortGetMacRequest>(&header, _body_bytes, handles, &mut req)?;
3350                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3351                        Ok(PortRequest::GetMac { mac: req.mac, control_handle })
3352                    }
3353                    0x7de34747235d2d80 => {
3354                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3355                        let mut req = fidl::new_empty!(
3356                            PortGetDeviceRequest,
3357                            fidl::encoding::DefaultFuchsiaResourceDialect
3358                        );
3359                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PortGetDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
3360                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3361                        Ok(PortRequest::GetDevice { device: req.device, control_handle })
3362                    }
3363                    0x4e4764150b4942d3 => {
3364                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3365                        let mut req = fidl::new_empty!(
3366                            PortCloneRequest,
3367                            fidl::encoding::DefaultFuchsiaResourceDialect
3368                        );
3369                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PortCloneRequest>(&header, _body_bytes, handles, &mut req)?;
3370                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3371                        Ok(PortRequest::Clone { port: req.port, control_handle })
3372                    }
3373                    0x6a213b03c4fcbbac => {
3374                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3375                        let mut req = fidl::new_empty!(
3376                            fidl::encoding::EmptyPayload,
3377                            fidl::encoding::DefaultFuchsiaResourceDialect
3378                        );
3379                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3380                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3381                        Ok(PortRequest::GetCounters {
3382                            responder: PortGetCountersResponder {
3383                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3384                                tx_id: header.tx_id,
3385                            },
3386                        })
3387                    }
3388                    0x381faa4ed75e399c => {
3389                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3390                        let mut req = fidl::new_empty!(
3391                            PortGetDiagnosticsRequest,
3392                            fidl::encoding::DefaultFuchsiaResourceDialect
3393                        );
3394                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PortGetDiagnosticsRequest>(&header, _body_bytes, handles, &mut req)?;
3395                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3396                        Ok(PortRequest::GetDiagnostics {
3397                            diagnostics: req.diagnostics,
3398
3399                            control_handle,
3400                        })
3401                    }
3402                    0x75134ce0bc114e5a => {
3403                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3404                        let mut req = fidl::new_empty!(
3405                            fidl::encoding::EmptyPayload,
3406                            fidl::encoding::DefaultFuchsiaResourceDialect
3407                        );
3408                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3409                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3410                        Ok(PortRequest::GetIdentity {
3411                            responder: PortGetIdentityResponder {
3412                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3413                                tx_id: header.tx_id,
3414                            },
3415                        })
3416                    }
3417                    _ => Err(fidl::Error::UnknownOrdinal {
3418                        ordinal: header.ordinal,
3419                        protocol_name: <PortMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3420                    }),
3421                }))
3422            },
3423        )
3424    }
3425}
3426
3427/// A logical port belonging to a [`Device`].
3428#[derive(Debug)]
3429pub enum PortRequest {
3430    /// Obtain information about port.
3431    ///
3432    /// - response `info` port information.
3433    GetInfo { responder: PortGetInfoResponder },
3434    /// Obtain the operating port status.
3435    ///
3436    /// - response `status` snapshot of port's current status.
3437    GetStatus { responder: PortGetStatusResponder },
3438    /// Connects to a [`StatusWatcher`] to observe port status changes.
3439    ///
3440    /// + request `watcher` handle to the status watcher.
3441    /// + request `buffer` the number of status changes that the client requests
3442    /// to be stored by `StatusWatcher`. Values are capped at
3443    /// [`MAX_STATUS_BUFFER`]. A value of 0 or 1 causes the `StatusWatcher` to
3444    /// not keep any buffers on status changed. Clients that need to observe all
3445    /// changes to status (as opposed to only the current state) are encouraged
3446    /// to set a buffer value larger than 1, so that all edges can be observed.
3447    /// If `StatusWatcher`'s internal queue is filled and new status changes
3448    /// occur, the oldest samples will be dropped to make room for new ones.
3449    GetStatusWatcher {
3450        watcher: fidl::endpoints::ServerEnd<StatusWatcherMarker>,
3451        buffer: u32,
3452        control_handle: PortControlHandle,
3453    },
3454    /// Connects to a [`MacAddressing`] associated with the port.
3455    ///
3456    /// + request `mac` mac handle. Closed with `ZX_ERR_NOT_SUPPORTED` if this
3457    /// port does not support mac addressing.
3458    GetMac {
3459        mac: fidl::endpoints::ServerEnd<MacAddressingMarker>,
3460        control_handle: PortControlHandle,
3461    },
3462    /// Connects to the [`Device`] this port belongs to.
3463    ///
3464    /// + request `device` grants access to the parent device.
3465    GetDevice {
3466        device: fidl::endpoints::ServerEnd<DeviceMarker>,
3467        control_handle: PortControlHandle,
3468    },
3469    /// Establishes a new connection to this port.
3470    ///
3471    /// + request `port` the server end for the new connection.
3472    Clone { port: fidl::endpoints::ServerEnd<PortMarker>, control_handle: PortControlHandle },
3473    /// Retrieves a snapshot of traffic counters on this port.
3474    GetCounters { responder: PortGetCountersResponder },
3475    /// Grants access to [`Diagnostics`] for this port.
3476    ///
3477    /// + request `diagnostics` grants access to diagnostics information.
3478    GetDiagnostics {
3479        diagnostics: fidl::endpoints::ServerEnd<DiagnosticsMarker>,
3480        control_handle: PortControlHandle,
3481    },
3482    /// Retrieves a unique event handle that is always associated only with
3483    /// this port.
3484    ///
3485    /// This event may be used to uniquely identify a specific port instance
3486    /// across different APIs in the system.
3487    GetIdentity { responder: PortGetIdentityResponder },
3488}
3489
3490impl PortRequest {
3491    #[allow(irrefutable_let_patterns)]
3492    pub fn into_get_info(self) -> Option<(PortGetInfoResponder)> {
3493        if let PortRequest::GetInfo { responder } = self { Some((responder)) } else { None }
3494    }
3495
3496    #[allow(irrefutable_let_patterns)]
3497    pub fn into_get_status(self) -> Option<(PortGetStatusResponder)> {
3498        if let PortRequest::GetStatus { responder } = self { Some((responder)) } else { None }
3499    }
3500
3501    #[allow(irrefutable_let_patterns)]
3502    pub fn into_get_status_watcher(
3503        self,
3504    ) -> Option<(fidl::endpoints::ServerEnd<StatusWatcherMarker>, u32, PortControlHandle)> {
3505        if let PortRequest::GetStatusWatcher { watcher, buffer, control_handle } = self {
3506            Some((watcher, buffer, control_handle))
3507        } else {
3508            None
3509        }
3510    }
3511
3512    #[allow(irrefutable_let_patterns)]
3513    pub fn into_get_mac(
3514        self,
3515    ) -> Option<(fidl::endpoints::ServerEnd<MacAddressingMarker>, PortControlHandle)> {
3516        if let PortRequest::GetMac { mac, control_handle } = self {
3517            Some((mac, control_handle))
3518        } else {
3519            None
3520        }
3521    }
3522
3523    #[allow(irrefutable_let_patterns)]
3524    pub fn into_get_device(
3525        self,
3526    ) -> Option<(fidl::endpoints::ServerEnd<DeviceMarker>, PortControlHandle)> {
3527        if let PortRequest::GetDevice { device, control_handle } = self {
3528            Some((device, control_handle))
3529        } else {
3530            None
3531        }
3532    }
3533
3534    #[allow(irrefutable_let_patterns)]
3535    pub fn into_clone(self) -> Option<(fidl::endpoints::ServerEnd<PortMarker>, PortControlHandle)> {
3536        if let PortRequest::Clone { port, control_handle } = self {
3537            Some((port, control_handle))
3538        } else {
3539            None
3540        }
3541    }
3542
3543    #[allow(irrefutable_let_patterns)]
3544    pub fn into_get_counters(self) -> Option<(PortGetCountersResponder)> {
3545        if let PortRequest::GetCounters { responder } = self { Some((responder)) } else { None }
3546    }
3547
3548    #[allow(irrefutable_let_patterns)]
3549    pub fn into_get_diagnostics(
3550        self,
3551    ) -> Option<(fidl::endpoints::ServerEnd<DiagnosticsMarker>, PortControlHandle)> {
3552        if let PortRequest::GetDiagnostics { diagnostics, control_handle } = self {
3553            Some((diagnostics, control_handle))
3554        } else {
3555            None
3556        }
3557    }
3558
3559    #[allow(irrefutable_let_patterns)]
3560    pub fn into_get_identity(self) -> Option<(PortGetIdentityResponder)> {
3561        if let PortRequest::GetIdentity { responder } = self { Some((responder)) } else { None }
3562    }
3563
3564    /// Name of the method defined in FIDL
3565    pub fn method_name(&self) -> &'static str {
3566        match *self {
3567            PortRequest::GetInfo { .. } => "get_info",
3568            PortRequest::GetStatus { .. } => "get_status",
3569            PortRequest::GetStatusWatcher { .. } => "get_status_watcher",
3570            PortRequest::GetMac { .. } => "get_mac",
3571            PortRequest::GetDevice { .. } => "get_device",
3572            PortRequest::Clone { .. } => "clone",
3573            PortRequest::GetCounters { .. } => "get_counters",
3574            PortRequest::GetDiagnostics { .. } => "get_diagnostics",
3575            PortRequest::GetIdentity { .. } => "get_identity",
3576        }
3577    }
3578}
3579
3580#[derive(Debug, Clone)]
3581pub struct PortControlHandle {
3582    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3583}
3584
3585impl fidl::endpoints::ControlHandle for PortControlHandle {
3586    fn shutdown(&self) {
3587        self.inner.shutdown()
3588    }
3589
3590    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3591        self.inner.shutdown_with_epitaph(status)
3592    }
3593
3594    fn is_closed(&self) -> bool {
3595        self.inner.channel().is_closed()
3596    }
3597    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3598        self.inner.channel().on_closed()
3599    }
3600
3601    #[cfg(target_os = "fuchsia")]
3602    fn signal_peer(
3603        &self,
3604        clear_mask: zx::Signals,
3605        set_mask: zx::Signals,
3606    ) -> Result<(), zx_status::Status> {
3607        use fidl::Peered;
3608        self.inner.channel().signal_peer(clear_mask, set_mask)
3609    }
3610}
3611
3612impl PortControlHandle {}
3613
3614#[must_use = "FIDL methods require a response to be sent"]
3615#[derive(Debug)]
3616pub struct PortGetInfoResponder {
3617    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3618    tx_id: u32,
3619}
3620
3621/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3622/// if the responder is dropped without sending a response, so that the client
3623/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3624impl std::ops::Drop for PortGetInfoResponder {
3625    fn drop(&mut self) {
3626        self.control_handle.shutdown();
3627        // Safety: drops once, never accessed again
3628        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3629    }
3630}
3631
3632impl fidl::endpoints::Responder for PortGetInfoResponder {
3633    type ControlHandle = PortControlHandle;
3634
3635    fn control_handle(&self) -> &PortControlHandle {
3636        &self.control_handle
3637    }
3638
3639    fn drop_without_shutdown(mut self) {
3640        // Safety: drops once, never accessed again due to mem::forget
3641        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3642        // Prevent Drop from running (which would shut down the channel)
3643        std::mem::forget(self);
3644    }
3645}
3646
3647impl PortGetInfoResponder {
3648    /// Sends a response to the FIDL transaction.
3649    ///
3650    /// Sets the channel to shutdown if an error occurs.
3651    pub fn send(self, mut info: &PortInfo) -> Result<(), fidl::Error> {
3652        let _result = self.send_raw(info);
3653        if _result.is_err() {
3654            self.control_handle.shutdown();
3655        }
3656        self.drop_without_shutdown();
3657        _result
3658    }
3659
3660    /// Similar to "send" but does not shutdown the channel if an error occurs.
3661    pub fn send_no_shutdown_on_err(self, mut info: &PortInfo) -> Result<(), fidl::Error> {
3662        let _result = self.send_raw(info);
3663        self.drop_without_shutdown();
3664        _result
3665    }
3666
3667    fn send_raw(&self, mut info: &PortInfo) -> Result<(), fidl::Error> {
3668        self.control_handle.inner.send::<PortGetInfoResponse>(
3669            (info,),
3670            self.tx_id,
3671            0x276cf65feb554ebd,
3672            fidl::encoding::DynamicFlags::empty(),
3673        )
3674    }
3675}
3676
3677#[must_use = "FIDL methods require a response to be sent"]
3678#[derive(Debug)]
3679pub struct PortGetStatusResponder {
3680    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3681    tx_id: u32,
3682}
3683
3684/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3685/// if the responder is dropped without sending a response, so that the client
3686/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3687impl std::ops::Drop for PortGetStatusResponder {
3688    fn drop(&mut self) {
3689        self.control_handle.shutdown();
3690        // Safety: drops once, never accessed again
3691        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3692    }
3693}
3694
3695impl fidl::endpoints::Responder for PortGetStatusResponder {
3696    type ControlHandle = PortControlHandle;
3697
3698    fn control_handle(&self) -> &PortControlHandle {
3699        &self.control_handle
3700    }
3701
3702    fn drop_without_shutdown(mut self) {
3703        // Safety: drops once, never accessed again due to mem::forget
3704        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3705        // Prevent Drop from running (which would shut down the channel)
3706        std::mem::forget(self);
3707    }
3708}
3709
3710impl PortGetStatusResponder {
3711    /// Sends a response to the FIDL transaction.
3712    ///
3713    /// Sets the channel to shutdown if an error occurs.
3714    pub fn send(self, mut status: &PortStatus) -> Result<(), fidl::Error> {
3715        let _result = self.send_raw(status);
3716        if _result.is_err() {
3717            self.control_handle.shutdown();
3718        }
3719        self.drop_without_shutdown();
3720        _result
3721    }
3722
3723    /// Similar to "send" but does not shutdown the channel if an error occurs.
3724    pub fn send_no_shutdown_on_err(self, mut status: &PortStatus) -> Result<(), fidl::Error> {
3725        let _result = self.send_raw(status);
3726        self.drop_without_shutdown();
3727        _result
3728    }
3729
3730    fn send_raw(&self, mut status: &PortStatus) -> Result<(), fidl::Error> {
3731        self.control_handle.inner.send::<PortGetStatusResponse>(
3732            (status,),
3733            self.tx_id,
3734            0x4235650aacca60b2,
3735            fidl::encoding::DynamicFlags::empty(),
3736        )
3737    }
3738}
3739
3740#[must_use = "FIDL methods require a response to be sent"]
3741#[derive(Debug)]
3742pub struct PortGetCountersResponder {
3743    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3744    tx_id: u32,
3745}
3746
3747/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3748/// if the responder is dropped without sending a response, so that the client
3749/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3750impl std::ops::Drop for PortGetCountersResponder {
3751    fn drop(&mut self) {
3752        self.control_handle.shutdown();
3753        // Safety: drops once, never accessed again
3754        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3755    }
3756}
3757
3758impl fidl::endpoints::Responder for PortGetCountersResponder {
3759    type ControlHandle = PortControlHandle;
3760
3761    fn control_handle(&self) -> &PortControlHandle {
3762        &self.control_handle
3763    }
3764
3765    fn drop_without_shutdown(mut self) {
3766        // Safety: drops once, never accessed again due to mem::forget
3767        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3768        // Prevent Drop from running (which would shut down the channel)
3769        std::mem::forget(self);
3770    }
3771}
3772
3773impl PortGetCountersResponder {
3774    /// Sends a response to the FIDL transaction.
3775    ///
3776    /// Sets the channel to shutdown if an error occurs.
3777    pub fn send(self, mut payload: &PortGetCountersResponse) -> Result<(), fidl::Error> {
3778        let _result = self.send_raw(payload);
3779        if _result.is_err() {
3780            self.control_handle.shutdown();
3781        }
3782        self.drop_without_shutdown();
3783        _result
3784    }
3785
3786    /// Similar to "send" but does not shutdown the channel if an error occurs.
3787    pub fn send_no_shutdown_on_err(
3788        self,
3789        mut payload: &PortGetCountersResponse,
3790    ) -> Result<(), fidl::Error> {
3791        let _result = self.send_raw(payload);
3792        self.drop_without_shutdown();
3793        _result
3794    }
3795
3796    fn send_raw(&self, mut payload: &PortGetCountersResponse) -> Result<(), fidl::Error> {
3797        self.control_handle.inner.send::<PortGetCountersResponse>(
3798            payload,
3799            self.tx_id,
3800            0x6a213b03c4fcbbac,
3801            fidl::encoding::DynamicFlags::empty(),
3802        )
3803    }
3804}
3805
3806#[must_use = "FIDL methods require a response to be sent"]
3807#[derive(Debug)]
3808pub struct PortGetIdentityResponder {
3809    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3810    tx_id: u32,
3811}
3812
3813/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3814/// if the responder is dropped without sending a response, so that the client
3815/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3816impl std::ops::Drop for PortGetIdentityResponder {
3817    fn drop(&mut self) {
3818        self.control_handle.shutdown();
3819        // Safety: drops once, never accessed again
3820        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3821    }
3822}
3823
3824impl fidl::endpoints::Responder for PortGetIdentityResponder {
3825    type ControlHandle = PortControlHandle;
3826
3827    fn control_handle(&self) -> &PortControlHandle {
3828        &self.control_handle
3829    }
3830
3831    fn drop_without_shutdown(mut self) {
3832        // Safety: drops once, never accessed again due to mem::forget
3833        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3834        // Prevent Drop from running (which would shut down the channel)
3835        std::mem::forget(self);
3836    }
3837}
3838
3839impl PortGetIdentityResponder {
3840    /// Sends a response to the FIDL transaction.
3841    ///
3842    /// Sets the channel to shutdown if an error occurs.
3843    pub fn send(self, mut event: fidl::Event) -> Result<(), fidl::Error> {
3844        let _result = self.send_raw(event);
3845        if _result.is_err() {
3846            self.control_handle.shutdown();
3847        }
3848        self.drop_without_shutdown();
3849        _result
3850    }
3851
3852    /// Similar to "send" but does not shutdown the channel if an error occurs.
3853    pub fn send_no_shutdown_on_err(self, mut event: fidl::Event) -> Result<(), fidl::Error> {
3854        let _result = self.send_raw(event);
3855        self.drop_without_shutdown();
3856        _result
3857    }
3858
3859    fn send_raw(&self, mut event: fidl::Event) -> Result<(), fidl::Error> {
3860        self.control_handle.inner.send::<PortGetIdentityResponse>(
3861            (event,),
3862            self.tx_id,
3863            0x75134ce0bc114e5a,
3864            fidl::encoding::DynamicFlags::empty(),
3865        )
3866    }
3867}
3868
3869#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3870pub struct PortWatcherMarker;
3871
3872impl fidl::endpoints::ProtocolMarker for PortWatcherMarker {
3873    type Proxy = PortWatcherProxy;
3874    type RequestStream = PortWatcherRequestStream;
3875    #[cfg(target_os = "fuchsia")]
3876    type SynchronousProxy = PortWatcherSynchronousProxy;
3877
3878    const DEBUG_NAME: &'static str = "(anonymous) PortWatcher";
3879}
3880
3881pub trait PortWatcherProxyInterface: Send + Sync {
3882    type WatchResponseFut: std::future::Future<Output = Result<DevicePortEvent, fidl::Error>> + Send;
3883    fn r#watch(&self) -> Self::WatchResponseFut;
3884}
3885#[derive(Debug)]
3886#[cfg(target_os = "fuchsia")]
3887pub struct PortWatcherSynchronousProxy {
3888    client: fidl::client::sync::Client,
3889}
3890
3891#[cfg(target_os = "fuchsia")]
3892impl fidl::endpoints::SynchronousProxy for PortWatcherSynchronousProxy {
3893    type Proxy = PortWatcherProxy;
3894    type Protocol = PortWatcherMarker;
3895
3896    fn from_channel(inner: fidl::Channel) -> Self {
3897        Self::new(inner)
3898    }
3899
3900    fn into_channel(self) -> fidl::Channel {
3901        self.client.into_channel()
3902    }
3903
3904    fn as_channel(&self) -> &fidl::Channel {
3905        self.client.as_channel()
3906    }
3907}
3908
3909#[cfg(target_os = "fuchsia")]
3910impl PortWatcherSynchronousProxy {
3911    pub fn new(channel: fidl::Channel) -> Self {
3912        Self { client: fidl::client::sync::Client::new(channel) }
3913    }
3914
3915    pub fn into_channel(self) -> fidl::Channel {
3916        self.client.into_channel()
3917    }
3918
3919    /// Waits until an event arrives and returns it. It is safe for other
3920    /// threads to make concurrent requests while waiting for an event.
3921    pub fn wait_for_event(
3922        &self,
3923        deadline: zx::MonotonicInstant,
3924    ) -> Result<PortWatcherEvent, fidl::Error> {
3925        PortWatcherEvent::decode(self.client.wait_for_event::<PortWatcherMarker>(deadline)?)
3926    }
3927
3928    /// Get the next port event.
3929    ///
3930    /// The first N calls return [`DevicePortEvent.existing`] where N is the
3931    /// number of ports present on the device at the time of the watcher's
3932    /// creation. The next call returns [`DevicePortEvent.idle`] to indicate the
3933    /// end of existing ports. Subsequent calls block until a port is added
3934    /// ([`DevicePortEvent.added`]) or removed ([`DevicePortEvent.removed`]).
3935    ///
3936    /// The server closes the `PortWatcher` channel with `ZX_ERR_CANCELED` if
3937    /// the number of unread events reaches a server-selected limit that is at
3938    /// least two times [`MAX_PORTS`]. Clients are encouraged to maintain a
3939    /// hanging call to `Watch` at all times to avoid triggering this condition.
3940    ///
3941    /// - response `event` next port event.
3942    pub fn r#watch(
3943        &self,
3944        ___deadline: zx::MonotonicInstant,
3945    ) -> Result<DevicePortEvent, fidl::Error> {
3946        let _response = self.client.send_query::<
3947            fidl::encoding::EmptyPayload,
3948            PortWatcherWatchResponse,
3949            PortWatcherMarker,
3950        >(
3951            (),
3952            0x3e87244b74fff55e,
3953            fidl::encoding::DynamicFlags::empty(),
3954            ___deadline,
3955        )?;
3956        Ok(_response.event)
3957    }
3958}
3959
3960#[cfg(target_os = "fuchsia")]
3961impl From<PortWatcherSynchronousProxy> for zx::NullableHandle {
3962    fn from(value: PortWatcherSynchronousProxy) -> Self {
3963        value.into_channel().into()
3964    }
3965}
3966
3967#[cfg(target_os = "fuchsia")]
3968impl From<fidl::Channel> for PortWatcherSynchronousProxy {
3969    fn from(value: fidl::Channel) -> Self {
3970        Self::new(value)
3971    }
3972}
3973
3974#[cfg(target_os = "fuchsia")]
3975impl fidl::endpoints::FromClient for PortWatcherSynchronousProxy {
3976    type Protocol = PortWatcherMarker;
3977
3978    fn from_client(value: fidl::endpoints::ClientEnd<PortWatcherMarker>) -> Self {
3979        Self::new(value.into_channel())
3980    }
3981}
3982
3983#[derive(Debug, Clone)]
3984pub struct PortWatcherProxy {
3985    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3986}
3987
3988impl fidl::endpoints::Proxy for PortWatcherProxy {
3989    type Protocol = PortWatcherMarker;
3990
3991    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3992        Self::new(inner)
3993    }
3994
3995    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3996        self.client.into_channel().map_err(|client| Self { client })
3997    }
3998
3999    fn as_channel(&self) -> &::fidl::AsyncChannel {
4000        self.client.as_channel()
4001    }
4002}
4003
4004impl PortWatcherProxy {
4005    /// Create a new Proxy for fuchsia.hardware.network/PortWatcher.
4006    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4007        let protocol_name = <PortWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4008        Self { client: fidl::client::Client::new(channel, protocol_name) }
4009    }
4010
4011    /// Get a Stream of events from the remote end of the protocol.
4012    ///
4013    /// # Panics
4014    ///
4015    /// Panics if the event stream was already taken.
4016    pub fn take_event_stream(&self) -> PortWatcherEventStream {
4017        PortWatcherEventStream { event_receiver: self.client.take_event_receiver() }
4018    }
4019
4020    /// Get the next port event.
4021    ///
4022    /// The first N calls return [`DevicePortEvent.existing`] where N is the
4023    /// number of ports present on the device at the time of the watcher's
4024    /// creation. The next call returns [`DevicePortEvent.idle`] to indicate the
4025    /// end of existing ports. Subsequent calls block until a port is added
4026    /// ([`DevicePortEvent.added`]) or removed ([`DevicePortEvent.removed`]).
4027    ///
4028    /// The server closes the `PortWatcher` channel with `ZX_ERR_CANCELED` if
4029    /// the number of unread events reaches a server-selected limit that is at
4030    /// least two times [`MAX_PORTS`]. Clients are encouraged to maintain a
4031    /// hanging call to `Watch` at all times to avoid triggering this condition.
4032    ///
4033    /// - response `event` next port event.
4034    pub fn r#watch(
4035        &self,
4036    ) -> fidl::client::QueryResponseFut<
4037        DevicePortEvent,
4038        fidl::encoding::DefaultFuchsiaResourceDialect,
4039    > {
4040        PortWatcherProxyInterface::r#watch(self)
4041    }
4042}
4043
4044impl PortWatcherProxyInterface for PortWatcherProxy {
4045    type WatchResponseFut = fidl::client::QueryResponseFut<
4046        DevicePortEvent,
4047        fidl::encoding::DefaultFuchsiaResourceDialect,
4048    >;
4049    fn r#watch(&self) -> Self::WatchResponseFut {
4050        fn _decode(
4051            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4052        ) -> Result<DevicePortEvent, fidl::Error> {
4053            let _response = fidl::client::decode_transaction_body::<
4054                PortWatcherWatchResponse,
4055                fidl::encoding::DefaultFuchsiaResourceDialect,
4056                0x3e87244b74fff55e,
4057            >(_buf?)?;
4058            Ok(_response.event)
4059        }
4060        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DevicePortEvent>(
4061            (),
4062            0x3e87244b74fff55e,
4063            fidl::encoding::DynamicFlags::empty(),
4064            _decode,
4065        )
4066    }
4067}
4068
4069pub struct PortWatcherEventStream {
4070    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4071}
4072
4073impl std::marker::Unpin for PortWatcherEventStream {}
4074
4075impl futures::stream::FusedStream for PortWatcherEventStream {
4076    fn is_terminated(&self) -> bool {
4077        self.event_receiver.is_terminated()
4078    }
4079}
4080
4081impl futures::Stream for PortWatcherEventStream {
4082    type Item = Result<PortWatcherEvent, fidl::Error>;
4083
4084    fn poll_next(
4085        mut self: std::pin::Pin<&mut Self>,
4086        cx: &mut std::task::Context<'_>,
4087    ) -> std::task::Poll<Option<Self::Item>> {
4088        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4089            &mut self.event_receiver,
4090            cx
4091        )?) {
4092            Some(buf) => std::task::Poll::Ready(Some(PortWatcherEvent::decode(buf))),
4093            None => std::task::Poll::Ready(None),
4094        }
4095    }
4096}
4097
4098#[derive(Debug)]
4099pub enum PortWatcherEvent {}
4100
4101impl PortWatcherEvent {
4102    /// Decodes a message buffer as a [`PortWatcherEvent`].
4103    fn decode(
4104        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4105    ) -> Result<PortWatcherEvent, fidl::Error> {
4106        let (bytes, _handles) = buf.split_mut();
4107        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4108        debug_assert_eq!(tx_header.tx_id, 0);
4109        match tx_header.ordinal {
4110            _ => Err(fidl::Error::UnknownOrdinal {
4111                ordinal: tx_header.ordinal,
4112                protocol_name: <PortWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4113            }),
4114        }
4115    }
4116}
4117
4118/// A Stream of incoming requests for fuchsia.hardware.network/PortWatcher.
4119pub struct PortWatcherRequestStream {
4120    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4121    is_terminated: bool,
4122}
4123
4124impl std::marker::Unpin for PortWatcherRequestStream {}
4125
4126impl futures::stream::FusedStream for PortWatcherRequestStream {
4127    fn is_terminated(&self) -> bool {
4128        self.is_terminated
4129    }
4130}
4131
4132impl fidl::endpoints::RequestStream for PortWatcherRequestStream {
4133    type Protocol = PortWatcherMarker;
4134    type ControlHandle = PortWatcherControlHandle;
4135
4136    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4137        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4138    }
4139
4140    fn control_handle(&self) -> Self::ControlHandle {
4141        PortWatcherControlHandle { inner: self.inner.clone() }
4142    }
4143
4144    fn into_inner(
4145        self,
4146    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4147    {
4148        (self.inner, self.is_terminated)
4149    }
4150
4151    fn from_inner(
4152        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4153        is_terminated: bool,
4154    ) -> Self {
4155        Self { inner, is_terminated }
4156    }
4157}
4158
4159impl futures::Stream for PortWatcherRequestStream {
4160    type Item = Result<PortWatcherRequest, fidl::Error>;
4161
4162    fn poll_next(
4163        mut self: std::pin::Pin<&mut Self>,
4164        cx: &mut std::task::Context<'_>,
4165    ) -> std::task::Poll<Option<Self::Item>> {
4166        let this = &mut *self;
4167        if this.inner.check_shutdown(cx) {
4168            this.is_terminated = true;
4169            return std::task::Poll::Ready(None);
4170        }
4171        if this.is_terminated {
4172            panic!("polled PortWatcherRequestStream after completion");
4173        }
4174        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4175            |bytes, handles| {
4176                match this.inner.channel().read_etc(cx, bytes, handles) {
4177                    std::task::Poll::Ready(Ok(())) => {}
4178                    std::task::Poll::Pending => return std::task::Poll::Pending,
4179                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4180                        this.is_terminated = true;
4181                        return std::task::Poll::Ready(None);
4182                    }
4183                    std::task::Poll::Ready(Err(e)) => {
4184                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4185                            e.into(),
4186                        ))));
4187                    }
4188                }
4189
4190                // A message has been received from the channel
4191                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4192
4193                std::task::Poll::Ready(Some(match header.ordinal {
4194                    0x3e87244b74fff55e => {
4195                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4196                        let mut req = fidl::new_empty!(
4197                            fidl::encoding::EmptyPayload,
4198                            fidl::encoding::DefaultFuchsiaResourceDialect
4199                        );
4200                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4201                        let control_handle = PortWatcherControlHandle { inner: this.inner.clone() };
4202                        Ok(PortWatcherRequest::Watch {
4203                            responder: PortWatcherWatchResponder {
4204                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4205                                tx_id: header.tx_id,
4206                            },
4207                        })
4208                    }
4209                    _ => Err(fidl::Error::UnknownOrdinal {
4210                        ordinal: header.ordinal,
4211                        protocol_name:
4212                            <PortWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4213                    }),
4214                }))
4215            },
4216        )
4217    }
4218}
4219
4220/// Provides iteration over and updates for ports attached to a device.
4221#[derive(Debug)]
4222pub enum PortWatcherRequest {
4223    /// Get the next port event.
4224    ///
4225    /// The first N calls return [`DevicePortEvent.existing`] where N is the
4226    /// number of ports present on the device at the time of the watcher's
4227    /// creation. The next call returns [`DevicePortEvent.idle`] to indicate the
4228    /// end of existing ports. Subsequent calls block until a port is added
4229    /// ([`DevicePortEvent.added`]) or removed ([`DevicePortEvent.removed`]).
4230    ///
4231    /// The server closes the `PortWatcher` channel with `ZX_ERR_CANCELED` if
4232    /// the number of unread events reaches a server-selected limit that is at
4233    /// least two times [`MAX_PORTS`]. Clients are encouraged to maintain a
4234    /// hanging call to `Watch` at all times to avoid triggering this condition.
4235    ///
4236    /// - response `event` next port event.
4237    Watch { responder: PortWatcherWatchResponder },
4238}
4239
4240impl PortWatcherRequest {
4241    #[allow(irrefutable_let_patterns)]
4242    pub fn into_watch(self) -> Option<(PortWatcherWatchResponder)> {
4243        if let PortWatcherRequest::Watch { responder } = self { Some((responder)) } else { None }
4244    }
4245
4246    /// Name of the method defined in FIDL
4247    pub fn method_name(&self) -> &'static str {
4248        match *self {
4249            PortWatcherRequest::Watch { .. } => "watch",
4250        }
4251    }
4252}
4253
4254#[derive(Debug, Clone)]
4255pub struct PortWatcherControlHandle {
4256    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4257}
4258
4259impl fidl::endpoints::ControlHandle for PortWatcherControlHandle {
4260    fn shutdown(&self) {
4261        self.inner.shutdown()
4262    }
4263
4264    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4265        self.inner.shutdown_with_epitaph(status)
4266    }
4267
4268    fn is_closed(&self) -> bool {
4269        self.inner.channel().is_closed()
4270    }
4271    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4272        self.inner.channel().on_closed()
4273    }
4274
4275    #[cfg(target_os = "fuchsia")]
4276    fn signal_peer(
4277        &self,
4278        clear_mask: zx::Signals,
4279        set_mask: zx::Signals,
4280    ) -> Result<(), zx_status::Status> {
4281        use fidl::Peered;
4282        self.inner.channel().signal_peer(clear_mask, set_mask)
4283    }
4284}
4285
4286impl PortWatcherControlHandle {}
4287
4288#[must_use = "FIDL methods require a response to be sent"]
4289#[derive(Debug)]
4290pub struct PortWatcherWatchResponder {
4291    control_handle: std::mem::ManuallyDrop<PortWatcherControlHandle>,
4292    tx_id: u32,
4293}
4294
4295/// Set the the channel to be shutdown (see [`PortWatcherControlHandle::shutdown`])
4296/// if the responder is dropped without sending a response, so that the client
4297/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4298impl std::ops::Drop for PortWatcherWatchResponder {
4299    fn drop(&mut self) {
4300        self.control_handle.shutdown();
4301        // Safety: drops once, never accessed again
4302        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4303    }
4304}
4305
4306impl fidl::endpoints::Responder for PortWatcherWatchResponder {
4307    type ControlHandle = PortWatcherControlHandle;
4308
4309    fn control_handle(&self) -> &PortWatcherControlHandle {
4310        &self.control_handle
4311    }
4312
4313    fn drop_without_shutdown(mut self) {
4314        // Safety: drops once, never accessed again due to mem::forget
4315        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4316        // Prevent Drop from running (which would shut down the channel)
4317        std::mem::forget(self);
4318    }
4319}
4320
4321impl PortWatcherWatchResponder {
4322    /// Sends a response to the FIDL transaction.
4323    ///
4324    /// Sets the channel to shutdown if an error occurs.
4325    pub fn send(self, mut event: &DevicePortEvent) -> Result<(), fidl::Error> {
4326        let _result = self.send_raw(event);
4327        if _result.is_err() {
4328            self.control_handle.shutdown();
4329        }
4330        self.drop_without_shutdown();
4331        _result
4332    }
4333
4334    /// Similar to "send" but does not shutdown the channel if an error occurs.
4335    pub fn send_no_shutdown_on_err(self, mut event: &DevicePortEvent) -> Result<(), fidl::Error> {
4336        let _result = self.send_raw(event);
4337        self.drop_without_shutdown();
4338        _result
4339    }
4340
4341    fn send_raw(&self, mut event: &DevicePortEvent) -> Result<(), fidl::Error> {
4342        self.control_handle.inner.send::<PortWatcherWatchResponse>(
4343            (event,),
4344            self.tx_id,
4345            0x3e87244b74fff55e,
4346            fidl::encoding::DynamicFlags::empty(),
4347        )
4348    }
4349}
4350
4351#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4352pub struct SessionMarker;
4353
4354impl fidl::endpoints::ProtocolMarker for SessionMarker {
4355    type Proxy = SessionProxy;
4356    type RequestStream = SessionRequestStream;
4357    #[cfg(target_os = "fuchsia")]
4358    type SynchronousProxy = SessionSynchronousProxy;
4359
4360    const DEBUG_NAME: &'static str = "(anonymous) Session";
4361}
4362pub type SessionAttachResult = Result<(), i32>;
4363pub type SessionDetachResult = Result<(), i32>;
4364
4365pub trait SessionProxyInterface: Send + Sync {
4366    type AttachResponseFut: std::future::Future<Output = Result<SessionAttachResult, fidl::Error>>
4367        + Send;
4368    fn r#attach(&self, port: &PortId, rx_frames: &[FrameType]) -> Self::AttachResponseFut;
4369    type DetachResponseFut: std::future::Future<Output = Result<SessionDetachResult, fidl::Error>>
4370        + Send;
4371    fn r#detach(&self, port: &PortId) -> Self::DetachResponseFut;
4372    fn r#close(&self) -> Result<(), fidl::Error>;
4373    type WatchDelegatedRxLeaseResponseFut: std::future::Future<Output = Result<DelegatedRxLease, fidl::Error>>
4374        + Send;
4375    fn r#watch_delegated_rx_lease(&self) -> Self::WatchDelegatedRxLeaseResponseFut;
4376    type RegisterForTxResponseFut: std::future::Future<Output = Result<(u8, i32), fidl::Error>>
4377        + Send;
4378    fn r#register_for_tx(&self, vmos: &[u8]) -> Self::RegisterForTxResponseFut;
4379    type UnregisterForTxResponseFut: std::future::Future<Output = Result<(u8, i32), fidl::Error>>
4380        + Send;
4381    fn r#unregister_for_tx(&self, vmos: &[u8]) -> Self::UnregisterForTxResponseFut;
4382}
4383#[derive(Debug)]
4384#[cfg(target_os = "fuchsia")]
4385pub struct SessionSynchronousProxy {
4386    client: fidl::client::sync::Client,
4387}
4388
4389#[cfg(target_os = "fuchsia")]
4390impl fidl::endpoints::SynchronousProxy for SessionSynchronousProxy {
4391    type Proxy = SessionProxy;
4392    type Protocol = SessionMarker;
4393
4394    fn from_channel(inner: fidl::Channel) -> Self {
4395        Self::new(inner)
4396    }
4397
4398    fn into_channel(self) -> fidl::Channel {
4399        self.client.into_channel()
4400    }
4401
4402    fn as_channel(&self) -> &fidl::Channel {
4403        self.client.as_channel()
4404    }
4405}
4406
4407#[cfg(target_os = "fuchsia")]
4408impl SessionSynchronousProxy {
4409    pub fn new(channel: fidl::Channel) -> Self {
4410        Self { client: fidl::client::sync::Client::new(channel) }
4411    }
4412
4413    pub fn into_channel(self) -> fidl::Channel {
4414        self.client.into_channel()
4415    }
4416
4417    /// Waits until an event arrives and returns it. It is safe for other
4418    /// threads to make concurrent requests while waiting for an event.
4419    pub fn wait_for_event(
4420        &self,
4421        deadline: zx::MonotonicInstant,
4422    ) -> Result<SessionEvent, fidl::Error> {
4423        SessionEvent::decode(self.client.wait_for_event::<SessionMarker>(deadline)?)
4424    }
4425
4426    /// Attaches the session to `port`.
4427    ///
4428    /// Once attached, the session starts to receive the subscribed frames over
4429    /// the data FIFOs and it may send frames destined to the specified `port`.
4430    ///
4431    /// + request `port` port to subscribe to.
4432    /// + request `rx_frames` Frame types of interest on the port.
4433    /// * error `ZX_ERR_NOT_FOUND` if `port` is not valid.
4434    /// * error `ZX_ERR_INVALID_ARGS` if `rx_frames` is not a subset of the
4435    /// port's supported frames.
4436    /// * error `ZX_ERR_ALREADY_BOUND` if `port` is already attached.
4437    pub fn r#attach(
4438        &self,
4439        mut port: &PortId,
4440        mut rx_frames: &[FrameType],
4441        ___deadline: zx::MonotonicInstant,
4442    ) -> Result<SessionAttachResult, fidl::Error> {
4443        let _response = self.client.send_query::<
4444            SessionAttachRequest,
4445            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4446            SessionMarker,
4447        >(
4448            (port, rx_frames,),
4449            0x1e89c9013e201379,
4450            fidl::encoding::DynamicFlags::empty(),
4451            ___deadline,
4452        )?;
4453        Ok(_response.map(|x| x))
4454    }
4455
4456    /// Detaches the session from `port`.
4457    ///
4458    /// Once detached, the session stops receiving frames from `port`. Frames
4459    /// sent to a detached port may be returned with an error. It is not
4460    /// necessary to call `Detach` on ports that are removed from the device,
4461    /// doing so causes `ZX_ERR_NOT_FOUND` to be returned.
4462    ///
4463    /// + request `port` port to subscribe to.
4464    /// * error `ZX_ERR_NOT_FOUND` if the session is not currently attached to
4465    /// the port.
4466    pub fn r#detach(
4467        &self,
4468        mut port: &PortId,
4469        ___deadline: zx::MonotonicInstant,
4470    ) -> Result<SessionDetachResult, fidl::Error> {
4471        let _response = self.client.send_query::<
4472            SessionDetachRequest,
4473            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4474            SessionMarker,
4475        >(
4476            (port,),
4477            0x68c40cf8fb549867,
4478            fidl::encoding::DynamicFlags::empty(),
4479            ___deadline,
4480        )?;
4481        Ok(_response.map(|x| x))
4482    }
4483
4484    /// Cleanly closes a session.
4485    ///
4486    /// This will cause the session to send a `ZX_ERR_CANCELLED` epitaph and
4487    /// proceed to close the Session channel. Clients may only assume that they
4488    /// own all the buffers that are currently owned by the session (sent over
4489    /// either the rx or tx FIFOs) once the epitaph is received. Closing the rx
4490    /// or tx FIFO is equivalent to calling `Close`.
4491    pub fn r#close(&self) -> Result<(), fidl::Error> {
4492        self.client.send::<fidl::encoding::EmptyPayload>(
4493            (),
4494            0x393d5070394a92f6,
4495            fidl::encoding::DynamicFlags::empty(),
4496        )
4497    }
4498
4499    /// Watchers for delegated receive wakeup leases.
4500    ///
4501    /// Calls block until a lease is delegated by the device. If a call to
4502    /// `WatchDelegatedRxLease` is made while a previous call is blocking, the
4503    /// session is closed with `ZX_ERR_BAD_STATE`. Will never yield any values
4504    /// for sessions created without [`SessionFlags.RECEIVE_RX_POWER_LEASES`].
4505    ///
4506    /// Given a single lease is assumed sufficient to keep the system awake, the
4507    /// server only keeps a single lease in its buffer. If a new delegated lease
4508    /// becomes available and the client hasn't popped the previous one with a
4509    /// call to `WatchDelegatedRxLease`, the server drops the previously pending
4510    /// lease.
4511    ///
4512    /// See [`DelegatedRxLease`] for how to handle delegated leases.
4513    pub fn r#watch_delegated_rx_lease(
4514        &self,
4515        ___deadline: zx::MonotonicInstant,
4516    ) -> Result<DelegatedRxLease, fidl::Error> {
4517        let _response = self.client.send_query::<
4518            fidl::encoding::EmptyPayload,
4519            SessionWatchDelegatedRxLeaseResponse,
4520            SessionMarker,
4521        >(
4522            (),
4523            0x764d823ee64803b5,
4524            fidl::encoding::DynamicFlags::empty(),
4525            ___deadline,
4526        )?;
4527        Ok(_response.lease)
4528    }
4529
4530    /// Asks the network device to register the VMO for Tx.
4531    ///
4532    /// The network device prepares the VMOs in order and stops at the first
4533    /// error if any. It returns how many VMOs have been prepared alongside with
4534    /// the first error encountered. Note that network-device itself does not
4535    /// try to release earlier VMOs for a later error. It is up to the client
4536    /// how to recover from an error.
4537    ///
4538    /// * error `ZX_ERR_NOT_FOUND` if any of the VmoId is unknown.
4539    /// * error other zx status that can be reported by the driver.
4540    pub fn r#register_for_tx(
4541        &self,
4542        mut vmos: &[u8],
4543        ___deadline: zx::MonotonicInstant,
4544    ) -> Result<(u8, i32), fidl::Error> {
4545        let _response = self
4546            .client
4547            .send_query::<SessionRegisterForTxRequest, SessionRegisterForTxResponse, SessionMarker>(
4548                (vmos,),
4549                0x36321799ce2a081a,
4550                fidl::encoding::DynamicFlags::empty(),
4551                ___deadline,
4552            )?;
4553        Ok((_response.successful, _response.status))
4554    }
4555
4556    /// Tells the device that the client will no longer use the VMO for Tx,
4557    /// if the VMO is also unused for Rx, the device is free to release it
4558    /// at the implementation driver.
4559    ///
4560    /// The network device processes the VMOs in order and stops at the first
4561    /// error if any. It returns how many VMOs have been marked as unused for Tx
4562    /// alongside with the first error encountered. Note that network-device
4563    /// itself does not try to re-register earlier VMOs for a later error. It is
4564    /// up to the client how to recover from an error.
4565    ///
4566    /// * error `ZX_ERR_NOT_FOUND` if any of the VmoId is unknown.
4567    /// * error other zx status that can be reported by the driver.
4568    pub fn r#unregister_for_tx(
4569        &self,
4570        mut vmos: &[u8],
4571        ___deadline: zx::MonotonicInstant,
4572    ) -> Result<(u8, i32), fidl::Error> {
4573        let _response = self.client.send_query::<
4574            SessionUnregisterForTxRequest,
4575            SessionUnregisterForTxResponse,
4576            SessionMarker,
4577        >(
4578            (vmos,),
4579            0x3e76b16030d62796,
4580            fidl::encoding::DynamicFlags::empty(),
4581            ___deadline,
4582        )?;
4583        Ok((_response.successful, _response.status))
4584    }
4585}
4586
4587#[cfg(target_os = "fuchsia")]
4588impl From<SessionSynchronousProxy> for zx::NullableHandle {
4589    fn from(value: SessionSynchronousProxy) -> Self {
4590        value.into_channel().into()
4591    }
4592}
4593
4594#[cfg(target_os = "fuchsia")]
4595impl From<fidl::Channel> for SessionSynchronousProxy {
4596    fn from(value: fidl::Channel) -> Self {
4597        Self::new(value)
4598    }
4599}
4600
4601#[cfg(target_os = "fuchsia")]
4602impl fidl::endpoints::FromClient for SessionSynchronousProxy {
4603    type Protocol = SessionMarker;
4604
4605    fn from_client(value: fidl::endpoints::ClientEnd<SessionMarker>) -> Self {
4606        Self::new(value.into_channel())
4607    }
4608}
4609
4610#[derive(Debug, Clone)]
4611pub struct SessionProxy {
4612    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4613}
4614
4615impl fidl::endpoints::Proxy for SessionProxy {
4616    type Protocol = SessionMarker;
4617
4618    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4619        Self::new(inner)
4620    }
4621
4622    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4623        self.client.into_channel().map_err(|client| Self { client })
4624    }
4625
4626    fn as_channel(&self) -> &::fidl::AsyncChannel {
4627        self.client.as_channel()
4628    }
4629}
4630
4631impl SessionProxy {
4632    /// Create a new Proxy for fuchsia.hardware.network/Session.
4633    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4634        let protocol_name = <SessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4635        Self { client: fidl::client::Client::new(channel, protocol_name) }
4636    }
4637
4638    /// Get a Stream of events from the remote end of the protocol.
4639    ///
4640    /// # Panics
4641    ///
4642    /// Panics if the event stream was already taken.
4643    pub fn take_event_stream(&self) -> SessionEventStream {
4644        SessionEventStream { event_receiver: self.client.take_event_receiver() }
4645    }
4646
4647    /// Attaches the session to `port`.
4648    ///
4649    /// Once attached, the session starts to receive the subscribed frames over
4650    /// the data FIFOs and it may send frames destined to the specified `port`.
4651    ///
4652    /// + request `port` port to subscribe to.
4653    /// + request `rx_frames` Frame types of interest on the port.
4654    /// * error `ZX_ERR_NOT_FOUND` if `port` is not valid.
4655    /// * error `ZX_ERR_INVALID_ARGS` if `rx_frames` is not a subset of the
4656    /// port's supported frames.
4657    /// * error `ZX_ERR_ALREADY_BOUND` if `port` is already attached.
4658    pub fn r#attach(
4659        &self,
4660        mut port: &PortId,
4661        mut rx_frames: &[FrameType],
4662    ) -> fidl::client::QueryResponseFut<
4663        SessionAttachResult,
4664        fidl::encoding::DefaultFuchsiaResourceDialect,
4665    > {
4666        SessionProxyInterface::r#attach(self, port, rx_frames)
4667    }
4668
4669    /// Detaches the session from `port`.
4670    ///
4671    /// Once detached, the session stops receiving frames from `port`. Frames
4672    /// sent to a detached port may be returned with an error. It is not
4673    /// necessary to call `Detach` on ports that are removed from the device,
4674    /// doing so causes `ZX_ERR_NOT_FOUND` to be returned.
4675    ///
4676    /// + request `port` port to subscribe to.
4677    /// * error `ZX_ERR_NOT_FOUND` if the session is not currently attached to
4678    /// the port.
4679    pub fn r#detach(
4680        &self,
4681        mut port: &PortId,
4682    ) -> fidl::client::QueryResponseFut<
4683        SessionDetachResult,
4684        fidl::encoding::DefaultFuchsiaResourceDialect,
4685    > {
4686        SessionProxyInterface::r#detach(self, port)
4687    }
4688
4689    /// Cleanly closes a session.
4690    ///
4691    /// This will cause the session to send a `ZX_ERR_CANCELLED` epitaph and
4692    /// proceed to close the Session channel. Clients may only assume that they
4693    /// own all the buffers that are currently owned by the session (sent over
4694    /// either the rx or tx FIFOs) once the epitaph is received. Closing the rx
4695    /// or tx FIFO is equivalent to calling `Close`.
4696    pub fn r#close(&self) -> Result<(), fidl::Error> {
4697        SessionProxyInterface::r#close(self)
4698    }
4699
4700    /// Watchers for delegated receive wakeup leases.
4701    ///
4702    /// Calls block until a lease is delegated by the device. If a call to
4703    /// `WatchDelegatedRxLease` is made while a previous call is blocking, the
4704    /// session is closed with `ZX_ERR_BAD_STATE`. Will never yield any values
4705    /// for sessions created without [`SessionFlags.RECEIVE_RX_POWER_LEASES`].
4706    ///
4707    /// Given a single lease is assumed sufficient to keep the system awake, the
4708    /// server only keeps a single lease in its buffer. If a new delegated lease
4709    /// becomes available and the client hasn't popped the previous one with a
4710    /// call to `WatchDelegatedRxLease`, the server drops the previously pending
4711    /// lease.
4712    ///
4713    /// See [`DelegatedRxLease`] for how to handle delegated leases.
4714    pub fn r#watch_delegated_rx_lease(
4715        &self,
4716    ) -> fidl::client::QueryResponseFut<
4717        DelegatedRxLease,
4718        fidl::encoding::DefaultFuchsiaResourceDialect,
4719    > {
4720        SessionProxyInterface::r#watch_delegated_rx_lease(self)
4721    }
4722
4723    /// Asks the network device to register the VMO for Tx.
4724    ///
4725    /// The network device prepares the VMOs in order and stops at the first
4726    /// error if any. It returns how many VMOs have been prepared alongside with
4727    /// the first error encountered. Note that network-device itself does not
4728    /// try to release earlier VMOs for a later error. It is up to the client
4729    /// how to recover from an error.
4730    ///
4731    /// * error `ZX_ERR_NOT_FOUND` if any of the VmoId is unknown.
4732    /// * error other zx status that can be reported by the driver.
4733    pub fn r#register_for_tx(
4734        &self,
4735        mut vmos: &[u8],
4736    ) -> fidl::client::QueryResponseFut<(u8, i32), fidl::encoding::DefaultFuchsiaResourceDialect>
4737    {
4738        SessionProxyInterface::r#register_for_tx(self, vmos)
4739    }
4740
4741    /// Tells the device that the client will no longer use the VMO for Tx,
4742    /// if the VMO is also unused for Rx, the device is free to release it
4743    /// at the implementation driver.
4744    ///
4745    /// The network device processes the VMOs in order and stops at the first
4746    /// error if any. It returns how many VMOs have been marked as unused for Tx
4747    /// alongside with the first error encountered. Note that network-device
4748    /// itself does not try to re-register earlier VMOs for a later error. It is
4749    /// up to the client how to recover from an error.
4750    ///
4751    /// * error `ZX_ERR_NOT_FOUND` if any of the VmoId is unknown.
4752    /// * error other zx status that can be reported by the driver.
4753    pub fn r#unregister_for_tx(
4754        &self,
4755        mut vmos: &[u8],
4756    ) -> fidl::client::QueryResponseFut<(u8, i32), fidl::encoding::DefaultFuchsiaResourceDialect>
4757    {
4758        SessionProxyInterface::r#unregister_for_tx(self, vmos)
4759    }
4760}
4761
4762impl SessionProxyInterface for SessionProxy {
4763    type AttachResponseFut = fidl::client::QueryResponseFut<
4764        SessionAttachResult,
4765        fidl::encoding::DefaultFuchsiaResourceDialect,
4766    >;
4767    fn r#attach(&self, mut port: &PortId, mut rx_frames: &[FrameType]) -> Self::AttachResponseFut {
4768        fn _decode(
4769            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4770        ) -> Result<SessionAttachResult, fidl::Error> {
4771            let _response = fidl::client::decode_transaction_body::<
4772                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4773                fidl::encoding::DefaultFuchsiaResourceDialect,
4774                0x1e89c9013e201379,
4775            >(_buf?)?;
4776            Ok(_response.map(|x| x))
4777        }
4778        self.client.send_query_and_decode::<SessionAttachRequest, SessionAttachResult>(
4779            (port, rx_frames),
4780            0x1e89c9013e201379,
4781            fidl::encoding::DynamicFlags::empty(),
4782            _decode,
4783        )
4784    }
4785
4786    type DetachResponseFut = fidl::client::QueryResponseFut<
4787        SessionDetachResult,
4788        fidl::encoding::DefaultFuchsiaResourceDialect,
4789    >;
4790    fn r#detach(&self, mut port: &PortId) -> Self::DetachResponseFut {
4791        fn _decode(
4792            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4793        ) -> Result<SessionDetachResult, fidl::Error> {
4794            let _response = fidl::client::decode_transaction_body::<
4795                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4796                fidl::encoding::DefaultFuchsiaResourceDialect,
4797                0x68c40cf8fb549867,
4798            >(_buf?)?;
4799            Ok(_response.map(|x| x))
4800        }
4801        self.client.send_query_and_decode::<SessionDetachRequest, SessionDetachResult>(
4802            (port,),
4803            0x68c40cf8fb549867,
4804            fidl::encoding::DynamicFlags::empty(),
4805            _decode,
4806        )
4807    }
4808
4809    fn r#close(&self) -> Result<(), fidl::Error> {
4810        self.client.send::<fidl::encoding::EmptyPayload>(
4811            (),
4812            0x393d5070394a92f6,
4813            fidl::encoding::DynamicFlags::empty(),
4814        )
4815    }
4816
4817    type WatchDelegatedRxLeaseResponseFut = fidl::client::QueryResponseFut<
4818        DelegatedRxLease,
4819        fidl::encoding::DefaultFuchsiaResourceDialect,
4820    >;
4821    fn r#watch_delegated_rx_lease(&self) -> Self::WatchDelegatedRxLeaseResponseFut {
4822        fn _decode(
4823            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4824        ) -> Result<DelegatedRxLease, fidl::Error> {
4825            let _response = fidl::client::decode_transaction_body::<
4826                SessionWatchDelegatedRxLeaseResponse,
4827                fidl::encoding::DefaultFuchsiaResourceDialect,
4828                0x764d823ee64803b5,
4829            >(_buf?)?;
4830            Ok(_response.lease)
4831        }
4832        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DelegatedRxLease>(
4833            (),
4834            0x764d823ee64803b5,
4835            fidl::encoding::DynamicFlags::empty(),
4836            _decode,
4837        )
4838    }
4839
4840    type RegisterForTxResponseFut =
4841        fidl::client::QueryResponseFut<(u8, i32), fidl::encoding::DefaultFuchsiaResourceDialect>;
4842    fn r#register_for_tx(&self, mut vmos: &[u8]) -> Self::RegisterForTxResponseFut {
4843        fn _decode(
4844            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4845        ) -> Result<(u8, i32), fidl::Error> {
4846            let _response = fidl::client::decode_transaction_body::<
4847                SessionRegisterForTxResponse,
4848                fidl::encoding::DefaultFuchsiaResourceDialect,
4849                0x36321799ce2a081a,
4850            >(_buf?)?;
4851            Ok((_response.successful, _response.status))
4852        }
4853        self.client.send_query_and_decode::<SessionRegisterForTxRequest, (u8, i32)>(
4854            (vmos,),
4855            0x36321799ce2a081a,
4856            fidl::encoding::DynamicFlags::empty(),
4857            _decode,
4858        )
4859    }
4860
4861    type UnregisterForTxResponseFut =
4862        fidl::client::QueryResponseFut<(u8, i32), fidl::encoding::DefaultFuchsiaResourceDialect>;
4863    fn r#unregister_for_tx(&self, mut vmos: &[u8]) -> Self::UnregisterForTxResponseFut {
4864        fn _decode(
4865            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4866        ) -> Result<(u8, i32), fidl::Error> {
4867            let _response = fidl::client::decode_transaction_body::<
4868                SessionUnregisterForTxResponse,
4869                fidl::encoding::DefaultFuchsiaResourceDialect,
4870                0x3e76b16030d62796,
4871            >(_buf?)?;
4872            Ok((_response.successful, _response.status))
4873        }
4874        self.client.send_query_and_decode::<SessionUnregisterForTxRequest, (u8, i32)>(
4875            (vmos,),
4876            0x3e76b16030d62796,
4877            fidl::encoding::DynamicFlags::empty(),
4878            _decode,
4879        )
4880    }
4881}
4882
4883pub struct SessionEventStream {
4884    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4885}
4886
4887impl std::marker::Unpin for SessionEventStream {}
4888
4889impl futures::stream::FusedStream for SessionEventStream {
4890    fn is_terminated(&self) -> bool {
4891        self.event_receiver.is_terminated()
4892    }
4893}
4894
4895impl futures::Stream for SessionEventStream {
4896    type Item = Result<SessionEvent, fidl::Error>;
4897
4898    fn poll_next(
4899        mut self: std::pin::Pin<&mut Self>,
4900        cx: &mut std::task::Context<'_>,
4901    ) -> std::task::Poll<Option<Self::Item>> {
4902        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4903            &mut self.event_receiver,
4904            cx
4905        )?) {
4906            Some(buf) => std::task::Poll::Ready(Some(SessionEvent::decode(buf))),
4907            None => std::task::Poll::Ready(None),
4908        }
4909    }
4910}
4911
4912#[derive(Debug)]
4913pub enum SessionEvent {}
4914
4915impl SessionEvent {
4916    /// Decodes a message buffer as a [`SessionEvent`].
4917    fn decode(
4918        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4919    ) -> Result<SessionEvent, fidl::Error> {
4920        let (bytes, _handles) = buf.split_mut();
4921        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4922        debug_assert_eq!(tx_header.tx_id, 0);
4923        match tx_header.ordinal {
4924            _ => Err(fidl::Error::UnknownOrdinal {
4925                ordinal: tx_header.ordinal,
4926                protocol_name: <SessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4927            }),
4928        }
4929    }
4930}
4931
4932/// A Stream of incoming requests for fuchsia.hardware.network/Session.
4933pub struct SessionRequestStream {
4934    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4935    is_terminated: bool,
4936}
4937
4938impl std::marker::Unpin for SessionRequestStream {}
4939
4940impl futures::stream::FusedStream for SessionRequestStream {
4941    fn is_terminated(&self) -> bool {
4942        self.is_terminated
4943    }
4944}
4945
4946impl fidl::endpoints::RequestStream for SessionRequestStream {
4947    type Protocol = SessionMarker;
4948    type ControlHandle = SessionControlHandle;
4949
4950    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4951        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4952    }
4953
4954    fn control_handle(&self) -> Self::ControlHandle {
4955        SessionControlHandle { inner: self.inner.clone() }
4956    }
4957
4958    fn into_inner(
4959        self,
4960    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4961    {
4962        (self.inner, self.is_terminated)
4963    }
4964
4965    fn from_inner(
4966        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4967        is_terminated: bool,
4968    ) -> Self {
4969        Self { inner, is_terminated }
4970    }
4971}
4972
4973impl futures::Stream for SessionRequestStream {
4974    type Item = Result<SessionRequest, fidl::Error>;
4975
4976    fn poll_next(
4977        mut self: std::pin::Pin<&mut Self>,
4978        cx: &mut std::task::Context<'_>,
4979    ) -> std::task::Poll<Option<Self::Item>> {
4980        let this = &mut *self;
4981        if this.inner.check_shutdown(cx) {
4982            this.is_terminated = true;
4983            return std::task::Poll::Ready(None);
4984        }
4985        if this.is_terminated {
4986            panic!("polled SessionRequestStream after completion");
4987        }
4988        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4989            |bytes, handles| {
4990                match this.inner.channel().read_etc(cx, bytes, handles) {
4991                    std::task::Poll::Ready(Ok(())) => {}
4992                    std::task::Poll::Pending => return std::task::Poll::Pending,
4993                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4994                        this.is_terminated = true;
4995                        return std::task::Poll::Ready(None);
4996                    }
4997                    std::task::Poll::Ready(Err(e)) => {
4998                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4999                            e.into(),
5000                        ))));
5001                    }
5002                }
5003
5004                // A message has been received from the channel
5005                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5006
5007                std::task::Poll::Ready(Some(match header.ordinal {
5008                    0x1e89c9013e201379 => {
5009                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5010                        let mut req = fidl::new_empty!(
5011                            SessionAttachRequest,
5012                            fidl::encoding::DefaultFuchsiaResourceDialect
5013                        );
5014                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionAttachRequest>(&header, _body_bytes, handles, &mut req)?;
5015                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
5016                        Ok(SessionRequest::Attach {
5017                            port: req.port,
5018                            rx_frames: req.rx_frames,
5019
5020                            responder: SessionAttachResponder {
5021                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5022                                tx_id: header.tx_id,
5023                            },
5024                        })
5025                    }
5026                    0x68c40cf8fb549867 => {
5027                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5028                        let mut req = fidl::new_empty!(
5029                            SessionDetachRequest,
5030                            fidl::encoding::DefaultFuchsiaResourceDialect
5031                        );
5032                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionDetachRequest>(&header, _body_bytes, handles, &mut req)?;
5033                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
5034                        Ok(SessionRequest::Detach {
5035                            port: req.port,
5036
5037                            responder: SessionDetachResponder {
5038                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5039                                tx_id: header.tx_id,
5040                            },
5041                        })
5042                    }
5043                    0x393d5070394a92f6 => {
5044                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5045                        let mut req = fidl::new_empty!(
5046                            fidl::encoding::EmptyPayload,
5047                            fidl::encoding::DefaultFuchsiaResourceDialect
5048                        );
5049                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5050                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
5051                        Ok(SessionRequest::Close { control_handle })
5052                    }
5053                    0x764d823ee64803b5 => {
5054                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5055                        let mut req = fidl::new_empty!(
5056                            fidl::encoding::EmptyPayload,
5057                            fidl::encoding::DefaultFuchsiaResourceDialect
5058                        );
5059                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5060                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
5061                        Ok(SessionRequest::WatchDelegatedRxLease {
5062                            responder: SessionWatchDelegatedRxLeaseResponder {
5063                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5064                                tx_id: header.tx_id,
5065                            },
5066                        })
5067                    }
5068                    0x36321799ce2a081a => {
5069                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5070                        let mut req = fidl::new_empty!(
5071                            SessionRegisterForTxRequest,
5072                            fidl::encoding::DefaultFuchsiaResourceDialect
5073                        );
5074                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionRegisterForTxRequest>(&header, _body_bytes, handles, &mut req)?;
5075                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
5076                        Ok(SessionRequest::RegisterForTx {
5077                            vmos: req.vmos,
5078
5079                            responder: SessionRegisterForTxResponder {
5080                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5081                                tx_id: header.tx_id,
5082                            },
5083                        })
5084                    }
5085                    0x3e76b16030d62796 => {
5086                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5087                        let mut req = fidl::new_empty!(
5088                            SessionUnregisterForTxRequest,
5089                            fidl::encoding::DefaultFuchsiaResourceDialect
5090                        );
5091                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionUnregisterForTxRequest>(&header, _body_bytes, handles, &mut req)?;
5092                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
5093                        Ok(SessionRequest::UnregisterForTx {
5094                            vmos: req.vmos,
5095
5096                            responder: SessionUnregisterForTxResponder {
5097                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5098                                tx_id: header.tx_id,
5099                            },
5100                        })
5101                    }
5102                    _ => Err(fidl::Error::UnknownOrdinal {
5103                        ordinal: header.ordinal,
5104                        protocol_name:
5105                            <SessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5106                    }),
5107                }))
5108            },
5109        )
5110    }
5111}
5112
5113/// Represents a session with a Network device.
5114///
5115/// A session has a data plane and a control plane. The `Session` protocol
5116/// represents the control plane of the session and the FIFOs and VMOs exchanged
5117/// during the [`Device.OpenSession`] call are the data plane. Lifetime of the
5118/// session is controlled by a `Session` protocol handle.
5119///
5120/// Sessions must attach to ports of interest to start receiving and sending
5121/// data. Sessions are always created with no ports attached.
5122///
5123/// If a port is destroyed from the underlying device, it is automatically
5124/// detached from the session.
5125///
5126/// Inbound traffic is dispatched to all open sessions. Devices typically
5127/// operate with a single primary session, see [`SessionFlags.PRIMARY`]. Each
5128/// additional open session to the same device causes data copy overhead on the
5129/// device's data path.
5130///
5131/// The session is closed with an error epitaph if an invalid buffer descriptor
5132/// is sent over either the tx or rx FIFOs. Invalid descriptors include:
5133///    - Descriptor index larger than [`SessionInfo.descriptor_count`].
5134///    - Descriptor chains larger than [`MAX_DESCRIPTOR_CHAIN`].
5135///    - rx buffers smaller than [`Info.min_rx_buffer_length`].
5136///    - tx buffers smaller than [`Info.min_tx_buffer_length`].
5137///    - tx buffers not respecting [`Info.min_tx_buffer_head`] or
5138///      [`Info.min_tx_buffer_tail`].
5139#[derive(Debug)]
5140pub enum SessionRequest {
5141    /// Attaches the session to `port`.
5142    ///
5143    /// Once attached, the session starts to receive the subscribed frames over
5144    /// the data FIFOs and it may send frames destined to the specified `port`.
5145    ///
5146    /// + request `port` port to subscribe to.
5147    /// + request `rx_frames` Frame types of interest on the port.
5148    /// * error `ZX_ERR_NOT_FOUND` if `port` is not valid.
5149    /// * error `ZX_ERR_INVALID_ARGS` if `rx_frames` is not a subset of the
5150    /// port's supported frames.
5151    /// * error `ZX_ERR_ALREADY_BOUND` if `port` is already attached.
5152    Attach { port: PortId, rx_frames: Vec<FrameType>, responder: SessionAttachResponder },
5153    /// Detaches the session from `port`.
5154    ///
5155    /// Once detached, the session stops receiving frames from `port`. Frames
5156    /// sent to a detached port may be returned with an error. It is not
5157    /// necessary to call `Detach` on ports that are removed from the device,
5158    /// doing so causes `ZX_ERR_NOT_FOUND` to be returned.
5159    ///
5160    /// + request `port` port to subscribe to.
5161    /// * error `ZX_ERR_NOT_FOUND` if the session is not currently attached to
5162    /// the port.
5163    Detach { port: PortId, responder: SessionDetachResponder },
5164    /// Cleanly closes a session.
5165    ///
5166    /// This will cause the session to send a `ZX_ERR_CANCELLED` epitaph and
5167    /// proceed to close the Session channel. Clients may only assume that they
5168    /// own all the buffers that are currently owned by the session (sent over
5169    /// either the rx or tx FIFOs) once the epitaph is received. Closing the rx
5170    /// or tx FIFO is equivalent to calling `Close`.
5171    Close { control_handle: SessionControlHandle },
5172    /// Watchers for delegated receive wakeup leases.
5173    ///
5174    /// Calls block until a lease is delegated by the device. If a call to
5175    /// `WatchDelegatedRxLease` is made while a previous call is blocking, the
5176    /// session is closed with `ZX_ERR_BAD_STATE`. Will never yield any values
5177    /// for sessions created without [`SessionFlags.RECEIVE_RX_POWER_LEASES`].
5178    ///
5179    /// Given a single lease is assumed sufficient to keep the system awake, the
5180    /// server only keeps a single lease in its buffer. If a new delegated lease
5181    /// becomes available and the client hasn't popped the previous one with a
5182    /// call to `WatchDelegatedRxLease`, the server drops the previously pending
5183    /// lease.
5184    ///
5185    /// See [`DelegatedRxLease`] for how to handle delegated leases.
5186    WatchDelegatedRxLease { responder: SessionWatchDelegatedRxLeaseResponder },
5187    /// Asks the network device to register the VMO for Tx.
5188    ///
5189    /// The network device prepares the VMOs in order and stops at the first
5190    /// error if any. It returns how many VMOs have been prepared alongside with
5191    /// the first error encountered. Note that network-device itself does not
5192    /// try to release earlier VMOs for a later error. It is up to the client
5193    /// how to recover from an error.
5194    ///
5195    /// * error `ZX_ERR_NOT_FOUND` if any of the VmoId is unknown.
5196    /// * error other zx status that can be reported by the driver.
5197    RegisterForTx { vmos: Vec<u8>, responder: SessionRegisterForTxResponder },
5198    /// Tells the device that the client will no longer use the VMO for Tx,
5199    /// if the VMO is also unused for Rx, the device is free to release it
5200    /// at the implementation driver.
5201    ///
5202    /// The network device processes the VMOs in order and stops at the first
5203    /// error if any. It returns how many VMOs have been marked as unused for Tx
5204    /// alongside with the first error encountered. Note that network-device
5205    /// itself does not try to re-register earlier VMOs for a later error. It is
5206    /// up to the client how to recover from an error.
5207    ///
5208    /// * error `ZX_ERR_NOT_FOUND` if any of the VmoId is unknown.
5209    /// * error other zx status that can be reported by the driver.
5210    UnregisterForTx { vmos: Vec<u8>, responder: SessionUnregisterForTxResponder },
5211}
5212
5213impl SessionRequest {
5214    #[allow(irrefutable_let_patterns)]
5215    pub fn into_attach(self) -> Option<(PortId, Vec<FrameType>, SessionAttachResponder)> {
5216        if let SessionRequest::Attach { port, rx_frames, responder } = self {
5217            Some((port, rx_frames, responder))
5218        } else {
5219            None
5220        }
5221    }
5222
5223    #[allow(irrefutable_let_patterns)]
5224    pub fn into_detach(self) -> Option<(PortId, SessionDetachResponder)> {
5225        if let SessionRequest::Detach { port, responder } = self {
5226            Some((port, responder))
5227        } else {
5228            None
5229        }
5230    }
5231
5232    #[allow(irrefutable_let_patterns)]
5233    pub fn into_close(self) -> Option<(SessionControlHandle)> {
5234        if let SessionRequest::Close { control_handle } = self {
5235            Some((control_handle))
5236        } else {
5237            None
5238        }
5239    }
5240
5241    #[allow(irrefutable_let_patterns)]
5242    pub fn into_watch_delegated_rx_lease(self) -> Option<(SessionWatchDelegatedRxLeaseResponder)> {
5243        if let SessionRequest::WatchDelegatedRxLease { responder } = self {
5244            Some((responder))
5245        } else {
5246            None
5247        }
5248    }
5249
5250    #[allow(irrefutable_let_patterns)]
5251    pub fn into_register_for_tx(self) -> Option<(Vec<u8>, SessionRegisterForTxResponder)> {
5252        if let SessionRequest::RegisterForTx { vmos, responder } = self {
5253            Some((vmos, responder))
5254        } else {
5255            None
5256        }
5257    }
5258
5259    #[allow(irrefutable_let_patterns)]
5260    pub fn into_unregister_for_tx(self) -> Option<(Vec<u8>, SessionUnregisterForTxResponder)> {
5261        if let SessionRequest::UnregisterForTx { vmos, responder } = self {
5262            Some((vmos, responder))
5263        } else {
5264            None
5265        }
5266    }
5267
5268    /// Name of the method defined in FIDL
5269    pub fn method_name(&self) -> &'static str {
5270        match *self {
5271            SessionRequest::Attach { .. } => "attach",
5272            SessionRequest::Detach { .. } => "detach",
5273            SessionRequest::Close { .. } => "close",
5274            SessionRequest::WatchDelegatedRxLease { .. } => "watch_delegated_rx_lease",
5275            SessionRequest::RegisterForTx { .. } => "register_for_tx",
5276            SessionRequest::UnregisterForTx { .. } => "unregister_for_tx",
5277        }
5278    }
5279}
5280
5281#[derive(Debug, Clone)]
5282pub struct SessionControlHandle {
5283    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5284}
5285
5286impl fidl::endpoints::ControlHandle for SessionControlHandle {
5287    fn shutdown(&self) {
5288        self.inner.shutdown()
5289    }
5290
5291    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5292        self.inner.shutdown_with_epitaph(status)
5293    }
5294
5295    fn is_closed(&self) -> bool {
5296        self.inner.channel().is_closed()
5297    }
5298    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5299        self.inner.channel().on_closed()
5300    }
5301
5302    #[cfg(target_os = "fuchsia")]
5303    fn signal_peer(
5304        &self,
5305        clear_mask: zx::Signals,
5306        set_mask: zx::Signals,
5307    ) -> Result<(), zx_status::Status> {
5308        use fidl::Peered;
5309        self.inner.channel().signal_peer(clear_mask, set_mask)
5310    }
5311}
5312
5313impl SessionControlHandle {}
5314
5315#[must_use = "FIDL methods require a response to be sent"]
5316#[derive(Debug)]
5317pub struct SessionAttachResponder {
5318    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
5319    tx_id: u32,
5320}
5321
5322/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
5323/// if the responder is dropped without sending a response, so that the client
5324/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5325impl std::ops::Drop for SessionAttachResponder {
5326    fn drop(&mut self) {
5327        self.control_handle.shutdown();
5328        // Safety: drops once, never accessed again
5329        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5330    }
5331}
5332
5333impl fidl::endpoints::Responder for SessionAttachResponder {
5334    type ControlHandle = SessionControlHandle;
5335
5336    fn control_handle(&self) -> &SessionControlHandle {
5337        &self.control_handle
5338    }
5339
5340    fn drop_without_shutdown(mut self) {
5341        // Safety: drops once, never accessed again due to mem::forget
5342        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5343        // Prevent Drop from running (which would shut down the channel)
5344        std::mem::forget(self);
5345    }
5346}
5347
5348impl SessionAttachResponder {
5349    /// Sends a response to the FIDL transaction.
5350    ///
5351    /// Sets the channel to shutdown if an error occurs.
5352    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5353        let _result = self.send_raw(result);
5354        if _result.is_err() {
5355            self.control_handle.shutdown();
5356        }
5357        self.drop_without_shutdown();
5358        _result
5359    }
5360
5361    /// Similar to "send" but does not shutdown the channel if an error occurs.
5362    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5363        let _result = self.send_raw(result);
5364        self.drop_without_shutdown();
5365        _result
5366    }
5367
5368    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5369        self.control_handle
5370            .inner
5371            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5372                result,
5373                self.tx_id,
5374                0x1e89c9013e201379,
5375                fidl::encoding::DynamicFlags::empty(),
5376            )
5377    }
5378}
5379
5380#[must_use = "FIDL methods require a response to be sent"]
5381#[derive(Debug)]
5382pub struct SessionDetachResponder {
5383    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
5384    tx_id: u32,
5385}
5386
5387/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
5388/// if the responder is dropped without sending a response, so that the client
5389/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5390impl std::ops::Drop for SessionDetachResponder {
5391    fn drop(&mut self) {
5392        self.control_handle.shutdown();
5393        // Safety: drops once, never accessed again
5394        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5395    }
5396}
5397
5398impl fidl::endpoints::Responder for SessionDetachResponder {
5399    type ControlHandle = SessionControlHandle;
5400
5401    fn control_handle(&self) -> &SessionControlHandle {
5402        &self.control_handle
5403    }
5404
5405    fn drop_without_shutdown(mut self) {
5406        // Safety: drops once, never accessed again due to mem::forget
5407        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5408        // Prevent Drop from running (which would shut down the channel)
5409        std::mem::forget(self);
5410    }
5411}
5412
5413impl SessionDetachResponder {
5414    /// Sends a response to the FIDL transaction.
5415    ///
5416    /// Sets the channel to shutdown if an error occurs.
5417    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5418        let _result = self.send_raw(result);
5419        if _result.is_err() {
5420            self.control_handle.shutdown();
5421        }
5422        self.drop_without_shutdown();
5423        _result
5424    }
5425
5426    /// Similar to "send" but does not shutdown the channel if an error occurs.
5427    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5428        let _result = self.send_raw(result);
5429        self.drop_without_shutdown();
5430        _result
5431    }
5432
5433    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5434        self.control_handle
5435            .inner
5436            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5437                result,
5438                self.tx_id,
5439                0x68c40cf8fb549867,
5440                fidl::encoding::DynamicFlags::empty(),
5441            )
5442    }
5443}
5444
5445#[must_use = "FIDL methods require a response to be sent"]
5446#[derive(Debug)]
5447pub struct SessionWatchDelegatedRxLeaseResponder {
5448    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
5449    tx_id: u32,
5450}
5451
5452/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
5453/// if the responder is dropped without sending a response, so that the client
5454/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5455impl std::ops::Drop for SessionWatchDelegatedRxLeaseResponder {
5456    fn drop(&mut self) {
5457        self.control_handle.shutdown();
5458        // Safety: drops once, never accessed again
5459        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5460    }
5461}
5462
5463impl fidl::endpoints::Responder for SessionWatchDelegatedRxLeaseResponder {
5464    type ControlHandle = SessionControlHandle;
5465
5466    fn control_handle(&self) -> &SessionControlHandle {
5467        &self.control_handle
5468    }
5469
5470    fn drop_without_shutdown(mut self) {
5471        // Safety: drops once, never accessed again due to mem::forget
5472        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5473        // Prevent Drop from running (which would shut down the channel)
5474        std::mem::forget(self);
5475    }
5476}
5477
5478impl SessionWatchDelegatedRxLeaseResponder {
5479    /// Sends a response to the FIDL transaction.
5480    ///
5481    /// Sets the channel to shutdown if an error occurs.
5482    pub fn send(self, mut lease: DelegatedRxLease) -> Result<(), fidl::Error> {
5483        let _result = self.send_raw(lease);
5484        if _result.is_err() {
5485            self.control_handle.shutdown();
5486        }
5487        self.drop_without_shutdown();
5488        _result
5489    }
5490
5491    /// Similar to "send" but does not shutdown the channel if an error occurs.
5492    pub fn send_no_shutdown_on_err(self, mut lease: DelegatedRxLease) -> Result<(), fidl::Error> {
5493        let _result = self.send_raw(lease);
5494        self.drop_without_shutdown();
5495        _result
5496    }
5497
5498    fn send_raw(&self, mut lease: DelegatedRxLease) -> Result<(), fidl::Error> {
5499        self.control_handle.inner.send::<SessionWatchDelegatedRxLeaseResponse>(
5500            (&mut lease,),
5501            self.tx_id,
5502            0x764d823ee64803b5,
5503            fidl::encoding::DynamicFlags::empty(),
5504        )
5505    }
5506}
5507
5508#[must_use = "FIDL methods require a response to be sent"]
5509#[derive(Debug)]
5510pub struct SessionRegisterForTxResponder {
5511    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
5512    tx_id: u32,
5513}
5514
5515/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
5516/// if the responder is dropped without sending a response, so that the client
5517/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5518impl std::ops::Drop for SessionRegisterForTxResponder {
5519    fn drop(&mut self) {
5520        self.control_handle.shutdown();
5521        // Safety: drops once, never accessed again
5522        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5523    }
5524}
5525
5526impl fidl::endpoints::Responder for SessionRegisterForTxResponder {
5527    type ControlHandle = SessionControlHandle;
5528
5529    fn control_handle(&self) -> &SessionControlHandle {
5530        &self.control_handle
5531    }
5532
5533    fn drop_without_shutdown(mut self) {
5534        // Safety: drops once, never accessed again due to mem::forget
5535        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5536        // Prevent Drop from running (which would shut down the channel)
5537        std::mem::forget(self);
5538    }
5539}
5540
5541impl SessionRegisterForTxResponder {
5542    /// Sends a response to the FIDL transaction.
5543    ///
5544    /// Sets the channel to shutdown if an error occurs.
5545    pub fn send(self, mut successful: u8, mut status: i32) -> Result<(), fidl::Error> {
5546        let _result = self.send_raw(successful, status);
5547        if _result.is_err() {
5548            self.control_handle.shutdown();
5549        }
5550        self.drop_without_shutdown();
5551        _result
5552    }
5553
5554    /// Similar to "send" but does not shutdown the channel if an error occurs.
5555    pub fn send_no_shutdown_on_err(
5556        self,
5557        mut successful: u8,
5558        mut status: i32,
5559    ) -> Result<(), fidl::Error> {
5560        let _result = self.send_raw(successful, status);
5561        self.drop_without_shutdown();
5562        _result
5563    }
5564
5565    fn send_raw(&self, mut successful: u8, mut status: i32) -> Result<(), fidl::Error> {
5566        self.control_handle.inner.send::<SessionRegisterForTxResponse>(
5567            (successful, status),
5568            self.tx_id,
5569            0x36321799ce2a081a,
5570            fidl::encoding::DynamicFlags::empty(),
5571        )
5572    }
5573}
5574
5575#[must_use = "FIDL methods require a response to be sent"]
5576#[derive(Debug)]
5577pub struct SessionUnregisterForTxResponder {
5578    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
5579    tx_id: u32,
5580}
5581
5582/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
5583/// if the responder is dropped without sending a response, so that the client
5584/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5585impl std::ops::Drop for SessionUnregisterForTxResponder {
5586    fn drop(&mut self) {
5587        self.control_handle.shutdown();
5588        // Safety: drops once, never accessed again
5589        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5590    }
5591}
5592
5593impl fidl::endpoints::Responder for SessionUnregisterForTxResponder {
5594    type ControlHandle = SessionControlHandle;
5595
5596    fn control_handle(&self) -> &SessionControlHandle {
5597        &self.control_handle
5598    }
5599
5600    fn drop_without_shutdown(mut self) {
5601        // Safety: drops once, never accessed again due to mem::forget
5602        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5603        // Prevent Drop from running (which would shut down the channel)
5604        std::mem::forget(self);
5605    }
5606}
5607
5608impl SessionUnregisterForTxResponder {
5609    /// Sends a response to the FIDL transaction.
5610    ///
5611    /// Sets the channel to shutdown if an error occurs.
5612    pub fn send(self, mut successful: u8, mut status: i32) -> Result<(), fidl::Error> {
5613        let _result = self.send_raw(successful, status);
5614        if _result.is_err() {
5615            self.control_handle.shutdown();
5616        }
5617        self.drop_without_shutdown();
5618        _result
5619    }
5620
5621    /// Similar to "send" but does not shutdown the channel if an error occurs.
5622    pub fn send_no_shutdown_on_err(
5623        self,
5624        mut successful: u8,
5625        mut status: i32,
5626    ) -> Result<(), fidl::Error> {
5627        let _result = self.send_raw(successful, status);
5628        self.drop_without_shutdown();
5629        _result
5630    }
5631
5632    fn send_raw(&self, mut successful: u8, mut status: i32) -> Result<(), fidl::Error> {
5633        self.control_handle.inner.send::<SessionUnregisterForTxResponse>(
5634            (successful, status),
5635            self.tx_id,
5636            0x3e76b16030d62796,
5637            fidl::encoding::DynamicFlags::empty(),
5638        )
5639    }
5640}
5641
5642#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5643pub struct StatusWatcherMarker;
5644
5645impl fidl::endpoints::ProtocolMarker for StatusWatcherMarker {
5646    type Proxy = StatusWatcherProxy;
5647    type RequestStream = StatusWatcherRequestStream;
5648    #[cfg(target_os = "fuchsia")]
5649    type SynchronousProxy = StatusWatcherSynchronousProxy;
5650
5651    const DEBUG_NAME: &'static str = "(anonymous) StatusWatcher";
5652}
5653
5654pub trait StatusWatcherProxyInterface: Send + Sync {
5655    type WatchStatusResponseFut: std::future::Future<Output = Result<PortStatus, fidl::Error>>
5656        + Send;
5657    fn r#watch_status(&self) -> Self::WatchStatusResponseFut;
5658}
5659#[derive(Debug)]
5660#[cfg(target_os = "fuchsia")]
5661pub struct StatusWatcherSynchronousProxy {
5662    client: fidl::client::sync::Client,
5663}
5664
5665#[cfg(target_os = "fuchsia")]
5666impl fidl::endpoints::SynchronousProxy for StatusWatcherSynchronousProxy {
5667    type Proxy = StatusWatcherProxy;
5668    type Protocol = StatusWatcherMarker;
5669
5670    fn from_channel(inner: fidl::Channel) -> Self {
5671        Self::new(inner)
5672    }
5673
5674    fn into_channel(self) -> fidl::Channel {
5675        self.client.into_channel()
5676    }
5677
5678    fn as_channel(&self) -> &fidl::Channel {
5679        self.client.as_channel()
5680    }
5681}
5682
5683#[cfg(target_os = "fuchsia")]
5684impl StatusWatcherSynchronousProxy {
5685    pub fn new(channel: fidl::Channel) -> Self {
5686        Self { client: fidl::client::sync::Client::new(channel) }
5687    }
5688
5689    pub fn into_channel(self) -> fidl::Channel {
5690        self.client.into_channel()
5691    }
5692
5693    /// Waits until an event arrives and returns it. It is safe for other
5694    /// threads to make concurrent requests while waiting for an event.
5695    pub fn wait_for_event(
5696        &self,
5697        deadline: zx::MonotonicInstant,
5698    ) -> Result<StatusWatcherEvent, fidl::Error> {
5699        StatusWatcherEvent::decode(self.client.wait_for_event::<StatusWatcherMarker>(deadline)?)
5700    }
5701
5702    /// `WatchStatus` blocks until the port's status has changed.
5703    ///
5704    /// The first call to `WatchStatus` returns immediately with the current
5705    /// port status, subsequent calls complete when the port status differs from
5706    /// the last one that was returned through this `StatusWatcher`.
5707    ///
5708    /// If `StatusWatcher` was created with a buffer value larger than 1,
5709    /// `WatchStatus` may return a queued status change, depending on how many
5710    /// status changed happened since the last call to `WatchStatus`.
5711    ///
5712    /// - response `device_status` the most recent port status.
5713    pub fn r#watch_status(
5714        &self,
5715        ___deadline: zx::MonotonicInstant,
5716    ) -> Result<PortStatus, fidl::Error> {
5717        let _response = self.client.send_query::<
5718            fidl::encoding::EmptyPayload,
5719            StatusWatcherWatchStatusResponse,
5720            StatusWatcherMarker,
5721        >(
5722            (),
5723            0x1369a8125c0862b9,
5724            fidl::encoding::DynamicFlags::empty(),
5725            ___deadline,
5726        )?;
5727        Ok(_response.port_status)
5728    }
5729}
5730
5731#[cfg(target_os = "fuchsia")]
5732impl From<StatusWatcherSynchronousProxy> for zx::NullableHandle {
5733    fn from(value: StatusWatcherSynchronousProxy) -> Self {
5734        value.into_channel().into()
5735    }
5736}
5737
5738#[cfg(target_os = "fuchsia")]
5739impl From<fidl::Channel> for StatusWatcherSynchronousProxy {
5740    fn from(value: fidl::Channel) -> Self {
5741        Self::new(value)
5742    }
5743}
5744
5745#[cfg(target_os = "fuchsia")]
5746impl fidl::endpoints::FromClient for StatusWatcherSynchronousProxy {
5747    type Protocol = StatusWatcherMarker;
5748
5749    fn from_client(value: fidl::endpoints::ClientEnd<StatusWatcherMarker>) -> Self {
5750        Self::new(value.into_channel())
5751    }
5752}
5753
5754#[derive(Debug, Clone)]
5755pub struct StatusWatcherProxy {
5756    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5757}
5758
5759impl fidl::endpoints::Proxy for StatusWatcherProxy {
5760    type Protocol = StatusWatcherMarker;
5761
5762    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5763        Self::new(inner)
5764    }
5765
5766    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5767        self.client.into_channel().map_err(|client| Self { client })
5768    }
5769
5770    fn as_channel(&self) -> &::fidl::AsyncChannel {
5771        self.client.as_channel()
5772    }
5773}
5774
5775impl StatusWatcherProxy {
5776    /// Create a new Proxy for fuchsia.hardware.network/StatusWatcher.
5777    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5778        let protocol_name = <StatusWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5779        Self { client: fidl::client::Client::new(channel, protocol_name) }
5780    }
5781
5782    /// Get a Stream of events from the remote end of the protocol.
5783    ///
5784    /// # Panics
5785    ///
5786    /// Panics if the event stream was already taken.
5787    pub fn take_event_stream(&self) -> StatusWatcherEventStream {
5788        StatusWatcherEventStream { event_receiver: self.client.take_event_receiver() }
5789    }
5790
5791    /// `WatchStatus` blocks until the port's status has changed.
5792    ///
5793    /// The first call to `WatchStatus` returns immediately with the current
5794    /// port status, subsequent calls complete when the port status differs from
5795    /// the last one that was returned through this `StatusWatcher`.
5796    ///
5797    /// If `StatusWatcher` was created with a buffer value larger than 1,
5798    /// `WatchStatus` may return a queued status change, depending on how many
5799    /// status changed happened since the last call to `WatchStatus`.
5800    ///
5801    /// - response `device_status` the most recent port status.
5802    pub fn r#watch_status(
5803        &self,
5804    ) -> fidl::client::QueryResponseFut<PortStatus, fidl::encoding::DefaultFuchsiaResourceDialect>
5805    {
5806        StatusWatcherProxyInterface::r#watch_status(self)
5807    }
5808}
5809
5810impl StatusWatcherProxyInterface for StatusWatcherProxy {
5811    type WatchStatusResponseFut =
5812        fidl::client::QueryResponseFut<PortStatus, fidl::encoding::DefaultFuchsiaResourceDialect>;
5813    fn r#watch_status(&self) -> Self::WatchStatusResponseFut {
5814        fn _decode(
5815            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5816        ) -> Result<PortStatus, fidl::Error> {
5817            let _response = fidl::client::decode_transaction_body::<
5818                StatusWatcherWatchStatusResponse,
5819                fidl::encoding::DefaultFuchsiaResourceDialect,
5820                0x1369a8125c0862b9,
5821            >(_buf?)?;
5822            Ok(_response.port_status)
5823        }
5824        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PortStatus>(
5825            (),
5826            0x1369a8125c0862b9,
5827            fidl::encoding::DynamicFlags::empty(),
5828            _decode,
5829        )
5830    }
5831}
5832
5833pub struct StatusWatcherEventStream {
5834    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5835}
5836
5837impl std::marker::Unpin for StatusWatcherEventStream {}
5838
5839impl futures::stream::FusedStream for StatusWatcherEventStream {
5840    fn is_terminated(&self) -> bool {
5841        self.event_receiver.is_terminated()
5842    }
5843}
5844
5845impl futures::Stream for StatusWatcherEventStream {
5846    type Item = Result<StatusWatcherEvent, fidl::Error>;
5847
5848    fn poll_next(
5849        mut self: std::pin::Pin<&mut Self>,
5850        cx: &mut std::task::Context<'_>,
5851    ) -> std::task::Poll<Option<Self::Item>> {
5852        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5853            &mut self.event_receiver,
5854            cx
5855        )?) {
5856            Some(buf) => std::task::Poll::Ready(Some(StatusWatcherEvent::decode(buf))),
5857            None => std::task::Poll::Ready(None),
5858        }
5859    }
5860}
5861
5862#[derive(Debug)]
5863pub enum StatusWatcherEvent {}
5864
5865impl StatusWatcherEvent {
5866    /// Decodes a message buffer as a [`StatusWatcherEvent`].
5867    fn decode(
5868        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5869    ) -> Result<StatusWatcherEvent, fidl::Error> {
5870        let (bytes, _handles) = buf.split_mut();
5871        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5872        debug_assert_eq!(tx_header.tx_id, 0);
5873        match tx_header.ordinal {
5874            _ => Err(fidl::Error::UnknownOrdinal {
5875                ordinal: tx_header.ordinal,
5876                protocol_name: <StatusWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5877            }),
5878        }
5879    }
5880}
5881
5882/// A Stream of incoming requests for fuchsia.hardware.network/StatusWatcher.
5883pub struct StatusWatcherRequestStream {
5884    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5885    is_terminated: bool,
5886}
5887
5888impl std::marker::Unpin for StatusWatcherRequestStream {}
5889
5890impl futures::stream::FusedStream for StatusWatcherRequestStream {
5891    fn is_terminated(&self) -> bool {
5892        self.is_terminated
5893    }
5894}
5895
5896impl fidl::endpoints::RequestStream for StatusWatcherRequestStream {
5897    type Protocol = StatusWatcherMarker;
5898    type ControlHandle = StatusWatcherControlHandle;
5899
5900    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5901        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5902    }
5903
5904    fn control_handle(&self) -> Self::ControlHandle {
5905        StatusWatcherControlHandle { inner: self.inner.clone() }
5906    }
5907
5908    fn into_inner(
5909        self,
5910    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5911    {
5912        (self.inner, self.is_terminated)
5913    }
5914
5915    fn from_inner(
5916        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5917        is_terminated: bool,
5918    ) -> Self {
5919        Self { inner, is_terminated }
5920    }
5921}
5922
5923impl futures::Stream for StatusWatcherRequestStream {
5924    type Item = Result<StatusWatcherRequest, fidl::Error>;
5925
5926    fn poll_next(
5927        mut self: std::pin::Pin<&mut Self>,
5928        cx: &mut std::task::Context<'_>,
5929    ) -> std::task::Poll<Option<Self::Item>> {
5930        let this = &mut *self;
5931        if this.inner.check_shutdown(cx) {
5932            this.is_terminated = true;
5933            return std::task::Poll::Ready(None);
5934        }
5935        if this.is_terminated {
5936            panic!("polled StatusWatcherRequestStream after completion");
5937        }
5938        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5939            |bytes, handles| {
5940                match this.inner.channel().read_etc(cx, bytes, handles) {
5941                    std::task::Poll::Ready(Ok(())) => {}
5942                    std::task::Poll::Pending => return std::task::Poll::Pending,
5943                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5944                        this.is_terminated = true;
5945                        return std::task::Poll::Ready(None);
5946                    }
5947                    std::task::Poll::Ready(Err(e)) => {
5948                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5949                            e.into(),
5950                        ))));
5951                    }
5952                }
5953
5954                // A message has been received from the channel
5955                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5956
5957                std::task::Poll::Ready(Some(match header.ordinal {
5958                    0x1369a8125c0862b9 => {
5959                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5960                        let mut req = fidl::new_empty!(
5961                            fidl::encoding::EmptyPayload,
5962                            fidl::encoding::DefaultFuchsiaResourceDialect
5963                        );
5964                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5965                        let control_handle =
5966                            StatusWatcherControlHandle { inner: this.inner.clone() };
5967                        Ok(StatusWatcherRequest::WatchStatus {
5968                            responder: StatusWatcherWatchStatusResponder {
5969                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5970                                tx_id: header.tx_id,
5971                            },
5972                        })
5973                    }
5974                    _ => Err(fidl::Error::UnknownOrdinal {
5975                        ordinal: header.ordinal,
5976                        protocol_name:
5977                            <StatusWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5978                    }),
5979                }))
5980            },
5981        )
5982    }
5983}
5984
5985/// Provides a way to receive updates on port status changes.
5986#[derive(Debug)]
5987pub enum StatusWatcherRequest {
5988    /// `WatchStatus` blocks until the port's status has changed.
5989    ///
5990    /// The first call to `WatchStatus` returns immediately with the current
5991    /// port status, subsequent calls complete when the port status differs from
5992    /// the last one that was returned through this `StatusWatcher`.
5993    ///
5994    /// If `StatusWatcher` was created with a buffer value larger than 1,
5995    /// `WatchStatus` may return a queued status change, depending on how many
5996    /// status changed happened since the last call to `WatchStatus`.
5997    ///
5998    /// - response `device_status` the most recent port status.
5999    WatchStatus { responder: StatusWatcherWatchStatusResponder },
6000}
6001
6002impl StatusWatcherRequest {
6003    #[allow(irrefutable_let_patterns)]
6004    pub fn into_watch_status(self) -> Option<(StatusWatcherWatchStatusResponder)> {
6005        if let StatusWatcherRequest::WatchStatus { responder } = self {
6006            Some((responder))
6007        } else {
6008            None
6009        }
6010    }
6011
6012    /// Name of the method defined in FIDL
6013    pub fn method_name(&self) -> &'static str {
6014        match *self {
6015            StatusWatcherRequest::WatchStatus { .. } => "watch_status",
6016        }
6017    }
6018}
6019
6020#[derive(Debug, Clone)]
6021pub struct StatusWatcherControlHandle {
6022    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6023}
6024
6025impl fidl::endpoints::ControlHandle for StatusWatcherControlHandle {
6026    fn shutdown(&self) {
6027        self.inner.shutdown()
6028    }
6029
6030    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6031        self.inner.shutdown_with_epitaph(status)
6032    }
6033
6034    fn is_closed(&self) -> bool {
6035        self.inner.channel().is_closed()
6036    }
6037    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6038        self.inner.channel().on_closed()
6039    }
6040
6041    #[cfg(target_os = "fuchsia")]
6042    fn signal_peer(
6043        &self,
6044        clear_mask: zx::Signals,
6045        set_mask: zx::Signals,
6046    ) -> Result<(), zx_status::Status> {
6047        use fidl::Peered;
6048        self.inner.channel().signal_peer(clear_mask, set_mask)
6049    }
6050}
6051
6052impl StatusWatcherControlHandle {}
6053
6054#[must_use = "FIDL methods require a response to be sent"]
6055#[derive(Debug)]
6056pub struct StatusWatcherWatchStatusResponder {
6057    control_handle: std::mem::ManuallyDrop<StatusWatcherControlHandle>,
6058    tx_id: u32,
6059}
6060
6061/// Set the the channel to be shutdown (see [`StatusWatcherControlHandle::shutdown`])
6062/// if the responder is dropped without sending a response, so that the client
6063/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6064impl std::ops::Drop for StatusWatcherWatchStatusResponder {
6065    fn drop(&mut self) {
6066        self.control_handle.shutdown();
6067        // Safety: drops once, never accessed again
6068        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6069    }
6070}
6071
6072impl fidl::endpoints::Responder for StatusWatcherWatchStatusResponder {
6073    type ControlHandle = StatusWatcherControlHandle;
6074
6075    fn control_handle(&self) -> &StatusWatcherControlHandle {
6076        &self.control_handle
6077    }
6078
6079    fn drop_without_shutdown(mut self) {
6080        // Safety: drops once, never accessed again due to mem::forget
6081        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6082        // Prevent Drop from running (which would shut down the channel)
6083        std::mem::forget(self);
6084    }
6085}
6086
6087impl StatusWatcherWatchStatusResponder {
6088    /// Sends a response to the FIDL transaction.
6089    ///
6090    /// Sets the channel to shutdown if an error occurs.
6091    pub fn send(self, mut port_status: &PortStatus) -> Result<(), fidl::Error> {
6092        let _result = self.send_raw(port_status);
6093        if _result.is_err() {
6094            self.control_handle.shutdown();
6095        }
6096        self.drop_without_shutdown();
6097        _result
6098    }
6099
6100    /// Similar to "send" but does not shutdown the channel if an error occurs.
6101    pub fn send_no_shutdown_on_err(self, mut port_status: &PortStatus) -> Result<(), fidl::Error> {
6102        let _result = self.send_raw(port_status);
6103        self.drop_without_shutdown();
6104        _result
6105    }
6106
6107    fn send_raw(&self, mut port_status: &PortStatus) -> Result<(), fidl::Error> {
6108        self.control_handle.inner.send::<StatusWatcherWatchStatusResponse>(
6109            (port_status,),
6110            self.tx_id,
6111            0x1369a8125c0862b9,
6112            fidl::encoding::DynamicFlags::empty(),
6113        )
6114    }
6115}
6116
6117#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6118pub struct ServiceMarker;
6119
6120#[cfg(target_os = "fuchsia")]
6121impl fidl::endpoints::ServiceMarker for ServiceMarker {
6122    type Proxy = ServiceProxy;
6123    type Request = ServiceRequest;
6124    const SERVICE_NAME: &'static str = "fuchsia.hardware.network.Service";
6125}
6126
6127/// A request for one of the member protocols of Service.
6128///
6129#[cfg(target_os = "fuchsia")]
6130pub enum ServiceRequest {
6131    Device(DeviceRequestStream),
6132    DeviceTopology(fidl_fuchsia_device_fs::TopologicalPathRequestStream),
6133}
6134
6135#[cfg(target_os = "fuchsia")]
6136impl fidl::endpoints::ServiceRequest for ServiceRequest {
6137    type Service = ServiceMarker;
6138
6139    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
6140        match name {
6141            "device" => Self::Device(
6142                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
6143            ),
6144            "device_topology" => Self::DeviceTopology(
6145                <fidl_fuchsia_device_fs::TopologicalPathRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
6146            ),
6147            _ => panic!("no such member protocol name for service Service"),
6148        }
6149    }
6150
6151    fn member_names() -> &'static [&'static str] {
6152        &["device", "device_topology"]
6153    }
6154}
6155#[cfg(target_os = "fuchsia")]
6156pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
6157
6158#[cfg(target_os = "fuchsia")]
6159impl fidl::endpoints::ServiceProxy for ServiceProxy {
6160    type Service = ServiceMarker;
6161
6162    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
6163        Self(opener)
6164    }
6165}
6166
6167#[cfg(target_os = "fuchsia")]
6168impl ServiceProxy {
6169    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
6170        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
6171        self.connect_channel_to_device(server_end)?;
6172        Ok(proxy)
6173    }
6174
6175    /// Like `connect_to_device`, but returns a sync proxy.
6176    /// See [`Self::connect_to_device`] for more details.
6177    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
6178        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
6179        self.connect_channel_to_device(server_end)?;
6180        Ok(proxy)
6181    }
6182
6183    /// Like `connect_to_device`, but accepts a server end.
6184    /// See [`Self::connect_to_device`] for more details.
6185    pub fn connect_channel_to_device(
6186        &self,
6187        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
6188    ) -> Result<(), fidl::Error> {
6189        self.0.open_member("device", server_end.into_channel())
6190    }
6191    pub fn connect_to_device_topology(
6192        &self,
6193    ) -> Result<fidl_fuchsia_device_fs::TopologicalPathProxy, fidl::Error> {
6194        let (proxy, server_end) =
6195            fidl::endpoints::create_proxy::<fidl_fuchsia_device_fs::TopologicalPathMarker>();
6196        self.connect_channel_to_device_topology(server_end)?;
6197        Ok(proxy)
6198    }
6199
6200    /// Like `connect_to_device_topology`, but returns a sync proxy.
6201    /// See [`Self::connect_to_device_topology`] for more details.
6202    pub fn connect_to_device_topology_sync(
6203        &self,
6204    ) -> Result<fidl_fuchsia_device_fs::TopologicalPathSynchronousProxy, fidl::Error> {
6205        let (proxy, server_end) =
6206            fidl::endpoints::create_sync_proxy::<fidl_fuchsia_device_fs::TopologicalPathMarker>();
6207        self.connect_channel_to_device_topology(server_end)?;
6208        Ok(proxy)
6209    }
6210
6211    /// Like `connect_to_device_topology`, but accepts a server end.
6212    /// See [`Self::connect_to_device_topology`] for more details.
6213    pub fn connect_channel_to_device_topology(
6214        &self,
6215        server_end: fidl::endpoints::ServerEnd<fidl_fuchsia_device_fs::TopologicalPathMarker>,
6216    ) -> Result<(), fidl::Error> {
6217        self.0.open_member("device_topology", server_end.into_channel())
6218    }
6219
6220    pub fn instance_name(&self) -> &str {
6221        self.0.instance_name()
6222    }
6223}
6224
6225mod internal {
6226    use super::*;
6227
6228    impl fidl::encoding::ResourceTypeMarker for DeviceCloneRequest {
6229        type Borrowed<'a> = &'a mut Self;
6230        fn take_or_borrow<'a>(
6231            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6232        ) -> Self::Borrowed<'a> {
6233            value
6234        }
6235    }
6236
6237    unsafe impl fidl::encoding::TypeMarker for DeviceCloneRequest {
6238        type Owned = Self;
6239
6240        #[inline(always)]
6241        fn inline_align(_context: fidl::encoding::Context) -> usize {
6242            4
6243        }
6244
6245        #[inline(always)]
6246        fn inline_size(_context: fidl::encoding::Context) -> usize {
6247            4
6248        }
6249    }
6250
6251    unsafe impl
6252        fidl::encoding::Encode<DeviceCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6253        for &mut DeviceCloneRequest
6254    {
6255        #[inline]
6256        unsafe fn encode(
6257            self,
6258            encoder: &mut fidl::encoding::Encoder<
6259                '_,
6260                fidl::encoding::DefaultFuchsiaResourceDialect,
6261            >,
6262            offset: usize,
6263            _depth: fidl::encoding::Depth,
6264        ) -> fidl::Result<()> {
6265            encoder.debug_check_bounds::<DeviceCloneRequest>(offset);
6266            // Delegate to tuple encoding.
6267            fidl::encoding::Encode::<DeviceCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6268                (
6269                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.device),
6270                ),
6271                encoder, offset, _depth
6272            )
6273        }
6274    }
6275    unsafe impl<
6276        T0: fidl::encoding::Encode<
6277                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
6278                fidl::encoding::DefaultFuchsiaResourceDialect,
6279            >,
6280    > fidl::encoding::Encode<DeviceCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6281        for (T0,)
6282    {
6283        #[inline]
6284        unsafe fn encode(
6285            self,
6286            encoder: &mut fidl::encoding::Encoder<
6287                '_,
6288                fidl::encoding::DefaultFuchsiaResourceDialect,
6289            >,
6290            offset: usize,
6291            depth: fidl::encoding::Depth,
6292        ) -> fidl::Result<()> {
6293            encoder.debug_check_bounds::<DeviceCloneRequest>(offset);
6294            // Zero out padding regions. There's no need to apply masks
6295            // because the unmasked parts will be overwritten by fields.
6296            // Write the fields.
6297            self.0.encode(encoder, offset + 0, depth)?;
6298            Ok(())
6299        }
6300    }
6301
6302    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6303        for DeviceCloneRequest
6304    {
6305        #[inline(always)]
6306        fn new_empty() -> Self {
6307            Self {
6308                device: fidl::new_empty!(
6309                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
6310                    fidl::encoding::DefaultFuchsiaResourceDialect
6311                ),
6312            }
6313        }
6314
6315        #[inline]
6316        unsafe fn decode(
6317            &mut self,
6318            decoder: &mut fidl::encoding::Decoder<
6319                '_,
6320                fidl::encoding::DefaultFuchsiaResourceDialect,
6321            >,
6322            offset: usize,
6323            _depth: fidl::encoding::Depth,
6324        ) -> fidl::Result<()> {
6325            decoder.debug_check_bounds::<Self>(offset);
6326            // Verify that padding bytes are zero.
6327            fidl::decode!(
6328                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
6329                fidl::encoding::DefaultFuchsiaResourceDialect,
6330                &mut self.device,
6331                decoder,
6332                offset + 0,
6333                _depth
6334            )?;
6335            Ok(())
6336        }
6337    }
6338
6339    impl fidl::encoding::ResourceTypeMarker for DeviceGetPortRequest {
6340        type Borrowed<'a> = &'a mut Self;
6341        fn take_or_borrow<'a>(
6342            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6343        ) -> Self::Borrowed<'a> {
6344            value
6345        }
6346    }
6347
6348    unsafe impl fidl::encoding::TypeMarker for DeviceGetPortRequest {
6349        type Owned = Self;
6350
6351        #[inline(always)]
6352        fn inline_align(_context: fidl::encoding::Context) -> usize {
6353            4
6354        }
6355
6356        #[inline(always)]
6357        fn inline_size(_context: fidl::encoding::Context) -> usize {
6358            8
6359        }
6360    }
6361
6362    unsafe impl
6363        fidl::encoding::Encode<DeviceGetPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6364        for &mut DeviceGetPortRequest
6365    {
6366        #[inline]
6367        unsafe fn encode(
6368            self,
6369            encoder: &mut fidl::encoding::Encoder<
6370                '_,
6371                fidl::encoding::DefaultFuchsiaResourceDialect,
6372            >,
6373            offset: usize,
6374            _depth: fidl::encoding::Depth,
6375        ) -> fidl::Result<()> {
6376            encoder.debug_check_bounds::<DeviceGetPortRequest>(offset);
6377            // Delegate to tuple encoding.
6378            fidl::encoding::Encode::<DeviceGetPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6379                (
6380                    <PortId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
6381                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.port),
6382                ),
6383                encoder, offset, _depth
6384            )
6385        }
6386    }
6387    unsafe impl<
6388        T0: fidl::encoding::Encode<PortId, fidl::encoding::DefaultFuchsiaResourceDialect>,
6389        T1: fidl::encoding::Encode<
6390                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
6391                fidl::encoding::DefaultFuchsiaResourceDialect,
6392            >,
6393    >
6394        fidl::encoding::Encode<DeviceGetPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6395        for (T0, T1)
6396    {
6397        #[inline]
6398        unsafe fn encode(
6399            self,
6400            encoder: &mut fidl::encoding::Encoder<
6401                '_,
6402                fidl::encoding::DefaultFuchsiaResourceDialect,
6403            >,
6404            offset: usize,
6405            depth: fidl::encoding::Depth,
6406        ) -> fidl::Result<()> {
6407            encoder.debug_check_bounds::<DeviceGetPortRequest>(offset);
6408            // Zero out padding regions. There's no need to apply masks
6409            // because the unmasked parts will be overwritten by fields.
6410            unsafe {
6411                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
6412                (ptr as *mut u32).write_unaligned(0);
6413            }
6414            // Write the fields.
6415            self.0.encode(encoder, offset + 0, depth)?;
6416            self.1.encode(encoder, offset + 4, depth)?;
6417            Ok(())
6418        }
6419    }
6420
6421    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6422        for DeviceGetPortRequest
6423    {
6424        #[inline(always)]
6425        fn new_empty() -> Self {
6426            Self {
6427                id: fidl::new_empty!(PortId, fidl::encoding::DefaultFuchsiaResourceDialect),
6428                port: fidl::new_empty!(
6429                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
6430                    fidl::encoding::DefaultFuchsiaResourceDialect
6431                ),
6432            }
6433        }
6434
6435        #[inline]
6436        unsafe fn decode(
6437            &mut self,
6438            decoder: &mut fidl::encoding::Decoder<
6439                '_,
6440                fidl::encoding::DefaultFuchsiaResourceDialect,
6441            >,
6442            offset: usize,
6443            _depth: fidl::encoding::Depth,
6444        ) -> fidl::Result<()> {
6445            decoder.debug_check_bounds::<Self>(offset);
6446            // Verify that padding bytes are zero.
6447            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
6448            let padval = unsafe { (ptr as *const u32).read_unaligned() };
6449            let mask = 0xffff0000u32;
6450            let maskedval = padval & mask;
6451            if maskedval != 0 {
6452                return Err(fidl::Error::NonZeroPadding {
6453                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
6454                });
6455            }
6456            fidl::decode!(
6457                PortId,
6458                fidl::encoding::DefaultFuchsiaResourceDialect,
6459                &mut self.id,
6460                decoder,
6461                offset + 0,
6462                _depth
6463            )?;
6464            fidl::decode!(
6465                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
6466                fidl::encoding::DefaultFuchsiaResourceDialect,
6467                &mut self.port,
6468                decoder,
6469                offset + 4,
6470                _depth
6471            )?;
6472            Ok(())
6473        }
6474    }
6475
6476    impl fidl::encoding::ResourceTypeMarker for DeviceGetPortWatcherRequest {
6477        type Borrowed<'a> = &'a mut Self;
6478        fn take_or_borrow<'a>(
6479            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6480        ) -> Self::Borrowed<'a> {
6481            value
6482        }
6483    }
6484
6485    unsafe impl fidl::encoding::TypeMarker for DeviceGetPortWatcherRequest {
6486        type Owned = Self;
6487
6488        #[inline(always)]
6489        fn inline_align(_context: fidl::encoding::Context) -> usize {
6490            4
6491        }
6492
6493        #[inline(always)]
6494        fn inline_size(_context: fidl::encoding::Context) -> usize {
6495            4
6496        }
6497    }
6498
6499    unsafe impl
6500        fidl::encoding::Encode<
6501            DeviceGetPortWatcherRequest,
6502            fidl::encoding::DefaultFuchsiaResourceDialect,
6503        > for &mut DeviceGetPortWatcherRequest
6504    {
6505        #[inline]
6506        unsafe fn encode(
6507            self,
6508            encoder: &mut fidl::encoding::Encoder<
6509                '_,
6510                fidl::encoding::DefaultFuchsiaResourceDialect,
6511            >,
6512            offset: usize,
6513            _depth: fidl::encoding::Depth,
6514        ) -> fidl::Result<()> {
6515            encoder.debug_check_bounds::<DeviceGetPortWatcherRequest>(offset);
6516            // Delegate to tuple encoding.
6517            fidl::encoding::Encode::<DeviceGetPortWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6518                (
6519                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
6520                ),
6521                encoder, offset, _depth
6522            )
6523        }
6524    }
6525    unsafe impl<
6526        T0: fidl::encoding::Encode<
6527                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortWatcherMarker>>,
6528                fidl::encoding::DefaultFuchsiaResourceDialect,
6529            >,
6530    >
6531        fidl::encoding::Encode<
6532            DeviceGetPortWatcherRequest,
6533            fidl::encoding::DefaultFuchsiaResourceDialect,
6534        > for (T0,)
6535    {
6536        #[inline]
6537        unsafe fn encode(
6538            self,
6539            encoder: &mut fidl::encoding::Encoder<
6540                '_,
6541                fidl::encoding::DefaultFuchsiaResourceDialect,
6542            >,
6543            offset: usize,
6544            depth: fidl::encoding::Depth,
6545        ) -> fidl::Result<()> {
6546            encoder.debug_check_bounds::<DeviceGetPortWatcherRequest>(offset);
6547            // Zero out padding regions. There's no need to apply masks
6548            // because the unmasked parts will be overwritten by fields.
6549            // Write the fields.
6550            self.0.encode(encoder, offset + 0, depth)?;
6551            Ok(())
6552        }
6553    }
6554
6555    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6556        for DeviceGetPortWatcherRequest
6557    {
6558        #[inline(always)]
6559        fn new_empty() -> Self {
6560            Self {
6561                watcher: fidl::new_empty!(
6562                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortWatcherMarker>>,
6563                    fidl::encoding::DefaultFuchsiaResourceDialect
6564                ),
6565            }
6566        }
6567
6568        #[inline]
6569        unsafe fn decode(
6570            &mut self,
6571            decoder: &mut fidl::encoding::Decoder<
6572                '_,
6573                fidl::encoding::DefaultFuchsiaResourceDialect,
6574            >,
6575            offset: usize,
6576            _depth: fidl::encoding::Depth,
6577        ) -> fidl::Result<()> {
6578            decoder.debug_check_bounds::<Self>(offset);
6579            // Verify that padding bytes are zero.
6580            fidl::decode!(
6581                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortWatcherMarker>>,
6582                fidl::encoding::DefaultFuchsiaResourceDialect,
6583                &mut self.watcher,
6584                decoder,
6585                offset + 0,
6586                _depth
6587            )?;
6588            Ok(())
6589        }
6590    }
6591
6592    impl fidl::encoding::ResourceTypeMarker for DeviceOpenSessionRequest {
6593        type Borrowed<'a> = &'a mut Self;
6594        fn take_or_borrow<'a>(
6595            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6596        ) -> Self::Borrowed<'a> {
6597            value
6598        }
6599    }
6600
6601    unsafe impl fidl::encoding::TypeMarker for DeviceOpenSessionRequest {
6602        type Owned = Self;
6603
6604        #[inline(always)]
6605        fn inline_align(_context: fidl::encoding::Context) -> usize {
6606            8
6607        }
6608
6609        #[inline(always)]
6610        fn inline_size(_context: fidl::encoding::Context) -> usize {
6611            32
6612        }
6613    }
6614
6615    unsafe impl
6616        fidl::encoding::Encode<
6617            DeviceOpenSessionRequest,
6618            fidl::encoding::DefaultFuchsiaResourceDialect,
6619        > for &mut DeviceOpenSessionRequest
6620    {
6621        #[inline]
6622        unsafe fn encode(
6623            self,
6624            encoder: &mut fidl::encoding::Encoder<
6625                '_,
6626                fidl::encoding::DefaultFuchsiaResourceDialect,
6627            >,
6628            offset: usize,
6629            _depth: fidl::encoding::Depth,
6630        ) -> fidl::Result<()> {
6631            encoder.debug_check_bounds::<DeviceOpenSessionRequest>(offset);
6632            // Delegate to tuple encoding.
6633            fidl::encoding::Encode::<
6634                DeviceOpenSessionRequest,
6635                fidl::encoding::DefaultFuchsiaResourceDialect,
6636            >::encode(
6637                (
6638                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
6639                        &self.session_name,
6640                    ),
6641                    <SessionInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6642                        &mut self.session_info,
6643                    ),
6644                ),
6645                encoder,
6646                offset,
6647                _depth,
6648            )
6649        }
6650    }
6651    unsafe impl<
6652        T0: fidl::encoding::Encode<
6653                fidl::encoding::BoundedString<64>,
6654                fidl::encoding::DefaultFuchsiaResourceDialect,
6655            >,
6656        T1: fidl::encoding::Encode<SessionInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
6657    >
6658        fidl::encoding::Encode<
6659            DeviceOpenSessionRequest,
6660            fidl::encoding::DefaultFuchsiaResourceDialect,
6661        > for (T0, T1)
6662    {
6663        #[inline]
6664        unsafe fn encode(
6665            self,
6666            encoder: &mut fidl::encoding::Encoder<
6667                '_,
6668                fidl::encoding::DefaultFuchsiaResourceDialect,
6669            >,
6670            offset: usize,
6671            depth: fidl::encoding::Depth,
6672        ) -> fidl::Result<()> {
6673            encoder.debug_check_bounds::<DeviceOpenSessionRequest>(offset);
6674            // Zero out padding regions. There's no need to apply masks
6675            // because the unmasked parts will be overwritten by fields.
6676            // Write the fields.
6677            self.0.encode(encoder, offset + 0, depth)?;
6678            self.1.encode(encoder, offset + 16, depth)?;
6679            Ok(())
6680        }
6681    }
6682
6683    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6684        for DeviceOpenSessionRequest
6685    {
6686        #[inline(always)]
6687        fn new_empty() -> Self {
6688            Self {
6689                session_name: fidl::new_empty!(
6690                    fidl::encoding::BoundedString<64>,
6691                    fidl::encoding::DefaultFuchsiaResourceDialect
6692                ),
6693                session_info: fidl::new_empty!(
6694                    SessionInfo,
6695                    fidl::encoding::DefaultFuchsiaResourceDialect
6696                ),
6697            }
6698        }
6699
6700        #[inline]
6701        unsafe fn decode(
6702            &mut self,
6703            decoder: &mut fidl::encoding::Decoder<
6704                '_,
6705                fidl::encoding::DefaultFuchsiaResourceDialect,
6706            >,
6707            offset: usize,
6708            _depth: fidl::encoding::Depth,
6709        ) -> fidl::Result<()> {
6710            decoder.debug_check_bounds::<Self>(offset);
6711            // Verify that padding bytes are zero.
6712            fidl::decode!(
6713                fidl::encoding::BoundedString<64>,
6714                fidl::encoding::DefaultFuchsiaResourceDialect,
6715                &mut self.session_name,
6716                decoder,
6717                offset + 0,
6718                _depth
6719            )?;
6720            fidl::decode!(
6721                SessionInfo,
6722                fidl::encoding::DefaultFuchsiaResourceDialect,
6723                &mut self.session_info,
6724                decoder,
6725                offset + 16,
6726                _depth
6727            )?;
6728            Ok(())
6729        }
6730    }
6731
6732    impl fidl::encoding::ResourceTypeMarker for DeviceOpenSessionResponse {
6733        type Borrowed<'a> = &'a mut Self;
6734        fn take_or_borrow<'a>(
6735            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6736        ) -> Self::Borrowed<'a> {
6737            value
6738        }
6739    }
6740
6741    unsafe impl fidl::encoding::TypeMarker for DeviceOpenSessionResponse {
6742        type Owned = Self;
6743
6744        #[inline(always)]
6745        fn inline_align(_context: fidl::encoding::Context) -> usize {
6746            4
6747        }
6748
6749        #[inline(always)]
6750        fn inline_size(_context: fidl::encoding::Context) -> usize {
6751            12
6752        }
6753    }
6754
6755    unsafe impl
6756        fidl::encoding::Encode<
6757            DeviceOpenSessionResponse,
6758            fidl::encoding::DefaultFuchsiaResourceDialect,
6759        > for &mut DeviceOpenSessionResponse
6760    {
6761        #[inline]
6762        unsafe fn encode(
6763            self,
6764            encoder: &mut fidl::encoding::Encoder<
6765                '_,
6766                fidl::encoding::DefaultFuchsiaResourceDialect,
6767            >,
6768            offset: usize,
6769            _depth: fidl::encoding::Depth,
6770        ) -> fidl::Result<()> {
6771            encoder.debug_check_bounds::<DeviceOpenSessionResponse>(offset);
6772            // Delegate to tuple encoding.
6773            fidl::encoding::Encode::<DeviceOpenSessionResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6774                (
6775                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session),
6776                    <Fifos as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.fifos),
6777                ),
6778                encoder, offset, _depth
6779            )
6780        }
6781    }
6782    unsafe impl<
6783        T0: fidl::encoding::Encode<
6784                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionMarker>>,
6785                fidl::encoding::DefaultFuchsiaResourceDialect,
6786            >,
6787        T1: fidl::encoding::Encode<Fifos, fidl::encoding::DefaultFuchsiaResourceDialect>,
6788    >
6789        fidl::encoding::Encode<
6790            DeviceOpenSessionResponse,
6791            fidl::encoding::DefaultFuchsiaResourceDialect,
6792        > for (T0, T1)
6793    {
6794        #[inline]
6795        unsafe fn encode(
6796            self,
6797            encoder: &mut fidl::encoding::Encoder<
6798                '_,
6799                fidl::encoding::DefaultFuchsiaResourceDialect,
6800            >,
6801            offset: usize,
6802            depth: fidl::encoding::Depth,
6803        ) -> fidl::Result<()> {
6804            encoder.debug_check_bounds::<DeviceOpenSessionResponse>(offset);
6805            // Zero out padding regions. There's no need to apply masks
6806            // because the unmasked parts will be overwritten by fields.
6807            // Write the fields.
6808            self.0.encode(encoder, offset + 0, depth)?;
6809            self.1.encode(encoder, offset + 4, depth)?;
6810            Ok(())
6811        }
6812    }
6813
6814    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6815        for DeviceOpenSessionResponse
6816    {
6817        #[inline(always)]
6818        fn new_empty() -> Self {
6819            Self {
6820                session: fidl::new_empty!(
6821                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionMarker>>,
6822                    fidl::encoding::DefaultFuchsiaResourceDialect
6823                ),
6824                fifos: fidl::new_empty!(Fifos, fidl::encoding::DefaultFuchsiaResourceDialect),
6825            }
6826        }
6827
6828        #[inline]
6829        unsafe fn decode(
6830            &mut self,
6831            decoder: &mut fidl::encoding::Decoder<
6832                '_,
6833                fidl::encoding::DefaultFuchsiaResourceDialect,
6834            >,
6835            offset: usize,
6836            _depth: fidl::encoding::Depth,
6837        ) -> fidl::Result<()> {
6838            decoder.debug_check_bounds::<Self>(offset);
6839            // Verify that padding bytes are zero.
6840            fidl::decode!(
6841                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionMarker>>,
6842                fidl::encoding::DefaultFuchsiaResourceDialect,
6843                &mut self.session,
6844                decoder,
6845                offset + 0,
6846                _depth
6847            )?;
6848            fidl::decode!(
6849                Fifos,
6850                fidl::encoding::DefaultFuchsiaResourceDialect,
6851                &mut self.fifos,
6852                decoder,
6853                offset + 4,
6854                _depth
6855            )?;
6856            Ok(())
6857        }
6858    }
6859
6860    impl fidl::encoding::ResourceTypeMarker for Fifos {
6861        type Borrowed<'a> = &'a mut Self;
6862        fn take_or_borrow<'a>(
6863            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6864        ) -> Self::Borrowed<'a> {
6865            value
6866        }
6867    }
6868
6869    unsafe impl fidl::encoding::TypeMarker for Fifos {
6870        type Owned = Self;
6871
6872        #[inline(always)]
6873        fn inline_align(_context: fidl::encoding::Context) -> usize {
6874            4
6875        }
6876
6877        #[inline(always)]
6878        fn inline_size(_context: fidl::encoding::Context) -> usize {
6879            8
6880        }
6881    }
6882
6883    unsafe impl fidl::encoding::Encode<Fifos, fidl::encoding::DefaultFuchsiaResourceDialect>
6884        for &mut Fifos
6885    {
6886        #[inline]
6887        unsafe fn encode(
6888            self,
6889            encoder: &mut fidl::encoding::Encoder<
6890                '_,
6891                fidl::encoding::DefaultFuchsiaResourceDialect,
6892            >,
6893            offset: usize,
6894            _depth: fidl::encoding::Depth,
6895        ) -> fidl::Result<()> {
6896            encoder.debug_check_bounds::<Fifos>(offset);
6897            // Delegate to tuple encoding.
6898            fidl::encoding::Encode::<Fifos, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6899                (
6900                    <fidl::encoding::HandleType<
6901                        fidl::Fifo,
6902                        { fidl::ObjectType::FIFO.into_raw() },
6903                        2147483648,
6904                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6905                        &mut self.rx
6906                    ),
6907                    <fidl::encoding::HandleType<
6908                        fidl::Fifo,
6909                        { fidl::ObjectType::FIFO.into_raw() },
6910                        2147483648,
6911                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6912                        &mut self.tx
6913                    ),
6914                ),
6915                encoder,
6916                offset,
6917                _depth,
6918            )
6919        }
6920    }
6921    unsafe impl<
6922        T0: fidl::encoding::Encode<
6923                fidl::encoding::HandleType<
6924                    fidl::Fifo,
6925                    { fidl::ObjectType::FIFO.into_raw() },
6926                    2147483648,
6927                >,
6928                fidl::encoding::DefaultFuchsiaResourceDialect,
6929            >,
6930        T1: fidl::encoding::Encode<
6931                fidl::encoding::HandleType<
6932                    fidl::Fifo,
6933                    { fidl::ObjectType::FIFO.into_raw() },
6934                    2147483648,
6935                >,
6936                fidl::encoding::DefaultFuchsiaResourceDialect,
6937            >,
6938    > fidl::encoding::Encode<Fifos, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0, T1)
6939    {
6940        #[inline]
6941        unsafe fn encode(
6942            self,
6943            encoder: &mut fidl::encoding::Encoder<
6944                '_,
6945                fidl::encoding::DefaultFuchsiaResourceDialect,
6946            >,
6947            offset: usize,
6948            depth: fidl::encoding::Depth,
6949        ) -> fidl::Result<()> {
6950            encoder.debug_check_bounds::<Fifos>(offset);
6951            // Zero out padding regions. There's no need to apply masks
6952            // because the unmasked parts will be overwritten by fields.
6953            // Write the fields.
6954            self.0.encode(encoder, offset + 0, depth)?;
6955            self.1.encode(encoder, offset + 4, depth)?;
6956            Ok(())
6957        }
6958    }
6959
6960    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Fifos {
6961        #[inline(always)]
6962        fn new_empty() -> Self {
6963            Self {
6964                rx: fidl::new_empty!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
6965                tx: fidl::new_empty!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
6966            }
6967        }
6968
6969        #[inline]
6970        unsafe fn decode(
6971            &mut self,
6972            decoder: &mut fidl::encoding::Decoder<
6973                '_,
6974                fidl::encoding::DefaultFuchsiaResourceDialect,
6975            >,
6976            offset: usize,
6977            _depth: fidl::encoding::Depth,
6978        ) -> fidl::Result<()> {
6979            decoder.debug_check_bounds::<Self>(offset);
6980            // Verify that padding bytes are zero.
6981            fidl::decode!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.rx, decoder, offset + 0, _depth)?;
6982            fidl::decode!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.tx, decoder, offset + 4, _depth)?;
6983            Ok(())
6984        }
6985    }
6986
6987    impl fidl::encoding::ResourceTypeMarker for PortCloneRequest {
6988        type Borrowed<'a> = &'a mut Self;
6989        fn take_or_borrow<'a>(
6990            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6991        ) -> Self::Borrowed<'a> {
6992            value
6993        }
6994    }
6995
6996    unsafe impl fidl::encoding::TypeMarker for PortCloneRequest {
6997        type Owned = Self;
6998
6999        #[inline(always)]
7000        fn inline_align(_context: fidl::encoding::Context) -> usize {
7001            4
7002        }
7003
7004        #[inline(always)]
7005        fn inline_size(_context: fidl::encoding::Context) -> usize {
7006            4
7007        }
7008    }
7009
7010    unsafe impl
7011        fidl::encoding::Encode<PortCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
7012        for &mut PortCloneRequest
7013    {
7014        #[inline]
7015        unsafe fn encode(
7016            self,
7017            encoder: &mut fidl::encoding::Encoder<
7018                '_,
7019                fidl::encoding::DefaultFuchsiaResourceDialect,
7020            >,
7021            offset: usize,
7022            _depth: fidl::encoding::Depth,
7023        ) -> fidl::Result<()> {
7024            encoder.debug_check_bounds::<PortCloneRequest>(offset);
7025            // Delegate to tuple encoding.
7026            fidl::encoding::Encode::<PortCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7027                (
7028                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.port),
7029                ),
7030                encoder, offset, _depth
7031            )
7032        }
7033    }
7034    unsafe impl<
7035        T0: fidl::encoding::Encode<
7036                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
7037                fidl::encoding::DefaultFuchsiaResourceDialect,
7038            >,
7039    > fidl::encoding::Encode<PortCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
7040        for (T0,)
7041    {
7042        #[inline]
7043        unsafe fn encode(
7044            self,
7045            encoder: &mut fidl::encoding::Encoder<
7046                '_,
7047                fidl::encoding::DefaultFuchsiaResourceDialect,
7048            >,
7049            offset: usize,
7050            depth: fidl::encoding::Depth,
7051        ) -> fidl::Result<()> {
7052            encoder.debug_check_bounds::<PortCloneRequest>(offset);
7053            // Zero out padding regions. There's no need to apply masks
7054            // because the unmasked parts will be overwritten by fields.
7055            // Write the fields.
7056            self.0.encode(encoder, offset + 0, depth)?;
7057            Ok(())
7058        }
7059    }
7060
7061    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7062        for PortCloneRequest
7063    {
7064        #[inline(always)]
7065        fn new_empty() -> Self {
7066            Self {
7067                port: fidl::new_empty!(
7068                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
7069                    fidl::encoding::DefaultFuchsiaResourceDialect
7070                ),
7071            }
7072        }
7073
7074        #[inline]
7075        unsafe fn decode(
7076            &mut self,
7077            decoder: &mut fidl::encoding::Decoder<
7078                '_,
7079                fidl::encoding::DefaultFuchsiaResourceDialect,
7080            >,
7081            offset: usize,
7082            _depth: fidl::encoding::Depth,
7083        ) -> fidl::Result<()> {
7084            decoder.debug_check_bounds::<Self>(offset);
7085            // Verify that padding bytes are zero.
7086            fidl::decode!(
7087                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
7088                fidl::encoding::DefaultFuchsiaResourceDialect,
7089                &mut self.port,
7090                decoder,
7091                offset + 0,
7092                _depth
7093            )?;
7094            Ok(())
7095        }
7096    }
7097
7098    impl fidl::encoding::ResourceTypeMarker for PortGetDeviceRequest {
7099        type Borrowed<'a> = &'a mut Self;
7100        fn take_or_borrow<'a>(
7101            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7102        ) -> Self::Borrowed<'a> {
7103            value
7104        }
7105    }
7106
7107    unsafe impl fidl::encoding::TypeMarker for PortGetDeviceRequest {
7108        type Owned = Self;
7109
7110        #[inline(always)]
7111        fn inline_align(_context: fidl::encoding::Context) -> usize {
7112            4
7113        }
7114
7115        #[inline(always)]
7116        fn inline_size(_context: fidl::encoding::Context) -> usize {
7117            4
7118        }
7119    }
7120
7121    unsafe impl
7122        fidl::encoding::Encode<PortGetDeviceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
7123        for &mut PortGetDeviceRequest
7124    {
7125        #[inline]
7126        unsafe fn encode(
7127            self,
7128            encoder: &mut fidl::encoding::Encoder<
7129                '_,
7130                fidl::encoding::DefaultFuchsiaResourceDialect,
7131            >,
7132            offset: usize,
7133            _depth: fidl::encoding::Depth,
7134        ) -> fidl::Result<()> {
7135            encoder.debug_check_bounds::<PortGetDeviceRequest>(offset);
7136            // Delegate to tuple encoding.
7137            fidl::encoding::Encode::<PortGetDeviceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7138                (
7139                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.device),
7140                ),
7141                encoder, offset, _depth
7142            )
7143        }
7144    }
7145    unsafe impl<
7146        T0: fidl::encoding::Encode<
7147                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
7148                fidl::encoding::DefaultFuchsiaResourceDialect,
7149            >,
7150    >
7151        fidl::encoding::Encode<PortGetDeviceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
7152        for (T0,)
7153    {
7154        #[inline]
7155        unsafe fn encode(
7156            self,
7157            encoder: &mut fidl::encoding::Encoder<
7158                '_,
7159                fidl::encoding::DefaultFuchsiaResourceDialect,
7160            >,
7161            offset: usize,
7162            depth: fidl::encoding::Depth,
7163        ) -> fidl::Result<()> {
7164            encoder.debug_check_bounds::<PortGetDeviceRequest>(offset);
7165            // Zero out padding regions. There's no need to apply masks
7166            // because the unmasked parts will be overwritten by fields.
7167            // Write the fields.
7168            self.0.encode(encoder, offset + 0, depth)?;
7169            Ok(())
7170        }
7171    }
7172
7173    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7174        for PortGetDeviceRequest
7175    {
7176        #[inline(always)]
7177        fn new_empty() -> Self {
7178            Self {
7179                device: fidl::new_empty!(
7180                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
7181                    fidl::encoding::DefaultFuchsiaResourceDialect
7182                ),
7183            }
7184        }
7185
7186        #[inline]
7187        unsafe fn decode(
7188            &mut self,
7189            decoder: &mut fidl::encoding::Decoder<
7190                '_,
7191                fidl::encoding::DefaultFuchsiaResourceDialect,
7192            >,
7193            offset: usize,
7194            _depth: fidl::encoding::Depth,
7195        ) -> fidl::Result<()> {
7196            decoder.debug_check_bounds::<Self>(offset);
7197            // Verify that padding bytes are zero.
7198            fidl::decode!(
7199                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
7200                fidl::encoding::DefaultFuchsiaResourceDialect,
7201                &mut self.device,
7202                decoder,
7203                offset + 0,
7204                _depth
7205            )?;
7206            Ok(())
7207        }
7208    }
7209
7210    impl fidl::encoding::ResourceTypeMarker for PortGetDiagnosticsRequest {
7211        type Borrowed<'a> = &'a mut Self;
7212        fn take_or_borrow<'a>(
7213            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7214        ) -> Self::Borrowed<'a> {
7215            value
7216        }
7217    }
7218
7219    unsafe impl fidl::encoding::TypeMarker for PortGetDiagnosticsRequest {
7220        type Owned = Self;
7221
7222        #[inline(always)]
7223        fn inline_align(_context: fidl::encoding::Context) -> usize {
7224            4
7225        }
7226
7227        #[inline(always)]
7228        fn inline_size(_context: fidl::encoding::Context) -> usize {
7229            4
7230        }
7231    }
7232
7233    unsafe impl
7234        fidl::encoding::Encode<
7235            PortGetDiagnosticsRequest,
7236            fidl::encoding::DefaultFuchsiaResourceDialect,
7237        > for &mut PortGetDiagnosticsRequest
7238    {
7239        #[inline]
7240        unsafe fn encode(
7241            self,
7242            encoder: &mut fidl::encoding::Encoder<
7243                '_,
7244                fidl::encoding::DefaultFuchsiaResourceDialect,
7245            >,
7246            offset: usize,
7247            _depth: fidl::encoding::Depth,
7248        ) -> fidl::Result<()> {
7249            encoder.debug_check_bounds::<PortGetDiagnosticsRequest>(offset);
7250            // Delegate to tuple encoding.
7251            fidl::encoding::Encode::<PortGetDiagnosticsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7252                (
7253                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiagnosticsMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.diagnostics),
7254                ),
7255                encoder, offset, _depth
7256            )
7257        }
7258    }
7259    unsafe impl<
7260        T0: fidl::encoding::Encode<
7261                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiagnosticsMarker>>,
7262                fidl::encoding::DefaultFuchsiaResourceDialect,
7263            >,
7264    >
7265        fidl::encoding::Encode<
7266            PortGetDiagnosticsRequest,
7267            fidl::encoding::DefaultFuchsiaResourceDialect,
7268        > for (T0,)
7269    {
7270        #[inline]
7271        unsafe fn encode(
7272            self,
7273            encoder: &mut fidl::encoding::Encoder<
7274                '_,
7275                fidl::encoding::DefaultFuchsiaResourceDialect,
7276            >,
7277            offset: usize,
7278            depth: fidl::encoding::Depth,
7279        ) -> fidl::Result<()> {
7280            encoder.debug_check_bounds::<PortGetDiagnosticsRequest>(offset);
7281            // Zero out padding regions. There's no need to apply masks
7282            // because the unmasked parts will be overwritten by fields.
7283            // Write the fields.
7284            self.0.encode(encoder, offset + 0, depth)?;
7285            Ok(())
7286        }
7287    }
7288
7289    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7290        for PortGetDiagnosticsRequest
7291    {
7292        #[inline(always)]
7293        fn new_empty() -> Self {
7294            Self {
7295                diagnostics: fidl::new_empty!(
7296                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiagnosticsMarker>>,
7297                    fidl::encoding::DefaultFuchsiaResourceDialect
7298                ),
7299            }
7300        }
7301
7302        #[inline]
7303        unsafe fn decode(
7304            &mut self,
7305            decoder: &mut fidl::encoding::Decoder<
7306                '_,
7307                fidl::encoding::DefaultFuchsiaResourceDialect,
7308            >,
7309            offset: usize,
7310            _depth: fidl::encoding::Depth,
7311        ) -> fidl::Result<()> {
7312            decoder.debug_check_bounds::<Self>(offset);
7313            // Verify that padding bytes are zero.
7314            fidl::decode!(
7315                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiagnosticsMarker>>,
7316                fidl::encoding::DefaultFuchsiaResourceDialect,
7317                &mut self.diagnostics,
7318                decoder,
7319                offset + 0,
7320                _depth
7321            )?;
7322            Ok(())
7323        }
7324    }
7325
7326    impl fidl::encoding::ResourceTypeMarker for PortGetIdentityResponse {
7327        type Borrowed<'a> = &'a mut Self;
7328        fn take_or_borrow<'a>(
7329            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7330        ) -> Self::Borrowed<'a> {
7331            value
7332        }
7333    }
7334
7335    unsafe impl fidl::encoding::TypeMarker for PortGetIdentityResponse {
7336        type Owned = Self;
7337
7338        #[inline(always)]
7339        fn inline_align(_context: fidl::encoding::Context) -> usize {
7340            4
7341        }
7342
7343        #[inline(always)]
7344        fn inline_size(_context: fidl::encoding::Context) -> usize {
7345            4
7346        }
7347    }
7348
7349    unsafe impl
7350        fidl::encoding::Encode<
7351            PortGetIdentityResponse,
7352            fidl::encoding::DefaultFuchsiaResourceDialect,
7353        > for &mut PortGetIdentityResponse
7354    {
7355        #[inline]
7356        unsafe fn encode(
7357            self,
7358            encoder: &mut fidl::encoding::Encoder<
7359                '_,
7360                fidl::encoding::DefaultFuchsiaResourceDialect,
7361            >,
7362            offset: usize,
7363            _depth: fidl::encoding::Depth,
7364        ) -> fidl::Result<()> {
7365            encoder.debug_check_bounds::<PortGetIdentityResponse>(offset);
7366            // Delegate to tuple encoding.
7367            fidl::encoding::Encode::<
7368                PortGetIdentityResponse,
7369                fidl::encoding::DefaultFuchsiaResourceDialect,
7370            >::encode(
7371                (<fidl::encoding::HandleType<
7372                    fidl::Event,
7373                    { fidl::ObjectType::EVENT.into_raw() },
7374                    3,
7375                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7376                    &mut self.event
7377                ),),
7378                encoder,
7379                offset,
7380                _depth,
7381            )
7382        }
7383    }
7384    unsafe impl<
7385        T0: fidl::encoding::Encode<
7386                fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>,
7387                fidl::encoding::DefaultFuchsiaResourceDialect,
7388            >,
7389    >
7390        fidl::encoding::Encode<
7391            PortGetIdentityResponse,
7392            fidl::encoding::DefaultFuchsiaResourceDialect,
7393        > for (T0,)
7394    {
7395        #[inline]
7396        unsafe fn encode(
7397            self,
7398            encoder: &mut fidl::encoding::Encoder<
7399                '_,
7400                fidl::encoding::DefaultFuchsiaResourceDialect,
7401            >,
7402            offset: usize,
7403            depth: fidl::encoding::Depth,
7404        ) -> fidl::Result<()> {
7405            encoder.debug_check_bounds::<PortGetIdentityResponse>(offset);
7406            // Zero out padding regions. There's no need to apply masks
7407            // because the unmasked parts will be overwritten by fields.
7408            // Write the fields.
7409            self.0.encode(encoder, offset + 0, depth)?;
7410            Ok(())
7411        }
7412    }
7413
7414    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7415        for PortGetIdentityResponse
7416    {
7417        #[inline(always)]
7418        fn new_empty() -> Self {
7419            Self {
7420                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>, fidl::encoding::DefaultFuchsiaResourceDialect),
7421            }
7422        }
7423
7424        #[inline]
7425        unsafe fn decode(
7426            &mut self,
7427            decoder: &mut fidl::encoding::Decoder<
7428                '_,
7429                fidl::encoding::DefaultFuchsiaResourceDialect,
7430            >,
7431            offset: usize,
7432            _depth: fidl::encoding::Depth,
7433        ) -> fidl::Result<()> {
7434            decoder.debug_check_bounds::<Self>(offset);
7435            // Verify that padding bytes are zero.
7436            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
7437            Ok(())
7438        }
7439    }
7440
7441    impl fidl::encoding::ResourceTypeMarker for PortGetMacRequest {
7442        type Borrowed<'a> = &'a mut Self;
7443        fn take_or_borrow<'a>(
7444            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7445        ) -> Self::Borrowed<'a> {
7446            value
7447        }
7448    }
7449
7450    unsafe impl fidl::encoding::TypeMarker for PortGetMacRequest {
7451        type Owned = Self;
7452
7453        #[inline(always)]
7454        fn inline_align(_context: fidl::encoding::Context) -> usize {
7455            4
7456        }
7457
7458        #[inline(always)]
7459        fn inline_size(_context: fidl::encoding::Context) -> usize {
7460            4
7461        }
7462    }
7463
7464    unsafe impl
7465        fidl::encoding::Encode<PortGetMacRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
7466        for &mut PortGetMacRequest
7467    {
7468        #[inline]
7469        unsafe fn encode(
7470            self,
7471            encoder: &mut fidl::encoding::Encoder<
7472                '_,
7473                fidl::encoding::DefaultFuchsiaResourceDialect,
7474            >,
7475            offset: usize,
7476            _depth: fidl::encoding::Depth,
7477        ) -> fidl::Result<()> {
7478            encoder.debug_check_bounds::<PortGetMacRequest>(offset);
7479            // Delegate to tuple encoding.
7480            fidl::encoding::Encode::<PortGetMacRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7481                (
7482                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MacAddressingMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.mac),
7483                ),
7484                encoder, offset, _depth
7485            )
7486        }
7487    }
7488    unsafe impl<
7489        T0: fidl::encoding::Encode<
7490                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MacAddressingMarker>>,
7491                fidl::encoding::DefaultFuchsiaResourceDialect,
7492            >,
7493    > fidl::encoding::Encode<PortGetMacRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
7494        for (T0,)
7495    {
7496        #[inline]
7497        unsafe fn encode(
7498            self,
7499            encoder: &mut fidl::encoding::Encoder<
7500                '_,
7501                fidl::encoding::DefaultFuchsiaResourceDialect,
7502            >,
7503            offset: usize,
7504            depth: fidl::encoding::Depth,
7505        ) -> fidl::Result<()> {
7506            encoder.debug_check_bounds::<PortGetMacRequest>(offset);
7507            // Zero out padding regions. There's no need to apply masks
7508            // because the unmasked parts will be overwritten by fields.
7509            // Write the fields.
7510            self.0.encode(encoder, offset + 0, depth)?;
7511            Ok(())
7512        }
7513    }
7514
7515    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7516        for PortGetMacRequest
7517    {
7518        #[inline(always)]
7519        fn new_empty() -> Self {
7520            Self {
7521                mac: fidl::new_empty!(
7522                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MacAddressingMarker>>,
7523                    fidl::encoding::DefaultFuchsiaResourceDialect
7524                ),
7525            }
7526        }
7527
7528        #[inline]
7529        unsafe fn decode(
7530            &mut self,
7531            decoder: &mut fidl::encoding::Decoder<
7532                '_,
7533                fidl::encoding::DefaultFuchsiaResourceDialect,
7534            >,
7535            offset: usize,
7536            _depth: fidl::encoding::Depth,
7537        ) -> fidl::Result<()> {
7538            decoder.debug_check_bounds::<Self>(offset);
7539            // Verify that padding bytes are zero.
7540            fidl::decode!(
7541                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MacAddressingMarker>>,
7542                fidl::encoding::DefaultFuchsiaResourceDialect,
7543                &mut self.mac,
7544                decoder,
7545                offset + 0,
7546                _depth
7547            )?;
7548            Ok(())
7549        }
7550    }
7551
7552    impl fidl::encoding::ResourceTypeMarker for PortGetStatusWatcherRequest {
7553        type Borrowed<'a> = &'a mut Self;
7554        fn take_or_borrow<'a>(
7555            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7556        ) -> Self::Borrowed<'a> {
7557            value
7558        }
7559    }
7560
7561    unsafe impl fidl::encoding::TypeMarker for PortGetStatusWatcherRequest {
7562        type Owned = Self;
7563
7564        #[inline(always)]
7565        fn inline_align(_context: fidl::encoding::Context) -> usize {
7566            4
7567        }
7568
7569        #[inline(always)]
7570        fn inline_size(_context: fidl::encoding::Context) -> usize {
7571            8
7572        }
7573    }
7574
7575    unsafe impl
7576        fidl::encoding::Encode<
7577            PortGetStatusWatcherRequest,
7578            fidl::encoding::DefaultFuchsiaResourceDialect,
7579        > for &mut PortGetStatusWatcherRequest
7580    {
7581        #[inline]
7582        unsafe fn encode(
7583            self,
7584            encoder: &mut fidl::encoding::Encoder<
7585                '_,
7586                fidl::encoding::DefaultFuchsiaResourceDialect,
7587            >,
7588            offset: usize,
7589            _depth: fidl::encoding::Depth,
7590        ) -> fidl::Result<()> {
7591            encoder.debug_check_bounds::<PortGetStatusWatcherRequest>(offset);
7592            // Delegate to tuple encoding.
7593            fidl::encoding::Encode::<PortGetStatusWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7594                (
7595                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StatusWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
7596                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer),
7597                ),
7598                encoder, offset, _depth
7599            )
7600        }
7601    }
7602    unsafe impl<
7603        T0: fidl::encoding::Encode<
7604                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StatusWatcherMarker>>,
7605                fidl::encoding::DefaultFuchsiaResourceDialect,
7606            >,
7607        T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
7608    >
7609        fidl::encoding::Encode<
7610            PortGetStatusWatcherRequest,
7611            fidl::encoding::DefaultFuchsiaResourceDialect,
7612        > for (T0, T1)
7613    {
7614        #[inline]
7615        unsafe fn encode(
7616            self,
7617            encoder: &mut fidl::encoding::Encoder<
7618                '_,
7619                fidl::encoding::DefaultFuchsiaResourceDialect,
7620            >,
7621            offset: usize,
7622            depth: fidl::encoding::Depth,
7623        ) -> fidl::Result<()> {
7624            encoder.debug_check_bounds::<PortGetStatusWatcherRequest>(offset);
7625            // Zero out padding regions. There's no need to apply masks
7626            // because the unmasked parts will be overwritten by fields.
7627            // Write the fields.
7628            self.0.encode(encoder, offset + 0, depth)?;
7629            self.1.encode(encoder, offset + 4, depth)?;
7630            Ok(())
7631        }
7632    }
7633
7634    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7635        for PortGetStatusWatcherRequest
7636    {
7637        #[inline(always)]
7638        fn new_empty() -> Self {
7639            Self {
7640                watcher: fidl::new_empty!(
7641                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StatusWatcherMarker>>,
7642                    fidl::encoding::DefaultFuchsiaResourceDialect
7643                ),
7644                buffer: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
7645            }
7646        }
7647
7648        #[inline]
7649        unsafe fn decode(
7650            &mut self,
7651            decoder: &mut fidl::encoding::Decoder<
7652                '_,
7653                fidl::encoding::DefaultFuchsiaResourceDialect,
7654            >,
7655            offset: usize,
7656            _depth: fidl::encoding::Depth,
7657        ) -> fidl::Result<()> {
7658            decoder.debug_check_bounds::<Self>(offset);
7659            // Verify that padding bytes are zero.
7660            fidl::decode!(
7661                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StatusWatcherMarker>>,
7662                fidl::encoding::DefaultFuchsiaResourceDialect,
7663                &mut self.watcher,
7664                decoder,
7665                offset + 0,
7666                _depth
7667            )?;
7668            fidl::decode!(
7669                u32,
7670                fidl::encoding::DefaultFuchsiaResourceDialect,
7671                &mut self.buffer,
7672                decoder,
7673                offset + 4,
7674                _depth
7675            )?;
7676            Ok(())
7677        }
7678    }
7679
7680    impl fidl::encoding::ResourceTypeMarker for SessionRegisterForTxRequest {
7681        type Borrowed<'a> = &'a mut Self;
7682        fn take_or_borrow<'a>(
7683            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7684        ) -> Self::Borrowed<'a> {
7685            value
7686        }
7687    }
7688
7689    unsafe impl fidl::encoding::TypeMarker for SessionRegisterForTxRequest {
7690        type Owned = Self;
7691
7692        #[inline(always)]
7693        fn inline_align(_context: fidl::encoding::Context) -> usize {
7694            8
7695        }
7696
7697        #[inline(always)]
7698        fn inline_size(_context: fidl::encoding::Context) -> usize {
7699            16
7700        }
7701    }
7702
7703    unsafe impl
7704        fidl::encoding::Encode<
7705            SessionRegisterForTxRequest,
7706            fidl::encoding::DefaultFuchsiaResourceDialect,
7707        > for &mut SessionRegisterForTxRequest
7708    {
7709        #[inline]
7710        unsafe fn encode(
7711            self,
7712            encoder: &mut fidl::encoding::Encoder<
7713                '_,
7714                fidl::encoding::DefaultFuchsiaResourceDialect,
7715            >,
7716            offset: usize,
7717            _depth: fidl::encoding::Depth,
7718        ) -> fidl::Result<()> {
7719            encoder.debug_check_bounds::<SessionRegisterForTxRequest>(offset);
7720            // Delegate to tuple encoding.
7721            fidl::encoding::Encode::<
7722                SessionRegisterForTxRequest,
7723                fidl::encoding::DefaultFuchsiaResourceDialect,
7724            >::encode(
7725                (<fidl::encoding::Vector<u8, 32> as fidl::encoding::ValueTypeMarker>::borrow(
7726                    &self.vmos,
7727                ),),
7728                encoder,
7729                offset,
7730                _depth,
7731            )
7732        }
7733    }
7734    unsafe impl<
7735        T0: fidl::encoding::Encode<
7736                fidl::encoding::Vector<u8, 32>,
7737                fidl::encoding::DefaultFuchsiaResourceDialect,
7738            >,
7739    >
7740        fidl::encoding::Encode<
7741            SessionRegisterForTxRequest,
7742            fidl::encoding::DefaultFuchsiaResourceDialect,
7743        > for (T0,)
7744    {
7745        #[inline]
7746        unsafe fn encode(
7747            self,
7748            encoder: &mut fidl::encoding::Encoder<
7749                '_,
7750                fidl::encoding::DefaultFuchsiaResourceDialect,
7751            >,
7752            offset: usize,
7753            depth: fidl::encoding::Depth,
7754        ) -> fidl::Result<()> {
7755            encoder.debug_check_bounds::<SessionRegisterForTxRequest>(offset);
7756            // Zero out padding regions. There's no need to apply masks
7757            // because the unmasked parts will be overwritten by fields.
7758            // Write the fields.
7759            self.0.encode(encoder, offset + 0, depth)?;
7760            Ok(())
7761        }
7762    }
7763
7764    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7765        for SessionRegisterForTxRequest
7766    {
7767        #[inline(always)]
7768        fn new_empty() -> Self {
7769            Self {
7770                vmos: fidl::new_empty!(fidl::encoding::Vector<u8, 32>, fidl::encoding::DefaultFuchsiaResourceDialect),
7771            }
7772        }
7773
7774        #[inline]
7775        unsafe fn decode(
7776            &mut self,
7777            decoder: &mut fidl::encoding::Decoder<
7778                '_,
7779                fidl::encoding::DefaultFuchsiaResourceDialect,
7780            >,
7781            offset: usize,
7782            _depth: fidl::encoding::Depth,
7783        ) -> fidl::Result<()> {
7784            decoder.debug_check_bounds::<Self>(offset);
7785            // Verify that padding bytes are zero.
7786            fidl::decode!(fidl::encoding::Vector<u8, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmos, decoder, offset + 0, _depth)?;
7787            Ok(())
7788        }
7789    }
7790
7791    impl fidl::encoding::ResourceTypeMarker for SessionUnregisterForTxRequest {
7792        type Borrowed<'a> = &'a mut Self;
7793        fn take_or_borrow<'a>(
7794            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7795        ) -> Self::Borrowed<'a> {
7796            value
7797        }
7798    }
7799
7800    unsafe impl fidl::encoding::TypeMarker for SessionUnregisterForTxRequest {
7801        type Owned = Self;
7802
7803        #[inline(always)]
7804        fn inline_align(_context: fidl::encoding::Context) -> usize {
7805            8
7806        }
7807
7808        #[inline(always)]
7809        fn inline_size(_context: fidl::encoding::Context) -> usize {
7810            16
7811        }
7812    }
7813
7814    unsafe impl
7815        fidl::encoding::Encode<
7816            SessionUnregisterForTxRequest,
7817            fidl::encoding::DefaultFuchsiaResourceDialect,
7818        > for &mut SessionUnregisterForTxRequest
7819    {
7820        #[inline]
7821        unsafe fn encode(
7822            self,
7823            encoder: &mut fidl::encoding::Encoder<
7824                '_,
7825                fidl::encoding::DefaultFuchsiaResourceDialect,
7826            >,
7827            offset: usize,
7828            _depth: fidl::encoding::Depth,
7829        ) -> fidl::Result<()> {
7830            encoder.debug_check_bounds::<SessionUnregisterForTxRequest>(offset);
7831            // Delegate to tuple encoding.
7832            fidl::encoding::Encode::<
7833                SessionUnregisterForTxRequest,
7834                fidl::encoding::DefaultFuchsiaResourceDialect,
7835            >::encode(
7836                (<fidl::encoding::Vector<u8, 32> as fidl::encoding::ValueTypeMarker>::borrow(
7837                    &self.vmos,
7838                ),),
7839                encoder,
7840                offset,
7841                _depth,
7842            )
7843        }
7844    }
7845    unsafe impl<
7846        T0: fidl::encoding::Encode<
7847                fidl::encoding::Vector<u8, 32>,
7848                fidl::encoding::DefaultFuchsiaResourceDialect,
7849            >,
7850    >
7851        fidl::encoding::Encode<
7852            SessionUnregisterForTxRequest,
7853            fidl::encoding::DefaultFuchsiaResourceDialect,
7854        > for (T0,)
7855    {
7856        #[inline]
7857        unsafe fn encode(
7858            self,
7859            encoder: &mut fidl::encoding::Encoder<
7860                '_,
7861                fidl::encoding::DefaultFuchsiaResourceDialect,
7862            >,
7863            offset: usize,
7864            depth: fidl::encoding::Depth,
7865        ) -> fidl::Result<()> {
7866            encoder.debug_check_bounds::<SessionUnregisterForTxRequest>(offset);
7867            // Zero out padding regions. There's no need to apply masks
7868            // because the unmasked parts will be overwritten by fields.
7869            // Write the fields.
7870            self.0.encode(encoder, offset + 0, depth)?;
7871            Ok(())
7872        }
7873    }
7874
7875    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7876        for SessionUnregisterForTxRequest
7877    {
7878        #[inline(always)]
7879        fn new_empty() -> Self {
7880            Self {
7881                vmos: fidl::new_empty!(fidl::encoding::Vector<u8, 32>, fidl::encoding::DefaultFuchsiaResourceDialect),
7882            }
7883        }
7884
7885        #[inline]
7886        unsafe fn decode(
7887            &mut self,
7888            decoder: &mut fidl::encoding::Decoder<
7889                '_,
7890                fidl::encoding::DefaultFuchsiaResourceDialect,
7891            >,
7892            offset: usize,
7893            _depth: fidl::encoding::Depth,
7894        ) -> fidl::Result<()> {
7895            decoder.debug_check_bounds::<Self>(offset);
7896            // Verify that padding bytes are zero.
7897            fidl::decode!(fidl::encoding::Vector<u8, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmos, decoder, offset + 0, _depth)?;
7898            Ok(())
7899        }
7900    }
7901
7902    impl fidl::encoding::ResourceTypeMarker for SessionWatchDelegatedRxLeaseResponse {
7903        type Borrowed<'a> = &'a mut Self;
7904        fn take_or_borrow<'a>(
7905            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7906        ) -> Self::Borrowed<'a> {
7907            value
7908        }
7909    }
7910
7911    unsafe impl fidl::encoding::TypeMarker for SessionWatchDelegatedRxLeaseResponse {
7912        type Owned = Self;
7913
7914        #[inline(always)]
7915        fn inline_align(_context: fidl::encoding::Context) -> usize {
7916            8
7917        }
7918
7919        #[inline(always)]
7920        fn inline_size(_context: fidl::encoding::Context) -> usize {
7921            16
7922        }
7923    }
7924
7925    unsafe impl
7926        fidl::encoding::Encode<
7927            SessionWatchDelegatedRxLeaseResponse,
7928            fidl::encoding::DefaultFuchsiaResourceDialect,
7929        > for &mut SessionWatchDelegatedRxLeaseResponse
7930    {
7931        #[inline]
7932        unsafe fn encode(
7933            self,
7934            encoder: &mut fidl::encoding::Encoder<
7935                '_,
7936                fidl::encoding::DefaultFuchsiaResourceDialect,
7937            >,
7938            offset: usize,
7939            _depth: fidl::encoding::Depth,
7940        ) -> fidl::Result<()> {
7941            encoder.debug_check_bounds::<SessionWatchDelegatedRxLeaseResponse>(offset);
7942            // Delegate to tuple encoding.
7943            fidl::encoding::Encode::<
7944                SessionWatchDelegatedRxLeaseResponse,
7945                fidl::encoding::DefaultFuchsiaResourceDialect,
7946            >::encode(
7947                (<DelegatedRxLease as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7948                    &mut self.lease,
7949                ),),
7950                encoder,
7951                offset,
7952                _depth,
7953            )
7954        }
7955    }
7956    unsafe impl<
7957        T0: fidl::encoding::Encode<DelegatedRxLease, fidl::encoding::DefaultFuchsiaResourceDialect>,
7958    >
7959        fidl::encoding::Encode<
7960            SessionWatchDelegatedRxLeaseResponse,
7961            fidl::encoding::DefaultFuchsiaResourceDialect,
7962        > for (T0,)
7963    {
7964        #[inline]
7965        unsafe fn encode(
7966            self,
7967            encoder: &mut fidl::encoding::Encoder<
7968                '_,
7969                fidl::encoding::DefaultFuchsiaResourceDialect,
7970            >,
7971            offset: usize,
7972            depth: fidl::encoding::Depth,
7973        ) -> fidl::Result<()> {
7974            encoder.debug_check_bounds::<SessionWatchDelegatedRxLeaseResponse>(offset);
7975            // Zero out padding regions. There's no need to apply masks
7976            // because the unmasked parts will be overwritten by fields.
7977            // Write the fields.
7978            self.0.encode(encoder, offset + 0, depth)?;
7979            Ok(())
7980        }
7981    }
7982
7983    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7984        for SessionWatchDelegatedRxLeaseResponse
7985    {
7986        #[inline(always)]
7987        fn new_empty() -> Self {
7988            Self {
7989                lease: fidl::new_empty!(
7990                    DelegatedRxLease,
7991                    fidl::encoding::DefaultFuchsiaResourceDialect
7992                ),
7993            }
7994        }
7995
7996        #[inline]
7997        unsafe fn decode(
7998            &mut self,
7999            decoder: &mut fidl::encoding::Decoder<
8000                '_,
8001                fidl::encoding::DefaultFuchsiaResourceDialect,
8002            >,
8003            offset: usize,
8004            _depth: fidl::encoding::Depth,
8005        ) -> fidl::Result<()> {
8006            decoder.debug_check_bounds::<Self>(offset);
8007            // Verify that padding bytes are zero.
8008            fidl::decode!(
8009                DelegatedRxLease,
8010                fidl::encoding::DefaultFuchsiaResourceDialect,
8011                &mut self.lease,
8012                decoder,
8013                offset + 0,
8014                _depth
8015            )?;
8016            Ok(())
8017        }
8018    }
8019
8020    impl DataVmo {
8021        #[inline(always)]
8022        fn max_ordinal_present(&self) -> u64 {
8023            if let Some(_) = self.num_rx_buffers {
8024                return 3;
8025            }
8026            if let Some(_) = self.vmo {
8027                return 2;
8028            }
8029            if let Some(_) = self.id {
8030                return 1;
8031            }
8032            0
8033        }
8034    }
8035
8036    impl fidl::encoding::ResourceTypeMarker for DataVmo {
8037        type Borrowed<'a> = &'a mut Self;
8038        fn take_or_borrow<'a>(
8039            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8040        ) -> Self::Borrowed<'a> {
8041            value
8042        }
8043    }
8044
8045    unsafe impl fidl::encoding::TypeMarker for DataVmo {
8046        type Owned = Self;
8047
8048        #[inline(always)]
8049        fn inline_align(_context: fidl::encoding::Context) -> usize {
8050            8
8051        }
8052
8053        #[inline(always)]
8054        fn inline_size(_context: fidl::encoding::Context) -> usize {
8055            16
8056        }
8057    }
8058
8059    unsafe impl fidl::encoding::Encode<DataVmo, fidl::encoding::DefaultFuchsiaResourceDialect>
8060        for &mut DataVmo
8061    {
8062        unsafe fn encode(
8063            self,
8064            encoder: &mut fidl::encoding::Encoder<
8065                '_,
8066                fidl::encoding::DefaultFuchsiaResourceDialect,
8067            >,
8068            offset: usize,
8069            mut depth: fidl::encoding::Depth,
8070        ) -> fidl::Result<()> {
8071            encoder.debug_check_bounds::<DataVmo>(offset);
8072            // Vector header
8073            let max_ordinal: u64 = self.max_ordinal_present();
8074            encoder.write_num(max_ordinal, offset);
8075            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8076            // Calling encoder.out_of_line_offset(0) is not allowed.
8077            if max_ordinal == 0 {
8078                return Ok(());
8079            }
8080            depth.increment()?;
8081            let envelope_size = 8;
8082            let bytes_len = max_ordinal as usize * envelope_size;
8083            #[allow(unused_variables)]
8084            let offset = encoder.out_of_line_offset(bytes_len);
8085            let mut _prev_end_offset: usize = 0;
8086            if 1 > max_ordinal {
8087                return Ok(());
8088            }
8089
8090            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8091            // are envelope_size bytes.
8092            let cur_offset: usize = (1 - 1) * envelope_size;
8093
8094            // Zero reserved fields.
8095            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8096
8097            // Safety:
8098            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8099            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8100            //   envelope_size bytes, there is always sufficient room.
8101            fidl::encoding::encode_in_envelope_optional::<
8102                u8,
8103                fidl::encoding::DefaultFuchsiaResourceDialect,
8104            >(
8105                self.id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
8106                encoder,
8107                offset + cur_offset,
8108                depth,
8109            )?;
8110
8111            _prev_end_offset = cur_offset + envelope_size;
8112            if 2 > max_ordinal {
8113                return Ok(());
8114            }
8115
8116            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8117            // are envelope_size bytes.
8118            let cur_offset: usize = (2 - 1) * envelope_size;
8119
8120            // Zero reserved fields.
8121            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8122
8123            // Safety:
8124            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8125            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8126            //   envelope_size bytes, there is always sufficient room.
8127            fidl::encoding::encode_in_envelope_optional::<
8128                fidl::encoding::HandleType<
8129                    fidl::Vmo,
8130                    { fidl::ObjectType::VMO.into_raw() },
8131                    2147483648,
8132                >,
8133                fidl::encoding::DefaultFuchsiaResourceDialect,
8134            >(
8135                self.vmo.as_mut().map(
8136                    <fidl::encoding::HandleType<
8137                        fidl::Vmo,
8138                        { fidl::ObjectType::VMO.into_raw() },
8139                        2147483648,
8140                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
8141                ),
8142                encoder,
8143                offset + cur_offset,
8144                depth,
8145            )?;
8146
8147            _prev_end_offset = cur_offset + envelope_size;
8148            if 3 > max_ordinal {
8149                return Ok(());
8150            }
8151
8152            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8153            // are envelope_size bytes.
8154            let cur_offset: usize = (3 - 1) * envelope_size;
8155
8156            // Zero reserved fields.
8157            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8158
8159            // Safety:
8160            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8161            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8162            //   envelope_size bytes, there is always sufficient room.
8163            fidl::encoding::encode_in_envelope_optional::<
8164                u16,
8165                fidl::encoding::DefaultFuchsiaResourceDialect,
8166            >(
8167                self.num_rx_buffers.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
8168                encoder,
8169                offset + cur_offset,
8170                depth,
8171            )?;
8172
8173            _prev_end_offset = cur_offset + envelope_size;
8174
8175            Ok(())
8176        }
8177    }
8178
8179    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for DataVmo {
8180        #[inline(always)]
8181        fn new_empty() -> Self {
8182            Self::default()
8183        }
8184
8185        unsafe fn decode(
8186            &mut self,
8187            decoder: &mut fidl::encoding::Decoder<
8188                '_,
8189                fidl::encoding::DefaultFuchsiaResourceDialect,
8190            >,
8191            offset: usize,
8192            mut depth: fidl::encoding::Depth,
8193        ) -> fidl::Result<()> {
8194            decoder.debug_check_bounds::<Self>(offset);
8195            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8196                None => return Err(fidl::Error::NotNullable),
8197                Some(len) => len,
8198            };
8199            // Calling decoder.out_of_line_offset(0) is not allowed.
8200            if len == 0 {
8201                return Ok(());
8202            };
8203            depth.increment()?;
8204            let envelope_size = 8;
8205            let bytes_len = len * envelope_size;
8206            let offset = decoder.out_of_line_offset(bytes_len)?;
8207            // Decode the envelope for each type.
8208            let mut _next_ordinal_to_read = 0;
8209            let mut next_offset = offset;
8210            let end_offset = offset + bytes_len;
8211            _next_ordinal_to_read += 1;
8212            if next_offset >= end_offset {
8213                return Ok(());
8214            }
8215
8216            // Decode unknown envelopes for gaps in ordinals.
8217            while _next_ordinal_to_read < 1 {
8218                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8219                _next_ordinal_to_read += 1;
8220                next_offset += envelope_size;
8221            }
8222
8223            let next_out_of_line = decoder.next_out_of_line();
8224            let handles_before = decoder.remaining_handles();
8225            if let Some((inlined, num_bytes, num_handles)) =
8226                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8227            {
8228                let member_inline_size =
8229                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8230                if inlined != (member_inline_size <= 4) {
8231                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8232                }
8233                let inner_offset;
8234                let mut inner_depth = depth.clone();
8235                if inlined {
8236                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8237                    inner_offset = next_offset;
8238                } else {
8239                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8240                    inner_depth.increment()?;
8241                }
8242                let val_ref = self.id.get_or_insert_with(|| {
8243                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
8244                });
8245                fidl::decode!(
8246                    u8,
8247                    fidl::encoding::DefaultFuchsiaResourceDialect,
8248                    val_ref,
8249                    decoder,
8250                    inner_offset,
8251                    inner_depth
8252                )?;
8253                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8254                {
8255                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8256                }
8257                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8258                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8259                }
8260            }
8261
8262            next_offset += envelope_size;
8263            _next_ordinal_to_read += 1;
8264            if next_offset >= end_offset {
8265                return Ok(());
8266            }
8267
8268            // Decode unknown envelopes for gaps in ordinals.
8269            while _next_ordinal_to_read < 2 {
8270                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8271                _next_ordinal_to_read += 1;
8272                next_offset += envelope_size;
8273            }
8274
8275            let next_out_of_line = decoder.next_out_of_line();
8276            let handles_before = decoder.remaining_handles();
8277            if let Some((inlined, num_bytes, num_handles)) =
8278                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8279            {
8280                let member_inline_size = <fidl::encoding::HandleType<
8281                    fidl::Vmo,
8282                    { fidl::ObjectType::VMO.into_raw() },
8283                    2147483648,
8284                > as fidl::encoding::TypeMarker>::inline_size(
8285                    decoder.context
8286                );
8287                if inlined != (member_inline_size <= 4) {
8288                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8289                }
8290                let inner_offset;
8291                let mut inner_depth = depth.clone();
8292                if inlined {
8293                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8294                    inner_offset = next_offset;
8295                } else {
8296                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8297                    inner_depth.increment()?;
8298                }
8299                let val_ref =
8300                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
8301                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
8302                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8303                {
8304                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8305                }
8306                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8307                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8308                }
8309            }
8310
8311            next_offset += envelope_size;
8312            _next_ordinal_to_read += 1;
8313            if next_offset >= end_offset {
8314                return Ok(());
8315            }
8316
8317            // Decode unknown envelopes for gaps in ordinals.
8318            while _next_ordinal_to_read < 3 {
8319                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8320                _next_ordinal_to_read += 1;
8321                next_offset += envelope_size;
8322            }
8323
8324            let next_out_of_line = decoder.next_out_of_line();
8325            let handles_before = decoder.remaining_handles();
8326            if let Some((inlined, num_bytes, num_handles)) =
8327                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8328            {
8329                let member_inline_size =
8330                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8331                if inlined != (member_inline_size <= 4) {
8332                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8333                }
8334                let inner_offset;
8335                let mut inner_depth = depth.clone();
8336                if inlined {
8337                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8338                    inner_offset = next_offset;
8339                } else {
8340                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8341                    inner_depth.increment()?;
8342                }
8343                let val_ref = self.num_rx_buffers.get_or_insert_with(|| {
8344                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
8345                });
8346                fidl::decode!(
8347                    u16,
8348                    fidl::encoding::DefaultFuchsiaResourceDialect,
8349                    val_ref,
8350                    decoder,
8351                    inner_offset,
8352                    inner_depth
8353                )?;
8354                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8355                {
8356                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8357                }
8358                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8359                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8360                }
8361            }
8362
8363            next_offset += envelope_size;
8364
8365            // Decode the remaining unknown envelopes.
8366            while next_offset < end_offset {
8367                _next_ordinal_to_read += 1;
8368                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8369                next_offset += envelope_size;
8370            }
8371
8372            Ok(())
8373        }
8374    }
8375
8376    impl DelegatedRxLease {
8377        #[inline(always)]
8378        fn max_ordinal_present(&self) -> u64 {
8379            if let Some(_) = self.handle {
8380                return 2;
8381            }
8382            if let Some(_) = self.hold_until_frame {
8383                return 1;
8384            }
8385            0
8386        }
8387    }
8388
8389    impl fidl::encoding::ResourceTypeMarker for DelegatedRxLease {
8390        type Borrowed<'a> = &'a mut Self;
8391        fn take_or_borrow<'a>(
8392            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8393        ) -> Self::Borrowed<'a> {
8394            value
8395        }
8396    }
8397
8398    unsafe impl fidl::encoding::TypeMarker for DelegatedRxLease {
8399        type Owned = Self;
8400
8401        #[inline(always)]
8402        fn inline_align(_context: fidl::encoding::Context) -> usize {
8403            8
8404        }
8405
8406        #[inline(always)]
8407        fn inline_size(_context: fidl::encoding::Context) -> usize {
8408            16
8409        }
8410    }
8411
8412    unsafe impl
8413        fidl::encoding::Encode<DelegatedRxLease, fidl::encoding::DefaultFuchsiaResourceDialect>
8414        for &mut DelegatedRxLease
8415    {
8416        unsafe fn encode(
8417            self,
8418            encoder: &mut fidl::encoding::Encoder<
8419                '_,
8420                fidl::encoding::DefaultFuchsiaResourceDialect,
8421            >,
8422            offset: usize,
8423            mut depth: fidl::encoding::Depth,
8424        ) -> fidl::Result<()> {
8425            encoder.debug_check_bounds::<DelegatedRxLease>(offset);
8426            // Vector header
8427            let max_ordinal: u64 = self.max_ordinal_present();
8428            encoder.write_num(max_ordinal, offset);
8429            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8430            // Calling encoder.out_of_line_offset(0) is not allowed.
8431            if max_ordinal == 0 {
8432                return Ok(());
8433            }
8434            depth.increment()?;
8435            let envelope_size = 8;
8436            let bytes_len = max_ordinal as usize * envelope_size;
8437            #[allow(unused_variables)]
8438            let offset = encoder.out_of_line_offset(bytes_len);
8439            let mut _prev_end_offset: usize = 0;
8440            if 1 > max_ordinal {
8441                return Ok(());
8442            }
8443
8444            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8445            // are envelope_size bytes.
8446            let cur_offset: usize = (1 - 1) * envelope_size;
8447
8448            // Zero reserved fields.
8449            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8450
8451            // Safety:
8452            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8453            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8454            //   envelope_size bytes, there is always sufficient room.
8455            fidl::encoding::encode_in_envelope_optional::<
8456                u64,
8457                fidl::encoding::DefaultFuchsiaResourceDialect,
8458            >(
8459                self.hold_until_frame
8460                    .as_ref()
8461                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
8462                encoder,
8463                offset + cur_offset,
8464                depth,
8465            )?;
8466
8467            _prev_end_offset = cur_offset + envelope_size;
8468            if 2 > max_ordinal {
8469                return Ok(());
8470            }
8471
8472            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8473            // are envelope_size bytes.
8474            let cur_offset: usize = (2 - 1) * envelope_size;
8475
8476            // Zero reserved fields.
8477            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8478
8479            // Safety:
8480            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8481            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8482            //   envelope_size bytes, there is always sufficient room.
8483            fidl::encoding::encode_in_envelope_optional::<
8484                DelegatedRxLeaseHandle,
8485                fidl::encoding::DefaultFuchsiaResourceDialect,
8486            >(
8487                self.handle.as_mut().map(
8488                    <DelegatedRxLeaseHandle as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
8489                ),
8490                encoder,
8491                offset + cur_offset,
8492                depth,
8493            )?;
8494
8495            _prev_end_offset = cur_offset + envelope_size;
8496
8497            Ok(())
8498        }
8499    }
8500
8501    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8502        for DelegatedRxLease
8503    {
8504        #[inline(always)]
8505        fn new_empty() -> Self {
8506            Self::default()
8507        }
8508
8509        unsafe fn decode(
8510            &mut self,
8511            decoder: &mut fidl::encoding::Decoder<
8512                '_,
8513                fidl::encoding::DefaultFuchsiaResourceDialect,
8514            >,
8515            offset: usize,
8516            mut depth: fidl::encoding::Depth,
8517        ) -> fidl::Result<()> {
8518            decoder.debug_check_bounds::<Self>(offset);
8519            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8520                None => return Err(fidl::Error::NotNullable),
8521                Some(len) => len,
8522            };
8523            // Calling decoder.out_of_line_offset(0) is not allowed.
8524            if len == 0 {
8525                return Ok(());
8526            };
8527            depth.increment()?;
8528            let envelope_size = 8;
8529            let bytes_len = len * envelope_size;
8530            let offset = decoder.out_of_line_offset(bytes_len)?;
8531            // Decode the envelope for each type.
8532            let mut _next_ordinal_to_read = 0;
8533            let mut next_offset = offset;
8534            let end_offset = offset + bytes_len;
8535            _next_ordinal_to_read += 1;
8536            if next_offset >= end_offset {
8537                return Ok(());
8538            }
8539
8540            // Decode unknown envelopes for gaps in ordinals.
8541            while _next_ordinal_to_read < 1 {
8542                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8543                _next_ordinal_to_read += 1;
8544                next_offset += envelope_size;
8545            }
8546
8547            let next_out_of_line = decoder.next_out_of_line();
8548            let handles_before = decoder.remaining_handles();
8549            if let Some((inlined, num_bytes, num_handles)) =
8550                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8551            {
8552                let member_inline_size =
8553                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8554                if inlined != (member_inline_size <= 4) {
8555                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8556                }
8557                let inner_offset;
8558                let mut inner_depth = depth.clone();
8559                if inlined {
8560                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8561                    inner_offset = next_offset;
8562                } else {
8563                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8564                    inner_depth.increment()?;
8565                }
8566                let val_ref = self.hold_until_frame.get_or_insert_with(|| {
8567                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
8568                });
8569                fidl::decode!(
8570                    u64,
8571                    fidl::encoding::DefaultFuchsiaResourceDialect,
8572                    val_ref,
8573                    decoder,
8574                    inner_offset,
8575                    inner_depth
8576                )?;
8577                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8578                {
8579                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8580                }
8581                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8582                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8583                }
8584            }
8585
8586            next_offset += envelope_size;
8587            _next_ordinal_to_read += 1;
8588            if next_offset >= end_offset {
8589                return Ok(());
8590            }
8591
8592            // Decode unknown envelopes for gaps in ordinals.
8593            while _next_ordinal_to_read < 2 {
8594                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8595                _next_ordinal_to_read += 1;
8596                next_offset += envelope_size;
8597            }
8598
8599            let next_out_of_line = decoder.next_out_of_line();
8600            let handles_before = decoder.remaining_handles();
8601            if let Some((inlined, num_bytes, num_handles)) =
8602                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8603            {
8604                let member_inline_size =
8605                    <DelegatedRxLeaseHandle as fidl::encoding::TypeMarker>::inline_size(
8606                        decoder.context,
8607                    );
8608                if inlined != (member_inline_size <= 4) {
8609                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8610                }
8611                let inner_offset;
8612                let mut inner_depth = depth.clone();
8613                if inlined {
8614                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8615                    inner_offset = next_offset;
8616                } else {
8617                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8618                    inner_depth.increment()?;
8619                }
8620                let val_ref = self.handle.get_or_insert_with(|| {
8621                    fidl::new_empty!(
8622                        DelegatedRxLeaseHandle,
8623                        fidl::encoding::DefaultFuchsiaResourceDialect
8624                    )
8625                });
8626                fidl::decode!(
8627                    DelegatedRxLeaseHandle,
8628                    fidl::encoding::DefaultFuchsiaResourceDialect,
8629                    val_ref,
8630                    decoder,
8631                    inner_offset,
8632                    inner_depth
8633                )?;
8634                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8635                {
8636                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8637                }
8638                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8639                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8640                }
8641            }
8642
8643            next_offset += envelope_size;
8644
8645            // Decode the remaining unknown envelopes.
8646            while next_offset < end_offset {
8647                _next_ordinal_to_read += 1;
8648                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8649                next_offset += envelope_size;
8650            }
8651
8652            Ok(())
8653        }
8654    }
8655
8656    impl SessionInfo {
8657        #[inline(always)]
8658        fn max_ordinal_present(&self) -> u64 {
8659            if let Some(_) = self.options {
8660                return 6;
8661            }
8662            if let Some(_) = self.descriptor_count {
8663                return 5;
8664            }
8665            if let Some(_) = self.descriptor_length {
8666                return 4;
8667            }
8668            if let Some(_) = self.descriptor_version {
8669                return 3;
8670            }
8671            if let Some(_) = self.data {
8672                return 2;
8673            }
8674            if let Some(_) = self.descriptors {
8675                return 1;
8676            }
8677            0
8678        }
8679    }
8680
8681    impl fidl::encoding::ResourceTypeMarker for SessionInfo {
8682        type Borrowed<'a> = &'a mut Self;
8683        fn take_or_borrow<'a>(
8684            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8685        ) -> Self::Borrowed<'a> {
8686            value
8687        }
8688    }
8689
8690    unsafe impl fidl::encoding::TypeMarker for SessionInfo {
8691        type Owned = Self;
8692
8693        #[inline(always)]
8694        fn inline_align(_context: fidl::encoding::Context) -> usize {
8695            8
8696        }
8697
8698        #[inline(always)]
8699        fn inline_size(_context: fidl::encoding::Context) -> usize {
8700            16
8701        }
8702    }
8703
8704    unsafe impl fidl::encoding::Encode<SessionInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
8705        for &mut SessionInfo
8706    {
8707        unsafe fn encode(
8708            self,
8709            encoder: &mut fidl::encoding::Encoder<
8710                '_,
8711                fidl::encoding::DefaultFuchsiaResourceDialect,
8712            >,
8713            offset: usize,
8714            mut depth: fidl::encoding::Depth,
8715        ) -> fidl::Result<()> {
8716            encoder.debug_check_bounds::<SessionInfo>(offset);
8717            // Vector header
8718            let max_ordinal: u64 = self.max_ordinal_present();
8719            encoder.write_num(max_ordinal, offset);
8720            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8721            // Calling encoder.out_of_line_offset(0) is not allowed.
8722            if max_ordinal == 0 {
8723                return Ok(());
8724            }
8725            depth.increment()?;
8726            let envelope_size = 8;
8727            let bytes_len = max_ordinal as usize * envelope_size;
8728            #[allow(unused_variables)]
8729            let offset = encoder.out_of_line_offset(bytes_len);
8730            let mut _prev_end_offset: usize = 0;
8731            if 1 > max_ordinal {
8732                return Ok(());
8733            }
8734
8735            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8736            // are envelope_size bytes.
8737            let cur_offset: usize = (1 - 1) * envelope_size;
8738
8739            // Zero reserved fields.
8740            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8741
8742            // Safety:
8743            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8744            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8745            //   envelope_size bytes, there is always sufficient room.
8746            fidl::encoding::encode_in_envelope_optional::<
8747                fidl::encoding::HandleType<
8748                    fidl::Vmo,
8749                    { fidl::ObjectType::VMO.into_raw() },
8750                    2147483648,
8751                >,
8752                fidl::encoding::DefaultFuchsiaResourceDialect,
8753            >(
8754                self.descriptors.as_mut().map(
8755                    <fidl::encoding::HandleType<
8756                        fidl::Vmo,
8757                        { fidl::ObjectType::VMO.into_raw() },
8758                        2147483648,
8759                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
8760                ),
8761                encoder,
8762                offset + cur_offset,
8763                depth,
8764            )?;
8765
8766            _prev_end_offset = cur_offset + envelope_size;
8767            if 2 > max_ordinal {
8768                return Ok(());
8769            }
8770
8771            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8772            // are envelope_size bytes.
8773            let cur_offset: usize = (2 - 1) * envelope_size;
8774
8775            // Zero reserved fields.
8776            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8777
8778            // Safety:
8779            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8780            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8781            //   envelope_size bytes, there is always sufficient room.
8782            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<DataVmo, 32>, fidl::encoding::DefaultFuchsiaResourceDialect>(
8783            self.data.as_mut().map(<fidl::encoding::Vector<DataVmo, 32> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
8784            encoder, offset + cur_offset, depth
8785        )?;
8786
8787            _prev_end_offset = cur_offset + envelope_size;
8788            if 3 > max_ordinal {
8789                return Ok(());
8790            }
8791
8792            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8793            // are envelope_size bytes.
8794            let cur_offset: usize = (3 - 1) * envelope_size;
8795
8796            // Zero reserved fields.
8797            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8798
8799            // Safety:
8800            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8801            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8802            //   envelope_size bytes, there is always sufficient room.
8803            fidl::encoding::encode_in_envelope_optional::<
8804                u8,
8805                fidl::encoding::DefaultFuchsiaResourceDialect,
8806            >(
8807                self.descriptor_version
8808                    .as_ref()
8809                    .map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
8810                encoder,
8811                offset + cur_offset,
8812                depth,
8813            )?;
8814
8815            _prev_end_offset = cur_offset + envelope_size;
8816            if 4 > max_ordinal {
8817                return Ok(());
8818            }
8819
8820            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8821            // are envelope_size bytes.
8822            let cur_offset: usize = (4 - 1) * envelope_size;
8823
8824            // Zero reserved fields.
8825            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8826
8827            // Safety:
8828            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8829            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8830            //   envelope_size bytes, there is always sufficient room.
8831            fidl::encoding::encode_in_envelope_optional::<
8832                u8,
8833                fidl::encoding::DefaultFuchsiaResourceDialect,
8834            >(
8835                self.descriptor_length
8836                    .as_ref()
8837                    .map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
8838                encoder,
8839                offset + cur_offset,
8840                depth,
8841            )?;
8842
8843            _prev_end_offset = cur_offset + envelope_size;
8844            if 5 > max_ordinal {
8845                return Ok(());
8846            }
8847
8848            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8849            // are envelope_size bytes.
8850            let cur_offset: usize = (5 - 1) * envelope_size;
8851
8852            // Zero reserved fields.
8853            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8854
8855            // Safety:
8856            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8857            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8858            //   envelope_size bytes, there is always sufficient room.
8859            fidl::encoding::encode_in_envelope_optional::<
8860                u16,
8861                fidl::encoding::DefaultFuchsiaResourceDialect,
8862            >(
8863                self.descriptor_count
8864                    .as_ref()
8865                    .map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
8866                encoder,
8867                offset + cur_offset,
8868                depth,
8869            )?;
8870
8871            _prev_end_offset = cur_offset + envelope_size;
8872            if 6 > max_ordinal {
8873                return Ok(());
8874            }
8875
8876            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8877            // are envelope_size bytes.
8878            let cur_offset: usize = (6 - 1) * envelope_size;
8879
8880            // Zero reserved fields.
8881            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8882
8883            // Safety:
8884            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8885            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8886            //   envelope_size bytes, there is always sufficient room.
8887            fidl::encoding::encode_in_envelope_optional::<
8888                SessionFlags,
8889                fidl::encoding::DefaultFuchsiaResourceDialect,
8890            >(
8891                self.options
8892                    .as_ref()
8893                    .map(<SessionFlags as fidl::encoding::ValueTypeMarker>::borrow),
8894                encoder,
8895                offset + cur_offset,
8896                depth,
8897            )?;
8898
8899            _prev_end_offset = cur_offset + envelope_size;
8900
8901            Ok(())
8902        }
8903    }
8904
8905    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for SessionInfo {
8906        #[inline(always)]
8907        fn new_empty() -> Self {
8908            Self::default()
8909        }
8910
8911        unsafe fn decode(
8912            &mut self,
8913            decoder: &mut fidl::encoding::Decoder<
8914                '_,
8915                fidl::encoding::DefaultFuchsiaResourceDialect,
8916            >,
8917            offset: usize,
8918            mut depth: fidl::encoding::Depth,
8919        ) -> fidl::Result<()> {
8920            decoder.debug_check_bounds::<Self>(offset);
8921            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8922                None => return Err(fidl::Error::NotNullable),
8923                Some(len) => len,
8924            };
8925            // Calling decoder.out_of_line_offset(0) is not allowed.
8926            if len == 0 {
8927                return Ok(());
8928            };
8929            depth.increment()?;
8930            let envelope_size = 8;
8931            let bytes_len = len * envelope_size;
8932            let offset = decoder.out_of_line_offset(bytes_len)?;
8933            // Decode the envelope for each type.
8934            let mut _next_ordinal_to_read = 0;
8935            let mut next_offset = offset;
8936            let end_offset = offset + bytes_len;
8937            _next_ordinal_to_read += 1;
8938            if next_offset >= end_offset {
8939                return Ok(());
8940            }
8941
8942            // Decode unknown envelopes for gaps in ordinals.
8943            while _next_ordinal_to_read < 1 {
8944                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8945                _next_ordinal_to_read += 1;
8946                next_offset += envelope_size;
8947            }
8948
8949            let next_out_of_line = decoder.next_out_of_line();
8950            let handles_before = decoder.remaining_handles();
8951            if let Some((inlined, num_bytes, num_handles)) =
8952                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8953            {
8954                let member_inline_size = <fidl::encoding::HandleType<
8955                    fidl::Vmo,
8956                    { fidl::ObjectType::VMO.into_raw() },
8957                    2147483648,
8958                > as fidl::encoding::TypeMarker>::inline_size(
8959                    decoder.context
8960                );
8961                if inlined != (member_inline_size <= 4) {
8962                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8963                }
8964                let inner_offset;
8965                let mut inner_depth = depth.clone();
8966                if inlined {
8967                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8968                    inner_offset = next_offset;
8969                } else {
8970                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8971                    inner_depth.increment()?;
8972                }
8973                let val_ref =
8974                self.descriptors.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
8975                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
8976                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8977                {
8978                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8979                }
8980                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8981                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8982                }
8983            }
8984
8985            next_offset += envelope_size;
8986            _next_ordinal_to_read += 1;
8987            if next_offset >= end_offset {
8988                return Ok(());
8989            }
8990
8991            // Decode unknown envelopes for gaps in ordinals.
8992            while _next_ordinal_to_read < 2 {
8993                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8994                _next_ordinal_to_read += 1;
8995                next_offset += envelope_size;
8996            }
8997
8998            let next_out_of_line = decoder.next_out_of_line();
8999            let handles_before = decoder.remaining_handles();
9000            if let Some((inlined, num_bytes, num_handles)) =
9001                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9002            {
9003                let member_inline_size = <fidl::encoding::Vector<DataVmo, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9004                if inlined != (member_inline_size <= 4) {
9005                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9006                }
9007                let inner_offset;
9008                let mut inner_depth = depth.clone();
9009                if inlined {
9010                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9011                    inner_offset = next_offset;
9012                } else {
9013                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9014                    inner_depth.increment()?;
9015                }
9016                let val_ref =
9017                self.data.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<DataVmo, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
9018                fidl::decode!(fidl::encoding::Vector<DataVmo, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
9019                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9020                {
9021                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9022                }
9023                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9024                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9025                }
9026            }
9027
9028            next_offset += envelope_size;
9029            _next_ordinal_to_read += 1;
9030            if next_offset >= end_offset {
9031                return Ok(());
9032            }
9033
9034            // Decode unknown envelopes for gaps in ordinals.
9035            while _next_ordinal_to_read < 3 {
9036                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9037                _next_ordinal_to_read += 1;
9038                next_offset += envelope_size;
9039            }
9040
9041            let next_out_of_line = decoder.next_out_of_line();
9042            let handles_before = decoder.remaining_handles();
9043            if let Some((inlined, num_bytes, num_handles)) =
9044                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9045            {
9046                let member_inline_size =
9047                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9048                if inlined != (member_inline_size <= 4) {
9049                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9050                }
9051                let inner_offset;
9052                let mut inner_depth = depth.clone();
9053                if inlined {
9054                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9055                    inner_offset = next_offset;
9056                } else {
9057                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9058                    inner_depth.increment()?;
9059                }
9060                let val_ref = self.descriptor_version.get_or_insert_with(|| {
9061                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
9062                });
9063                fidl::decode!(
9064                    u8,
9065                    fidl::encoding::DefaultFuchsiaResourceDialect,
9066                    val_ref,
9067                    decoder,
9068                    inner_offset,
9069                    inner_depth
9070                )?;
9071                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9072                {
9073                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9074                }
9075                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9076                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9077                }
9078            }
9079
9080            next_offset += envelope_size;
9081            _next_ordinal_to_read += 1;
9082            if next_offset >= end_offset {
9083                return Ok(());
9084            }
9085
9086            // Decode unknown envelopes for gaps in ordinals.
9087            while _next_ordinal_to_read < 4 {
9088                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9089                _next_ordinal_to_read += 1;
9090                next_offset += envelope_size;
9091            }
9092
9093            let next_out_of_line = decoder.next_out_of_line();
9094            let handles_before = decoder.remaining_handles();
9095            if let Some((inlined, num_bytes, num_handles)) =
9096                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9097            {
9098                let member_inline_size =
9099                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9100                if inlined != (member_inline_size <= 4) {
9101                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9102                }
9103                let inner_offset;
9104                let mut inner_depth = depth.clone();
9105                if inlined {
9106                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9107                    inner_offset = next_offset;
9108                } else {
9109                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9110                    inner_depth.increment()?;
9111                }
9112                let val_ref = self.descriptor_length.get_or_insert_with(|| {
9113                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
9114                });
9115                fidl::decode!(
9116                    u8,
9117                    fidl::encoding::DefaultFuchsiaResourceDialect,
9118                    val_ref,
9119                    decoder,
9120                    inner_offset,
9121                    inner_depth
9122                )?;
9123                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9124                {
9125                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9126                }
9127                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9128                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9129                }
9130            }
9131
9132            next_offset += envelope_size;
9133            _next_ordinal_to_read += 1;
9134            if next_offset >= end_offset {
9135                return Ok(());
9136            }
9137
9138            // Decode unknown envelopes for gaps in ordinals.
9139            while _next_ordinal_to_read < 5 {
9140                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9141                _next_ordinal_to_read += 1;
9142                next_offset += envelope_size;
9143            }
9144
9145            let next_out_of_line = decoder.next_out_of_line();
9146            let handles_before = decoder.remaining_handles();
9147            if let Some((inlined, num_bytes, num_handles)) =
9148                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9149            {
9150                let member_inline_size =
9151                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9152                if inlined != (member_inline_size <= 4) {
9153                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9154                }
9155                let inner_offset;
9156                let mut inner_depth = depth.clone();
9157                if inlined {
9158                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9159                    inner_offset = next_offset;
9160                } else {
9161                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9162                    inner_depth.increment()?;
9163                }
9164                let val_ref = self.descriptor_count.get_or_insert_with(|| {
9165                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
9166                });
9167                fidl::decode!(
9168                    u16,
9169                    fidl::encoding::DefaultFuchsiaResourceDialect,
9170                    val_ref,
9171                    decoder,
9172                    inner_offset,
9173                    inner_depth
9174                )?;
9175                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9176                {
9177                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9178                }
9179                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9180                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9181                }
9182            }
9183
9184            next_offset += envelope_size;
9185            _next_ordinal_to_read += 1;
9186            if next_offset >= end_offset {
9187                return Ok(());
9188            }
9189
9190            // Decode unknown envelopes for gaps in ordinals.
9191            while _next_ordinal_to_read < 6 {
9192                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9193                _next_ordinal_to_read += 1;
9194                next_offset += envelope_size;
9195            }
9196
9197            let next_out_of_line = decoder.next_out_of_line();
9198            let handles_before = decoder.remaining_handles();
9199            if let Some((inlined, num_bytes, num_handles)) =
9200                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9201            {
9202                let member_inline_size =
9203                    <SessionFlags as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9204                if inlined != (member_inline_size <= 4) {
9205                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9206                }
9207                let inner_offset;
9208                let mut inner_depth = depth.clone();
9209                if inlined {
9210                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9211                    inner_offset = next_offset;
9212                } else {
9213                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9214                    inner_depth.increment()?;
9215                }
9216                let val_ref = self.options.get_or_insert_with(|| {
9217                    fidl::new_empty!(SessionFlags, fidl::encoding::DefaultFuchsiaResourceDialect)
9218                });
9219                fidl::decode!(
9220                    SessionFlags,
9221                    fidl::encoding::DefaultFuchsiaResourceDialect,
9222                    val_ref,
9223                    decoder,
9224                    inner_offset,
9225                    inner_depth
9226                )?;
9227                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9228                {
9229                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9230                }
9231                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9232                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9233                }
9234            }
9235
9236            next_offset += envelope_size;
9237
9238            // Decode the remaining unknown envelopes.
9239            while next_offset < end_offset {
9240                _next_ordinal_to_read += 1;
9241                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9242                next_offset += envelope_size;
9243            }
9244
9245            Ok(())
9246        }
9247    }
9248
9249    impl fidl::encoding::ResourceTypeMarker for DelegatedRxLeaseHandle {
9250        type Borrowed<'a> = &'a mut Self;
9251        fn take_or_borrow<'a>(
9252            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9253        ) -> Self::Borrowed<'a> {
9254            value
9255        }
9256    }
9257
9258    unsafe impl fidl::encoding::TypeMarker for DelegatedRxLeaseHandle {
9259        type Owned = Self;
9260
9261        #[inline(always)]
9262        fn inline_align(_context: fidl::encoding::Context) -> usize {
9263            8
9264        }
9265
9266        #[inline(always)]
9267        fn inline_size(_context: fidl::encoding::Context) -> usize {
9268            16
9269        }
9270    }
9271
9272    unsafe impl
9273        fidl::encoding::Encode<
9274            DelegatedRxLeaseHandle,
9275            fidl::encoding::DefaultFuchsiaResourceDialect,
9276        > for &mut DelegatedRxLeaseHandle
9277    {
9278        #[inline]
9279        unsafe fn encode(
9280            self,
9281            encoder: &mut fidl::encoding::Encoder<
9282                '_,
9283                fidl::encoding::DefaultFuchsiaResourceDialect,
9284            >,
9285            offset: usize,
9286            _depth: fidl::encoding::Depth,
9287        ) -> fidl::Result<()> {
9288            encoder.debug_check_bounds::<DelegatedRxLeaseHandle>(offset);
9289            encoder.write_num::<u64>(self.ordinal(), offset);
9290            match self {
9291                DelegatedRxLeaseHandle::Channel(ref mut val) => {
9292                    fidl::encoding::encode_in_envelope::<
9293                        fidl::encoding::HandleType<
9294                            fidl::Channel,
9295                            { fidl::ObjectType::CHANNEL.into_raw() },
9296                            2147483648,
9297                        >,
9298                        fidl::encoding::DefaultFuchsiaResourceDialect,
9299                    >(
9300                        <fidl::encoding::HandleType<
9301                            fidl::Channel,
9302                            { fidl::ObjectType::CHANNEL.into_raw() },
9303                            2147483648,
9304                        > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9305                            val
9306                        ),
9307                        encoder,
9308                        offset + 8,
9309                        _depth,
9310                    )
9311                }
9312                DelegatedRxLeaseHandle::Eventpair(ref mut val) => {
9313                    fidl::encoding::encode_in_envelope::<
9314                        fidl::encoding::HandleType<
9315                            fidl::EventPair,
9316                            { fidl::ObjectType::EVENTPAIR.into_raw() },
9317                            16387,
9318                        >,
9319                        fidl::encoding::DefaultFuchsiaResourceDialect,
9320                    >(
9321                        <fidl::encoding::HandleType<
9322                            fidl::EventPair,
9323                            { fidl::ObjectType::EVENTPAIR.into_raw() },
9324                            16387,
9325                        > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9326                            val
9327                        ),
9328                        encoder,
9329                        offset + 8,
9330                        _depth,
9331                    )
9332                }
9333                DelegatedRxLeaseHandle::__SourceBreaking { .. } => {
9334                    Err(fidl::Error::UnknownUnionTag)
9335                }
9336            }
9337        }
9338    }
9339
9340    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9341        for DelegatedRxLeaseHandle
9342    {
9343        #[inline(always)]
9344        fn new_empty() -> Self {
9345            Self::__SourceBreaking { unknown_ordinal: 0 }
9346        }
9347
9348        #[inline]
9349        unsafe fn decode(
9350            &mut self,
9351            decoder: &mut fidl::encoding::Decoder<
9352                '_,
9353                fidl::encoding::DefaultFuchsiaResourceDialect,
9354            >,
9355            offset: usize,
9356            mut depth: fidl::encoding::Depth,
9357        ) -> fidl::Result<()> {
9358            decoder.debug_check_bounds::<Self>(offset);
9359            #[allow(unused_variables)]
9360            let next_out_of_line = decoder.next_out_of_line();
9361            let handles_before = decoder.remaining_handles();
9362            let (ordinal, inlined, num_bytes, num_handles) =
9363                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
9364
9365            let member_inline_size = match ordinal {
9366                1 => <fidl::encoding::HandleType<
9367                    fidl::Channel,
9368                    { fidl::ObjectType::CHANNEL.into_raw() },
9369                    2147483648,
9370                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
9371                2 => <fidl::encoding::HandleType<
9372                    fidl::EventPair,
9373                    { fidl::ObjectType::EVENTPAIR.into_raw() },
9374                    16387,
9375                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
9376                0 => return Err(fidl::Error::UnknownUnionTag),
9377                _ => num_bytes as usize,
9378            };
9379
9380            if inlined != (member_inline_size <= 4) {
9381                return Err(fidl::Error::InvalidInlineBitInEnvelope);
9382            }
9383            let _inner_offset;
9384            if inlined {
9385                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
9386                _inner_offset = offset + 8;
9387            } else {
9388                depth.increment()?;
9389                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9390            }
9391            match ordinal {
9392                1 => {
9393                    #[allow(irrefutable_let_patterns)]
9394                    if let DelegatedRxLeaseHandle::Channel(_) = self {
9395                        // Do nothing, read the value into the object
9396                    } else {
9397                        // Initialize `self` to the right variant
9398                        *self = DelegatedRxLeaseHandle::Channel(
9399                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9400                        );
9401                    }
9402                    #[allow(irrefutable_let_patterns)]
9403                    if let DelegatedRxLeaseHandle::Channel(ref mut val) = self {
9404                        fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
9405                    } else {
9406                        unreachable!()
9407                    }
9408                }
9409                2 => {
9410                    #[allow(irrefutable_let_patterns)]
9411                    if let DelegatedRxLeaseHandle::Eventpair(_) = self {
9412                        // Do nothing, read the value into the object
9413                    } else {
9414                        // Initialize `self` to the right variant
9415                        *self = DelegatedRxLeaseHandle::Eventpair(
9416                            fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
9417                        );
9418                    }
9419                    #[allow(irrefutable_let_patterns)]
9420                    if let DelegatedRxLeaseHandle::Eventpair(ref mut val) = self {
9421                        fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
9422                    } else {
9423                        unreachable!()
9424                    }
9425                }
9426                #[allow(deprecated)]
9427                ordinal => {
9428                    for _ in 0..num_handles {
9429                        decoder.drop_next_handle()?;
9430                    }
9431                    *self = DelegatedRxLeaseHandle::__SourceBreaking { unknown_ordinal: ordinal };
9432                }
9433            }
9434            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
9435                return Err(fidl::Error::InvalidNumBytesInEnvelope);
9436            }
9437            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9438                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9439            }
9440            Ok(())
9441        }
9442    }
9443}