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