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