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