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