Skip to main content

fidl_fuchsia_hardware_network/
fidl_fuchsia_hardware_network.rs

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