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