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
5729mod internal {
5730    use super::*;
5731
5732    impl fidl::encoding::ResourceTypeMarker for DeviceCloneRequest {
5733        type Borrowed<'a> = &'a mut Self;
5734        fn take_or_borrow<'a>(
5735            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5736        ) -> Self::Borrowed<'a> {
5737            value
5738        }
5739    }
5740
5741    unsafe impl fidl::encoding::TypeMarker for DeviceCloneRequest {
5742        type Owned = Self;
5743
5744        #[inline(always)]
5745        fn inline_align(_context: fidl::encoding::Context) -> usize {
5746            4
5747        }
5748
5749        #[inline(always)]
5750        fn inline_size(_context: fidl::encoding::Context) -> usize {
5751            4
5752        }
5753    }
5754
5755    unsafe impl
5756        fidl::encoding::Encode<DeviceCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
5757        for &mut DeviceCloneRequest
5758    {
5759        #[inline]
5760        unsafe fn encode(
5761            self,
5762            encoder: &mut fidl::encoding::Encoder<
5763                '_,
5764                fidl::encoding::DefaultFuchsiaResourceDialect,
5765            >,
5766            offset: usize,
5767            _depth: fidl::encoding::Depth,
5768        ) -> fidl::Result<()> {
5769            encoder.debug_check_bounds::<DeviceCloneRequest>(offset);
5770            // Delegate to tuple encoding.
5771            fidl::encoding::Encode::<DeviceCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5772                (
5773                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.device),
5774                ),
5775                encoder, offset, _depth
5776            )
5777        }
5778    }
5779    unsafe impl<
5780        T0: fidl::encoding::Encode<
5781                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
5782                fidl::encoding::DefaultFuchsiaResourceDialect,
5783            >,
5784    > fidl::encoding::Encode<DeviceCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
5785        for (T0,)
5786    {
5787        #[inline]
5788        unsafe fn encode(
5789            self,
5790            encoder: &mut fidl::encoding::Encoder<
5791                '_,
5792                fidl::encoding::DefaultFuchsiaResourceDialect,
5793            >,
5794            offset: usize,
5795            depth: fidl::encoding::Depth,
5796        ) -> fidl::Result<()> {
5797            encoder.debug_check_bounds::<DeviceCloneRequest>(offset);
5798            // Zero out padding regions. There's no need to apply masks
5799            // because the unmasked parts will be overwritten by fields.
5800            // Write the fields.
5801            self.0.encode(encoder, offset + 0, depth)?;
5802            Ok(())
5803        }
5804    }
5805
5806    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5807        for DeviceCloneRequest
5808    {
5809        #[inline(always)]
5810        fn new_empty() -> Self {
5811            Self {
5812                device: fidl::new_empty!(
5813                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
5814                    fidl::encoding::DefaultFuchsiaResourceDialect
5815                ),
5816            }
5817        }
5818
5819        #[inline]
5820        unsafe fn decode(
5821            &mut self,
5822            decoder: &mut fidl::encoding::Decoder<
5823                '_,
5824                fidl::encoding::DefaultFuchsiaResourceDialect,
5825            >,
5826            offset: usize,
5827            _depth: fidl::encoding::Depth,
5828        ) -> fidl::Result<()> {
5829            decoder.debug_check_bounds::<Self>(offset);
5830            // Verify that padding bytes are zero.
5831            fidl::decode!(
5832                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
5833                fidl::encoding::DefaultFuchsiaResourceDialect,
5834                &mut self.device,
5835                decoder,
5836                offset + 0,
5837                _depth
5838            )?;
5839            Ok(())
5840        }
5841    }
5842
5843    impl fidl::encoding::ResourceTypeMarker for DeviceGetPortRequest {
5844        type Borrowed<'a> = &'a mut Self;
5845        fn take_or_borrow<'a>(
5846            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5847        ) -> Self::Borrowed<'a> {
5848            value
5849        }
5850    }
5851
5852    unsafe impl fidl::encoding::TypeMarker for DeviceGetPortRequest {
5853        type Owned = Self;
5854
5855        #[inline(always)]
5856        fn inline_align(_context: fidl::encoding::Context) -> usize {
5857            4
5858        }
5859
5860        #[inline(always)]
5861        fn inline_size(_context: fidl::encoding::Context) -> usize {
5862            8
5863        }
5864    }
5865
5866    unsafe impl
5867        fidl::encoding::Encode<DeviceGetPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
5868        for &mut DeviceGetPortRequest
5869    {
5870        #[inline]
5871        unsafe fn encode(
5872            self,
5873            encoder: &mut fidl::encoding::Encoder<
5874                '_,
5875                fidl::encoding::DefaultFuchsiaResourceDialect,
5876            >,
5877            offset: usize,
5878            _depth: fidl::encoding::Depth,
5879        ) -> fidl::Result<()> {
5880            encoder.debug_check_bounds::<DeviceGetPortRequest>(offset);
5881            // Delegate to tuple encoding.
5882            fidl::encoding::Encode::<DeviceGetPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
5883                (
5884                    <PortId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
5885                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.port),
5886                ),
5887                encoder, offset, _depth
5888            )
5889        }
5890    }
5891    unsafe impl<
5892        T0: fidl::encoding::Encode<PortId, fidl::encoding::DefaultFuchsiaResourceDialect>,
5893        T1: fidl::encoding::Encode<
5894                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
5895                fidl::encoding::DefaultFuchsiaResourceDialect,
5896            >,
5897    >
5898        fidl::encoding::Encode<DeviceGetPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
5899        for (T0, T1)
5900    {
5901        #[inline]
5902        unsafe fn encode(
5903            self,
5904            encoder: &mut fidl::encoding::Encoder<
5905                '_,
5906                fidl::encoding::DefaultFuchsiaResourceDialect,
5907            >,
5908            offset: usize,
5909            depth: fidl::encoding::Depth,
5910        ) -> fidl::Result<()> {
5911            encoder.debug_check_bounds::<DeviceGetPortRequest>(offset);
5912            // Zero out padding regions. There's no need to apply masks
5913            // because the unmasked parts will be overwritten by fields.
5914            unsafe {
5915                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
5916                (ptr as *mut u32).write_unaligned(0);
5917            }
5918            // Write the fields.
5919            self.0.encode(encoder, offset + 0, depth)?;
5920            self.1.encode(encoder, offset + 4, depth)?;
5921            Ok(())
5922        }
5923    }
5924
5925    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5926        for DeviceGetPortRequest
5927    {
5928        #[inline(always)]
5929        fn new_empty() -> Self {
5930            Self {
5931                id: fidl::new_empty!(PortId, fidl::encoding::DefaultFuchsiaResourceDialect),
5932                port: fidl::new_empty!(
5933                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
5934                    fidl::encoding::DefaultFuchsiaResourceDialect
5935                ),
5936            }
5937        }
5938
5939        #[inline]
5940        unsafe fn decode(
5941            &mut self,
5942            decoder: &mut fidl::encoding::Decoder<
5943                '_,
5944                fidl::encoding::DefaultFuchsiaResourceDialect,
5945            >,
5946            offset: usize,
5947            _depth: fidl::encoding::Depth,
5948        ) -> fidl::Result<()> {
5949            decoder.debug_check_bounds::<Self>(offset);
5950            // Verify that padding bytes are zero.
5951            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
5952            let padval = unsafe { (ptr as *const u32).read_unaligned() };
5953            let mask = 0xffff0000u32;
5954            let maskedval = padval & mask;
5955            if maskedval != 0 {
5956                return Err(fidl::Error::NonZeroPadding {
5957                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
5958                });
5959            }
5960            fidl::decode!(
5961                PortId,
5962                fidl::encoding::DefaultFuchsiaResourceDialect,
5963                &mut self.id,
5964                decoder,
5965                offset + 0,
5966                _depth
5967            )?;
5968            fidl::decode!(
5969                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
5970                fidl::encoding::DefaultFuchsiaResourceDialect,
5971                &mut self.port,
5972                decoder,
5973                offset + 4,
5974                _depth
5975            )?;
5976            Ok(())
5977        }
5978    }
5979
5980    impl fidl::encoding::ResourceTypeMarker for DeviceGetPortWatcherRequest {
5981        type Borrowed<'a> = &'a mut Self;
5982        fn take_or_borrow<'a>(
5983            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5984        ) -> Self::Borrowed<'a> {
5985            value
5986        }
5987    }
5988
5989    unsafe impl fidl::encoding::TypeMarker for DeviceGetPortWatcherRequest {
5990        type Owned = Self;
5991
5992        #[inline(always)]
5993        fn inline_align(_context: fidl::encoding::Context) -> usize {
5994            4
5995        }
5996
5997        #[inline(always)]
5998        fn inline_size(_context: fidl::encoding::Context) -> usize {
5999            4
6000        }
6001    }
6002
6003    unsafe impl
6004        fidl::encoding::Encode<
6005            DeviceGetPortWatcherRequest,
6006            fidl::encoding::DefaultFuchsiaResourceDialect,
6007        > for &mut DeviceGetPortWatcherRequest
6008    {
6009        #[inline]
6010        unsafe fn encode(
6011            self,
6012            encoder: &mut fidl::encoding::Encoder<
6013                '_,
6014                fidl::encoding::DefaultFuchsiaResourceDialect,
6015            >,
6016            offset: usize,
6017            _depth: fidl::encoding::Depth,
6018        ) -> fidl::Result<()> {
6019            encoder.debug_check_bounds::<DeviceGetPortWatcherRequest>(offset);
6020            // Delegate to tuple encoding.
6021            fidl::encoding::Encode::<DeviceGetPortWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6022                (
6023                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
6024                ),
6025                encoder, offset, _depth
6026            )
6027        }
6028    }
6029    unsafe impl<
6030        T0: fidl::encoding::Encode<
6031                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortWatcherMarker>>,
6032                fidl::encoding::DefaultFuchsiaResourceDialect,
6033            >,
6034    >
6035        fidl::encoding::Encode<
6036            DeviceGetPortWatcherRequest,
6037            fidl::encoding::DefaultFuchsiaResourceDialect,
6038        > for (T0,)
6039    {
6040        #[inline]
6041        unsafe fn encode(
6042            self,
6043            encoder: &mut fidl::encoding::Encoder<
6044                '_,
6045                fidl::encoding::DefaultFuchsiaResourceDialect,
6046            >,
6047            offset: usize,
6048            depth: fidl::encoding::Depth,
6049        ) -> fidl::Result<()> {
6050            encoder.debug_check_bounds::<DeviceGetPortWatcherRequest>(offset);
6051            // Zero out padding regions. There's no need to apply masks
6052            // because the unmasked parts will be overwritten by fields.
6053            // Write the fields.
6054            self.0.encode(encoder, offset + 0, depth)?;
6055            Ok(())
6056        }
6057    }
6058
6059    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6060        for DeviceGetPortWatcherRequest
6061    {
6062        #[inline(always)]
6063        fn new_empty() -> Self {
6064            Self {
6065                watcher: fidl::new_empty!(
6066                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortWatcherMarker>>,
6067                    fidl::encoding::DefaultFuchsiaResourceDialect
6068                ),
6069            }
6070        }
6071
6072        #[inline]
6073        unsafe fn decode(
6074            &mut self,
6075            decoder: &mut fidl::encoding::Decoder<
6076                '_,
6077                fidl::encoding::DefaultFuchsiaResourceDialect,
6078            >,
6079            offset: usize,
6080            _depth: fidl::encoding::Depth,
6081        ) -> fidl::Result<()> {
6082            decoder.debug_check_bounds::<Self>(offset);
6083            // Verify that padding bytes are zero.
6084            fidl::decode!(
6085                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortWatcherMarker>>,
6086                fidl::encoding::DefaultFuchsiaResourceDialect,
6087                &mut self.watcher,
6088                decoder,
6089                offset + 0,
6090                _depth
6091            )?;
6092            Ok(())
6093        }
6094    }
6095
6096    impl fidl::encoding::ResourceTypeMarker for DeviceOpenSessionRequest {
6097        type Borrowed<'a> = &'a mut Self;
6098        fn take_or_borrow<'a>(
6099            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6100        ) -> Self::Borrowed<'a> {
6101            value
6102        }
6103    }
6104
6105    unsafe impl fidl::encoding::TypeMarker for DeviceOpenSessionRequest {
6106        type Owned = Self;
6107
6108        #[inline(always)]
6109        fn inline_align(_context: fidl::encoding::Context) -> usize {
6110            8
6111        }
6112
6113        #[inline(always)]
6114        fn inline_size(_context: fidl::encoding::Context) -> usize {
6115            32
6116        }
6117    }
6118
6119    unsafe impl
6120        fidl::encoding::Encode<
6121            DeviceOpenSessionRequest,
6122            fidl::encoding::DefaultFuchsiaResourceDialect,
6123        > for &mut DeviceOpenSessionRequest
6124    {
6125        #[inline]
6126        unsafe fn encode(
6127            self,
6128            encoder: &mut fidl::encoding::Encoder<
6129                '_,
6130                fidl::encoding::DefaultFuchsiaResourceDialect,
6131            >,
6132            offset: usize,
6133            _depth: fidl::encoding::Depth,
6134        ) -> fidl::Result<()> {
6135            encoder.debug_check_bounds::<DeviceOpenSessionRequest>(offset);
6136            // Delegate to tuple encoding.
6137            fidl::encoding::Encode::<
6138                DeviceOpenSessionRequest,
6139                fidl::encoding::DefaultFuchsiaResourceDialect,
6140            >::encode(
6141                (
6142                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
6143                        &self.session_name,
6144                    ),
6145                    <SessionInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6146                        &mut self.session_info,
6147                    ),
6148                ),
6149                encoder,
6150                offset,
6151                _depth,
6152            )
6153        }
6154    }
6155    unsafe impl<
6156        T0: fidl::encoding::Encode<
6157                fidl::encoding::BoundedString<64>,
6158                fidl::encoding::DefaultFuchsiaResourceDialect,
6159            >,
6160        T1: fidl::encoding::Encode<SessionInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
6161    >
6162        fidl::encoding::Encode<
6163            DeviceOpenSessionRequest,
6164            fidl::encoding::DefaultFuchsiaResourceDialect,
6165        > for (T0, T1)
6166    {
6167        #[inline]
6168        unsafe fn encode(
6169            self,
6170            encoder: &mut fidl::encoding::Encoder<
6171                '_,
6172                fidl::encoding::DefaultFuchsiaResourceDialect,
6173            >,
6174            offset: usize,
6175            depth: fidl::encoding::Depth,
6176        ) -> fidl::Result<()> {
6177            encoder.debug_check_bounds::<DeviceOpenSessionRequest>(offset);
6178            // Zero out padding regions. There's no need to apply masks
6179            // because the unmasked parts will be overwritten by fields.
6180            // Write the fields.
6181            self.0.encode(encoder, offset + 0, depth)?;
6182            self.1.encode(encoder, offset + 16, depth)?;
6183            Ok(())
6184        }
6185    }
6186
6187    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6188        for DeviceOpenSessionRequest
6189    {
6190        #[inline(always)]
6191        fn new_empty() -> Self {
6192            Self {
6193                session_name: fidl::new_empty!(
6194                    fidl::encoding::BoundedString<64>,
6195                    fidl::encoding::DefaultFuchsiaResourceDialect
6196                ),
6197                session_info: fidl::new_empty!(
6198                    SessionInfo,
6199                    fidl::encoding::DefaultFuchsiaResourceDialect
6200                ),
6201            }
6202        }
6203
6204        #[inline]
6205        unsafe fn decode(
6206            &mut self,
6207            decoder: &mut fidl::encoding::Decoder<
6208                '_,
6209                fidl::encoding::DefaultFuchsiaResourceDialect,
6210            >,
6211            offset: usize,
6212            _depth: fidl::encoding::Depth,
6213        ) -> fidl::Result<()> {
6214            decoder.debug_check_bounds::<Self>(offset);
6215            // Verify that padding bytes are zero.
6216            fidl::decode!(
6217                fidl::encoding::BoundedString<64>,
6218                fidl::encoding::DefaultFuchsiaResourceDialect,
6219                &mut self.session_name,
6220                decoder,
6221                offset + 0,
6222                _depth
6223            )?;
6224            fidl::decode!(
6225                SessionInfo,
6226                fidl::encoding::DefaultFuchsiaResourceDialect,
6227                &mut self.session_info,
6228                decoder,
6229                offset + 16,
6230                _depth
6231            )?;
6232            Ok(())
6233        }
6234    }
6235
6236    impl fidl::encoding::ResourceTypeMarker for DeviceOpenSessionResponse {
6237        type Borrowed<'a> = &'a mut Self;
6238        fn take_or_borrow<'a>(
6239            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6240        ) -> Self::Borrowed<'a> {
6241            value
6242        }
6243    }
6244
6245    unsafe impl fidl::encoding::TypeMarker for DeviceOpenSessionResponse {
6246        type Owned = Self;
6247
6248        #[inline(always)]
6249        fn inline_align(_context: fidl::encoding::Context) -> usize {
6250            4
6251        }
6252
6253        #[inline(always)]
6254        fn inline_size(_context: fidl::encoding::Context) -> usize {
6255            12
6256        }
6257    }
6258
6259    unsafe impl
6260        fidl::encoding::Encode<
6261            DeviceOpenSessionResponse,
6262            fidl::encoding::DefaultFuchsiaResourceDialect,
6263        > for &mut DeviceOpenSessionResponse
6264    {
6265        #[inline]
6266        unsafe fn encode(
6267            self,
6268            encoder: &mut fidl::encoding::Encoder<
6269                '_,
6270                fidl::encoding::DefaultFuchsiaResourceDialect,
6271            >,
6272            offset: usize,
6273            _depth: fidl::encoding::Depth,
6274        ) -> fidl::Result<()> {
6275            encoder.debug_check_bounds::<DeviceOpenSessionResponse>(offset);
6276            // Delegate to tuple encoding.
6277            fidl::encoding::Encode::<DeviceOpenSessionResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6278                (
6279                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session),
6280                    <Fifos as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.fifos),
6281                ),
6282                encoder, offset, _depth
6283            )
6284        }
6285    }
6286    unsafe impl<
6287        T0: fidl::encoding::Encode<
6288                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionMarker>>,
6289                fidl::encoding::DefaultFuchsiaResourceDialect,
6290            >,
6291        T1: fidl::encoding::Encode<Fifos, fidl::encoding::DefaultFuchsiaResourceDialect>,
6292    >
6293        fidl::encoding::Encode<
6294            DeviceOpenSessionResponse,
6295            fidl::encoding::DefaultFuchsiaResourceDialect,
6296        > for (T0, T1)
6297    {
6298        #[inline]
6299        unsafe fn encode(
6300            self,
6301            encoder: &mut fidl::encoding::Encoder<
6302                '_,
6303                fidl::encoding::DefaultFuchsiaResourceDialect,
6304            >,
6305            offset: usize,
6306            depth: fidl::encoding::Depth,
6307        ) -> fidl::Result<()> {
6308            encoder.debug_check_bounds::<DeviceOpenSessionResponse>(offset);
6309            // Zero out padding regions. There's no need to apply masks
6310            // because the unmasked parts will be overwritten by fields.
6311            // Write the fields.
6312            self.0.encode(encoder, offset + 0, depth)?;
6313            self.1.encode(encoder, offset + 4, depth)?;
6314            Ok(())
6315        }
6316    }
6317
6318    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6319        for DeviceOpenSessionResponse
6320    {
6321        #[inline(always)]
6322        fn new_empty() -> Self {
6323            Self {
6324                session: fidl::new_empty!(
6325                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionMarker>>,
6326                    fidl::encoding::DefaultFuchsiaResourceDialect
6327                ),
6328                fifos: fidl::new_empty!(Fifos, fidl::encoding::DefaultFuchsiaResourceDialect),
6329            }
6330        }
6331
6332        #[inline]
6333        unsafe fn decode(
6334            &mut self,
6335            decoder: &mut fidl::encoding::Decoder<
6336                '_,
6337                fidl::encoding::DefaultFuchsiaResourceDialect,
6338            >,
6339            offset: usize,
6340            _depth: fidl::encoding::Depth,
6341        ) -> fidl::Result<()> {
6342            decoder.debug_check_bounds::<Self>(offset);
6343            // Verify that padding bytes are zero.
6344            fidl::decode!(
6345                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionMarker>>,
6346                fidl::encoding::DefaultFuchsiaResourceDialect,
6347                &mut self.session,
6348                decoder,
6349                offset + 0,
6350                _depth
6351            )?;
6352            fidl::decode!(
6353                Fifos,
6354                fidl::encoding::DefaultFuchsiaResourceDialect,
6355                &mut self.fifos,
6356                decoder,
6357                offset + 4,
6358                _depth
6359            )?;
6360            Ok(())
6361        }
6362    }
6363
6364    impl fidl::encoding::ResourceTypeMarker for Fifos {
6365        type Borrowed<'a> = &'a mut Self;
6366        fn take_or_borrow<'a>(
6367            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6368        ) -> Self::Borrowed<'a> {
6369            value
6370        }
6371    }
6372
6373    unsafe impl fidl::encoding::TypeMarker for Fifos {
6374        type Owned = Self;
6375
6376        #[inline(always)]
6377        fn inline_align(_context: fidl::encoding::Context) -> usize {
6378            4
6379        }
6380
6381        #[inline(always)]
6382        fn inline_size(_context: fidl::encoding::Context) -> usize {
6383            8
6384        }
6385    }
6386
6387    unsafe impl fidl::encoding::Encode<Fifos, fidl::encoding::DefaultFuchsiaResourceDialect>
6388        for &mut Fifos
6389    {
6390        #[inline]
6391        unsafe fn encode(
6392            self,
6393            encoder: &mut fidl::encoding::Encoder<
6394                '_,
6395                fidl::encoding::DefaultFuchsiaResourceDialect,
6396            >,
6397            offset: usize,
6398            _depth: fidl::encoding::Depth,
6399        ) -> fidl::Result<()> {
6400            encoder.debug_check_bounds::<Fifos>(offset);
6401            // Delegate to tuple encoding.
6402            fidl::encoding::Encode::<Fifos, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6403                (
6404                    <fidl::encoding::HandleType<
6405                        fidl::Fifo,
6406                        { fidl::ObjectType::FIFO.into_raw() },
6407                        2147483648,
6408                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6409                        &mut self.rx
6410                    ),
6411                    <fidl::encoding::HandleType<
6412                        fidl::Fifo,
6413                        { fidl::ObjectType::FIFO.into_raw() },
6414                        2147483648,
6415                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6416                        &mut self.tx
6417                    ),
6418                ),
6419                encoder,
6420                offset,
6421                _depth,
6422            )
6423        }
6424    }
6425    unsafe impl<
6426        T0: fidl::encoding::Encode<
6427                fidl::encoding::HandleType<
6428                    fidl::Fifo,
6429                    { fidl::ObjectType::FIFO.into_raw() },
6430                    2147483648,
6431                >,
6432                fidl::encoding::DefaultFuchsiaResourceDialect,
6433            >,
6434        T1: fidl::encoding::Encode<
6435                fidl::encoding::HandleType<
6436                    fidl::Fifo,
6437                    { fidl::ObjectType::FIFO.into_raw() },
6438                    2147483648,
6439                >,
6440                fidl::encoding::DefaultFuchsiaResourceDialect,
6441            >,
6442    > fidl::encoding::Encode<Fifos, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0, T1)
6443    {
6444        #[inline]
6445        unsafe fn encode(
6446            self,
6447            encoder: &mut fidl::encoding::Encoder<
6448                '_,
6449                fidl::encoding::DefaultFuchsiaResourceDialect,
6450            >,
6451            offset: usize,
6452            depth: fidl::encoding::Depth,
6453        ) -> fidl::Result<()> {
6454            encoder.debug_check_bounds::<Fifos>(offset);
6455            // Zero out padding regions. There's no need to apply masks
6456            // because the unmasked parts will be overwritten by fields.
6457            // Write the fields.
6458            self.0.encode(encoder, offset + 0, depth)?;
6459            self.1.encode(encoder, offset + 4, depth)?;
6460            Ok(())
6461        }
6462    }
6463
6464    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Fifos {
6465        #[inline(always)]
6466        fn new_empty() -> Self {
6467            Self {
6468                rx: fidl::new_empty!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
6469                tx: fidl::new_empty!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
6470            }
6471        }
6472
6473        #[inline]
6474        unsafe fn decode(
6475            &mut self,
6476            decoder: &mut fidl::encoding::Decoder<
6477                '_,
6478                fidl::encoding::DefaultFuchsiaResourceDialect,
6479            >,
6480            offset: usize,
6481            _depth: fidl::encoding::Depth,
6482        ) -> fidl::Result<()> {
6483            decoder.debug_check_bounds::<Self>(offset);
6484            // Verify that padding bytes are zero.
6485            fidl::decode!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.rx, decoder, offset + 0, _depth)?;
6486            fidl::decode!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.tx, decoder, offset + 4, _depth)?;
6487            Ok(())
6488        }
6489    }
6490
6491    impl fidl::encoding::ResourceTypeMarker for PortCloneRequest {
6492        type Borrowed<'a> = &'a mut Self;
6493        fn take_or_borrow<'a>(
6494            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6495        ) -> Self::Borrowed<'a> {
6496            value
6497        }
6498    }
6499
6500    unsafe impl fidl::encoding::TypeMarker for PortCloneRequest {
6501        type Owned = Self;
6502
6503        #[inline(always)]
6504        fn inline_align(_context: fidl::encoding::Context) -> usize {
6505            4
6506        }
6507
6508        #[inline(always)]
6509        fn inline_size(_context: fidl::encoding::Context) -> usize {
6510            4
6511        }
6512    }
6513
6514    unsafe impl
6515        fidl::encoding::Encode<PortCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6516        for &mut PortCloneRequest
6517    {
6518        #[inline]
6519        unsafe fn encode(
6520            self,
6521            encoder: &mut fidl::encoding::Encoder<
6522                '_,
6523                fidl::encoding::DefaultFuchsiaResourceDialect,
6524            >,
6525            offset: usize,
6526            _depth: fidl::encoding::Depth,
6527        ) -> fidl::Result<()> {
6528            encoder.debug_check_bounds::<PortCloneRequest>(offset);
6529            // Delegate to tuple encoding.
6530            fidl::encoding::Encode::<PortCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6531                (
6532                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.port),
6533                ),
6534                encoder, offset, _depth
6535            )
6536        }
6537    }
6538    unsafe impl<
6539        T0: fidl::encoding::Encode<
6540                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
6541                fidl::encoding::DefaultFuchsiaResourceDialect,
6542            >,
6543    > fidl::encoding::Encode<PortCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6544        for (T0,)
6545    {
6546        #[inline]
6547        unsafe fn encode(
6548            self,
6549            encoder: &mut fidl::encoding::Encoder<
6550                '_,
6551                fidl::encoding::DefaultFuchsiaResourceDialect,
6552            >,
6553            offset: usize,
6554            depth: fidl::encoding::Depth,
6555        ) -> fidl::Result<()> {
6556            encoder.debug_check_bounds::<PortCloneRequest>(offset);
6557            // Zero out padding regions. There's no need to apply masks
6558            // because the unmasked parts will be overwritten by fields.
6559            // Write the fields.
6560            self.0.encode(encoder, offset + 0, depth)?;
6561            Ok(())
6562        }
6563    }
6564
6565    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6566        for PortCloneRequest
6567    {
6568        #[inline(always)]
6569        fn new_empty() -> Self {
6570            Self {
6571                port: fidl::new_empty!(
6572                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
6573                    fidl::encoding::DefaultFuchsiaResourceDialect
6574                ),
6575            }
6576        }
6577
6578        #[inline]
6579        unsafe fn decode(
6580            &mut self,
6581            decoder: &mut fidl::encoding::Decoder<
6582                '_,
6583                fidl::encoding::DefaultFuchsiaResourceDialect,
6584            >,
6585            offset: usize,
6586            _depth: fidl::encoding::Depth,
6587        ) -> fidl::Result<()> {
6588            decoder.debug_check_bounds::<Self>(offset);
6589            // Verify that padding bytes are zero.
6590            fidl::decode!(
6591                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
6592                fidl::encoding::DefaultFuchsiaResourceDialect,
6593                &mut self.port,
6594                decoder,
6595                offset + 0,
6596                _depth
6597            )?;
6598            Ok(())
6599        }
6600    }
6601
6602    impl fidl::encoding::ResourceTypeMarker for PortGetDeviceRequest {
6603        type Borrowed<'a> = &'a mut Self;
6604        fn take_or_borrow<'a>(
6605            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6606        ) -> Self::Borrowed<'a> {
6607            value
6608        }
6609    }
6610
6611    unsafe impl fidl::encoding::TypeMarker for PortGetDeviceRequest {
6612        type Owned = Self;
6613
6614        #[inline(always)]
6615        fn inline_align(_context: fidl::encoding::Context) -> usize {
6616            4
6617        }
6618
6619        #[inline(always)]
6620        fn inline_size(_context: fidl::encoding::Context) -> usize {
6621            4
6622        }
6623    }
6624
6625    unsafe impl
6626        fidl::encoding::Encode<PortGetDeviceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6627        for &mut PortGetDeviceRequest
6628    {
6629        #[inline]
6630        unsafe fn encode(
6631            self,
6632            encoder: &mut fidl::encoding::Encoder<
6633                '_,
6634                fidl::encoding::DefaultFuchsiaResourceDialect,
6635            >,
6636            offset: usize,
6637            _depth: fidl::encoding::Depth,
6638        ) -> fidl::Result<()> {
6639            encoder.debug_check_bounds::<PortGetDeviceRequest>(offset);
6640            // Delegate to tuple encoding.
6641            fidl::encoding::Encode::<PortGetDeviceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6642                (
6643                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.device),
6644                ),
6645                encoder, offset, _depth
6646            )
6647        }
6648    }
6649    unsafe impl<
6650        T0: fidl::encoding::Encode<
6651                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
6652                fidl::encoding::DefaultFuchsiaResourceDialect,
6653            >,
6654    >
6655        fidl::encoding::Encode<PortGetDeviceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6656        for (T0,)
6657    {
6658        #[inline]
6659        unsafe fn encode(
6660            self,
6661            encoder: &mut fidl::encoding::Encoder<
6662                '_,
6663                fidl::encoding::DefaultFuchsiaResourceDialect,
6664            >,
6665            offset: usize,
6666            depth: fidl::encoding::Depth,
6667        ) -> fidl::Result<()> {
6668            encoder.debug_check_bounds::<PortGetDeviceRequest>(offset);
6669            // Zero out padding regions. There's no need to apply masks
6670            // because the unmasked parts will be overwritten by fields.
6671            // Write the fields.
6672            self.0.encode(encoder, offset + 0, depth)?;
6673            Ok(())
6674        }
6675    }
6676
6677    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6678        for PortGetDeviceRequest
6679    {
6680        #[inline(always)]
6681        fn new_empty() -> Self {
6682            Self {
6683                device: fidl::new_empty!(
6684                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
6685                    fidl::encoding::DefaultFuchsiaResourceDialect
6686                ),
6687            }
6688        }
6689
6690        #[inline]
6691        unsafe fn decode(
6692            &mut self,
6693            decoder: &mut fidl::encoding::Decoder<
6694                '_,
6695                fidl::encoding::DefaultFuchsiaResourceDialect,
6696            >,
6697            offset: usize,
6698            _depth: fidl::encoding::Depth,
6699        ) -> fidl::Result<()> {
6700            decoder.debug_check_bounds::<Self>(offset);
6701            // Verify that padding bytes are zero.
6702            fidl::decode!(
6703                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
6704                fidl::encoding::DefaultFuchsiaResourceDialect,
6705                &mut self.device,
6706                decoder,
6707                offset + 0,
6708                _depth
6709            )?;
6710            Ok(())
6711        }
6712    }
6713
6714    impl fidl::encoding::ResourceTypeMarker for PortGetDiagnosticsRequest {
6715        type Borrowed<'a> = &'a mut Self;
6716        fn take_or_borrow<'a>(
6717            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6718        ) -> Self::Borrowed<'a> {
6719            value
6720        }
6721    }
6722
6723    unsafe impl fidl::encoding::TypeMarker for PortGetDiagnosticsRequest {
6724        type Owned = Self;
6725
6726        #[inline(always)]
6727        fn inline_align(_context: fidl::encoding::Context) -> usize {
6728            4
6729        }
6730
6731        #[inline(always)]
6732        fn inline_size(_context: fidl::encoding::Context) -> usize {
6733            4
6734        }
6735    }
6736
6737    unsafe impl
6738        fidl::encoding::Encode<
6739            PortGetDiagnosticsRequest,
6740            fidl::encoding::DefaultFuchsiaResourceDialect,
6741        > for &mut PortGetDiagnosticsRequest
6742    {
6743        #[inline]
6744        unsafe fn encode(
6745            self,
6746            encoder: &mut fidl::encoding::Encoder<
6747                '_,
6748                fidl::encoding::DefaultFuchsiaResourceDialect,
6749            >,
6750            offset: usize,
6751            _depth: fidl::encoding::Depth,
6752        ) -> fidl::Result<()> {
6753            encoder.debug_check_bounds::<PortGetDiagnosticsRequest>(offset);
6754            // Delegate to tuple encoding.
6755            fidl::encoding::Encode::<PortGetDiagnosticsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6756                (
6757                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiagnosticsMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.diagnostics),
6758                ),
6759                encoder, offset, _depth
6760            )
6761        }
6762    }
6763    unsafe impl<
6764        T0: fidl::encoding::Encode<
6765                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiagnosticsMarker>>,
6766                fidl::encoding::DefaultFuchsiaResourceDialect,
6767            >,
6768    >
6769        fidl::encoding::Encode<
6770            PortGetDiagnosticsRequest,
6771            fidl::encoding::DefaultFuchsiaResourceDialect,
6772        > for (T0,)
6773    {
6774        #[inline]
6775        unsafe fn encode(
6776            self,
6777            encoder: &mut fidl::encoding::Encoder<
6778                '_,
6779                fidl::encoding::DefaultFuchsiaResourceDialect,
6780            >,
6781            offset: usize,
6782            depth: fidl::encoding::Depth,
6783        ) -> fidl::Result<()> {
6784            encoder.debug_check_bounds::<PortGetDiagnosticsRequest>(offset);
6785            // Zero out padding regions. There's no need to apply masks
6786            // because the unmasked parts will be overwritten by fields.
6787            // Write the fields.
6788            self.0.encode(encoder, offset + 0, depth)?;
6789            Ok(())
6790        }
6791    }
6792
6793    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6794        for PortGetDiagnosticsRequest
6795    {
6796        #[inline(always)]
6797        fn new_empty() -> Self {
6798            Self {
6799                diagnostics: fidl::new_empty!(
6800                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiagnosticsMarker>>,
6801                    fidl::encoding::DefaultFuchsiaResourceDialect
6802                ),
6803            }
6804        }
6805
6806        #[inline]
6807        unsafe fn decode(
6808            &mut self,
6809            decoder: &mut fidl::encoding::Decoder<
6810                '_,
6811                fidl::encoding::DefaultFuchsiaResourceDialect,
6812            >,
6813            offset: usize,
6814            _depth: fidl::encoding::Depth,
6815        ) -> fidl::Result<()> {
6816            decoder.debug_check_bounds::<Self>(offset);
6817            // Verify that padding bytes are zero.
6818            fidl::decode!(
6819                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiagnosticsMarker>>,
6820                fidl::encoding::DefaultFuchsiaResourceDialect,
6821                &mut self.diagnostics,
6822                decoder,
6823                offset + 0,
6824                _depth
6825            )?;
6826            Ok(())
6827        }
6828    }
6829
6830    impl fidl::encoding::ResourceTypeMarker for PortGetIdentityResponse {
6831        type Borrowed<'a> = &'a mut Self;
6832        fn take_or_borrow<'a>(
6833            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6834        ) -> Self::Borrowed<'a> {
6835            value
6836        }
6837    }
6838
6839    unsafe impl fidl::encoding::TypeMarker for PortGetIdentityResponse {
6840        type Owned = Self;
6841
6842        #[inline(always)]
6843        fn inline_align(_context: fidl::encoding::Context) -> usize {
6844            4
6845        }
6846
6847        #[inline(always)]
6848        fn inline_size(_context: fidl::encoding::Context) -> usize {
6849            4
6850        }
6851    }
6852
6853    unsafe impl
6854        fidl::encoding::Encode<
6855            PortGetIdentityResponse,
6856            fidl::encoding::DefaultFuchsiaResourceDialect,
6857        > for &mut PortGetIdentityResponse
6858    {
6859        #[inline]
6860        unsafe fn encode(
6861            self,
6862            encoder: &mut fidl::encoding::Encoder<
6863                '_,
6864                fidl::encoding::DefaultFuchsiaResourceDialect,
6865            >,
6866            offset: usize,
6867            _depth: fidl::encoding::Depth,
6868        ) -> fidl::Result<()> {
6869            encoder.debug_check_bounds::<PortGetIdentityResponse>(offset);
6870            // Delegate to tuple encoding.
6871            fidl::encoding::Encode::<
6872                PortGetIdentityResponse,
6873                fidl::encoding::DefaultFuchsiaResourceDialect,
6874            >::encode(
6875                (<fidl::encoding::HandleType<
6876                    fidl::Event,
6877                    { fidl::ObjectType::EVENT.into_raw() },
6878                    3,
6879                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6880                    &mut self.event
6881                ),),
6882                encoder,
6883                offset,
6884                _depth,
6885            )
6886        }
6887    }
6888    unsafe impl<
6889        T0: fidl::encoding::Encode<
6890                fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>,
6891                fidl::encoding::DefaultFuchsiaResourceDialect,
6892            >,
6893    >
6894        fidl::encoding::Encode<
6895            PortGetIdentityResponse,
6896            fidl::encoding::DefaultFuchsiaResourceDialect,
6897        > for (T0,)
6898    {
6899        #[inline]
6900        unsafe fn encode(
6901            self,
6902            encoder: &mut fidl::encoding::Encoder<
6903                '_,
6904                fidl::encoding::DefaultFuchsiaResourceDialect,
6905            >,
6906            offset: usize,
6907            depth: fidl::encoding::Depth,
6908        ) -> fidl::Result<()> {
6909            encoder.debug_check_bounds::<PortGetIdentityResponse>(offset);
6910            // Zero out padding regions. There's no need to apply masks
6911            // because the unmasked parts will be overwritten by fields.
6912            // Write the fields.
6913            self.0.encode(encoder, offset + 0, depth)?;
6914            Ok(())
6915        }
6916    }
6917
6918    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6919        for PortGetIdentityResponse
6920    {
6921        #[inline(always)]
6922        fn new_empty() -> Self {
6923            Self {
6924                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>, fidl::encoding::DefaultFuchsiaResourceDialect),
6925            }
6926        }
6927
6928        #[inline]
6929        unsafe fn decode(
6930            &mut self,
6931            decoder: &mut fidl::encoding::Decoder<
6932                '_,
6933                fidl::encoding::DefaultFuchsiaResourceDialect,
6934            >,
6935            offset: usize,
6936            _depth: fidl::encoding::Depth,
6937        ) -> fidl::Result<()> {
6938            decoder.debug_check_bounds::<Self>(offset);
6939            // Verify that padding bytes are zero.
6940            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
6941            Ok(())
6942        }
6943    }
6944
6945    impl fidl::encoding::ResourceTypeMarker for PortGetMacRequest {
6946        type Borrowed<'a> = &'a mut Self;
6947        fn take_or_borrow<'a>(
6948            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6949        ) -> Self::Borrowed<'a> {
6950            value
6951        }
6952    }
6953
6954    unsafe impl fidl::encoding::TypeMarker for PortGetMacRequest {
6955        type Owned = Self;
6956
6957        #[inline(always)]
6958        fn inline_align(_context: fidl::encoding::Context) -> usize {
6959            4
6960        }
6961
6962        #[inline(always)]
6963        fn inline_size(_context: fidl::encoding::Context) -> usize {
6964            4
6965        }
6966    }
6967
6968    unsafe impl
6969        fidl::encoding::Encode<PortGetMacRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6970        for &mut PortGetMacRequest
6971    {
6972        #[inline]
6973        unsafe fn encode(
6974            self,
6975            encoder: &mut fidl::encoding::Encoder<
6976                '_,
6977                fidl::encoding::DefaultFuchsiaResourceDialect,
6978            >,
6979            offset: usize,
6980            _depth: fidl::encoding::Depth,
6981        ) -> fidl::Result<()> {
6982            encoder.debug_check_bounds::<PortGetMacRequest>(offset);
6983            // Delegate to tuple encoding.
6984            fidl::encoding::Encode::<PortGetMacRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6985                (
6986                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MacAddressingMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.mac),
6987                ),
6988                encoder, offset, _depth
6989            )
6990        }
6991    }
6992    unsafe impl<
6993        T0: fidl::encoding::Encode<
6994                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MacAddressingMarker>>,
6995                fidl::encoding::DefaultFuchsiaResourceDialect,
6996            >,
6997    > fidl::encoding::Encode<PortGetMacRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6998        for (T0,)
6999    {
7000        #[inline]
7001        unsafe fn encode(
7002            self,
7003            encoder: &mut fidl::encoding::Encoder<
7004                '_,
7005                fidl::encoding::DefaultFuchsiaResourceDialect,
7006            >,
7007            offset: usize,
7008            depth: fidl::encoding::Depth,
7009        ) -> fidl::Result<()> {
7010            encoder.debug_check_bounds::<PortGetMacRequest>(offset);
7011            // Zero out padding regions. There's no need to apply masks
7012            // because the unmasked parts will be overwritten by fields.
7013            // Write the fields.
7014            self.0.encode(encoder, offset + 0, depth)?;
7015            Ok(())
7016        }
7017    }
7018
7019    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7020        for PortGetMacRequest
7021    {
7022        #[inline(always)]
7023        fn new_empty() -> Self {
7024            Self {
7025                mac: fidl::new_empty!(
7026                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MacAddressingMarker>>,
7027                    fidl::encoding::DefaultFuchsiaResourceDialect
7028                ),
7029            }
7030        }
7031
7032        #[inline]
7033        unsafe fn decode(
7034            &mut self,
7035            decoder: &mut fidl::encoding::Decoder<
7036                '_,
7037                fidl::encoding::DefaultFuchsiaResourceDialect,
7038            >,
7039            offset: usize,
7040            _depth: fidl::encoding::Depth,
7041        ) -> fidl::Result<()> {
7042            decoder.debug_check_bounds::<Self>(offset);
7043            // Verify that padding bytes are zero.
7044            fidl::decode!(
7045                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MacAddressingMarker>>,
7046                fidl::encoding::DefaultFuchsiaResourceDialect,
7047                &mut self.mac,
7048                decoder,
7049                offset + 0,
7050                _depth
7051            )?;
7052            Ok(())
7053        }
7054    }
7055
7056    impl fidl::encoding::ResourceTypeMarker for PortGetStatusWatcherRequest {
7057        type Borrowed<'a> = &'a mut Self;
7058        fn take_or_borrow<'a>(
7059            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7060        ) -> Self::Borrowed<'a> {
7061            value
7062        }
7063    }
7064
7065    unsafe impl fidl::encoding::TypeMarker for PortGetStatusWatcherRequest {
7066        type Owned = Self;
7067
7068        #[inline(always)]
7069        fn inline_align(_context: fidl::encoding::Context) -> usize {
7070            4
7071        }
7072
7073        #[inline(always)]
7074        fn inline_size(_context: fidl::encoding::Context) -> usize {
7075            8
7076        }
7077    }
7078
7079    unsafe impl
7080        fidl::encoding::Encode<
7081            PortGetStatusWatcherRequest,
7082            fidl::encoding::DefaultFuchsiaResourceDialect,
7083        > for &mut PortGetStatusWatcherRequest
7084    {
7085        #[inline]
7086        unsafe fn encode(
7087            self,
7088            encoder: &mut fidl::encoding::Encoder<
7089                '_,
7090                fidl::encoding::DefaultFuchsiaResourceDialect,
7091            >,
7092            offset: usize,
7093            _depth: fidl::encoding::Depth,
7094        ) -> fidl::Result<()> {
7095            encoder.debug_check_bounds::<PortGetStatusWatcherRequest>(offset);
7096            // Delegate to tuple encoding.
7097            fidl::encoding::Encode::<PortGetStatusWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7098                (
7099                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StatusWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
7100                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer),
7101                ),
7102                encoder, offset, _depth
7103            )
7104        }
7105    }
7106    unsafe impl<
7107        T0: fidl::encoding::Encode<
7108                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StatusWatcherMarker>>,
7109                fidl::encoding::DefaultFuchsiaResourceDialect,
7110            >,
7111        T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
7112    >
7113        fidl::encoding::Encode<
7114            PortGetStatusWatcherRequest,
7115            fidl::encoding::DefaultFuchsiaResourceDialect,
7116        > for (T0, T1)
7117    {
7118        #[inline]
7119        unsafe fn encode(
7120            self,
7121            encoder: &mut fidl::encoding::Encoder<
7122                '_,
7123                fidl::encoding::DefaultFuchsiaResourceDialect,
7124            >,
7125            offset: usize,
7126            depth: fidl::encoding::Depth,
7127        ) -> fidl::Result<()> {
7128            encoder.debug_check_bounds::<PortGetStatusWatcherRequest>(offset);
7129            // Zero out padding regions. There's no need to apply masks
7130            // because the unmasked parts will be overwritten by fields.
7131            // Write the fields.
7132            self.0.encode(encoder, offset + 0, depth)?;
7133            self.1.encode(encoder, offset + 4, depth)?;
7134            Ok(())
7135        }
7136    }
7137
7138    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7139        for PortGetStatusWatcherRequest
7140    {
7141        #[inline(always)]
7142        fn new_empty() -> Self {
7143            Self {
7144                watcher: fidl::new_empty!(
7145                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StatusWatcherMarker>>,
7146                    fidl::encoding::DefaultFuchsiaResourceDialect
7147                ),
7148                buffer: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
7149            }
7150        }
7151
7152        #[inline]
7153        unsafe fn decode(
7154            &mut self,
7155            decoder: &mut fidl::encoding::Decoder<
7156                '_,
7157                fidl::encoding::DefaultFuchsiaResourceDialect,
7158            >,
7159            offset: usize,
7160            _depth: fidl::encoding::Depth,
7161        ) -> fidl::Result<()> {
7162            decoder.debug_check_bounds::<Self>(offset);
7163            // Verify that padding bytes are zero.
7164            fidl::decode!(
7165                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StatusWatcherMarker>>,
7166                fidl::encoding::DefaultFuchsiaResourceDialect,
7167                &mut self.watcher,
7168                decoder,
7169                offset + 0,
7170                _depth
7171            )?;
7172            fidl::decode!(
7173                u32,
7174                fidl::encoding::DefaultFuchsiaResourceDialect,
7175                &mut self.buffer,
7176                decoder,
7177                offset + 4,
7178                _depth
7179            )?;
7180            Ok(())
7181        }
7182    }
7183
7184    impl fidl::encoding::ResourceTypeMarker for SessionWatchDelegatedRxLeaseResponse {
7185        type Borrowed<'a> = &'a mut Self;
7186        fn take_or_borrow<'a>(
7187            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7188        ) -> Self::Borrowed<'a> {
7189            value
7190        }
7191    }
7192
7193    unsafe impl fidl::encoding::TypeMarker for SessionWatchDelegatedRxLeaseResponse {
7194        type Owned = Self;
7195
7196        #[inline(always)]
7197        fn inline_align(_context: fidl::encoding::Context) -> usize {
7198            8
7199        }
7200
7201        #[inline(always)]
7202        fn inline_size(_context: fidl::encoding::Context) -> usize {
7203            16
7204        }
7205    }
7206
7207    unsafe impl
7208        fidl::encoding::Encode<
7209            SessionWatchDelegatedRxLeaseResponse,
7210            fidl::encoding::DefaultFuchsiaResourceDialect,
7211        > for &mut SessionWatchDelegatedRxLeaseResponse
7212    {
7213        #[inline]
7214        unsafe fn encode(
7215            self,
7216            encoder: &mut fidl::encoding::Encoder<
7217                '_,
7218                fidl::encoding::DefaultFuchsiaResourceDialect,
7219            >,
7220            offset: usize,
7221            _depth: fidl::encoding::Depth,
7222        ) -> fidl::Result<()> {
7223            encoder.debug_check_bounds::<SessionWatchDelegatedRxLeaseResponse>(offset);
7224            // Delegate to tuple encoding.
7225            fidl::encoding::Encode::<
7226                SessionWatchDelegatedRxLeaseResponse,
7227                fidl::encoding::DefaultFuchsiaResourceDialect,
7228            >::encode(
7229                (<DelegatedRxLease as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7230                    &mut self.lease,
7231                ),),
7232                encoder,
7233                offset,
7234                _depth,
7235            )
7236        }
7237    }
7238    unsafe impl<
7239        T0: fidl::encoding::Encode<DelegatedRxLease, fidl::encoding::DefaultFuchsiaResourceDialect>,
7240    >
7241        fidl::encoding::Encode<
7242            SessionWatchDelegatedRxLeaseResponse,
7243            fidl::encoding::DefaultFuchsiaResourceDialect,
7244        > for (T0,)
7245    {
7246        #[inline]
7247        unsafe fn encode(
7248            self,
7249            encoder: &mut fidl::encoding::Encoder<
7250                '_,
7251                fidl::encoding::DefaultFuchsiaResourceDialect,
7252            >,
7253            offset: usize,
7254            depth: fidl::encoding::Depth,
7255        ) -> fidl::Result<()> {
7256            encoder.debug_check_bounds::<SessionWatchDelegatedRxLeaseResponse>(offset);
7257            // Zero out padding regions. There's no need to apply masks
7258            // because the unmasked parts will be overwritten by fields.
7259            // Write the fields.
7260            self.0.encode(encoder, offset + 0, depth)?;
7261            Ok(())
7262        }
7263    }
7264
7265    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7266        for SessionWatchDelegatedRxLeaseResponse
7267    {
7268        #[inline(always)]
7269        fn new_empty() -> Self {
7270            Self {
7271                lease: fidl::new_empty!(
7272                    DelegatedRxLease,
7273                    fidl::encoding::DefaultFuchsiaResourceDialect
7274                ),
7275            }
7276        }
7277
7278        #[inline]
7279        unsafe fn decode(
7280            &mut self,
7281            decoder: &mut fidl::encoding::Decoder<
7282                '_,
7283                fidl::encoding::DefaultFuchsiaResourceDialect,
7284            >,
7285            offset: usize,
7286            _depth: fidl::encoding::Depth,
7287        ) -> fidl::Result<()> {
7288            decoder.debug_check_bounds::<Self>(offset);
7289            // Verify that padding bytes are zero.
7290            fidl::decode!(
7291                DelegatedRxLease,
7292                fidl::encoding::DefaultFuchsiaResourceDialect,
7293                &mut self.lease,
7294                decoder,
7295                offset + 0,
7296                _depth
7297            )?;
7298            Ok(())
7299        }
7300    }
7301
7302    impl DelegatedRxLease {
7303        #[inline(always)]
7304        fn max_ordinal_present(&self) -> u64 {
7305            if let Some(_) = self.handle {
7306                return 2;
7307            }
7308            if let Some(_) = self.hold_until_frame {
7309                return 1;
7310            }
7311            0
7312        }
7313    }
7314
7315    impl fidl::encoding::ResourceTypeMarker for DelegatedRxLease {
7316        type Borrowed<'a> = &'a mut Self;
7317        fn take_or_borrow<'a>(
7318            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7319        ) -> Self::Borrowed<'a> {
7320            value
7321        }
7322    }
7323
7324    unsafe impl fidl::encoding::TypeMarker for DelegatedRxLease {
7325        type Owned = Self;
7326
7327        #[inline(always)]
7328        fn inline_align(_context: fidl::encoding::Context) -> usize {
7329            8
7330        }
7331
7332        #[inline(always)]
7333        fn inline_size(_context: fidl::encoding::Context) -> usize {
7334            16
7335        }
7336    }
7337
7338    unsafe impl
7339        fidl::encoding::Encode<DelegatedRxLease, fidl::encoding::DefaultFuchsiaResourceDialect>
7340        for &mut DelegatedRxLease
7341    {
7342        unsafe fn encode(
7343            self,
7344            encoder: &mut fidl::encoding::Encoder<
7345                '_,
7346                fidl::encoding::DefaultFuchsiaResourceDialect,
7347            >,
7348            offset: usize,
7349            mut depth: fidl::encoding::Depth,
7350        ) -> fidl::Result<()> {
7351            encoder.debug_check_bounds::<DelegatedRxLease>(offset);
7352            // Vector header
7353            let max_ordinal: u64 = self.max_ordinal_present();
7354            encoder.write_num(max_ordinal, offset);
7355            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7356            // Calling encoder.out_of_line_offset(0) is not allowed.
7357            if max_ordinal == 0 {
7358                return Ok(());
7359            }
7360            depth.increment()?;
7361            let envelope_size = 8;
7362            let bytes_len = max_ordinal as usize * envelope_size;
7363            #[allow(unused_variables)]
7364            let offset = encoder.out_of_line_offset(bytes_len);
7365            let mut _prev_end_offset: usize = 0;
7366            if 1 > max_ordinal {
7367                return Ok(());
7368            }
7369
7370            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7371            // are envelope_size bytes.
7372            let cur_offset: usize = (1 - 1) * envelope_size;
7373
7374            // Zero reserved fields.
7375            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7376
7377            // Safety:
7378            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7379            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7380            //   envelope_size bytes, there is always sufficient room.
7381            fidl::encoding::encode_in_envelope_optional::<
7382                u64,
7383                fidl::encoding::DefaultFuchsiaResourceDialect,
7384            >(
7385                self.hold_until_frame
7386                    .as_ref()
7387                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
7388                encoder,
7389                offset + cur_offset,
7390                depth,
7391            )?;
7392
7393            _prev_end_offset = cur_offset + envelope_size;
7394            if 2 > max_ordinal {
7395                return Ok(());
7396            }
7397
7398            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7399            // are envelope_size bytes.
7400            let cur_offset: usize = (2 - 1) * envelope_size;
7401
7402            // Zero reserved fields.
7403            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7404
7405            // Safety:
7406            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7407            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7408            //   envelope_size bytes, there is always sufficient room.
7409            fidl::encoding::encode_in_envelope_optional::<
7410                DelegatedRxLeaseHandle,
7411                fidl::encoding::DefaultFuchsiaResourceDialect,
7412            >(
7413                self.handle.as_mut().map(
7414                    <DelegatedRxLeaseHandle as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
7415                ),
7416                encoder,
7417                offset + cur_offset,
7418                depth,
7419            )?;
7420
7421            _prev_end_offset = cur_offset + envelope_size;
7422
7423            Ok(())
7424        }
7425    }
7426
7427    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7428        for DelegatedRxLease
7429    {
7430        #[inline(always)]
7431        fn new_empty() -> Self {
7432            Self::default()
7433        }
7434
7435        unsafe fn decode(
7436            &mut self,
7437            decoder: &mut fidl::encoding::Decoder<
7438                '_,
7439                fidl::encoding::DefaultFuchsiaResourceDialect,
7440            >,
7441            offset: usize,
7442            mut depth: fidl::encoding::Depth,
7443        ) -> fidl::Result<()> {
7444            decoder.debug_check_bounds::<Self>(offset);
7445            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7446                None => return Err(fidl::Error::NotNullable),
7447                Some(len) => len,
7448            };
7449            // Calling decoder.out_of_line_offset(0) is not allowed.
7450            if len == 0 {
7451                return Ok(());
7452            };
7453            depth.increment()?;
7454            let envelope_size = 8;
7455            let bytes_len = len * envelope_size;
7456            let offset = decoder.out_of_line_offset(bytes_len)?;
7457            // Decode the envelope for each type.
7458            let mut _next_ordinal_to_read = 0;
7459            let mut next_offset = offset;
7460            let end_offset = offset + bytes_len;
7461            _next_ordinal_to_read += 1;
7462            if next_offset >= end_offset {
7463                return Ok(());
7464            }
7465
7466            // Decode unknown envelopes for gaps in ordinals.
7467            while _next_ordinal_to_read < 1 {
7468                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7469                _next_ordinal_to_read += 1;
7470                next_offset += envelope_size;
7471            }
7472
7473            let next_out_of_line = decoder.next_out_of_line();
7474            let handles_before = decoder.remaining_handles();
7475            if let Some((inlined, num_bytes, num_handles)) =
7476                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7477            {
7478                let member_inline_size =
7479                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7480                if inlined != (member_inline_size <= 4) {
7481                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7482                }
7483                let inner_offset;
7484                let mut inner_depth = depth.clone();
7485                if inlined {
7486                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7487                    inner_offset = next_offset;
7488                } else {
7489                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7490                    inner_depth.increment()?;
7491                }
7492                let val_ref = self.hold_until_frame.get_or_insert_with(|| {
7493                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
7494                });
7495                fidl::decode!(
7496                    u64,
7497                    fidl::encoding::DefaultFuchsiaResourceDialect,
7498                    val_ref,
7499                    decoder,
7500                    inner_offset,
7501                    inner_depth
7502                )?;
7503                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7504                {
7505                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7506                }
7507                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7508                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7509                }
7510            }
7511
7512            next_offset += envelope_size;
7513            _next_ordinal_to_read += 1;
7514            if next_offset >= end_offset {
7515                return Ok(());
7516            }
7517
7518            // Decode unknown envelopes for gaps in ordinals.
7519            while _next_ordinal_to_read < 2 {
7520                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7521                _next_ordinal_to_read += 1;
7522                next_offset += envelope_size;
7523            }
7524
7525            let next_out_of_line = decoder.next_out_of_line();
7526            let handles_before = decoder.remaining_handles();
7527            if let Some((inlined, num_bytes, num_handles)) =
7528                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7529            {
7530                let member_inline_size =
7531                    <DelegatedRxLeaseHandle as fidl::encoding::TypeMarker>::inline_size(
7532                        decoder.context,
7533                    );
7534                if inlined != (member_inline_size <= 4) {
7535                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7536                }
7537                let inner_offset;
7538                let mut inner_depth = depth.clone();
7539                if inlined {
7540                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7541                    inner_offset = next_offset;
7542                } else {
7543                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7544                    inner_depth.increment()?;
7545                }
7546                let val_ref = self.handle.get_or_insert_with(|| {
7547                    fidl::new_empty!(
7548                        DelegatedRxLeaseHandle,
7549                        fidl::encoding::DefaultFuchsiaResourceDialect
7550                    )
7551                });
7552                fidl::decode!(
7553                    DelegatedRxLeaseHandle,
7554                    fidl::encoding::DefaultFuchsiaResourceDialect,
7555                    val_ref,
7556                    decoder,
7557                    inner_offset,
7558                    inner_depth
7559                )?;
7560                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7561                {
7562                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7563                }
7564                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7565                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7566                }
7567            }
7568
7569            next_offset += envelope_size;
7570
7571            // Decode the remaining unknown envelopes.
7572            while next_offset < end_offset {
7573                _next_ordinal_to_read += 1;
7574                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7575                next_offset += envelope_size;
7576            }
7577
7578            Ok(())
7579        }
7580    }
7581
7582    impl SessionInfo {
7583        #[inline(always)]
7584        fn max_ordinal_present(&self) -> u64 {
7585            if let Some(_) = self.options {
7586                return 6;
7587            }
7588            if let Some(_) = self.descriptor_count {
7589                return 5;
7590            }
7591            if let Some(_) = self.descriptor_length {
7592                return 4;
7593            }
7594            if let Some(_) = self.descriptor_version {
7595                return 3;
7596            }
7597            if let Some(_) = self.data {
7598                return 2;
7599            }
7600            if let Some(_) = self.descriptors {
7601                return 1;
7602            }
7603            0
7604        }
7605    }
7606
7607    impl fidl::encoding::ResourceTypeMarker for SessionInfo {
7608        type Borrowed<'a> = &'a mut Self;
7609        fn take_or_borrow<'a>(
7610            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7611        ) -> Self::Borrowed<'a> {
7612            value
7613        }
7614    }
7615
7616    unsafe impl fidl::encoding::TypeMarker for SessionInfo {
7617        type Owned = Self;
7618
7619        #[inline(always)]
7620        fn inline_align(_context: fidl::encoding::Context) -> usize {
7621            8
7622        }
7623
7624        #[inline(always)]
7625        fn inline_size(_context: fidl::encoding::Context) -> usize {
7626            16
7627        }
7628    }
7629
7630    unsafe impl fidl::encoding::Encode<SessionInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
7631        for &mut SessionInfo
7632    {
7633        unsafe fn encode(
7634            self,
7635            encoder: &mut fidl::encoding::Encoder<
7636                '_,
7637                fidl::encoding::DefaultFuchsiaResourceDialect,
7638            >,
7639            offset: usize,
7640            mut depth: fidl::encoding::Depth,
7641        ) -> fidl::Result<()> {
7642            encoder.debug_check_bounds::<SessionInfo>(offset);
7643            // Vector header
7644            let max_ordinal: u64 = self.max_ordinal_present();
7645            encoder.write_num(max_ordinal, offset);
7646            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7647            // Calling encoder.out_of_line_offset(0) is not allowed.
7648            if max_ordinal == 0 {
7649                return Ok(());
7650            }
7651            depth.increment()?;
7652            let envelope_size = 8;
7653            let bytes_len = max_ordinal as usize * envelope_size;
7654            #[allow(unused_variables)]
7655            let offset = encoder.out_of_line_offset(bytes_len);
7656            let mut _prev_end_offset: usize = 0;
7657            if 1 > max_ordinal {
7658                return Ok(());
7659            }
7660
7661            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7662            // are envelope_size bytes.
7663            let cur_offset: usize = (1 - 1) * envelope_size;
7664
7665            // Zero reserved fields.
7666            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7667
7668            // Safety:
7669            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7670            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7671            //   envelope_size bytes, there is always sufficient room.
7672            fidl::encoding::encode_in_envelope_optional::<
7673                fidl::encoding::HandleType<
7674                    fidl::Vmo,
7675                    { fidl::ObjectType::VMO.into_raw() },
7676                    2147483648,
7677                >,
7678                fidl::encoding::DefaultFuchsiaResourceDialect,
7679            >(
7680                self.descriptors.as_mut().map(
7681                    <fidl::encoding::HandleType<
7682                        fidl::Vmo,
7683                        { fidl::ObjectType::VMO.into_raw() },
7684                        2147483648,
7685                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
7686                ),
7687                encoder,
7688                offset + cur_offset,
7689                depth,
7690            )?;
7691
7692            _prev_end_offset = cur_offset + envelope_size;
7693            if 2 > max_ordinal {
7694                return Ok(());
7695            }
7696
7697            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7698            // are envelope_size bytes.
7699            let cur_offset: usize = (2 - 1) * envelope_size;
7700
7701            // Zero reserved fields.
7702            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7703
7704            // Safety:
7705            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7706            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7707            //   envelope_size bytes, there is always sufficient room.
7708            fidl::encoding::encode_in_envelope_optional::<
7709                fidl::encoding::HandleType<
7710                    fidl::Vmo,
7711                    { fidl::ObjectType::VMO.into_raw() },
7712                    2147483648,
7713                >,
7714                fidl::encoding::DefaultFuchsiaResourceDialect,
7715            >(
7716                self.data.as_mut().map(
7717                    <fidl::encoding::HandleType<
7718                        fidl::Vmo,
7719                        { fidl::ObjectType::VMO.into_raw() },
7720                        2147483648,
7721                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
7722                ),
7723                encoder,
7724                offset + cur_offset,
7725                depth,
7726            )?;
7727
7728            _prev_end_offset = cur_offset + envelope_size;
7729            if 3 > max_ordinal {
7730                return Ok(());
7731            }
7732
7733            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7734            // are envelope_size bytes.
7735            let cur_offset: usize = (3 - 1) * envelope_size;
7736
7737            // Zero reserved fields.
7738            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7739
7740            // Safety:
7741            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7742            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7743            //   envelope_size bytes, there is always sufficient room.
7744            fidl::encoding::encode_in_envelope_optional::<
7745                u8,
7746                fidl::encoding::DefaultFuchsiaResourceDialect,
7747            >(
7748                self.descriptor_version
7749                    .as_ref()
7750                    .map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
7751                encoder,
7752                offset + cur_offset,
7753                depth,
7754            )?;
7755
7756            _prev_end_offset = cur_offset + envelope_size;
7757            if 4 > max_ordinal {
7758                return Ok(());
7759            }
7760
7761            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7762            // are envelope_size bytes.
7763            let cur_offset: usize = (4 - 1) * envelope_size;
7764
7765            // Zero reserved fields.
7766            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7767
7768            // Safety:
7769            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7770            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7771            //   envelope_size bytes, there is always sufficient room.
7772            fidl::encoding::encode_in_envelope_optional::<
7773                u8,
7774                fidl::encoding::DefaultFuchsiaResourceDialect,
7775            >(
7776                self.descriptor_length
7777                    .as_ref()
7778                    .map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
7779                encoder,
7780                offset + cur_offset,
7781                depth,
7782            )?;
7783
7784            _prev_end_offset = cur_offset + envelope_size;
7785            if 5 > max_ordinal {
7786                return Ok(());
7787            }
7788
7789            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7790            // are envelope_size bytes.
7791            let cur_offset: usize = (5 - 1) * envelope_size;
7792
7793            // Zero reserved fields.
7794            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7795
7796            // Safety:
7797            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7798            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7799            //   envelope_size bytes, there is always sufficient room.
7800            fidl::encoding::encode_in_envelope_optional::<
7801                u16,
7802                fidl::encoding::DefaultFuchsiaResourceDialect,
7803            >(
7804                self.descriptor_count
7805                    .as_ref()
7806                    .map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
7807                encoder,
7808                offset + cur_offset,
7809                depth,
7810            )?;
7811
7812            _prev_end_offset = cur_offset + envelope_size;
7813            if 6 > max_ordinal {
7814                return Ok(());
7815            }
7816
7817            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7818            // are envelope_size bytes.
7819            let cur_offset: usize = (6 - 1) * envelope_size;
7820
7821            // Zero reserved fields.
7822            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7823
7824            // Safety:
7825            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7826            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7827            //   envelope_size bytes, there is always sufficient room.
7828            fidl::encoding::encode_in_envelope_optional::<
7829                SessionFlags,
7830                fidl::encoding::DefaultFuchsiaResourceDialect,
7831            >(
7832                self.options
7833                    .as_ref()
7834                    .map(<SessionFlags as fidl::encoding::ValueTypeMarker>::borrow),
7835                encoder,
7836                offset + cur_offset,
7837                depth,
7838            )?;
7839
7840            _prev_end_offset = cur_offset + envelope_size;
7841
7842            Ok(())
7843        }
7844    }
7845
7846    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for SessionInfo {
7847        #[inline(always)]
7848        fn new_empty() -> Self {
7849            Self::default()
7850        }
7851
7852        unsafe fn decode(
7853            &mut self,
7854            decoder: &mut fidl::encoding::Decoder<
7855                '_,
7856                fidl::encoding::DefaultFuchsiaResourceDialect,
7857            >,
7858            offset: usize,
7859            mut depth: fidl::encoding::Depth,
7860        ) -> fidl::Result<()> {
7861            decoder.debug_check_bounds::<Self>(offset);
7862            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7863                None => return Err(fidl::Error::NotNullable),
7864                Some(len) => len,
7865            };
7866            // Calling decoder.out_of_line_offset(0) is not allowed.
7867            if len == 0 {
7868                return Ok(());
7869            };
7870            depth.increment()?;
7871            let envelope_size = 8;
7872            let bytes_len = len * envelope_size;
7873            let offset = decoder.out_of_line_offset(bytes_len)?;
7874            // Decode the envelope for each type.
7875            let mut _next_ordinal_to_read = 0;
7876            let mut next_offset = offset;
7877            let end_offset = offset + bytes_len;
7878            _next_ordinal_to_read += 1;
7879            if next_offset >= end_offset {
7880                return Ok(());
7881            }
7882
7883            // Decode unknown envelopes for gaps in ordinals.
7884            while _next_ordinal_to_read < 1 {
7885                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7886                _next_ordinal_to_read += 1;
7887                next_offset += envelope_size;
7888            }
7889
7890            let next_out_of_line = decoder.next_out_of_line();
7891            let handles_before = decoder.remaining_handles();
7892            if let Some((inlined, num_bytes, num_handles)) =
7893                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7894            {
7895                let member_inline_size = <fidl::encoding::HandleType<
7896                    fidl::Vmo,
7897                    { fidl::ObjectType::VMO.into_raw() },
7898                    2147483648,
7899                > as fidl::encoding::TypeMarker>::inline_size(
7900                    decoder.context
7901                );
7902                if inlined != (member_inline_size <= 4) {
7903                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7904                }
7905                let inner_offset;
7906                let mut inner_depth = depth.clone();
7907                if inlined {
7908                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7909                    inner_offset = next_offset;
7910                } else {
7911                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7912                    inner_depth.increment()?;
7913                }
7914                let val_ref =
7915                self.descriptors.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
7916                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
7917                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7918                {
7919                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7920                }
7921                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7922                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7923                }
7924            }
7925
7926            next_offset += envelope_size;
7927            _next_ordinal_to_read += 1;
7928            if next_offset >= end_offset {
7929                return Ok(());
7930            }
7931
7932            // Decode unknown envelopes for gaps in ordinals.
7933            while _next_ordinal_to_read < 2 {
7934                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7935                _next_ordinal_to_read += 1;
7936                next_offset += envelope_size;
7937            }
7938
7939            let next_out_of_line = decoder.next_out_of_line();
7940            let handles_before = decoder.remaining_handles();
7941            if let Some((inlined, num_bytes, num_handles)) =
7942                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7943            {
7944                let member_inline_size = <fidl::encoding::HandleType<
7945                    fidl::Vmo,
7946                    { fidl::ObjectType::VMO.into_raw() },
7947                    2147483648,
7948                > as fidl::encoding::TypeMarker>::inline_size(
7949                    decoder.context
7950                );
7951                if inlined != (member_inline_size <= 4) {
7952                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7953                }
7954                let inner_offset;
7955                let mut inner_depth = depth.clone();
7956                if inlined {
7957                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7958                    inner_offset = next_offset;
7959                } else {
7960                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7961                    inner_depth.increment()?;
7962                }
7963                let val_ref =
7964                self.data.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
7965                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
7966                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7967                {
7968                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7969                }
7970                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7971                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7972                }
7973            }
7974
7975            next_offset += envelope_size;
7976            _next_ordinal_to_read += 1;
7977            if next_offset >= end_offset {
7978                return Ok(());
7979            }
7980
7981            // Decode unknown envelopes for gaps in ordinals.
7982            while _next_ordinal_to_read < 3 {
7983                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7984                _next_ordinal_to_read += 1;
7985                next_offset += envelope_size;
7986            }
7987
7988            let next_out_of_line = decoder.next_out_of_line();
7989            let handles_before = decoder.remaining_handles();
7990            if let Some((inlined, num_bytes, num_handles)) =
7991                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7992            {
7993                let member_inline_size =
7994                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7995                if inlined != (member_inline_size <= 4) {
7996                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7997                }
7998                let inner_offset;
7999                let mut inner_depth = depth.clone();
8000                if inlined {
8001                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8002                    inner_offset = next_offset;
8003                } else {
8004                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8005                    inner_depth.increment()?;
8006                }
8007                let val_ref = self.descriptor_version.get_or_insert_with(|| {
8008                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
8009                });
8010                fidl::decode!(
8011                    u8,
8012                    fidl::encoding::DefaultFuchsiaResourceDialect,
8013                    val_ref,
8014                    decoder,
8015                    inner_offset,
8016                    inner_depth
8017                )?;
8018                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8019                {
8020                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8021                }
8022                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8023                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8024                }
8025            }
8026
8027            next_offset += envelope_size;
8028            _next_ordinal_to_read += 1;
8029            if next_offset >= end_offset {
8030                return Ok(());
8031            }
8032
8033            // Decode unknown envelopes for gaps in ordinals.
8034            while _next_ordinal_to_read < 4 {
8035                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8036                _next_ordinal_to_read += 1;
8037                next_offset += envelope_size;
8038            }
8039
8040            let next_out_of_line = decoder.next_out_of_line();
8041            let handles_before = decoder.remaining_handles();
8042            if let Some((inlined, num_bytes, num_handles)) =
8043                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8044            {
8045                let member_inline_size =
8046                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8047                if inlined != (member_inline_size <= 4) {
8048                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8049                }
8050                let inner_offset;
8051                let mut inner_depth = depth.clone();
8052                if inlined {
8053                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8054                    inner_offset = next_offset;
8055                } else {
8056                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8057                    inner_depth.increment()?;
8058                }
8059                let val_ref = self.descriptor_length.get_or_insert_with(|| {
8060                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
8061                });
8062                fidl::decode!(
8063                    u8,
8064                    fidl::encoding::DefaultFuchsiaResourceDialect,
8065                    val_ref,
8066                    decoder,
8067                    inner_offset,
8068                    inner_depth
8069                )?;
8070                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8071                {
8072                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8073                }
8074                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8075                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8076                }
8077            }
8078
8079            next_offset += envelope_size;
8080            _next_ordinal_to_read += 1;
8081            if next_offset >= end_offset {
8082                return Ok(());
8083            }
8084
8085            // Decode unknown envelopes for gaps in ordinals.
8086            while _next_ordinal_to_read < 5 {
8087                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8088                _next_ordinal_to_read += 1;
8089                next_offset += envelope_size;
8090            }
8091
8092            let next_out_of_line = decoder.next_out_of_line();
8093            let handles_before = decoder.remaining_handles();
8094            if let Some((inlined, num_bytes, num_handles)) =
8095                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8096            {
8097                let member_inline_size =
8098                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8099                if inlined != (member_inline_size <= 4) {
8100                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8101                }
8102                let inner_offset;
8103                let mut inner_depth = depth.clone();
8104                if inlined {
8105                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8106                    inner_offset = next_offset;
8107                } else {
8108                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8109                    inner_depth.increment()?;
8110                }
8111                let val_ref = self.descriptor_count.get_or_insert_with(|| {
8112                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
8113                });
8114                fidl::decode!(
8115                    u16,
8116                    fidl::encoding::DefaultFuchsiaResourceDialect,
8117                    val_ref,
8118                    decoder,
8119                    inner_offset,
8120                    inner_depth
8121                )?;
8122                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8123                {
8124                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8125                }
8126                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8127                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8128                }
8129            }
8130
8131            next_offset += envelope_size;
8132            _next_ordinal_to_read += 1;
8133            if next_offset >= end_offset {
8134                return Ok(());
8135            }
8136
8137            // Decode unknown envelopes for gaps in ordinals.
8138            while _next_ordinal_to_read < 6 {
8139                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8140                _next_ordinal_to_read += 1;
8141                next_offset += envelope_size;
8142            }
8143
8144            let next_out_of_line = decoder.next_out_of_line();
8145            let handles_before = decoder.remaining_handles();
8146            if let Some((inlined, num_bytes, num_handles)) =
8147                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8148            {
8149                let member_inline_size =
8150                    <SessionFlags as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8151                if inlined != (member_inline_size <= 4) {
8152                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8153                }
8154                let inner_offset;
8155                let mut inner_depth = depth.clone();
8156                if inlined {
8157                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8158                    inner_offset = next_offset;
8159                } else {
8160                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8161                    inner_depth.increment()?;
8162                }
8163                let val_ref = self.options.get_or_insert_with(|| {
8164                    fidl::new_empty!(SessionFlags, fidl::encoding::DefaultFuchsiaResourceDialect)
8165                });
8166                fidl::decode!(
8167                    SessionFlags,
8168                    fidl::encoding::DefaultFuchsiaResourceDialect,
8169                    val_ref,
8170                    decoder,
8171                    inner_offset,
8172                    inner_depth
8173                )?;
8174                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8175                {
8176                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8177                }
8178                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8179                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8180                }
8181            }
8182
8183            next_offset += envelope_size;
8184
8185            // Decode the remaining unknown envelopes.
8186            while next_offset < end_offset {
8187                _next_ordinal_to_read += 1;
8188                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8189                next_offset += envelope_size;
8190            }
8191
8192            Ok(())
8193        }
8194    }
8195
8196    impl fidl::encoding::ResourceTypeMarker for DelegatedRxLeaseHandle {
8197        type Borrowed<'a> = &'a mut Self;
8198        fn take_or_borrow<'a>(
8199            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8200        ) -> Self::Borrowed<'a> {
8201            value
8202        }
8203    }
8204
8205    unsafe impl fidl::encoding::TypeMarker for DelegatedRxLeaseHandle {
8206        type Owned = Self;
8207
8208        #[inline(always)]
8209        fn inline_align(_context: fidl::encoding::Context) -> usize {
8210            8
8211        }
8212
8213        #[inline(always)]
8214        fn inline_size(_context: fidl::encoding::Context) -> usize {
8215            16
8216        }
8217    }
8218
8219    unsafe impl
8220        fidl::encoding::Encode<
8221            DelegatedRxLeaseHandle,
8222            fidl::encoding::DefaultFuchsiaResourceDialect,
8223        > for &mut DelegatedRxLeaseHandle
8224    {
8225        #[inline]
8226        unsafe fn encode(
8227            self,
8228            encoder: &mut fidl::encoding::Encoder<
8229                '_,
8230                fidl::encoding::DefaultFuchsiaResourceDialect,
8231            >,
8232            offset: usize,
8233            _depth: fidl::encoding::Depth,
8234        ) -> fidl::Result<()> {
8235            encoder.debug_check_bounds::<DelegatedRxLeaseHandle>(offset);
8236            encoder.write_num::<u64>(self.ordinal(), offset);
8237            match self {
8238                DelegatedRxLeaseHandle::Channel(ref mut val) => {
8239                    fidl::encoding::encode_in_envelope::<
8240                        fidl::encoding::HandleType<
8241                            fidl::Channel,
8242                            { fidl::ObjectType::CHANNEL.into_raw() },
8243                            2147483648,
8244                        >,
8245                        fidl::encoding::DefaultFuchsiaResourceDialect,
8246                    >(
8247                        <fidl::encoding::HandleType<
8248                            fidl::Channel,
8249                            { fidl::ObjectType::CHANNEL.into_raw() },
8250                            2147483648,
8251                        > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8252                            val
8253                        ),
8254                        encoder,
8255                        offset + 8,
8256                        _depth,
8257                    )
8258                }
8259                DelegatedRxLeaseHandle::Eventpair(ref mut val) => {
8260                    fidl::encoding::encode_in_envelope::<
8261                        fidl::encoding::HandleType<
8262                            fidl::EventPair,
8263                            { fidl::ObjectType::EVENTPAIR.into_raw() },
8264                            16387,
8265                        >,
8266                        fidl::encoding::DefaultFuchsiaResourceDialect,
8267                    >(
8268                        <fidl::encoding::HandleType<
8269                            fidl::EventPair,
8270                            { fidl::ObjectType::EVENTPAIR.into_raw() },
8271                            16387,
8272                        > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8273                            val
8274                        ),
8275                        encoder,
8276                        offset + 8,
8277                        _depth,
8278                    )
8279                }
8280                DelegatedRxLeaseHandle::__SourceBreaking { .. } => {
8281                    Err(fidl::Error::UnknownUnionTag)
8282                }
8283            }
8284        }
8285    }
8286
8287    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8288        for DelegatedRxLeaseHandle
8289    {
8290        #[inline(always)]
8291        fn new_empty() -> Self {
8292            Self::__SourceBreaking { unknown_ordinal: 0 }
8293        }
8294
8295        #[inline]
8296        unsafe fn decode(
8297            &mut self,
8298            decoder: &mut fidl::encoding::Decoder<
8299                '_,
8300                fidl::encoding::DefaultFuchsiaResourceDialect,
8301            >,
8302            offset: usize,
8303            mut depth: fidl::encoding::Depth,
8304        ) -> fidl::Result<()> {
8305            decoder.debug_check_bounds::<Self>(offset);
8306            #[allow(unused_variables)]
8307            let next_out_of_line = decoder.next_out_of_line();
8308            let handles_before = decoder.remaining_handles();
8309            let (ordinal, inlined, num_bytes, num_handles) =
8310                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
8311
8312            let member_inline_size = match ordinal {
8313                1 => <fidl::encoding::HandleType<
8314                    fidl::Channel,
8315                    { fidl::ObjectType::CHANNEL.into_raw() },
8316                    2147483648,
8317                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
8318                2 => <fidl::encoding::HandleType<
8319                    fidl::EventPair,
8320                    { fidl::ObjectType::EVENTPAIR.into_raw() },
8321                    16387,
8322                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
8323                0 => return Err(fidl::Error::UnknownUnionTag),
8324                _ => num_bytes as usize,
8325            };
8326
8327            if inlined != (member_inline_size <= 4) {
8328                return Err(fidl::Error::InvalidInlineBitInEnvelope);
8329            }
8330            let _inner_offset;
8331            if inlined {
8332                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
8333                _inner_offset = offset + 8;
8334            } else {
8335                depth.increment()?;
8336                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8337            }
8338            match ordinal {
8339                1 => {
8340                    #[allow(irrefutable_let_patterns)]
8341                    if let DelegatedRxLeaseHandle::Channel(_) = self {
8342                        // Do nothing, read the value into the object
8343                    } else {
8344                        // Initialize `self` to the right variant
8345                        *self = DelegatedRxLeaseHandle::Channel(
8346                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8347                        );
8348                    }
8349                    #[allow(irrefutable_let_patterns)]
8350                    if let DelegatedRxLeaseHandle::Channel(ref mut val) = self {
8351                        fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
8352                    } else {
8353                        unreachable!()
8354                    }
8355                }
8356                2 => {
8357                    #[allow(irrefutable_let_patterns)]
8358                    if let DelegatedRxLeaseHandle::Eventpair(_) = self {
8359                        // Do nothing, read the value into the object
8360                    } else {
8361                        // Initialize `self` to the right variant
8362                        *self = DelegatedRxLeaseHandle::Eventpair(
8363                            fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
8364                        );
8365                    }
8366                    #[allow(irrefutable_let_patterns)]
8367                    if let DelegatedRxLeaseHandle::Eventpair(ref mut val) = self {
8368                        fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
8369                    } else {
8370                        unreachable!()
8371                    }
8372                }
8373                #[allow(deprecated)]
8374                ordinal => {
8375                    for _ in 0..num_handles {
8376                        decoder.drop_next_handle()?;
8377                    }
8378                    *self = DelegatedRxLeaseHandle::__SourceBreaking { unknown_ordinal: ordinal };
8379                }
8380            }
8381            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
8382                return Err(fidl::Error::InvalidNumBytesInEnvelope);
8383            }
8384            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8385                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8386            }
8387            Ok(())
8388        }
8389    }
8390}