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