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