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    /// - response `token` must have `zx.Rights.DUPLICATE`.
2914    pub fn r#get_power_dependency_token(
2915        &self,
2916        ___deadline: zx::MonotonicInstant,
2917    ) -> Result<Option<fidl::Event>, fidl::Error> {
2918        let _response = self.client.send_query::<
2919            fidl::encoding::EmptyPayload,
2920            PortGetPowerDependencyTokenResponse,
2921            PortMarker,
2922        >(
2923            (),
2924            0x7bec1da6ec2476ed,
2925            fidl::encoding::DynamicFlags::empty(),
2926            ___deadline,
2927        )?;
2928        Ok(_response.token)
2929    }
2930}
2931
2932#[cfg(target_os = "fuchsia")]
2933impl From<PortSynchronousProxy> for zx::NullableHandle {
2934    fn from(value: PortSynchronousProxy) -> Self {
2935        value.into_channel().into()
2936    }
2937}
2938
2939#[cfg(target_os = "fuchsia")]
2940impl From<fidl::Channel> for PortSynchronousProxy {
2941    fn from(value: fidl::Channel) -> Self {
2942        Self::new(value)
2943    }
2944}
2945
2946#[cfg(target_os = "fuchsia")]
2947impl fidl::endpoints::FromClient for PortSynchronousProxy {
2948    type Protocol = PortMarker;
2949
2950    fn from_client(value: fidl::endpoints::ClientEnd<PortMarker>) -> Self {
2951        Self::new(value.into_channel())
2952    }
2953}
2954
2955#[derive(Debug, Clone)]
2956pub struct PortProxy {
2957    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2958}
2959
2960impl fidl::endpoints::Proxy for PortProxy {
2961    type Protocol = PortMarker;
2962
2963    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2964        Self::new(inner)
2965    }
2966
2967    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2968        self.client.into_channel().map_err(|client| Self { client })
2969    }
2970
2971    fn as_channel(&self) -> &::fidl::AsyncChannel {
2972        self.client.as_channel()
2973    }
2974}
2975
2976impl PortProxy {
2977    /// Create a new Proxy for fuchsia.hardware.network/Port.
2978    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2979        let protocol_name = <PortMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2980        Self { client: fidl::client::Client::new(channel, protocol_name) }
2981    }
2982
2983    /// Get a Stream of events from the remote end of the protocol.
2984    ///
2985    /// # Panics
2986    ///
2987    /// Panics if the event stream was already taken.
2988    pub fn take_event_stream(&self) -> PortEventStream {
2989        PortEventStream { event_receiver: self.client.take_event_receiver() }
2990    }
2991
2992    /// Obtain information about port.
2993    ///
2994    /// - response `info` port information.
2995    pub fn r#get_info(
2996        &self,
2997    ) -> fidl::client::QueryResponseFut<PortInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
2998    {
2999        PortProxyInterface::r#get_info(self)
3000    }
3001
3002    /// Obtain the operating port status.
3003    ///
3004    /// - response `status` snapshot of port's current status.
3005    pub fn r#get_status(
3006        &self,
3007    ) -> fidl::client::QueryResponseFut<PortStatus, fidl::encoding::DefaultFuchsiaResourceDialect>
3008    {
3009        PortProxyInterface::r#get_status(self)
3010    }
3011
3012    /// Connects to a [`StatusWatcher`] to observe port status changes.
3013    ///
3014    /// + request `watcher` handle to the status watcher.
3015    /// + request `buffer` the number of status changes that the client requests
3016    /// to be stored by `StatusWatcher`. Values are capped at
3017    /// [`MAX_STATUS_BUFFER`]. A value of 0 or 1 causes the `StatusWatcher` to
3018    /// not keep any buffers on status changed. Clients that need to observe all
3019    /// changes to status (as opposed to only the current state) are encouraged
3020    /// to set a buffer value larger than 1, so that all edges can be observed.
3021    /// If `StatusWatcher`'s internal queue is filled and new status changes
3022    /// occur, the oldest samples will be dropped to make room for new ones.
3023    pub fn r#get_status_watcher(
3024        &self,
3025        mut watcher: fidl::endpoints::ServerEnd<StatusWatcherMarker>,
3026        mut buffer: u32,
3027    ) -> Result<(), fidl::Error> {
3028        PortProxyInterface::r#get_status_watcher(self, watcher, buffer)
3029    }
3030
3031    /// Connects to a [`MacAddressing`] associated with the port.
3032    ///
3033    /// + request `mac` mac handle. Closed with `ZX_ERR_NOT_SUPPORTED` if this
3034    /// port does not support mac addressing.
3035    pub fn r#get_mac(
3036        &self,
3037        mut mac: fidl::endpoints::ServerEnd<MacAddressingMarker>,
3038    ) -> Result<(), fidl::Error> {
3039        PortProxyInterface::r#get_mac(self, mac)
3040    }
3041
3042    /// Connects to the [`Device`] this port belongs to.
3043    ///
3044    /// + request `device` grants access to the parent device.
3045    pub fn r#get_device(
3046        &self,
3047        mut device: fidl::endpoints::ServerEnd<DeviceMarker>,
3048    ) -> Result<(), fidl::Error> {
3049        PortProxyInterface::r#get_device(self, device)
3050    }
3051
3052    /// Establishes a new connection to this port.
3053    ///
3054    /// + request `port` the server end for the new connection.
3055    pub fn r#clone(
3056        &self,
3057        mut port: fidl::endpoints::ServerEnd<PortMarker>,
3058    ) -> Result<(), fidl::Error> {
3059        PortProxyInterface::r#clone(self, port)
3060    }
3061
3062    /// Retrieves a snapshot of traffic counters on this port.
3063    pub fn r#get_counters(
3064        &self,
3065    ) -> fidl::client::QueryResponseFut<
3066        PortGetCountersResponse,
3067        fidl::encoding::DefaultFuchsiaResourceDialect,
3068    > {
3069        PortProxyInterface::r#get_counters(self)
3070    }
3071
3072    /// Grants access to [`Diagnostics`] for this port.
3073    ///
3074    /// + request `diagnostics` grants access to diagnostics information.
3075    pub fn r#get_diagnostics(
3076        &self,
3077        mut diagnostics: fidl::endpoints::ServerEnd<DiagnosticsMarker>,
3078    ) -> Result<(), fidl::Error> {
3079        PortProxyInterface::r#get_diagnostics(self, diagnostics)
3080    }
3081
3082    /// Retrieves a unique event handle that is always associated only with
3083    /// this port.
3084    ///
3085    /// This event may be used to uniquely identify a specific port instance
3086    /// across different APIs in the system.
3087    pub fn r#get_identity(
3088        &self,
3089    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
3090    {
3091        PortProxyInterface::r#get_identity(self)
3092    }
3093
3094    /// Gets the Power Broker dependency token for this port's power element.
3095    ///
3096    /// The token exposes two levels: `0` (off) and `1` (on). Clients lease
3097    /// level `1` whenever the port's datapath is required and hold the lease
3098    /// for as long as it is required. Drivers are free to internally
3099    /// power-manage a leased-but-idle port so long as it's invisible to upper
3100    /// layers.
3101    ///
3102    /// The token is fixed for the lifetime of the port.
3103    ///
3104    /// - response `token` absent if this port does not participate in power
3105    ///   management.
3106    /// - response `token` must have `zx.Rights.DUPLICATE`.
3107    pub fn r#get_power_dependency_token(
3108        &self,
3109    ) -> fidl::client::QueryResponseFut<
3110        Option<fidl::Event>,
3111        fidl::encoding::DefaultFuchsiaResourceDialect,
3112    > {
3113        PortProxyInterface::r#get_power_dependency_token(self)
3114    }
3115}
3116
3117impl PortProxyInterface for PortProxy {
3118    type GetInfoResponseFut =
3119        fidl::client::QueryResponseFut<PortInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
3120    fn r#get_info(&self) -> Self::GetInfoResponseFut {
3121        fn _decode(
3122            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3123        ) -> Result<PortInfo, fidl::Error> {
3124            let _response = fidl::client::decode_transaction_body::<
3125                PortGetInfoResponse,
3126                fidl::encoding::DefaultFuchsiaResourceDialect,
3127                0x276cf65feb554ebd,
3128            >(_buf?)?;
3129            Ok(_response.info)
3130        }
3131        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PortInfo>(
3132            (),
3133            0x276cf65feb554ebd,
3134            fidl::encoding::DynamicFlags::empty(),
3135            _decode,
3136        )
3137    }
3138
3139    type GetStatusResponseFut =
3140        fidl::client::QueryResponseFut<PortStatus, fidl::encoding::DefaultFuchsiaResourceDialect>;
3141    fn r#get_status(&self) -> Self::GetStatusResponseFut {
3142        fn _decode(
3143            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3144        ) -> Result<PortStatus, fidl::Error> {
3145            let _response = fidl::client::decode_transaction_body::<
3146                PortGetStatusResponse,
3147                fidl::encoding::DefaultFuchsiaResourceDialect,
3148                0x4235650aacca60b2,
3149            >(_buf?)?;
3150            Ok(_response.status)
3151        }
3152        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PortStatus>(
3153            (),
3154            0x4235650aacca60b2,
3155            fidl::encoding::DynamicFlags::empty(),
3156            _decode,
3157        )
3158    }
3159
3160    fn r#get_status_watcher(
3161        &self,
3162        mut watcher: fidl::endpoints::ServerEnd<StatusWatcherMarker>,
3163        mut buffer: u32,
3164    ) -> Result<(), fidl::Error> {
3165        self.client.send::<PortGetStatusWatcherRequest>(
3166            (watcher, buffer),
3167            0x65511ab81c1bd8d4,
3168            fidl::encoding::DynamicFlags::empty(),
3169        )
3170    }
3171
3172    fn r#get_mac(
3173        &self,
3174        mut mac: fidl::endpoints::ServerEnd<MacAddressingMarker>,
3175    ) -> Result<(), fidl::Error> {
3176        self.client.send::<PortGetMacRequest>(
3177            (mac,),
3178            0x2c6ec2988aefc0f6,
3179            fidl::encoding::DynamicFlags::empty(),
3180        )
3181    }
3182
3183    fn r#get_device(
3184        &self,
3185        mut device: fidl::endpoints::ServerEnd<DeviceMarker>,
3186    ) -> Result<(), fidl::Error> {
3187        self.client.send::<PortGetDeviceRequest>(
3188            (device,),
3189            0x7de34747235d2d80,
3190            fidl::encoding::DynamicFlags::empty(),
3191        )
3192    }
3193
3194    fn r#clone(&self, mut port: fidl::endpoints::ServerEnd<PortMarker>) -> Result<(), fidl::Error> {
3195        self.client.send::<PortCloneRequest>(
3196            (port,),
3197            0x4e4764150b4942d3,
3198            fidl::encoding::DynamicFlags::empty(),
3199        )
3200    }
3201
3202    type GetCountersResponseFut = fidl::client::QueryResponseFut<
3203        PortGetCountersResponse,
3204        fidl::encoding::DefaultFuchsiaResourceDialect,
3205    >;
3206    fn r#get_counters(&self) -> Self::GetCountersResponseFut {
3207        fn _decode(
3208            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3209        ) -> Result<PortGetCountersResponse, fidl::Error> {
3210            let _response = fidl::client::decode_transaction_body::<
3211                PortGetCountersResponse,
3212                fidl::encoding::DefaultFuchsiaResourceDialect,
3213                0x6a213b03c4fcbbac,
3214            >(_buf?)?;
3215            Ok(_response)
3216        }
3217        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PortGetCountersResponse>(
3218            (),
3219            0x6a213b03c4fcbbac,
3220            fidl::encoding::DynamicFlags::empty(),
3221            _decode,
3222        )
3223    }
3224
3225    fn r#get_diagnostics(
3226        &self,
3227        mut diagnostics: fidl::endpoints::ServerEnd<DiagnosticsMarker>,
3228    ) -> Result<(), fidl::Error> {
3229        self.client.send::<PortGetDiagnosticsRequest>(
3230            (diagnostics,),
3231            0x381faa4ed75e399c,
3232            fidl::encoding::DynamicFlags::empty(),
3233        )
3234    }
3235
3236    type GetIdentityResponseFut =
3237        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
3238    fn r#get_identity(&self) -> Self::GetIdentityResponseFut {
3239        fn _decode(
3240            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3241        ) -> Result<fidl::Event, fidl::Error> {
3242            let _response = fidl::client::decode_transaction_body::<
3243                PortGetIdentityResponse,
3244                fidl::encoding::DefaultFuchsiaResourceDialect,
3245                0x75134ce0bc114e5a,
3246            >(_buf?)?;
3247            Ok(_response.event)
3248        }
3249        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
3250            (),
3251            0x75134ce0bc114e5a,
3252            fidl::encoding::DynamicFlags::empty(),
3253            _decode,
3254        )
3255    }
3256
3257    type GetPowerDependencyTokenResponseFut = fidl::client::QueryResponseFut<
3258        Option<fidl::Event>,
3259        fidl::encoding::DefaultFuchsiaResourceDialect,
3260    >;
3261    fn r#get_power_dependency_token(&self) -> Self::GetPowerDependencyTokenResponseFut {
3262        fn _decode(
3263            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3264        ) -> Result<Option<fidl::Event>, fidl::Error> {
3265            let _response = fidl::client::decode_transaction_body::<
3266                PortGetPowerDependencyTokenResponse,
3267                fidl::encoding::DefaultFuchsiaResourceDialect,
3268                0x7bec1da6ec2476ed,
3269            >(_buf?)?;
3270            Ok(_response.token)
3271        }
3272        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Option<fidl::Event>>(
3273            (),
3274            0x7bec1da6ec2476ed,
3275            fidl::encoding::DynamicFlags::empty(),
3276            _decode,
3277        )
3278    }
3279}
3280
3281pub struct PortEventStream {
3282    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3283}
3284
3285impl std::marker::Unpin for PortEventStream {}
3286
3287impl futures::stream::FusedStream for PortEventStream {
3288    fn is_terminated(&self) -> bool {
3289        self.event_receiver.is_terminated()
3290    }
3291}
3292
3293impl futures::Stream for PortEventStream {
3294    type Item = Result<PortEvent, fidl::Error>;
3295
3296    fn poll_next(
3297        mut self: std::pin::Pin<&mut Self>,
3298        cx: &mut std::task::Context<'_>,
3299    ) -> std::task::Poll<Option<Self::Item>> {
3300        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3301            &mut self.event_receiver,
3302            cx
3303        )?) {
3304            Some(buf) => std::task::Poll::Ready(Some(PortEvent::decode(buf))),
3305            None => std::task::Poll::Ready(None),
3306        }
3307    }
3308}
3309
3310#[derive(Debug)]
3311pub enum PortEvent {}
3312
3313impl PortEvent {
3314    /// Decodes a message buffer as a [`PortEvent`].
3315    fn decode(
3316        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3317    ) -> Result<PortEvent, fidl::Error> {
3318        let (bytes, _handles) = buf.split_mut();
3319        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3320        debug_assert_eq!(tx_header.tx_id, 0);
3321        match tx_header.ordinal {
3322            _ => Err(fidl::Error::UnknownOrdinal {
3323                ordinal: tx_header.ordinal,
3324                protocol_name: <PortMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3325            }),
3326        }
3327    }
3328}
3329
3330/// A Stream of incoming requests for fuchsia.hardware.network/Port.
3331pub struct PortRequestStream {
3332    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3333    is_terminated: bool,
3334}
3335
3336impl std::marker::Unpin for PortRequestStream {}
3337
3338impl futures::stream::FusedStream for PortRequestStream {
3339    fn is_terminated(&self) -> bool {
3340        self.is_terminated
3341    }
3342}
3343
3344impl fidl::endpoints::RequestStream for PortRequestStream {
3345    type Protocol = PortMarker;
3346    type ControlHandle = PortControlHandle;
3347
3348    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3349        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3350    }
3351
3352    fn control_handle(&self) -> Self::ControlHandle {
3353        PortControlHandle { inner: self.inner.clone() }
3354    }
3355
3356    fn into_inner(
3357        self,
3358    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3359    {
3360        (self.inner, self.is_terminated)
3361    }
3362
3363    fn from_inner(
3364        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3365        is_terminated: bool,
3366    ) -> Self {
3367        Self { inner, is_terminated }
3368    }
3369}
3370
3371impl futures::Stream for PortRequestStream {
3372    type Item = Result<PortRequest, fidl::Error>;
3373
3374    fn poll_next(
3375        mut self: std::pin::Pin<&mut Self>,
3376        cx: &mut std::task::Context<'_>,
3377    ) -> std::task::Poll<Option<Self::Item>> {
3378        let this = &mut *self;
3379        if this.inner.check_shutdown(cx) {
3380            this.is_terminated = true;
3381            return std::task::Poll::Ready(None);
3382        }
3383        if this.is_terminated {
3384            panic!("polled PortRequestStream after completion");
3385        }
3386        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3387            |bytes, handles| {
3388                match this.inner.channel().read_etc(cx, bytes, handles) {
3389                    std::task::Poll::Ready(Ok(())) => {}
3390                    std::task::Poll::Pending => return std::task::Poll::Pending,
3391                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3392                        this.is_terminated = true;
3393                        return std::task::Poll::Ready(None);
3394                    }
3395                    std::task::Poll::Ready(Err(e)) => {
3396                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3397                            e.into(),
3398                        ))));
3399                    }
3400                }
3401
3402                // A message has been received from the channel
3403                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3404
3405                std::task::Poll::Ready(Some(match header.ordinal {
3406                    0x276cf65feb554ebd => {
3407                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3408                        let mut req = fidl::new_empty!(
3409                            fidl::encoding::EmptyPayload,
3410                            fidl::encoding::DefaultFuchsiaResourceDialect
3411                        );
3412                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3413                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3414                        Ok(PortRequest::GetInfo {
3415                            responder: PortGetInfoResponder {
3416                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3417                                tx_id: header.tx_id,
3418                            },
3419                        })
3420                    }
3421                    0x4235650aacca60b2 => {
3422                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3423                        let mut req = fidl::new_empty!(
3424                            fidl::encoding::EmptyPayload,
3425                            fidl::encoding::DefaultFuchsiaResourceDialect
3426                        );
3427                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3428                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3429                        Ok(PortRequest::GetStatus {
3430                            responder: PortGetStatusResponder {
3431                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3432                                tx_id: header.tx_id,
3433                            },
3434                        })
3435                    }
3436                    0x65511ab81c1bd8d4 => {
3437                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3438                        let mut req = fidl::new_empty!(
3439                            PortGetStatusWatcherRequest,
3440                            fidl::encoding::DefaultFuchsiaResourceDialect
3441                        );
3442                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PortGetStatusWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
3443                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3444                        Ok(PortRequest::GetStatusWatcher {
3445                            watcher: req.watcher,
3446                            buffer: req.buffer,
3447
3448                            control_handle,
3449                        })
3450                    }
3451                    0x2c6ec2988aefc0f6 => {
3452                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3453                        let mut req = fidl::new_empty!(
3454                            PortGetMacRequest,
3455                            fidl::encoding::DefaultFuchsiaResourceDialect
3456                        );
3457                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PortGetMacRequest>(&header, _body_bytes, handles, &mut req)?;
3458                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3459                        Ok(PortRequest::GetMac { mac: req.mac, control_handle })
3460                    }
3461                    0x7de34747235d2d80 => {
3462                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3463                        let mut req = fidl::new_empty!(
3464                            PortGetDeviceRequest,
3465                            fidl::encoding::DefaultFuchsiaResourceDialect
3466                        );
3467                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PortGetDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
3468                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3469                        Ok(PortRequest::GetDevice { device: req.device, control_handle })
3470                    }
3471                    0x4e4764150b4942d3 => {
3472                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3473                        let mut req = fidl::new_empty!(
3474                            PortCloneRequest,
3475                            fidl::encoding::DefaultFuchsiaResourceDialect
3476                        );
3477                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PortCloneRequest>(&header, _body_bytes, handles, &mut req)?;
3478                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3479                        Ok(PortRequest::Clone { port: req.port, control_handle })
3480                    }
3481                    0x6a213b03c4fcbbac => {
3482                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3483                        let mut req = fidl::new_empty!(
3484                            fidl::encoding::EmptyPayload,
3485                            fidl::encoding::DefaultFuchsiaResourceDialect
3486                        );
3487                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3488                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3489                        Ok(PortRequest::GetCounters {
3490                            responder: PortGetCountersResponder {
3491                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3492                                tx_id: header.tx_id,
3493                            },
3494                        })
3495                    }
3496                    0x381faa4ed75e399c => {
3497                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3498                        let mut req = fidl::new_empty!(
3499                            PortGetDiagnosticsRequest,
3500                            fidl::encoding::DefaultFuchsiaResourceDialect
3501                        );
3502                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PortGetDiagnosticsRequest>(&header, _body_bytes, handles, &mut req)?;
3503                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3504                        Ok(PortRequest::GetDiagnostics {
3505                            diagnostics: req.diagnostics,
3506
3507                            control_handle,
3508                        })
3509                    }
3510                    0x75134ce0bc114e5a => {
3511                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3512                        let mut req = fidl::new_empty!(
3513                            fidl::encoding::EmptyPayload,
3514                            fidl::encoding::DefaultFuchsiaResourceDialect
3515                        );
3516                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3517                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3518                        Ok(PortRequest::GetIdentity {
3519                            responder: PortGetIdentityResponder {
3520                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3521                                tx_id: header.tx_id,
3522                            },
3523                        })
3524                    }
3525                    0x7bec1da6ec2476ed => {
3526                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3527                        let mut req = fidl::new_empty!(
3528                            fidl::encoding::EmptyPayload,
3529                            fidl::encoding::DefaultFuchsiaResourceDialect
3530                        );
3531                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3532                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3533                        Ok(PortRequest::GetPowerDependencyToken {
3534                            responder: PortGetPowerDependencyTokenResponder {
3535                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3536                                tx_id: header.tx_id,
3537                            },
3538                        })
3539                    }
3540                    _ => Err(fidl::Error::UnknownOrdinal {
3541                        ordinal: header.ordinal,
3542                        protocol_name: <PortMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3543                    }),
3544                }))
3545            },
3546        )
3547    }
3548}
3549
3550/// A logical port belonging to a [`Device`].
3551#[derive(Debug)]
3552pub enum PortRequest {
3553    /// Obtain information about port.
3554    ///
3555    /// - response `info` port information.
3556    GetInfo { responder: PortGetInfoResponder },
3557    /// Obtain the operating port status.
3558    ///
3559    /// - response `status` snapshot of port's current status.
3560    GetStatus { responder: PortGetStatusResponder },
3561    /// Connects to a [`StatusWatcher`] to observe port status changes.
3562    ///
3563    /// + request `watcher` handle to the status watcher.
3564    /// + request `buffer` the number of status changes that the client requests
3565    /// to be stored by `StatusWatcher`. Values are capped at
3566    /// [`MAX_STATUS_BUFFER`]. A value of 0 or 1 causes the `StatusWatcher` to
3567    /// not keep any buffers on status changed. Clients that need to observe all
3568    /// changes to status (as opposed to only the current state) are encouraged
3569    /// to set a buffer value larger than 1, so that all edges can be observed.
3570    /// If `StatusWatcher`'s internal queue is filled and new status changes
3571    /// occur, the oldest samples will be dropped to make room for new ones.
3572    GetStatusWatcher {
3573        watcher: fidl::endpoints::ServerEnd<StatusWatcherMarker>,
3574        buffer: u32,
3575        control_handle: PortControlHandle,
3576    },
3577    /// Connects to a [`MacAddressing`] associated with the port.
3578    ///
3579    /// + request `mac` mac handle. Closed with `ZX_ERR_NOT_SUPPORTED` if this
3580    /// port does not support mac addressing.
3581    GetMac {
3582        mac: fidl::endpoints::ServerEnd<MacAddressingMarker>,
3583        control_handle: PortControlHandle,
3584    },
3585    /// Connects to the [`Device`] this port belongs to.
3586    ///
3587    /// + request `device` grants access to the parent device.
3588    GetDevice {
3589        device: fidl::endpoints::ServerEnd<DeviceMarker>,
3590        control_handle: PortControlHandle,
3591    },
3592    /// Establishes a new connection to this port.
3593    ///
3594    /// + request `port` the server end for the new connection.
3595    Clone { port: fidl::endpoints::ServerEnd<PortMarker>, control_handle: PortControlHandle },
3596    /// Retrieves a snapshot of traffic counters on this port.
3597    GetCounters { responder: PortGetCountersResponder },
3598    /// Grants access to [`Diagnostics`] for this port.
3599    ///
3600    /// + request `diagnostics` grants access to diagnostics information.
3601    GetDiagnostics {
3602        diagnostics: fidl::endpoints::ServerEnd<DiagnosticsMarker>,
3603        control_handle: PortControlHandle,
3604    },
3605    /// Retrieves a unique event handle that is always associated only with
3606    /// this port.
3607    ///
3608    /// This event may be used to uniquely identify a specific port instance
3609    /// across different APIs in the system.
3610    GetIdentity { responder: PortGetIdentityResponder },
3611    /// Gets the Power Broker dependency token for this port's power element.
3612    ///
3613    /// The token exposes two levels: `0` (off) and `1` (on). Clients lease
3614    /// level `1` whenever the port's datapath is required and hold the lease
3615    /// for as long as it is required. Drivers are free to internally
3616    /// power-manage a leased-but-idle port so long as it's invisible to upper
3617    /// layers.
3618    ///
3619    /// The token is fixed for the lifetime of the port.
3620    ///
3621    /// - response `token` absent if this port does not participate in power
3622    ///   management.
3623    /// - response `token` must have `zx.Rights.DUPLICATE`.
3624    GetPowerDependencyToken { responder: PortGetPowerDependencyTokenResponder },
3625}
3626
3627impl PortRequest {
3628    #[allow(irrefutable_let_patterns)]
3629    pub fn into_get_info(self) -> Option<(PortGetInfoResponder)> {
3630        if let PortRequest::GetInfo { responder } = self { Some((responder)) } else { None }
3631    }
3632
3633    #[allow(irrefutable_let_patterns)]
3634    pub fn into_get_status(self) -> Option<(PortGetStatusResponder)> {
3635        if let PortRequest::GetStatus { responder } = self { Some((responder)) } else { None }
3636    }
3637
3638    #[allow(irrefutable_let_patterns)]
3639    pub fn into_get_status_watcher(
3640        self,
3641    ) -> Option<(fidl::endpoints::ServerEnd<StatusWatcherMarker>, u32, PortControlHandle)> {
3642        if let PortRequest::GetStatusWatcher { watcher, buffer, control_handle } = self {
3643            Some((watcher, buffer, control_handle))
3644        } else {
3645            None
3646        }
3647    }
3648
3649    #[allow(irrefutable_let_patterns)]
3650    pub fn into_get_mac(
3651        self,
3652    ) -> Option<(fidl::endpoints::ServerEnd<MacAddressingMarker>, PortControlHandle)> {
3653        if let PortRequest::GetMac { mac, control_handle } = self {
3654            Some((mac, control_handle))
3655        } else {
3656            None
3657        }
3658    }
3659
3660    #[allow(irrefutable_let_patterns)]
3661    pub fn into_get_device(
3662        self,
3663    ) -> Option<(fidl::endpoints::ServerEnd<DeviceMarker>, PortControlHandle)> {
3664        if let PortRequest::GetDevice { device, control_handle } = self {
3665            Some((device, control_handle))
3666        } else {
3667            None
3668        }
3669    }
3670
3671    #[allow(irrefutable_let_patterns)]
3672    pub fn into_clone(self) -> Option<(fidl::endpoints::ServerEnd<PortMarker>, PortControlHandle)> {
3673        if let PortRequest::Clone { port, control_handle } = self {
3674            Some((port, control_handle))
3675        } else {
3676            None
3677        }
3678    }
3679
3680    #[allow(irrefutable_let_patterns)]
3681    pub fn into_get_counters(self) -> Option<(PortGetCountersResponder)> {
3682        if let PortRequest::GetCounters { responder } = self { Some((responder)) } else { None }
3683    }
3684
3685    #[allow(irrefutable_let_patterns)]
3686    pub fn into_get_diagnostics(
3687        self,
3688    ) -> Option<(fidl::endpoints::ServerEnd<DiagnosticsMarker>, PortControlHandle)> {
3689        if let PortRequest::GetDiagnostics { diagnostics, control_handle } = self {
3690            Some((diagnostics, control_handle))
3691        } else {
3692            None
3693        }
3694    }
3695
3696    #[allow(irrefutable_let_patterns)]
3697    pub fn into_get_identity(self) -> Option<(PortGetIdentityResponder)> {
3698        if let PortRequest::GetIdentity { responder } = self { Some((responder)) } else { None }
3699    }
3700
3701    #[allow(irrefutable_let_patterns)]
3702    pub fn into_get_power_dependency_token(self) -> Option<(PortGetPowerDependencyTokenResponder)> {
3703        if let PortRequest::GetPowerDependencyToken { responder } = self {
3704            Some((responder))
3705        } else {
3706            None
3707        }
3708    }
3709
3710    /// Name of the method defined in FIDL
3711    pub fn method_name(&self) -> &'static str {
3712        match *self {
3713            PortRequest::GetInfo { .. } => "get_info",
3714            PortRequest::GetStatus { .. } => "get_status",
3715            PortRequest::GetStatusWatcher { .. } => "get_status_watcher",
3716            PortRequest::GetMac { .. } => "get_mac",
3717            PortRequest::GetDevice { .. } => "get_device",
3718            PortRequest::Clone { .. } => "clone",
3719            PortRequest::GetCounters { .. } => "get_counters",
3720            PortRequest::GetDiagnostics { .. } => "get_diagnostics",
3721            PortRequest::GetIdentity { .. } => "get_identity",
3722            PortRequest::GetPowerDependencyToken { .. } => "get_power_dependency_token",
3723        }
3724    }
3725}
3726
3727#[derive(Debug, Clone)]
3728pub struct PortControlHandle {
3729    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3730}
3731
3732impl PortControlHandle {
3733    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3734        self.inner.shutdown_with_epitaph(status.into())
3735    }
3736}
3737
3738impl fidl::endpoints::ControlHandle for PortControlHandle {
3739    fn shutdown(&self) {
3740        self.inner.shutdown()
3741    }
3742
3743    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3744        self.inner.shutdown_with_epitaph(status)
3745    }
3746
3747    fn is_closed(&self) -> bool {
3748        self.inner.channel().is_closed()
3749    }
3750    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3751        self.inner.channel().on_closed()
3752    }
3753
3754    #[cfg(target_os = "fuchsia")]
3755    fn signal_peer(
3756        &self,
3757        clear_mask: zx::Signals,
3758        set_mask: zx::Signals,
3759    ) -> Result<(), zx_status::Status> {
3760        use fidl::Peered;
3761        self.inner.channel().signal_peer(clear_mask, set_mask)
3762    }
3763}
3764
3765impl PortControlHandle {}
3766
3767#[must_use = "FIDL methods require a response to be sent"]
3768#[derive(Debug)]
3769pub struct PortGetInfoResponder {
3770    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3771    tx_id: u32,
3772}
3773
3774/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3775/// if the responder is dropped without sending a response, so that the client
3776/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3777impl std::ops::Drop for PortGetInfoResponder {
3778    fn drop(&mut self) {
3779        self.control_handle.shutdown();
3780        // Safety: drops once, never accessed again
3781        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3782    }
3783}
3784
3785impl fidl::endpoints::Responder for PortGetInfoResponder {
3786    type ControlHandle = PortControlHandle;
3787
3788    fn control_handle(&self) -> &PortControlHandle {
3789        &self.control_handle
3790    }
3791
3792    fn drop_without_shutdown(mut self) {
3793        // Safety: drops once, never accessed again due to mem::forget
3794        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3795        // Prevent Drop from running (which would shut down the channel)
3796        std::mem::forget(self);
3797    }
3798}
3799
3800impl PortGetInfoResponder {
3801    /// Sends a response to the FIDL transaction.
3802    ///
3803    /// Sets the channel to shutdown if an error occurs.
3804    pub fn send(self, mut info: &PortInfo) -> Result<(), fidl::Error> {
3805        let _result = self.send_raw(info);
3806        if _result.is_err() {
3807            self.control_handle.shutdown();
3808        }
3809        self.drop_without_shutdown();
3810        _result
3811    }
3812
3813    /// Similar to "send" but does not shutdown the channel if an error occurs.
3814    pub fn send_no_shutdown_on_err(self, mut info: &PortInfo) -> Result<(), fidl::Error> {
3815        let _result = self.send_raw(info);
3816        self.drop_without_shutdown();
3817        _result
3818    }
3819
3820    fn send_raw(&self, mut info: &PortInfo) -> Result<(), fidl::Error> {
3821        self.control_handle.inner.send::<PortGetInfoResponse>(
3822            (info,),
3823            self.tx_id,
3824            0x276cf65feb554ebd,
3825            fidl::encoding::DynamicFlags::empty(),
3826        )
3827    }
3828}
3829
3830#[must_use = "FIDL methods require a response to be sent"]
3831#[derive(Debug)]
3832pub struct PortGetStatusResponder {
3833    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3834    tx_id: u32,
3835}
3836
3837/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3838/// if the responder is dropped without sending a response, so that the client
3839/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3840impl std::ops::Drop for PortGetStatusResponder {
3841    fn drop(&mut self) {
3842        self.control_handle.shutdown();
3843        // Safety: drops once, never accessed again
3844        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3845    }
3846}
3847
3848impl fidl::endpoints::Responder for PortGetStatusResponder {
3849    type ControlHandle = PortControlHandle;
3850
3851    fn control_handle(&self) -> &PortControlHandle {
3852        &self.control_handle
3853    }
3854
3855    fn drop_without_shutdown(mut self) {
3856        // Safety: drops once, never accessed again due to mem::forget
3857        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3858        // Prevent Drop from running (which would shut down the channel)
3859        std::mem::forget(self);
3860    }
3861}
3862
3863impl PortGetStatusResponder {
3864    /// Sends a response to the FIDL transaction.
3865    ///
3866    /// Sets the channel to shutdown if an error occurs.
3867    pub fn send(self, mut status: &PortStatus) -> Result<(), fidl::Error> {
3868        let _result = self.send_raw(status);
3869        if _result.is_err() {
3870            self.control_handle.shutdown();
3871        }
3872        self.drop_without_shutdown();
3873        _result
3874    }
3875
3876    /// Similar to "send" but does not shutdown the channel if an error occurs.
3877    pub fn send_no_shutdown_on_err(self, mut status: &PortStatus) -> Result<(), fidl::Error> {
3878        let _result = self.send_raw(status);
3879        self.drop_without_shutdown();
3880        _result
3881    }
3882
3883    fn send_raw(&self, mut status: &PortStatus) -> Result<(), fidl::Error> {
3884        self.control_handle.inner.send::<PortGetStatusResponse>(
3885            (status,),
3886            self.tx_id,
3887            0x4235650aacca60b2,
3888            fidl::encoding::DynamicFlags::empty(),
3889        )
3890    }
3891}
3892
3893#[must_use = "FIDL methods require a response to be sent"]
3894#[derive(Debug)]
3895pub struct PortGetCountersResponder {
3896    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3897    tx_id: u32,
3898}
3899
3900/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3901/// if the responder is dropped without sending a response, so that the client
3902/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3903impl std::ops::Drop for PortGetCountersResponder {
3904    fn drop(&mut self) {
3905        self.control_handle.shutdown();
3906        // Safety: drops once, never accessed again
3907        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3908    }
3909}
3910
3911impl fidl::endpoints::Responder for PortGetCountersResponder {
3912    type ControlHandle = PortControlHandle;
3913
3914    fn control_handle(&self) -> &PortControlHandle {
3915        &self.control_handle
3916    }
3917
3918    fn drop_without_shutdown(mut self) {
3919        // Safety: drops once, never accessed again due to mem::forget
3920        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3921        // Prevent Drop from running (which would shut down the channel)
3922        std::mem::forget(self);
3923    }
3924}
3925
3926impl PortGetCountersResponder {
3927    /// Sends a response to the FIDL transaction.
3928    ///
3929    /// Sets the channel to shutdown if an error occurs.
3930    pub fn send(self, mut payload: &PortGetCountersResponse) -> Result<(), fidl::Error> {
3931        let _result = self.send_raw(payload);
3932        if _result.is_err() {
3933            self.control_handle.shutdown();
3934        }
3935        self.drop_without_shutdown();
3936        _result
3937    }
3938
3939    /// Similar to "send" but does not shutdown the channel if an error occurs.
3940    pub fn send_no_shutdown_on_err(
3941        self,
3942        mut payload: &PortGetCountersResponse,
3943    ) -> Result<(), fidl::Error> {
3944        let _result = self.send_raw(payload);
3945        self.drop_without_shutdown();
3946        _result
3947    }
3948
3949    fn send_raw(&self, mut payload: &PortGetCountersResponse) -> Result<(), fidl::Error> {
3950        self.control_handle.inner.send::<PortGetCountersResponse>(
3951            payload,
3952            self.tx_id,
3953            0x6a213b03c4fcbbac,
3954            fidl::encoding::DynamicFlags::empty(),
3955        )
3956    }
3957}
3958
3959#[must_use = "FIDL methods require a response to be sent"]
3960#[derive(Debug)]
3961pub struct PortGetIdentityResponder {
3962    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3963    tx_id: u32,
3964}
3965
3966/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3967/// if the responder is dropped without sending a response, so that the client
3968/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3969impl std::ops::Drop for PortGetIdentityResponder {
3970    fn drop(&mut self) {
3971        self.control_handle.shutdown();
3972        // Safety: drops once, never accessed again
3973        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3974    }
3975}
3976
3977impl fidl::endpoints::Responder for PortGetIdentityResponder {
3978    type ControlHandle = PortControlHandle;
3979
3980    fn control_handle(&self) -> &PortControlHandle {
3981        &self.control_handle
3982    }
3983
3984    fn drop_without_shutdown(mut self) {
3985        // Safety: drops once, never accessed again due to mem::forget
3986        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3987        // Prevent Drop from running (which would shut down the channel)
3988        std::mem::forget(self);
3989    }
3990}
3991
3992impl PortGetIdentityResponder {
3993    /// Sends a response to the FIDL transaction.
3994    ///
3995    /// Sets the channel to shutdown if an error occurs.
3996    pub fn send(self, mut event: fidl::Event) -> Result<(), fidl::Error> {
3997        let _result = self.send_raw(event);
3998        if _result.is_err() {
3999            self.control_handle.shutdown();
4000        }
4001        self.drop_without_shutdown();
4002        _result
4003    }
4004
4005    /// Similar to "send" but does not shutdown the channel if an error occurs.
4006    pub fn send_no_shutdown_on_err(self, mut event: fidl::Event) -> Result<(), fidl::Error> {
4007        let _result = self.send_raw(event);
4008        self.drop_without_shutdown();
4009        _result
4010    }
4011
4012    fn send_raw(&self, mut event: fidl::Event) -> Result<(), fidl::Error> {
4013        self.control_handle.inner.send::<PortGetIdentityResponse>(
4014            (event,),
4015            self.tx_id,
4016            0x75134ce0bc114e5a,
4017            fidl::encoding::DynamicFlags::empty(),
4018        )
4019    }
4020}
4021
4022#[must_use = "FIDL methods require a response to be sent"]
4023#[derive(Debug)]
4024pub struct PortGetPowerDependencyTokenResponder {
4025    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
4026    tx_id: u32,
4027}
4028
4029/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
4030/// if the responder is dropped without sending a response, so that the client
4031/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4032impl std::ops::Drop for PortGetPowerDependencyTokenResponder {
4033    fn drop(&mut self) {
4034        self.control_handle.shutdown();
4035        // Safety: drops once, never accessed again
4036        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4037    }
4038}
4039
4040impl fidl::endpoints::Responder for PortGetPowerDependencyTokenResponder {
4041    type ControlHandle = PortControlHandle;
4042
4043    fn control_handle(&self) -> &PortControlHandle {
4044        &self.control_handle
4045    }
4046
4047    fn drop_without_shutdown(mut self) {
4048        // Safety: drops once, never accessed again due to mem::forget
4049        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4050        // Prevent Drop from running (which would shut down the channel)
4051        std::mem::forget(self);
4052    }
4053}
4054
4055impl PortGetPowerDependencyTokenResponder {
4056    /// Sends a response to the FIDL transaction.
4057    ///
4058    /// Sets the channel to shutdown if an error occurs.
4059    pub fn send(self, mut token: Option<fidl::Event>) -> Result<(), fidl::Error> {
4060        let _result = self.send_raw(token);
4061        if _result.is_err() {
4062            self.control_handle.shutdown();
4063        }
4064        self.drop_without_shutdown();
4065        _result
4066    }
4067
4068    /// Similar to "send" but does not shutdown the channel if an error occurs.
4069    pub fn send_no_shutdown_on_err(
4070        self,
4071        mut token: Option<fidl::Event>,
4072    ) -> Result<(), fidl::Error> {
4073        let _result = self.send_raw(token);
4074        self.drop_without_shutdown();
4075        _result
4076    }
4077
4078    fn send_raw(&self, mut token: Option<fidl::Event>) -> Result<(), fidl::Error> {
4079        self.control_handle.inner.send::<PortGetPowerDependencyTokenResponse>(
4080            (token,),
4081            self.tx_id,
4082            0x7bec1da6ec2476ed,
4083            fidl::encoding::DynamicFlags::empty(),
4084        )
4085    }
4086}
4087
4088#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4089pub struct PortWatcherMarker;
4090
4091impl fidl::endpoints::ProtocolMarker for PortWatcherMarker {
4092    type Proxy = PortWatcherProxy;
4093    type RequestStream = PortWatcherRequestStream;
4094    #[cfg(target_os = "fuchsia")]
4095    type SynchronousProxy = PortWatcherSynchronousProxy;
4096
4097    const DEBUG_NAME: &'static str = "(anonymous) PortWatcher";
4098}
4099
4100pub trait PortWatcherProxyInterface: Send + Sync {
4101    type WatchResponseFut: std::future::Future<Output = Result<DevicePortEvent, fidl::Error>> + Send;
4102    fn r#watch(&self) -> Self::WatchResponseFut;
4103}
4104#[derive(Debug)]
4105#[cfg(target_os = "fuchsia")]
4106pub struct PortWatcherSynchronousProxy {
4107    client: fidl::client::sync::Client,
4108}
4109
4110#[cfg(target_os = "fuchsia")]
4111impl fidl::endpoints::SynchronousProxy for PortWatcherSynchronousProxy {
4112    type Proxy = PortWatcherProxy;
4113    type Protocol = PortWatcherMarker;
4114
4115    fn from_channel(inner: fidl::Channel) -> Self {
4116        Self::new(inner)
4117    }
4118
4119    fn into_channel(self) -> fidl::Channel {
4120        self.client.into_channel()
4121    }
4122
4123    fn as_channel(&self) -> &fidl::Channel {
4124        self.client.as_channel()
4125    }
4126}
4127
4128#[cfg(target_os = "fuchsia")]
4129impl PortWatcherSynchronousProxy {
4130    pub fn new(channel: fidl::Channel) -> Self {
4131        Self { client: fidl::client::sync::Client::new(channel) }
4132    }
4133
4134    pub fn into_channel(self) -> fidl::Channel {
4135        self.client.into_channel()
4136    }
4137
4138    /// Waits until an event arrives and returns it. It is safe for other
4139    /// threads to make concurrent requests while waiting for an event.
4140    pub fn wait_for_event(
4141        &self,
4142        deadline: zx::MonotonicInstant,
4143    ) -> Result<PortWatcherEvent, fidl::Error> {
4144        PortWatcherEvent::decode(self.client.wait_for_event::<PortWatcherMarker>(deadline)?)
4145    }
4146
4147    /// Get the next port event.
4148    ///
4149    /// The first N calls return [`DevicePortEvent.existing`] where N is the
4150    /// number of ports present on the device at the time of the watcher's
4151    /// creation. The next call returns [`DevicePortEvent.idle`] to indicate the
4152    /// end of existing ports. Subsequent calls block until a port is added
4153    /// ([`DevicePortEvent.added`]) or removed ([`DevicePortEvent.removed`]).
4154    ///
4155    /// The server closes the `PortWatcher` channel with `ZX_ERR_CANCELED` if
4156    /// the number of unread events reaches a server-selected limit that is at
4157    /// least two times [`MAX_PORTS`]. Clients are encouraged to maintain a
4158    /// hanging call to `Watch` at all times to avoid triggering this condition.
4159    ///
4160    /// - response `event` next port event.
4161    pub fn r#watch(
4162        &self,
4163        ___deadline: zx::MonotonicInstant,
4164    ) -> Result<DevicePortEvent, fidl::Error> {
4165        let _response = self.client.send_query::<
4166            fidl::encoding::EmptyPayload,
4167            PortWatcherWatchResponse,
4168            PortWatcherMarker,
4169        >(
4170            (),
4171            0x3e87244b74fff55e,
4172            fidl::encoding::DynamicFlags::empty(),
4173            ___deadline,
4174        )?;
4175        Ok(_response.event)
4176    }
4177}
4178
4179#[cfg(target_os = "fuchsia")]
4180impl From<PortWatcherSynchronousProxy> for zx::NullableHandle {
4181    fn from(value: PortWatcherSynchronousProxy) -> Self {
4182        value.into_channel().into()
4183    }
4184}
4185
4186#[cfg(target_os = "fuchsia")]
4187impl From<fidl::Channel> for PortWatcherSynchronousProxy {
4188    fn from(value: fidl::Channel) -> Self {
4189        Self::new(value)
4190    }
4191}
4192
4193#[cfg(target_os = "fuchsia")]
4194impl fidl::endpoints::FromClient for PortWatcherSynchronousProxy {
4195    type Protocol = PortWatcherMarker;
4196
4197    fn from_client(value: fidl::endpoints::ClientEnd<PortWatcherMarker>) -> Self {
4198        Self::new(value.into_channel())
4199    }
4200}
4201
4202#[derive(Debug, Clone)]
4203pub struct PortWatcherProxy {
4204    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4205}
4206
4207impl fidl::endpoints::Proxy for PortWatcherProxy {
4208    type Protocol = PortWatcherMarker;
4209
4210    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4211        Self::new(inner)
4212    }
4213
4214    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4215        self.client.into_channel().map_err(|client| Self { client })
4216    }
4217
4218    fn as_channel(&self) -> &::fidl::AsyncChannel {
4219        self.client.as_channel()
4220    }
4221}
4222
4223impl PortWatcherProxy {
4224    /// Create a new Proxy for fuchsia.hardware.network/PortWatcher.
4225    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4226        let protocol_name = <PortWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4227        Self { client: fidl::client::Client::new(channel, protocol_name) }
4228    }
4229
4230    /// Get a Stream of events from the remote end of the protocol.
4231    ///
4232    /// # Panics
4233    ///
4234    /// Panics if the event stream was already taken.
4235    pub fn take_event_stream(&self) -> PortWatcherEventStream {
4236        PortWatcherEventStream { event_receiver: self.client.take_event_receiver() }
4237    }
4238
4239    /// Get the next port event.
4240    ///
4241    /// The first N calls return [`DevicePortEvent.existing`] where N is the
4242    /// number of ports present on the device at the time of the watcher's
4243    /// creation. The next call returns [`DevicePortEvent.idle`] to indicate the
4244    /// end of existing ports. Subsequent calls block until a port is added
4245    /// ([`DevicePortEvent.added`]) or removed ([`DevicePortEvent.removed`]).
4246    ///
4247    /// The server closes the `PortWatcher` channel with `ZX_ERR_CANCELED` if
4248    /// the number of unread events reaches a server-selected limit that is at
4249    /// least two times [`MAX_PORTS`]. Clients are encouraged to maintain a
4250    /// hanging call to `Watch` at all times to avoid triggering this condition.
4251    ///
4252    /// - response `event` next port event.
4253    pub fn r#watch(
4254        &self,
4255    ) -> fidl::client::QueryResponseFut<
4256        DevicePortEvent,
4257        fidl::encoding::DefaultFuchsiaResourceDialect,
4258    > {
4259        PortWatcherProxyInterface::r#watch(self)
4260    }
4261}
4262
4263impl PortWatcherProxyInterface for PortWatcherProxy {
4264    type WatchResponseFut = fidl::client::QueryResponseFut<
4265        DevicePortEvent,
4266        fidl::encoding::DefaultFuchsiaResourceDialect,
4267    >;
4268    fn r#watch(&self) -> Self::WatchResponseFut {
4269        fn _decode(
4270            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4271        ) -> Result<DevicePortEvent, fidl::Error> {
4272            let _response = fidl::client::decode_transaction_body::<
4273                PortWatcherWatchResponse,
4274                fidl::encoding::DefaultFuchsiaResourceDialect,
4275                0x3e87244b74fff55e,
4276            >(_buf?)?;
4277            Ok(_response.event)
4278        }
4279        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DevicePortEvent>(
4280            (),
4281            0x3e87244b74fff55e,
4282            fidl::encoding::DynamicFlags::empty(),
4283            _decode,
4284        )
4285    }
4286}
4287
4288pub struct PortWatcherEventStream {
4289    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4290}
4291
4292impl std::marker::Unpin for PortWatcherEventStream {}
4293
4294impl futures::stream::FusedStream for PortWatcherEventStream {
4295    fn is_terminated(&self) -> bool {
4296        self.event_receiver.is_terminated()
4297    }
4298}
4299
4300impl futures::Stream for PortWatcherEventStream {
4301    type Item = Result<PortWatcherEvent, fidl::Error>;
4302
4303    fn poll_next(
4304        mut self: std::pin::Pin<&mut Self>,
4305        cx: &mut std::task::Context<'_>,
4306    ) -> std::task::Poll<Option<Self::Item>> {
4307        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4308            &mut self.event_receiver,
4309            cx
4310        )?) {
4311            Some(buf) => std::task::Poll::Ready(Some(PortWatcherEvent::decode(buf))),
4312            None => std::task::Poll::Ready(None),
4313        }
4314    }
4315}
4316
4317#[derive(Debug)]
4318pub enum PortWatcherEvent {}
4319
4320impl PortWatcherEvent {
4321    /// Decodes a message buffer as a [`PortWatcherEvent`].
4322    fn decode(
4323        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4324    ) -> Result<PortWatcherEvent, fidl::Error> {
4325        let (bytes, _handles) = buf.split_mut();
4326        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4327        debug_assert_eq!(tx_header.tx_id, 0);
4328        match tx_header.ordinal {
4329            _ => Err(fidl::Error::UnknownOrdinal {
4330                ordinal: tx_header.ordinal,
4331                protocol_name: <PortWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4332            }),
4333        }
4334    }
4335}
4336
4337/// A Stream of incoming requests for fuchsia.hardware.network/PortWatcher.
4338pub struct PortWatcherRequestStream {
4339    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4340    is_terminated: bool,
4341}
4342
4343impl std::marker::Unpin for PortWatcherRequestStream {}
4344
4345impl futures::stream::FusedStream for PortWatcherRequestStream {
4346    fn is_terminated(&self) -> bool {
4347        self.is_terminated
4348    }
4349}
4350
4351impl fidl::endpoints::RequestStream for PortWatcherRequestStream {
4352    type Protocol = PortWatcherMarker;
4353    type ControlHandle = PortWatcherControlHandle;
4354
4355    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4356        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4357    }
4358
4359    fn control_handle(&self) -> Self::ControlHandle {
4360        PortWatcherControlHandle { inner: self.inner.clone() }
4361    }
4362
4363    fn into_inner(
4364        self,
4365    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4366    {
4367        (self.inner, self.is_terminated)
4368    }
4369
4370    fn from_inner(
4371        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4372        is_terminated: bool,
4373    ) -> Self {
4374        Self { inner, is_terminated }
4375    }
4376}
4377
4378impl futures::Stream for PortWatcherRequestStream {
4379    type Item = Result<PortWatcherRequest, fidl::Error>;
4380
4381    fn poll_next(
4382        mut self: std::pin::Pin<&mut Self>,
4383        cx: &mut std::task::Context<'_>,
4384    ) -> std::task::Poll<Option<Self::Item>> {
4385        let this = &mut *self;
4386        if this.inner.check_shutdown(cx) {
4387            this.is_terminated = true;
4388            return std::task::Poll::Ready(None);
4389        }
4390        if this.is_terminated {
4391            panic!("polled PortWatcherRequestStream after completion");
4392        }
4393        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4394            |bytes, handles| {
4395                match this.inner.channel().read_etc(cx, bytes, handles) {
4396                    std::task::Poll::Ready(Ok(())) => {}
4397                    std::task::Poll::Pending => return std::task::Poll::Pending,
4398                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4399                        this.is_terminated = true;
4400                        return std::task::Poll::Ready(None);
4401                    }
4402                    std::task::Poll::Ready(Err(e)) => {
4403                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4404                            e.into(),
4405                        ))));
4406                    }
4407                }
4408
4409                // A message has been received from the channel
4410                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4411
4412                std::task::Poll::Ready(Some(match header.ordinal {
4413                    0x3e87244b74fff55e => {
4414                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4415                        let mut req = fidl::new_empty!(
4416                            fidl::encoding::EmptyPayload,
4417                            fidl::encoding::DefaultFuchsiaResourceDialect
4418                        );
4419                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4420                        let control_handle = PortWatcherControlHandle { inner: this.inner.clone() };
4421                        Ok(PortWatcherRequest::Watch {
4422                            responder: PortWatcherWatchResponder {
4423                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4424                                tx_id: header.tx_id,
4425                            },
4426                        })
4427                    }
4428                    _ => Err(fidl::Error::UnknownOrdinal {
4429                        ordinal: header.ordinal,
4430                        protocol_name:
4431                            <PortWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4432                    }),
4433                }))
4434            },
4435        )
4436    }
4437}
4438
4439/// Provides iteration over and updates for ports attached to a device.
4440#[derive(Debug)]
4441pub enum PortWatcherRequest {
4442    /// Get the next port event.
4443    ///
4444    /// The first N calls return [`DevicePortEvent.existing`] where N is the
4445    /// number of ports present on the device at the time of the watcher's
4446    /// creation. The next call returns [`DevicePortEvent.idle`] to indicate the
4447    /// end of existing ports. Subsequent calls block until a port is added
4448    /// ([`DevicePortEvent.added`]) or removed ([`DevicePortEvent.removed`]).
4449    ///
4450    /// The server closes the `PortWatcher` channel with `ZX_ERR_CANCELED` if
4451    /// the number of unread events reaches a server-selected limit that is at
4452    /// least two times [`MAX_PORTS`]. Clients are encouraged to maintain a
4453    /// hanging call to `Watch` at all times to avoid triggering this condition.
4454    ///
4455    /// - response `event` next port event.
4456    Watch { responder: PortWatcherWatchResponder },
4457}
4458
4459impl PortWatcherRequest {
4460    #[allow(irrefutable_let_patterns)]
4461    pub fn into_watch(self) -> Option<(PortWatcherWatchResponder)> {
4462        if let PortWatcherRequest::Watch { responder } = self { Some((responder)) } else { None }
4463    }
4464
4465    /// Name of the method defined in FIDL
4466    pub fn method_name(&self) -> &'static str {
4467        match *self {
4468            PortWatcherRequest::Watch { .. } => "watch",
4469        }
4470    }
4471}
4472
4473#[derive(Debug, Clone)]
4474pub struct PortWatcherControlHandle {
4475    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4476}
4477
4478impl PortWatcherControlHandle {
4479    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4480        self.inner.shutdown_with_epitaph(status.into())
4481    }
4482}
4483
4484impl fidl::endpoints::ControlHandle for PortWatcherControlHandle {
4485    fn shutdown(&self) {
4486        self.inner.shutdown()
4487    }
4488
4489    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4490        self.inner.shutdown_with_epitaph(status)
4491    }
4492
4493    fn is_closed(&self) -> bool {
4494        self.inner.channel().is_closed()
4495    }
4496    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4497        self.inner.channel().on_closed()
4498    }
4499
4500    #[cfg(target_os = "fuchsia")]
4501    fn signal_peer(
4502        &self,
4503        clear_mask: zx::Signals,
4504        set_mask: zx::Signals,
4505    ) -> Result<(), zx_status::Status> {
4506        use fidl::Peered;
4507        self.inner.channel().signal_peer(clear_mask, set_mask)
4508    }
4509}
4510
4511impl PortWatcherControlHandle {}
4512
4513#[must_use = "FIDL methods require a response to be sent"]
4514#[derive(Debug)]
4515pub struct PortWatcherWatchResponder {
4516    control_handle: std::mem::ManuallyDrop<PortWatcherControlHandle>,
4517    tx_id: u32,
4518}
4519
4520/// Set the the channel to be shutdown (see [`PortWatcherControlHandle::shutdown`])
4521/// if the responder is dropped without sending a response, so that the client
4522/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4523impl std::ops::Drop for PortWatcherWatchResponder {
4524    fn drop(&mut self) {
4525        self.control_handle.shutdown();
4526        // Safety: drops once, never accessed again
4527        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4528    }
4529}
4530
4531impl fidl::endpoints::Responder for PortWatcherWatchResponder {
4532    type ControlHandle = PortWatcherControlHandle;
4533
4534    fn control_handle(&self) -> &PortWatcherControlHandle {
4535        &self.control_handle
4536    }
4537
4538    fn drop_without_shutdown(mut self) {
4539        // Safety: drops once, never accessed again due to mem::forget
4540        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4541        // Prevent Drop from running (which would shut down the channel)
4542        std::mem::forget(self);
4543    }
4544}
4545
4546impl PortWatcherWatchResponder {
4547    /// Sends a response to the FIDL transaction.
4548    ///
4549    /// Sets the channel to shutdown if an error occurs.
4550    pub fn send(self, mut event: &DevicePortEvent) -> Result<(), fidl::Error> {
4551        let _result = self.send_raw(event);
4552        if _result.is_err() {
4553            self.control_handle.shutdown();
4554        }
4555        self.drop_without_shutdown();
4556        _result
4557    }
4558
4559    /// Similar to "send" but does not shutdown the channel if an error occurs.
4560    pub fn send_no_shutdown_on_err(self, mut event: &DevicePortEvent) -> Result<(), fidl::Error> {
4561        let _result = self.send_raw(event);
4562        self.drop_without_shutdown();
4563        _result
4564    }
4565
4566    fn send_raw(&self, mut event: &DevicePortEvent) -> Result<(), fidl::Error> {
4567        self.control_handle.inner.send::<PortWatcherWatchResponse>(
4568            (event,),
4569            self.tx_id,
4570            0x3e87244b74fff55e,
4571            fidl::encoding::DynamicFlags::empty(),
4572        )
4573    }
4574}
4575
4576#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4577pub struct SessionMarker;
4578
4579impl fidl::endpoints::ProtocolMarker for SessionMarker {
4580    type Proxy = SessionProxy;
4581    type RequestStream = SessionRequestStream;
4582    #[cfg(target_os = "fuchsia")]
4583    type SynchronousProxy = SessionSynchronousProxy;
4584
4585    const DEBUG_NAME: &'static str = "(anonymous) Session";
4586}
4587pub type SessionAttachResult = Result<(), i32>;
4588pub type SessionDetachResult = Result<(), i32>;
4589
4590pub trait SessionProxyInterface: Send + Sync {
4591    type AttachResponseFut: std::future::Future<Output = Result<SessionAttachResult, fidl::Error>>
4592        + Send;
4593    fn r#attach(&self, port: &PortId, rx_frames: &[FrameType]) -> Self::AttachResponseFut;
4594    type DetachResponseFut: std::future::Future<Output = Result<SessionDetachResult, fidl::Error>>
4595        + Send;
4596    fn r#detach(&self, port: &PortId) -> Self::DetachResponseFut;
4597    fn r#close(&self) -> Result<(), fidl::Error>;
4598    type WatchDelegatedRxLeaseResponseFut: std::future::Future<Output = Result<DelegatedRxLease, fidl::Error>>
4599        + Send;
4600    fn r#watch_delegated_rx_lease(&self) -> Self::WatchDelegatedRxLeaseResponseFut;
4601    type RegisterForTxResponseFut: std::future::Future<Output = Result<(u8, i32), fidl::Error>>
4602        + Send;
4603    fn r#register_for_tx(&self, vmos: &[u8]) -> Self::RegisterForTxResponseFut;
4604    type UnregisterForTxResponseFut: std::future::Future<Output = Result<(u8, i32), fidl::Error>>
4605        + Send;
4606    fn r#unregister_for_tx(&self, vmos: &[u8]) -> Self::UnregisterForTxResponseFut;
4607}
4608#[derive(Debug)]
4609#[cfg(target_os = "fuchsia")]
4610pub struct SessionSynchronousProxy {
4611    client: fidl::client::sync::Client,
4612}
4613
4614#[cfg(target_os = "fuchsia")]
4615impl fidl::endpoints::SynchronousProxy for SessionSynchronousProxy {
4616    type Proxy = SessionProxy;
4617    type Protocol = SessionMarker;
4618
4619    fn from_channel(inner: fidl::Channel) -> Self {
4620        Self::new(inner)
4621    }
4622
4623    fn into_channel(self) -> fidl::Channel {
4624        self.client.into_channel()
4625    }
4626
4627    fn as_channel(&self) -> &fidl::Channel {
4628        self.client.as_channel()
4629    }
4630}
4631
4632#[cfg(target_os = "fuchsia")]
4633impl SessionSynchronousProxy {
4634    pub fn new(channel: fidl::Channel) -> Self {
4635        Self { client: fidl::client::sync::Client::new(channel) }
4636    }
4637
4638    pub fn into_channel(self) -> fidl::Channel {
4639        self.client.into_channel()
4640    }
4641
4642    /// Waits until an event arrives and returns it. It is safe for other
4643    /// threads to make concurrent requests while waiting for an event.
4644    pub fn wait_for_event(
4645        &self,
4646        deadline: zx::MonotonicInstant,
4647    ) -> Result<SessionEvent, fidl::Error> {
4648        SessionEvent::decode(self.client.wait_for_event::<SessionMarker>(deadline)?)
4649    }
4650
4651    /// Attaches the session to `port`.
4652    ///
4653    /// Once attached, the session starts to receive the subscribed frames over
4654    /// the data FIFOs and it may send frames destined to the specified `port`.
4655    ///
4656    /// + request `port` port to subscribe to.
4657    /// + request `rx_frames` Frame types of interest on the port.
4658    /// * error `ZX_ERR_NOT_FOUND` if `port` is not valid.
4659    /// * error `ZX_ERR_INVALID_ARGS` if `rx_frames` is not a subset of the
4660    /// port's supported frames.
4661    /// * error `ZX_ERR_ALREADY_BOUND` if `port` is already attached.
4662    pub fn r#attach(
4663        &self,
4664        mut port: &PortId,
4665        mut rx_frames: &[FrameType],
4666        ___deadline: zx::MonotonicInstant,
4667    ) -> Result<SessionAttachResult, fidl::Error> {
4668        let _response = self.client.send_query::<
4669            SessionAttachRequest,
4670            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4671            SessionMarker,
4672        >(
4673            (port, rx_frames,),
4674            0x1e89c9013e201379,
4675            fidl::encoding::DynamicFlags::empty(),
4676            ___deadline,
4677        )?;
4678        Ok(_response.map(|x| x))
4679    }
4680
4681    /// Detaches the session from `port`.
4682    ///
4683    /// Once detached, the session stops receiving frames from `port`. Frames
4684    /// sent to a detached port may be returned with an error. It is not
4685    /// necessary to call `Detach` on ports that are removed from the device,
4686    /// doing so causes `ZX_ERR_NOT_FOUND` to be returned.
4687    ///
4688    /// + request `port` port to subscribe to.
4689    /// * error `ZX_ERR_NOT_FOUND` if the session is not currently attached to
4690    /// the port.
4691    pub fn r#detach(
4692        &self,
4693        mut port: &PortId,
4694        ___deadline: zx::MonotonicInstant,
4695    ) -> Result<SessionDetachResult, fidl::Error> {
4696        let _response = self.client.send_query::<
4697            SessionDetachRequest,
4698            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4699            SessionMarker,
4700        >(
4701            (port,),
4702            0x68c40cf8fb549867,
4703            fidl::encoding::DynamicFlags::empty(),
4704            ___deadline,
4705        )?;
4706        Ok(_response.map(|x| x))
4707    }
4708
4709    /// Cleanly closes a session.
4710    ///
4711    /// This will cause the session to send a `ZX_ERR_CANCELLED` epitaph and
4712    /// proceed to close the Session channel. Clients may only assume that they
4713    /// own all the buffers that are currently owned by the session (sent over
4714    /// either the rx or tx FIFOs) once the epitaph is received. Closing the rx
4715    /// or tx FIFO is equivalent to calling `Close`.
4716    pub fn r#close(&self) -> Result<(), fidl::Error> {
4717        self.client.send::<fidl::encoding::EmptyPayload>(
4718            (),
4719            0x393d5070394a92f6,
4720            fidl::encoding::DynamicFlags::empty(),
4721        )
4722    }
4723
4724    /// Watchers for delegated receive wakeup leases.
4725    ///
4726    /// Calls block until a lease is delegated by the device. If a call to
4727    /// `WatchDelegatedRxLease` is made while a previous call is blocking, the
4728    /// session is closed with `ZX_ERR_BAD_STATE`. Will never yield any values
4729    /// for sessions created without [`SessionFlags.RECEIVE_RX_POWER_LEASES`].
4730    ///
4731    /// Given a single lease is assumed sufficient to keep the system awake, the
4732    /// server only keeps a single lease in its buffer. If a new delegated lease
4733    /// becomes available and the client hasn't popped the previous one with a
4734    /// call to `WatchDelegatedRxLease`, the server drops the previously pending
4735    /// lease.
4736    ///
4737    /// See [`DelegatedRxLease`] for how to handle delegated leases.
4738    pub fn r#watch_delegated_rx_lease(
4739        &self,
4740        ___deadline: zx::MonotonicInstant,
4741    ) -> Result<DelegatedRxLease, fidl::Error> {
4742        let _response = self.client.send_query::<
4743            fidl::encoding::EmptyPayload,
4744            SessionWatchDelegatedRxLeaseResponse,
4745            SessionMarker,
4746        >(
4747            (),
4748            0x764d823ee64803b5,
4749            fidl::encoding::DynamicFlags::empty(),
4750            ___deadline,
4751        )?;
4752        Ok(_response.lease)
4753    }
4754
4755    /// Asks the network device to register the VMO for Tx.
4756    ///
4757    /// The network device prepares the VMOs in order and stops at the first
4758    /// error if any. It returns how many VMOs have been prepared alongside with
4759    /// the first error encountered. Note that network-device itself does not
4760    /// try to release earlier VMOs for a later error. It is up to the client
4761    /// how to recover from an error.
4762    ///
4763    /// * error `ZX_ERR_NOT_FOUND` if any of the VmoId is unknown.
4764    /// * error other zx status that can be reported by the driver.
4765    pub fn r#register_for_tx(
4766        &self,
4767        mut vmos: &[u8],
4768        ___deadline: zx::MonotonicInstant,
4769    ) -> Result<(u8, i32), fidl::Error> {
4770        let _response = self
4771            .client
4772            .send_query::<SessionRegisterForTxRequest, SessionRegisterForTxResponse, SessionMarker>(
4773                (vmos,),
4774                0x36321799ce2a081a,
4775                fidl::encoding::DynamicFlags::empty(),
4776                ___deadline,
4777            )?;
4778        Ok((_response.successful, _response.status))
4779    }
4780
4781    /// Tells the device that the client will no longer use the VMO for Tx,
4782    /// if the VMO is also unused for Rx, the device is free to release it
4783    /// at the implementation driver.
4784    ///
4785    /// The network device processes the VMOs in order and stops at the first
4786    /// error if any. It returns how many VMOs have been marked as unused for Tx
4787    /// alongside with the first error encountered. Note that network-device
4788    /// itself does not try to re-register earlier VMOs for a later error. It is
4789    /// up to the client how to recover from an error.
4790    ///
4791    /// * error `ZX_ERR_NOT_FOUND` if any of the VmoId is unknown.
4792    /// * error other zx status that can be reported by the driver.
4793    pub fn r#unregister_for_tx(
4794        &self,
4795        mut vmos: &[u8],
4796        ___deadline: zx::MonotonicInstant,
4797    ) -> Result<(u8, i32), fidl::Error> {
4798        let _response = self.client.send_query::<
4799            SessionUnregisterForTxRequest,
4800            SessionUnregisterForTxResponse,
4801            SessionMarker,
4802        >(
4803            (vmos,),
4804            0x3e76b16030d62796,
4805            fidl::encoding::DynamicFlags::empty(),
4806            ___deadline,
4807        )?;
4808        Ok((_response.successful, _response.status))
4809    }
4810}
4811
4812#[cfg(target_os = "fuchsia")]
4813impl From<SessionSynchronousProxy> for zx::NullableHandle {
4814    fn from(value: SessionSynchronousProxy) -> Self {
4815        value.into_channel().into()
4816    }
4817}
4818
4819#[cfg(target_os = "fuchsia")]
4820impl From<fidl::Channel> for SessionSynchronousProxy {
4821    fn from(value: fidl::Channel) -> Self {
4822        Self::new(value)
4823    }
4824}
4825
4826#[cfg(target_os = "fuchsia")]
4827impl fidl::endpoints::FromClient for SessionSynchronousProxy {
4828    type Protocol = SessionMarker;
4829
4830    fn from_client(value: fidl::endpoints::ClientEnd<SessionMarker>) -> Self {
4831        Self::new(value.into_channel())
4832    }
4833}
4834
4835#[derive(Debug, Clone)]
4836pub struct SessionProxy {
4837    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4838}
4839
4840impl fidl::endpoints::Proxy for SessionProxy {
4841    type Protocol = SessionMarker;
4842
4843    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4844        Self::new(inner)
4845    }
4846
4847    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4848        self.client.into_channel().map_err(|client| Self { client })
4849    }
4850
4851    fn as_channel(&self) -> &::fidl::AsyncChannel {
4852        self.client.as_channel()
4853    }
4854}
4855
4856impl SessionProxy {
4857    /// Create a new Proxy for fuchsia.hardware.network/Session.
4858    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4859        let protocol_name = <SessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4860        Self { client: fidl::client::Client::new(channel, protocol_name) }
4861    }
4862
4863    /// Get a Stream of events from the remote end of the protocol.
4864    ///
4865    /// # Panics
4866    ///
4867    /// Panics if the event stream was already taken.
4868    pub fn take_event_stream(&self) -> SessionEventStream {
4869        SessionEventStream { event_receiver: self.client.take_event_receiver() }
4870    }
4871
4872    /// Attaches the session to `port`.
4873    ///
4874    /// Once attached, the session starts to receive the subscribed frames over
4875    /// the data FIFOs and it may send frames destined to the specified `port`.
4876    ///
4877    /// + request `port` port to subscribe to.
4878    /// + request `rx_frames` Frame types of interest on the port.
4879    /// * error `ZX_ERR_NOT_FOUND` if `port` is not valid.
4880    /// * error `ZX_ERR_INVALID_ARGS` if `rx_frames` is not a subset of the
4881    /// port's supported frames.
4882    /// * error `ZX_ERR_ALREADY_BOUND` if `port` is already attached.
4883    pub fn r#attach(
4884        &self,
4885        mut port: &PortId,
4886        mut rx_frames: &[FrameType],
4887    ) -> fidl::client::QueryResponseFut<
4888        SessionAttachResult,
4889        fidl::encoding::DefaultFuchsiaResourceDialect,
4890    > {
4891        SessionProxyInterface::r#attach(self, port, rx_frames)
4892    }
4893
4894    /// Detaches the session from `port`.
4895    ///
4896    /// Once detached, the session stops receiving frames from `port`. Frames
4897    /// sent to a detached port may be returned with an error. It is not
4898    /// necessary to call `Detach` on ports that are removed from the device,
4899    /// doing so causes `ZX_ERR_NOT_FOUND` to be returned.
4900    ///
4901    /// + request `port` port to subscribe to.
4902    /// * error `ZX_ERR_NOT_FOUND` if the session is not currently attached to
4903    /// the port.
4904    pub fn r#detach(
4905        &self,
4906        mut port: &PortId,
4907    ) -> fidl::client::QueryResponseFut<
4908        SessionDetachResult,
4909        fidl::encoding::DefaultFuchsiaResourceDialect,
4910    > {
4911        SessionProxyInterface::r#detach(self, port)
4912    }
4913
4914    /// Cleanly closes a session.
4915    ///
4916    /// This will cause the session to send a `ZX_ERR_CANCELLED` epitaph and
4917    /// proceed to close the Session channel. Clients may only assume that they
4918    /// own all the buffers that are currently owned by the session (sent over
4919    /// either the rx or tx FIFOs) once the epitaph is received. Closing the rx
4920    /// or tx FIFO is equivalent to calling `Close`.
4921    pub fn r#close(&self) -> Result<(), fidl::Error> {
4922        SessionProxyInterface::r#close(self)
4923    }
4924
4925    /// Watchers for delegated receive wakeup leases.
4926    ///
4927    /// Calls block until a lease is delegated by the device. If a call to
4928    /// `WatchDelegatedRxLease` is made while a previous call is blocking, the
4929    /// session is closed with `ZX_ERR_BAD_STATE`. Will never yield any values
4930    /// for sessions created without [`SessionFlags.RECEIVE_RX_POWER_LEASES`].
4931    ///
4932    /// Given a single lease is assumed sufficient to keep the system awake, the
4933    /// server only keeps a single lease in its buffer. If a new delegated lease
4934    /// becomes available and the client hasn't popped the previous one with a
4935    /// call to `WatchDelegatedRxLease`, the server drops the previously pending
4936    /// lease.
4937    ///
4938    /// See [`DelegatedRxLease`] for how to handle delegated leases.
4939    pub fn r#watch_delegated_rx_lease(
4940        &self,
4941    ) -> fidl::client::QueryResponseFut<
4942        DelegatedRxLease,
4943        fidl::encoding::DefaultFuchsiaResourceDialect,
4944    > {
4945        SessionProxyInterface::r#watch_delegated_rx_lease(self)
4946    }
4947
4948    /// Asks the network device to register the VMO for Tx.
4949    ///
4950    /// The network device prepares the VMOs in order and stops at the first
4951    /// error if any. It returns how many VMOs have been prepared alongside with
4952    /// the first error encountered. Note that network-device itself does not
4953    /// try to release earlier VMOs for a later error. It is up to the client
4954    /// how to recover from an error.
4955    ///
4956    /// * error `ZX_ERR_NOT_FOUND` if any of the VmoId is unknown.
4957    /// * error other zx status that can be reported by the driver.
4958    pub fn r#register_for_tx(
4959        &self,
4960        mut vmos: &[u8],
4961    ) -> fidl::client::QueryResponseFut<(u8, i32), fidl::encoding::DefaultFuchsiaResourceDialect>
4962    {
4963        SessionProxyInterface::r#register_for_tx(self, vmos)
4964    }
4965
4966    /// Tells the device that the client will no longer use the VMO for Tx,
4967    /// if the VMO is also unused for Rx, the device is free to release it
4968    /// at the implementation driver.
4969    ///
4970    /// The network device processes the VMOs in order and stops at the first
4971    /// error if any. It returns how many VMOs have been marked as unused for Tx
4972    /// alongside with the first error encountered. Note that network-device
4973    /// itself does not try to re-register earlier VMOs for a later error. It is
4974    /// up to the client how to recover from an error.
4975    ///
4976    /// * error `ZX_ERR_NOT_FOUND` if any of the VmoId is unknown.
4977    /// * error other zx status that can be reported by the driver.
4978    pub fn r#unregister_for_tx(
4979        &self,
4980        mut vmos: &[u8],
4981    ) -> fidl::client::QueryResponseFut<(u8, i32), fidl::encoding::DefaultFuchsiaResourceDialect>
4982    {
4983        SessionProxyInterface::r#unregister_for_tx(self, vmos)
4984    }
4985}
4986
4987impl SessionProxyInterface for SessionProxy {
4988    type AttachResponseFut = fidl::client::QueryResponseFut<
4989        SessionAttachResult,
4990        fidl::encoding::DefaultFuchsiaResourceDialect,
4991    >;
4992    fn r#attach(&self, mut port: &PortId, mut rx_frames: &[FrameType]) -> Self::AttachResponseFut {
4993        fn _decode(
4994            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4995        ) -> Result<SessionAttachResult, fidl::Error> {
4996            let _response = fidl::client::decode_transaction_body::<
4997                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4998                fidl::encoding::DefaultFuchsiaResourceDialect,
4999                0x1e89c9013e201379,
5000            >(_buf?)?;
5001            Ok(_response.map(|x| x))
5002        }
5003        self.client.send_query_and_decode::<SessionAttachRequest, SessionAttachResult>(
5004            (port, rx_frames),
5005            0x1e89c9013e201379,
5006            fidl::encoding::DynamicFlags::empty(),
5007            _decode,
5008        )
5009    }
5010
5011    type DetachResponseFut = fidl::client::QueryResponseFut<
5012        SessionDetachResult,
5013        fidl::encoding::DefaultFuchsiaResourceDialect,
5014    >;
5015    fn r#detach(&self, mut port: &PortId) -> Self::DetachResponseFut {
5016        fn _decode(
5017            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5018        ) -> Result<SessionDetachResult, fidl::Error> {
5019            let _response = fidl::client::decode_transaction_body::<
5020                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5021                fidl::encoding::DefaultFuchsiaResourceDialect,
5022                0x68c40cf8fb549867,
5023            >(_buf?)?;
5024            Ok(_response.map(|x| x))
5025        }
5026        self.client.send_query_and_decode::<SessionDetachRequest, SessionDetachResult>(
5027            (port,),
5028            0x68c40cf8fb549867,
5029            fidl::encoding::DynamicFlags::empty(),
5030            _decode,
5031        )
5032    }
5033
5034    fn r#close(&self) -> Result<(), fidl::Error> {
5035        self.client.send::<fidl::encoding::EmptyPayload>(
5036            (),
5037            0x393d5070394a92f6,
5038            fidl::encoding::DynamicFlags::empty(),
5039        )
5040    }
5041
5042    type WatchDelegatedRxLeaseResponseFut = fidl::client::QueryResponseFut<
5043        DelegatedRxLease,
5044        fidl::encoding::DefaultFuchsiaResourceDialect,
5045    >;
5046    fn r#watch_delegated_rx_lease(&self) -> Self::WatchDelegatedRxLeaseResponseFut {
5047        fn _decode(
5048            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5049        ) -> Result<DelegatedRxLease, fidl::Error> {
5050            let _response = fidl::client::decode_transaction_body::<
5051                SessionWatchDelegatedRxLeaseResponse,
5052                fidl::encoding::DefaultFuchsiaResourceDialect,
5053                0x764d823ee64803b5,
5054            >(_buf?)?;
5055            Ok(_response.lease)
5056        }
5057        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DelegatedRxLease>(
5058            (),
5059            0x764d823ee64803b5,
5060            fidl::encoding::DynamicFlags::empty(),
5061            _decode,
5062        )
5063    }
5064
5065    type RegisterForTxResponseFut =
5066        fidl::client::QueryResponseFut<(u8, i32), fidl::encoding::DefaultFuchsiaResourceDialect>;
5067    fn r#register_for_tx(&self, mut vmos: &[u8]) -> Self::RegisterForTxResponseFut {
5068        fn _decode(
5069            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5070        ) -> Result<(u8, i32), fidl::Error> {
5071            let _response = fidl::client::decode_transaction_body::<
5072                SessionRegisterForTxResponse,
5073                fidl::encoding::DefaultFuchsiaResourceDialect,
5074                0x36321799ce2a081a,
5075            >(_buf?)?;
5076            Ok((_response.successful, _response.status))
5077        }
5078        self.client.send_query_and_decode::<SessionRegisterForTxRequest, (u8, i32)>(
5079            (vmos,),
5080            0x36321799ce2a081a,
5081            fidl::encoding::DynamicFlags::empty(),
5082            _decode,
5083        )
5084    }
5085
5086    type UnregisterForTxResponseFut =
5087        fidl::client::QueryResponseFut<(u8, i32), fidl::encoding::DefaultFuchsiaResourceDialect>;
5088    fn r#unregister_for_tx(&self, mut vmos: &[u8]) -> Self::UnregisterForTxResponseFut {
5089        fn _decode(
5090            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5091        ) -> Result<(u8, i32), fidl::Error> {
5092            let _response = fidl::client::decode_transaction_body::<
5093                SessionUnregisterForTxResponse,
5094                fidl::encoding::DefaultFuchsiaResourceDialect,
5095                0x3e76b16030d62796,
5096            >(_buf?)?;
5097            Ok((_response.successful, _response.status))
5098        }
5099        self.client.send_query_and_decode::<SessionUnregisterForTxRequest, (u8, i32)>(
5100            (vmos,),
5101            0x3e76b16030d62796,
5102            fidl::encoding::DynamicFlags::empty(),
5103            _decode,
5104        )
5105    }
5106}
5107
5108pub struct SessionEventStream {
5109    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5110}
5111
5112impl std::marker::Unpin for SessionEventStream {}
5113
5114impl futures::stream::FusedStream for SessionEventStream {
5115    fn is_terminated(&self) -> bool {
5116        self.event_receiver.is_terminated()
5117    }
5118}
5119
5120impl futures::Stream for SessionEventStream {
5121    type Item = Result<SessionEvent, fidl::Error>;
5122
5123    fn poll_next(
5124        mut self: std::pin::Pin<&mut Self>,
5125        cx: &mut std::task::Context<'_>,
5126    ) -> std::task::Poll<Option<Self::Item>> {
5127        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5128            &mut self.event_receiver,
5129            cx
5130        )?) {
5131            Some(buf) => std::task::Poll::Ready(Some(SessionEvent::decode(buf))),
5132            None => std::task::Poll::Ready(None),
5133        }
5134    }
5135}
5136
5137#[derive(Debug)]
5138pub enum SessionEvent {}
5139
5140impl SessionEvent {
5141    /// Decodes a message buffer as a [`SessionEvent`].
5142    fn decode(
5143        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5144    ) -> Result<SessionEvent, fidl::Error> {
5145        let (bytes, _handles) = buf.split_mut();
5146        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5147        debug_assert_eq!(tx_header.tx_id, 0);
5148        match tx_header.ordinal {
5149            _ => Err(fidl::Error::UnknownOrdinal {
5150                ordinal: tx_header.ordinal,
5151                protocol_name: <SessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5152            }),
5153        }
5154    }
5155}
5156
5157/// A Stream of incoming requests for fuchsia.hardware.network/Session.
5158pub struct SessionRequestStream {
5159    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5160    is_terminated: bool,
5161}
5162
5163impl std::marker::Unpin for SessionRequestStream {}
5164
5165impl futures::stream::FusedStream for SessionRequestStream {
5166    fn is_terminated(&self) -> bool {
5167        self.is_terminated
5168    }
5169}
5170
5171impl fidl::endpoints::RequestStream for SessionRequestStream {
5172    type Protocol = SessionMarker;
5173    type ControlHandle = SessionControlHandle;
5174
5175    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5176        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5177    }
5178
5179    fn control_handle(&self) -> Self::ControlHandle {
5180        SessionControlHandle { inner: self.inner.clone() }
5181    }
5182
5183    fn into_inner(
5184        self,
5185    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5186    {
5187        (self.inner, self.is_terminated)
5188    }
5189
5190    fn from_inner(
5191        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5192        is_terminated: bool,
5193    ) -> Self {
5194        Self { inner, is_terminated }
5195    }
5196}
5197
5198impl futures::Stream for SessionRequestStream {
5199    type Item = Result<SessionRequest, fidl::Error>;
5200
5201    fn poll_next(
5202        mut self: std::pin::Pin<&mut Self>,
5203        cx: &mut std::task::Context<'_>,
5204    ) -> std::task::Poll<Option<Self::Item>> {
5205        let this = &mut *self;
5206        if this.inner.check_shutdown(cx) {
5207            this.is_terminated = true;
5208            return std::task::Poll::Ready(None);
5209        }
5210        if this.is_terminated {
5211            panic!("polled SessionRequestStream after completion");
5212        }
5213        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5214            |bytes, handles| {
5215                match this.inner.channel().read_etc(cx, bytes, handles) {
5216                    std::task::Poll::Ready(Ok(())) => {}
5217                    std::task::Poll::Pending => return std::task::Poll::Pending,
5218                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5219                        this.is_terminated = true;
5220                        return std::task::Poll::Ready(None);
5221                    }
5222                    std::task::Poll::Ready(Err(e)) => {
5223                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5224                            e.into(),
5225                        ))));
5226                    }
5227                }
5228
5229                // A message has been received from the channel
5230                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5231
5232                std::task::Poll::Ready(Some(match header.ordinal {
5233                    0x1e89c9013e201379 => {
5234                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5235                        let mut req = fidl::new_empty!(
5236                            SessionAttachRequest,
5237                            fidl::encoding::DefaultFuchsiaResourceDialect
5238                        );
5239                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionAttachRequest>(&header, _body_bytes, handles, &mut req)?;
5240                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
5241                        Ok(SessionRequest::Attach {
5242                            port: req.port,
5243                            rx_frames: req.rx_frames,
5244
5245                            responder: SessionAttachResponder {
5246                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5247                                tx_id: header.tx_id,
5248                            },
5249                        })
5250                    }
5251                    0x68c40cf8fb549867 => {
5252                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5253                        let mut req = fidl::new_empty!(
5254                            SessionDetachRequest,
5255                            fidl::encoding::DefaultFuchsiaResourceDialect
5256                        );
5257                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionDetachRequest>(&header, _body_bytes, handles, &mut req)?;
5258                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
5259                        Ok(SessionRequest::Detach {
5260                            port: req.port,
5261
5262                            responder: SessionDetachResponder {
5263                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5264                                tx_id: header.tx_id,
5265                            },
5266                        })
5267                    }
5268                    0x393d5070394a92f6 => {
5269                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5270                        let mut req = fidl::new_empty!(
5271                            fidl::encoding::EmptyPayload,
5272                            fidl::encoding::DefaultFuchsiaResourceDialect
5273                        );
5274                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5275                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
5276                        Ok(SessionRequest::Close { control_handle })
5277                    }
5278                    0x764d823ee64803b5 => {
5279                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5280                        let mut req = fidl::new_empty!(
5281                            fidl::encoding::EmptyPayload,
5282                            fidl::encoding::DefaultFuchsiaResourceDialect
5283                        );
5284                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5285                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
5286                        Ok(SessionRequest::WatchDelegatedRxLease {
5287                            responder: SessionWatchDelegatedRxLeaseResponder {
5288                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5289                                tx_id: header.tx_id,
5290                            },
5291                        })
5292                    }
5293                    0x36321799ce2a081a => {
5294                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5295                        let mut req = fidl::new_empty!(
5296                            SessionRegisterForTxRequest,
5297                            fidl::encoding::DefaultFuchsiaResourceDialect
5298                        );
5299                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionRegisterForTxRequest>(&header, _body_bytes, handles, &mut req)?;
5300                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
5301                        Ok(SessionRequest::RegisterForTx {
5302                            vmos: req.vmos,
5303
5304                            responder: SessionRegisterForTxResponder {
5305                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5306                                tx_id: header.tx_id,
5307                            },
5308                        })
5309                    }
5310                    0x3e76b16030d62796 => {
5311                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5312                        let mut req = fidl::new_empty!(
5313                            SessionUnregisterForTxRequest,
5314                            fidl::encoding::DefaultFuchsiaResourceDialect
5315                        );
5316                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionUnregisterForTxRequest>(&header, _body_bytes, handles, &mut req)?;
5317                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
5318                        Ok(SessionRequest::UnregisterForTx {
5319                            vmos: req.vmos,
5320
5321                            responder: SessionUnregisterForTxResponder {
5322                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5323                                tx_id: header.tx_id,
5324                            },
5325                        })
5326                    }
5327                    _ => Err(fidl::Error::UnknownOrdinal {
5328                        ordinal: header.ordinal,
5329                        protocol_name:
5330                            <SessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5331                    }),
5332                }))
5333            },
5334        )
5335    }
5336}
5337
5338/// Represents a session with a Network device.
5339///
5340/// A session has a data plane and a control plane. The `Session` protocol
5341/// represents the control plane of the session and the FIFOs and VMOs exchanged
5342/// during the [`Device.OpenSession`] call are the data plane. Lifetime of the
5343/// session is controlled by a `Session` protocol handle.
5344///
5345/// Sessions must attach to ports of interest to start receiving and sending
5346/// data. Sessions are always created with no ports attached.
5347///
5348/// If a port is destroyed from the underlying device, it is automatically
5349/// detached from the session.
5350///
5351/// Inbound traffic is dispatched to all open sessions. Devices typically
5352/// operate with a single primary session, see [`SessionFlags.PRIMARY`]. Each
5353/// additional open session to the same device causes data copy overhead on the
5354/// device's data path.
5355///
5356/// The session is closed with an error epitaph if an invalid buffer descriptor
5357/// is sent over either the tx or rx FIFOs. Invalid descriptors include:
5358///    - Descriptor index larger than [`SessionInfo.descriptor_count`].
5359///    - Descriptor chains larger than [`MAX_DESCRIPTOR_CHAIN`].
5360///    - rx buffers smaller than [`Info.min_rx_buffer_length`].
5361///    - tx buffers smaller than [`Info.min_tx_buffer_length`].
5362///    - tx buffers not respecting [`Info.min_tx_buffer_head`] or
5363///      [`Info.min_tx_buffer_tail`].
5364#[derive(Debug)]
5365pub enum SessionRequest {
5366    /// Attaches the session to `port`.
5367    ///
5368    /// Once attached, the session starts to receive the subscribed frames over
5369    /// the data FIFOs and it may send frames destined to the specified `port`.
5370    ///
5371    /// + request `port` port to subscribe to.
5372    /// + request `rx_frames` Frame types of interest on the port.
5373    /// * error `ZX_ERR_NOT_FOUND` if `port` is not valid.
5374    /// * error `ZX_ERR_INVALID_ARGS` if `rx_frames` is not a subset of the
5375    /// port's supported frames.
5376    /// * error `ZX_ERR_ALREADY_BOUND` if `port` is already attached.
5377    Attach { port: PortId, rx_frames: Vec<FrameType>, responder: SessionAttachResponder },
5378    /// Detaches the session from `port`.
5379    ///
5380    /// Once detached, the session stops receiving frames from `port`. Frames
5381    /// sent to a detached port may be returned with an error. It is not
5382    /// necessary to call `Detach` on ports that are removed from the device,
5383    /// doing so causes `ZX_ERR_NOT_FOUND` to be returned.
5384    ///
5385    /// + request `port` port to subscribe to.
5386    /// * error `ZX_ERR_NOT_FOUND` if the session is not currently attached to
5387    /// the port.
5388    Detach { port: PortId, responder: SessionDetachResponder },
5389    /// Cleanly closes a session.
5390    ///
5391    /// This will cause the session to send a `ZX_ERR_CANCELLED` epitaph and
5392    /// proceed to close the Session channel. Clients may only assume that they
5393    /// own all the buffers that are currently owned by the session (sent over
5394    /// either the rx or tx FIFOs) once the epitaph is received. Closing the rx
5395    /// or tx FIFO is equivalent to calling `Close`.
5396    Close { control_handle: SessionControlHandle },
5397    /// Watchers for delegated receive wakeup leases.
5398    ///
5399    /// Calls block until a lease is delegated by the device. If a call to
5400    /// `WatchDelegatedRxLease` is made while a previous call is blocking, the
5401    /// session is closed with `ZX_ERR_BAD_STATE`. Will never yield any values
5402    /// for sessions created without [`SessionFlags.RECEIVE_RX_POWER_LEASES`].
5403    ///
5404    /// Given a single lease is assumed sufficient to keep the system awake, the
5405    /// server only keeps a single lease in its buffer. If a new delegated lease
5406    /// becomes available and the client hasn't popped the previous one with a
5407    /// call to `WatchDelegatedRxLease`, the server drops the previously pending
5408    /// lease.
5409    ///
5410    /// See [`DelegatedRxLease`] for how to handle delegated leases.
5411    WatchDelegatedRxLease { responder: SessionWatchDelegatedRxLeaseResponder },
5412    /// Asks the network device to register the VMO for Tx.
5413    ///
5414    /// The network device prepares the VMOs in order and stops at the first
5415    /// error if any. It returns how many VMOs have been prepared alongside with
5416    /// the first error encountered. Note that network-device itself does not
5417    /// try to release earlier VMOs for a later error. It is up to the client
5418    /// how to recover from an error.
5419    ///
5420    /// * error `ZX_ERR_NOT_FOUND` if any of the VmoId is unknown.
5421    /// * error other zx status that can be reported by the driver.
5422    RegisterForTx { vmos: Vec<u8>, responder: SessionRegisterForTxResponder },
5423    /// Tells the device that the client will no longer use the VMO for Tx,
5424    /// if the VMO is also unused for Rx, the device is free to release it
5425    /// at the implementation driver.
5426    ///
5427    /// The network device processes the VMOs in order and stops at the first
5428    /// error if any. It returns how many VMOs have been marked as unused for Tx
5429    /// alongside with the first error encountered. Note that network-device
5430    /// itself does not try to re-register earlier VMOs for a later error. It is
5431    /// up to the client how to recover from an error.
5432    ///
5433    /// * error `ZX_ERR_NOT_FOUND` if any of the VmoId is unknown.
5434    /// * error other zx status that can be reported by the driver.
5435    UnregisterForTx { vmos: Vec<u8>, responder: SessionUnregisterForTxResponder },
5436}
5437
5438impl SessionRequest {
5439    #[allow(irrefutable_let_patterns)]
5440    pub fn into_attach(self) -> Option<(PortId, Vec<FrameType>, SessionAttachResponder)> {
5441        if let SessionRequest::Attach { port, rx_frames, responder } = self {
5442            Some((port, rx_frames, responder))
5443        } else {
5444            None
5445        }
5446    }
5447
5448    #[allow(irrefutable_let_patterns)]
5449    pub fn into_detach(self) -> Option<(PortId, SessionDetachResponder)> {
5450        if let SessionRequest::Detach { port, responder } = self {
5451            Some((port, responder))
5452        } else {
5453            None
5454        }
5455    }
5456
5457    #[allow(irrefutable_let_patterns)]
5458    pub fn into_close(self) -> Option<(SessionControlHandle)> {
5459        if let SessionRequest::Close { control_handle } = self {
5460            Some((control_handle))
5461        } else {
5462            None
5463        }
5464    }
5465
5466    #[allow(irrefutable_let_patterns)]
5467    pub fn into_watch_delegated_rx_lease(self) -> Option<(SessionWatchDelegatedRxLeaseResponder)> {
5468        if let SessionRequest::WatchDelegatedRxLease { responder } = self {
5469            Some((responder))
5470        } else {
5471            None
5472        }
5473    }
5474
5475    #[allow(irrefutable_let_patterns)]
5476    pub fn into_register_for_tx(self) -> Option<(Vec<u8>, SessionRegisterForTxResponder)> {
5477        if let SessionRequest::RegisterForTx { vmos, responder } = self {
5478            Some((vmos, responder))
5479        } else {
5480            None
5481        }
5482    }
5483
5484    #[allow(irrefutable_let_patterns)]
5485    pub fn into_unregister_for_tx(self) -> Option<(Vec<u8>, SessionUnregisterForTxResponder)> {
5486        if let SessionRequest::UnregisterForTx { vmos, responder } = self {
5487            Some((vmos, responder))
5488        } else {
5489            None
5490        }
5491    }
5492
5493    /// Name of the method defined in FIDL
5494    pub fn method_name(&self) -> &'static str {
5495        match *self {
5496            SessionRequest::Attach { .. } => "attach",
5497            SessionRequest::Detach { .. } => "detach",
5498            SessionRequest::Close { .. } => "close",
5499            SessionRequest::WatchDelegatedRxLease { .. } => "watch_delegated_rx_lease",
5500            SessionRequest::RegisterForTx { .. } => "register_for_tx",
5501            SessionRequest::UnregisterForTx { .. } => "unregister_for_tx",
5502        }
5503    }
5504}
5505
5506#[derive(Debug, Clone)]
5507pub struct SessionControlHandle {
5508    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5509}
5510
5511impl SessionControlHandle {
5512    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
5513        self.inner.shutdown_with_epitaph(status.into())
5514    }
5515}
5516
5517impl fidl::endpoints::ControlHandle for SessionControlHandle {
5518    fn shutdown(&self) {
5519        self.inner.shutdown()
5520    }
5521
5522    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
5523        self.inner.shutdown_with_epitaph(status)
5524    }
5525
5526    fn is_closed(&self) -> bool {
5527        self.inner.channel().is_closed()
5528    }
5529    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5530        self.inner.channel().on_closed()
5531    }
5532
5533    #[cfg(target_os = "fuchsia")]
5534    fn signal_peer(
5535        &self,
5536        clear_mask: zx::Signals,
5537        set_mask: zx::Signals,
5538    ) -> Result<(), zx_status::Status> {
5539        use fidl::Peered;
5540        self.inner.channel().signal_peer(clear_mask, set_mask)
5541    }
5542}
5543
5544impl SessionControlHandle {}
5545
5546#[must_use = "FIDL methods require a response to be sent"]
5547#[derive(Debug)]
5548pub struct SessionAttachResponder {
5549    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
5550    tx_id: u32,
5551}
5552
5553/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
5554/// if the responder is dropped without sending a response, so that the client
5555/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5556impl std::ops::Drop for SessionAttachResponder {
5557    fn drop(&mut self) {
5558        self.control_handle.shutdown();
5559        // Safety: drops once, never accessed again
5560        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5561    }
5562}
5563
5564impl fidl::endpoints::Responder for SessionAttachResponder {
5565    type ControlHandle = SessionControlHandle;
5566
5567    fn control_handle(&self) -> &SessionControlHandle {
5568        &self.control_handle
5569    }
5570
5571    fn drop_without_shutdown(mut self) {
5572        // Safety: drops once, never accessed again due to mem::forget
5573        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5574        // Prevent Drop from running (which would shut down the channel)
5575        std::mem::forget(self);
5576    }
5577}
5578
5579impl SessionAttachResponder {
5580    /// Sends a response to the FIDL transaction.
5581    ///
5582    /// Sets the channel to shutdown if an error occurs.
5583    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5584        let _result = self.send_raw(result);
5585        if _result.is_err() {
5586            self.control_handle.shutdown();
5587        }
5588        self.drop_without_shutdown();
5589        _result
5590    }
5591
5592    /// Similar to "send" but does not shutdown the channel if an error occurs.
5593    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5594        let _result = self.send_raw(result);
5595        self.drop_without_shutdown();
5596        _result
5597    }
5598
5599    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5600        self.control_handle
5601            .inner
5602            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5603                result,
5604                self.tx_id,
5605                0x1e89c9013e201379,
5606                fidl::encoding::DynamicFlags::empty(),
5607            )
5608    }
5609}
5610
5611#[must_use = "FIDL methods require a response to be sent"]
5612#[derive(Debug)]
5613pub struct SessionDetachResponder {
5614    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
5615    tx_id: u32,
5616}
5617
5618/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
5619/// if the responder is dropped without sending a response, so that the client
5620/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5621impl std::ops::Drop for SessionDetachResponder {
5622    fn drop(&mut self) {
5623        self.control_handle.shutdown();
5624        // Safety: drops once, never accessed again
5625        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5626    }
5627}
5628
5629impl fidl::endpoints::Responder for SessionDetachResponder {
5630    type ControlHandle = SessionControlHandle;
5631
5632    fn control_handle(&self) -> &SessionControlHandle {
5633        &self.control_handle
5634    }
5635
5636    fn drop_without_shutdown(mut self) {
5637        // Safety: drops once, never accessed again due to mem::forget
5638        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5639        // Prevent Drop from running (which would shut down the channel)
5640        std::mem::forget(self);
5641    }
5642}
5643
5644impl SessionDetachResponder {
5645    /// Sends a response to the FIDL transaction.
5646    ///
5647    /// Sets the channel to shutdown if an error occurs.
5648    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5649        let _result = self.send_raw(result);
5650        if _result.is_err() {
5651            self.control_handle.shutdown();
5652        }
5653        self.drop_without_shutdown();
5654        _result
5655    }
5656
5657    /// Similar to "send" but does not shutdown the channel if an error occurs.
5658    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5659        let _result = self.send_raw(result);
5660        self.drop_without_shutdown();
5661        _result
5662    }
5663
5664    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5665        self.control_handle
5666            .inner
5667            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5668                result,
5669                self.tx_id,
5670                0x68c40cf8fb549867,
5671                fidl::encoding::DynamicFlags::empty(),
5672            )
5673    }
5674}
5675
5676#[must_use = "FIDL methods require a response to be sent"]
5677#[derive(Debug)]
5678pub struct SessionWatchDelegatedRxLeaseResponder {
5679    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
5680    tx_id: u32,
5681}
5682
5683/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
5684/// if the responder is dropped without sending a response, so that the client
5685/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5686impl std::ops::Drop for SessionWatchDelegatedRxLeaseResponder {
5687    fn drop(&mut self) {
5688        self.control_handle.shutdown();
5689        // Safety: drops once, never accessed again
5690        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5691    }
5692}
5693
5694impl fidl::endpoints::Responder for SessionWatchDelegatedRxLeaseResponder {
5695    type ControlHandle = SessionControlHandle;
5696
5697    fn control_handle(&self) -> &SessionControlHandle {
5698        &self.control_handle
5699    }
5700
5701    fn drop_without_shutdown(mut self) {
5702        // Safety: drops once, never accessed again due to mem::forget
5703        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5704        // Prevent Drop from running (which would shut down the channel)
5705        std::mem::forget(self);
5706    }
5707}
5708
5709impl SessionWatchDelegatedRxLeaseResponder {
5710    /// Sends a response to the FIDL transaction.
5711    ///
5712    /// Sets the channel to shutdown if an error occurs.
5713    pub fn send(self, mut lease: DelegatedRxLease) -> Result<(), fidl::Error> {
5714        let _result = self.send_raw(lease);
5715        if _result.is_err() {
5716            self.control_handle.shutdown();
5717        }
5718        self.drop_without_shutdown();
5719        _result
5720    }
5721
5722    /// Similar to "send" but does not shutdown the channel if an error occurs.
5723    pub fn send_no_shutdown_on_err(self, mut lease: DelegatedRxLease) -> Result<(), fidl::Error> {
5724        let _result = self.send_raw(lease);
5725        self.drop_without_shutdown();
5726        _result
5727    }
5728
5729    fn send_raw(&self, mut lease: DelegatedRxLease) -> Result<(), fidl::Error> {
5730        self.control_handle.inner.send::<SessionWatchDelegatedRxLeaseResponse>(
5731            (&mut lease,),
5732            self.tx_id,
5733            0x764d823ee64803b5,
5734            fidl::encoding::DynamicFlags::empty(),
5735        )
5736    }
5737}
5738
5739#[must_use = "FIDL methods require a response to be sent"]
5740#[derive(Debug)]
5741pub struct SessionRegisterForTxResponder {
5742    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
5743    tx_id: u32,
5744}
5745
5746/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
5747/// if the responder is dropped without sending a response, so that the client
5748/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5749impl std::ops::Drop for SessionRegisterForTxResponder {
5750    fn drop(&mut self) {
5751        self.control_handle.shutdown();
5752        // Safety: drops once, never accessed again
5753        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5754    }
5755}
5756
5757impl fidl::endpoints::Responder for SessionRegisterForTxResponder {
5758    type ControlHandle = SessionControlHandle;
5759
5760    fn control_handle(&self) -> &SessionControlHandle {
5761        &self.control_handle
5762    }
5763
5764    fn drop_without_shutdown(mut self) {
5765        // Safety: drops once, never accessed again due to mem::forget
5766        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5767        // Prevent Drop from running (which would shut down the channel)
5768        std::mem::forget(self);
5769    }
5770}
5771
5772impl SessionRegisterForTxResponder {
5773    /// Sends a response to the FIDL transaction.
5774    ///
5775    /// Sets the channel to shutdown if an error occurs.
5776    pub fn send(self, mut successful: u8, mut status: i32) -> Result<(), fidl::Error> {
5777        let _result = self.send_raw(successful, status);
5778        if _result.is_err() {
5779            self.control_handle.shutdown();
5780        }
5781        self.drop_without_shutdown();
5782        _result
5783    }
5784
5785    /// Similar to "send" but does not shutdown the channel if an error occurs.
5786    pub fn send_no_shutdown_on_err(
5787        self,
5788        mut successful: u8,
5789        mut status: i32,
5790    ) -> Result<(), fidl::Error> {
5791        let _result = self.send_raw(successful, status);
5792        self.drop_without_shutdown();
5793        _result
5794    }
5795
5796    fn send_raw(&self, mut successful: u8, mut status: i32) -> Result<(), fidl::Error> {
5797        self.control_handle.inner.send::<SessionRegisterForTxResponse>(
5798            (successful, status),
5799            self.tx_id,
5800            0x36321799ce2a081a,
5801            fidl::encoding::DynamicFlags::empty(),
5802        )
5803    }
5804}
5805
5806#[must_use = "FIDL methods require a response to be sent"]
5807#[derive(Debug)]
5808pub struct SessionUnregisterForTxResponder {
5809    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
5810    tx_id: u32,
5811}
5812
5813/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
5814/// if the responder is dropped without sending a response, so that the client
5815/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5816impl std::ops::Drop for SessionUnregisterForTxResponder {
5817    fn drop(&mut self) {
5818        self.control_handle.shutdown();
5819        // Safety: drops once, never accessed again
5820        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5821    }
5822}
5823
5824impl fidl::endpoints::Responder for SessionUnregisterForTxResponder {
5825    type ControlHandle = SessionControlHandle;
5826
5827    fn control_handle(&self) -> &SessionControlHandle {
5828        &self.control_handle
5829    }
5830
5831    fn drop_without_shutdown(mut self) {
5832        // Safety: drops once, never accessed again due to mem::forget
5833        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5834        // Prevent Drop from running (which would shut down the channel)
5835        std::mem::forget(self);
5836    }
5837}
5838
5839impl SessionUnregisterForTxResponder {
5840    /// Sends a response to the FIDL transaction.
5841    ///
5842    /// Sets the channel to shutdown if an error occurs.
5843    pub fn send(self, mut successful: u8, mut status: i32) -> Result<(), fidl::Error> {
5844        let _result = self.send_raw(successful, status);
5845        if _result.is_err() {
5846            self.control_handle.shutdown();
5847        }
5848        self.drop_without_shutdown();
5849        _result
5850    }
5851
5852    /// Similar to "send" but does not shutdown the channel if an error occurs.
5853    pub fn send_no_shutdown_on_err(
5854        self,
5855        mut successful: u8,
5856        mut status: i32,
5857    ) -> Result<(), fidl::Error> {
5858        let _result = self.send_raw(successful, status);
5859        self.drop_without_shutdown();
5860        _result
5861    }
5862
5863    fn send_raw(&self, mut successful: u8, mut status: i32) -> Result<(), fidl::Error> {
5864        self.control_handle.inner.send::<SessionUnregisterForTxResponse>(
5865            (successful, status),
5866            self.tx_id,
5867            0x3e76b16030d62796,
5868            fidl::encoding::DynamicFlags::empty(),
5869        )
5870    }
5871}
5872
5873#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5874pub struct StatusWatcherMarker;
5875
5876impl fidl::endpoints::ProtocolMarker for StatusWatcherMarker {
5877    type Proxy = StatusWatcherProxy;
5878    type RequestStream = StatusWatcherRequestStream;
5879    #[cfg(target_os = "fuchsia")]
5880    type SynchronousProxy = StatusWatcherSynchronousProxy;
5881
5882    const DEBUG_NAME: &'static str = "(anonymous) StatusWatcher";
5883}
5884
5885pub trait StatusWatcherProxyInterface: Send + Sync {
5886    type WatchStatusResponseFut: std::future::Future<Output = Result<PortStatus, fidl::Error>>
5887        + Send;
5888    fn r#watch_status(&self) -> Self::WatchStatusResponseFut;
5889}
5890#[derive(Debug)]
5891#[cfg(target_os = "fuchsia")]
5892pub struct StatusWatcherSynchronousProxy {
5893    client: fidl::client::sync::Client,
5894}
5895
5896#[cfg(target_os = "fuchsia")]
5897impl fidl::endpoints::SynchronousProxy for StatusWatcherSynchronousProxy {
5898    type Proxy = StatusWatcherProxy;
5899    type Protocol = StatusWatcherMarker;
5900
5901    fn from_channel(inner: fidl::Channel) -> Self {
5902        Self::new(inner)
5903    }
5904
5905    fn into_channel(self) -> fidl::Channel {
5906        self.client.into_channel()
5907    }
5908
5909    fn as_channel(&self) -> &fidl::Channel {
5910        self.client.as_channel()
5911    }
5912}
5913
5914#[cfg(target_os = "fuchsia")]
5915impl StatusWatcherSynchronousProxy {
5916    pub fn new(channel: fidl::Channel) -> Self {
5917        Self { client: fidl::client::sync::Client::new(channel) }
5918    }
5919
5920    pub fn into_channel(self) -> fidl::Channel {
5921        self.client.into_channel()
5922    }
5923
5924    /// Waits until an event arrives and returns it. It is safe for other
5925    /// threads to make concurrent requests while waiting for an event.
5926    pub fn wait_for_event(
5927        &self,
5928        deadline: zx::MonotonicInstant,
5929    ) -> Result<StatusWatcherEvent, fidl::Error> {
5930        StatusWatcherEvent::decode(self.client.wait_for_event::<StatusWatcherMarker>(deadline)?)
5931    }
5932
5933    /// `WatchStatus` blocks until the port's status has changed.
5934    ///
5935    /// The first call to `WatchStatus` returns immediately with the current
5936    /// port status, subsequent calls complete when the port status differs from
5937    /// the last one that was returned through this `StatusWatcher`.
5938    ///
5939    /// If `StatusWatcher` was created with a buffer value larger than 1,
5940    /// `WatchStatus` may return a queued status change, depending on how many
5941    /// status changed happened since the last call to `WatchStatus`.
5942    ///
5943    /// - response `device_status` the most recent port status.
5944    pub fn r#watch_status(
5945        &self,
5946        ___deadline: zx::MonotonicInstant,
5947    ) -> Result<PortStatus, fidl::Error> {
5948        let _response = self.client.send_query::<
5949            fidl::encoding::EmptyPayload,
5950            StatusWatcherWatchStatusResponse,
5951            StatusWatcherMarker,
5952        >(
5953            (),
5954            0x1369a8125c0862b9,
5955            fidl::encoding::DynamicFlags::empty(),
5956            ___deadline,
5957        )?;
5958        Ok(_response.port_status)
5959    }
5960}
5961
5962#[cfg(target_os = "fuchsia")]
5963impl From<StatusWatcherSynchronousProxy> for zx::NullableHandle {
5964    fn from(value: StatusWatcherSynchronousProxy) -> Self {
5965        value.into_channel().into()
5966    }
5967}
5968
5969#[cfg(target_os = "fuchsia")]
5970impl From<fidl::Channel> for StatusWatcherSynchronousProxy {
5971    fn from(value: fidl::Channel) -> Self {
5972        Self::new(value)
5973    }
5974}
5975
5976#[cfg(target_os = "fuchsia")]
5977impl fidl::endpoints::FromClient for StatusWatcherSynchronousProxy {
5978    type Protocol = StatusWatcherMarker;
5979
5980    fn from_client(value: fidl::endpoints::ClientEnd<StatusWatcherMarker>) -> Self {
5981        Self::new(value.into_channel())
5982    }
5983}
5984
5985#[derive(Debug, Clone)]
5986pub struct StatusWatcherProxy {
5987    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5988}
5989
5990impl fidl::endpoints::Proxy for StatusWatcherProxy {
5991    type Protocol = StatusWatcherMarker;
5992
5993    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5994        Self::new(inner)
5995    }
5996
5997    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5998        self.client.into_channel().map_err(|client| Self { client })
5999    }
6000
6001    fn as_channel(&self) -> &::fidl::AsyncChannel {
6002        self.client.as_channel()
6003    }
6004}
6005
6006impl StatusWatcherProxy {
6007    /// Create a new Proxy for fuchsia.hardware.network/StatusWatcher.
6008    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6009        let protocol_name = <StatusWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6010        Self { client: fidl::client::Client::new(channel, protocol_name) }
6011    }
6012
6013    /// Get a Stream of events from the remote end of the protocol.
6014    ///
6015    /// # Panics
6016    ///
6017    /// Panics if the event stream was already taken.
6018    pub fn take_event_stream(&self) -> StatusWatcherEventStream {
6019        StatusWatcherEventStream { event_receiver: self.client.take_event_receiver() }
6020    }
6021
6022    /// `WatchStatus` blocks until the port's status has changed.
6023    ///
6024    /// The first call to `WatchStatus` returns immediately with the current
6025    /// port status, subsequent calls complete when the port status differs from
6026    /// the last one that was returned through this `StatusWatcher`.
6027    ///
6028    /// If `StatusWatcher` was created with a buffer value larger than 1,
6029    /// `WatchStatus` may return a queued status change, depending on how many
6030    /// status changed happened since the last call to `WatchStatus`.
6031    ///
6032    /// - response `device_status` the most recent port status.
6033    pub fn r#watch_status(
6034        &self,
6035    ) -> fidl::client::QueryResponseFut<PortStatus, fidl::encoding::DefaultFuchsiaResourceDialect>
6036    {
6037        StatusWatcherProxyInterface::r#watch_status(self)
6038    }
6039}
6040
6041impl StatusWatcherProxyInterface for StatusWatcherProxy {
6042    type WatchStatusResponseFut =
6043        fidl::client::QueryResponseFut<PortStatus, fidl::encoding::DefaultFuchsiaResourceDialect>;
6044    fn r#watch_status(&self) -> Self::WatchStatusResponseFut {
6045        fn _decode(
6046            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6047        ) -> Result<PortStatus, fidl::Error> {
6048            let _response = fidl::client::decode_transaction_body::<
6049                StatusWatcherWatchStatusResponse,
6050                fidl::encoding::DefaultFuchsiaResourceDialect,
6051                0x1369a8125c0862b9,
6052            >(_buf?)?;
6053            Ok(_response.port_status)
6054        }
6055        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PortStatus>(
6056            (),
6057            0x1369a8125c0862b9,
6058            fidl::encoding::DynamicFlags::empty(),
6059            _decode,
6060        )
6061    }
6062}
6063
6064pub struct StatusWatcherEventStream {
6065    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6066}
6067
6068impl std::marker::Unpin for StatusWatcherEventStream {}
6069
6070impl futures::stream::FusedStream for StatusWatcherEventStream {
6071    fn is_terminated(&self) -> bool {
6072        self.event_receiver.is_terminated()
6073    }
6074}
6075
6076impl futures::Stream for StatusWatcherEventStream {
6077    type Item = Result<StatusWatcherEvent, fidl::Error>;
6078
6079    fn poll_next(
6080        mut self: std::pin::Pin<&mut Self>,
6081        cx: &mut std::task::Context<'_>,
6082    ) -> std::task::Poll<Option<Self::Item>> {
6083        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6084            &mut self.event_receiver,
6085            cx
6086        )?) {
6087            Some(buf) => std::task::Poll::Ready(Some(StatusWatcherEvent::decode(buf))),
6088            None => std::task::Poll::Ready(None),
6089        }
6090    }
6091}
6092
6093#[derive(Debug)]
6094pub enum StatusWatcherEvent {}
6095
6096impl StatusWatcherEvent {
6097    /// Decodes a message buffer as a [`StatusWatcherEvent`].
6098    fn decode(
6099        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6100    ) -> Result<StatusWatcherEvent, fidl::Error> {
6101        let (bytes, _handles) = buf.split_mut();
6102        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6103        debug_assert_eq!(tx_header.tx_id, 0);
6104        match tx_header.ordinal {
6105            _ => Err(fidl::Error::UnknownOrdinal {
6106                ordinal: tx_header.ordinal,
6107                protocol_name: <StatusWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6108            }),
6109        }
6110    }
6111}
6112
6113/// A Stream of incoming requests for fuchsia.hardware.network/StatusWatcher.
6114pub struct StatusWatcherRequestStream {
6115    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6116    is_terminated: bool,
6117}
6118
6119impl std::marker::Unpin for StatusWatcherRequestStream {}
6120
6121impl futures::stream::FusedStream for StatusWatcherRequestStream {
6122    fn is_terminated(&self) -> bool {
6123        self.is_terminated
6124    }
6125}
6126
6127impl fidl::endpoints::RequestStream for StatusWatcherRequestStream {
6128    type Protocol = StatusWatcherMarker;
6129    type ControlHandle = StatusWatcherControlHandle;
6130
6131    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6132        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6133    }
6134
6135    fn control_handle(&self) -> Self::ControlHandle {
6136        StatusWatcherControlHandle { inner: self.inner.clone() }
6137    }
6138
6139    fn into_inner(
6140        self,
6141    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6142    {
6143        (self.inner, self.is_terminated)
6144    }
6145
6146    fn from_inner(
6147        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6148        is_terminated: bool,
6149    ) -> Self {
6150        Self { inner, is_terminated }
6151    }
6152}
6153
6154impl futures::Stream for StatusWatcherRequestStream {
6155    type Item = Result<StatusWatcherRequest, fidl::Error>;
6156
6157    fn poll_next(
6158        mut self: std::pin::Pin<&mut Self>,
6159        cx: &mut std::task::Context<'_>,
6160    ) -> std::task::Poll<Option<Self::Item>> {
6161        let this = &mut *self;
6162        if this.inner.check_shutdown(cx) {
6163            this.is_terminated = true;
6164            return std::task::Poll::Ready(None);
6165        }
6166        if this.is_terminated {
6167            panic!("polled StatusWatcherRequestStream after completion");
6168        }
6169        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6170            |bytes, handles| {
6171                match this.inner.channel().read_etc(cx, bytes, handles) {
6172                    std::task::Poll::Ready(Ok(())) => {}
6173                    std::task::Poll::Pending => return std::task::Poll::Pending,
6174                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6175                        this.is_terminated = true;
6176                        return std::task::Poll::Ready(None);
6177                    }
6178                    std::task::Poll::Ready(Err(e)) => {
6179                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6180                            e.into(),
6181                        ))));
6182                    }
6183                }
6184
6185                // A message has been received from the channel
6186                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6187
6188                std::task::Poll::Ready(Some(match header.ordinal {
6189                    0x1369a8125c0862b9 => {
6190                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6191                        let mut req = fidl::new_empty!(
6192                            fidl::encoding::EmptyPayload,
6193                            fidl::encoding::DefaultFuchsiaResourceDialect
6194                        );
6195                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6196                        let control_handle =
6197                            StatusWatcherControlHandle { inner: this.inner.clone() };
6198                        Ok(StatusWatcherRequest::WatchStatus {
6199                            responder: StatusWatcherWatchStatusResponder {
6200                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6201                                tx_id: header.tx_id,
6202                            },
6203                        })
6204                    }
6205                    _ => Err(fidl::Error::UnknownOrdinal {
6206                        ordinal: header.ordinal,
6207                        protocol_name:
6208                            <StatusWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6209                    }),
6210                }))
6211            },
6212        )
6213    }
6214}
6215
6216/// Provides a way to receive updates on port status changes.
6217#[derive(Debug)]
6218pub enum StatusWatcherRequest {
6219    /// `WatchStatus` blocks until the port's status has changed.
6220    ///
6221    /// The first call to `WatchStatus` returns immediately with the current
6222    /// port status, subsequent calls complete when the port status differs from
6223    /// the last one that was returned through this `StatusWatcher`.
6224    ///
6225    /// If `StatusWatcher` was created with a buffer value larger than 1,
6226    /// `WatchStatus` may return a queued status change, depending on how many
6227    /// status changed happened since the last call to `WatchStatus`.
6228    ///
6229    /// - response `device_status` the most recent port status.
6230    WatchStatus { responder: StatusWatcherWatchStatusResponder },
6231}
6232
6233impl StatusWatcherRequest {
6234    #[allow(irrefutable_let_patterns)]
6235    pub fn into_watch_status(self) -> Option<(StatusWatcherWatchStatusResponder)> {
6236        if let StatusWatcherRequest::WatchStatus { responder } = self {
6237            Some((responder))
6238        } else {
6239            None
6240        }
6241    }
6242
6243    /// Name of the method defined in FIDL
6244    pub fn method_name(&self) -> &'static str {
6245        match *self {
6246            StatusWatcherRequest::WatchStatus { .. } => "watch_status",
6247        }
6248    }
6249}
6250
6251#[derive(Debug, Clone)]
6252pub struct StatusWatcherControlHandle {
6253    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6254}
6255
6256impl StatusWatcherControlHandle {
6257    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
6258        self.inner.shutdown_with_epitaph(status.into())
6259    }
6260}
6261
6262impl fidl::endpoints::ControlHandle for StatusWatcherControlHandle {
6263    fn shutdown(&self) {
6264        self.inner.shutdown()
6265    }
6266
6267    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
6268        self.inner.shutdown_with_epitaph(status)
6269    }
6270
6271    fn is_closed(&self) -> bool {
6272        self.inner.channel().is_closed()
6273    }
6274    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6275        self.inner.channel().on_closed()
6276    }
6277
6278    #[cfg(target_os = "fuchsia")]
6279    fn signal_peer(
6280        &self,
6281        clear_mask: zx::Signals,
6282        set_mask: zx::Signals,
6283    ) -> Result<(), zx_status::Status> {
6284        use fidl::Peered;
6285        self.inner.channel().signal_peer(clear_mask, set_mask)
6286    }
6287}
6288
6289impl StatusWatcherControlHandle {}
6290
6291#[must_use = "FIDL methods require a response to be sent"]
6292#[derive(Debug)]
6293pub struct StatusWatcherWatchStatusResponder {
6294    control_handle: std::mem::ManuallyDrop<StatusWatcherControlHandle>,
6295    tx_id: u32,
6296}
6297
6298/// Set the the channel to be shutdown (see [`StatusWatcherControlHandle::shutdown`])
6299/// if the responder is dropped without sending a response, so that the client
6300/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6301impl std::ops::Drop for StatusWatcherWatchStatusResponder {
6302    fn drop(&mut self) {
6303        self.control_handle.shutdown();
6304        // Safety: drops once, never accessed again
6305        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6306    }
6307}
6308
6309impl fidl::endpoints::Responder for StatusWatcherWatchStatusResponder {
6310    type ControlHandle = StatusWatcherControlHandle;
6311
6312    fn control_handle(&self) -> &StatusWatcherControlHandle {
6313        &self.control_handle
6314    }
6315
6316    fn drop_without_shutdown(mut self) {
6317        // Safety: drops once, never accessed again due to mem::forget
6318        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6319        // Prevent Drop from running (which would shut down the channel)
6320        std::mem::forget(self);
6321    }
6322}
6323
6324impl StatusWatcherWatchStatusResponder {
6325    /// Sends a response to the FIDL transaction.
6326    ///
6327    /// Sets the channel to shutdown if an error occurs.
6328    pub fn send(self, mut port_status: &PortStatus) -> Result<(), fidl::Error> {
6329        let _result = self.send_raw(port_status);
6330        if _result.is_err() {
6331            self.control_handle.shutdown();
6332        }
6333        self.drop_without_shutdown();
6334        _result
6335    }
6336
6337    /// Similar to "send" but does not shutdown the channel if an error occurs.
6338    pub fn send_no_shutdown_on_err(self, mut port_status: &PortStatus) -> Result<(), fidl::Error> {
6339        let _result = self.send_raw(port_status);
6340        self.drop_without_shutdown();
6341        _result
6342    }
6343
6344    fn send_raw(&self, mut port_status: &PortStatus) -> Result<(), fidl::Error> {
6345        self.control_handle.inner.send::<StatusWatcherWatchStatusResponse>(
6346            (port_status,),
6347            self.tx_id,
6348            0x1369a8125c0862b9,
6349            fidl::encoding::DynamicFlags::empty(),
6350        )
6351    }
6352}
6353
6354#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6355pub struct ServiceMarker;
6356
6357#[cfg(target_os = "fuchsia")]
6358impl fidl::endpoints::ServiceMarker for ServiceMarker {
6359    type Proxy = ServiceProxy;
6360    type Request = ServiceRequest;
6361    const SERVICE_NAME: &'static str = "fuchsia.hardware.network.Service";
6362}
6363
6364/// A request for one of the member protocols of Service.
6365///
6366#[cfg(target_os = "fuchsia")]
6367pub enum ServiceRequest {
6368    Device(DeviceRequestStream),
6369    DeviceTopology(fidl_fuchsia_device_fs::TopologicalPathRequestStream),
6370}
6371
6372#[cfg(target_os = "fuchsia")]
6373impl fidl::endpoints::ServiceRequest for ServiceRequest {
6374    type Service = ServiceMarker;
6375
6376    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
6377        match name {
6378            "device" => Self::Device(
6379                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
6380            ),
6381            "device_topology" => Self::DeviceTopology(
6382                <fidl_fuchsia_device_fs::TopologicalPathRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
6383            ),
6384            _ => panic!("no such member protocol name for service Service"),
6385        }
6386    }
6387
6388    fn member_names() -> &'static [&'static str] {
6389        &["device", "device_topology"]
6390    }
6391}
6392#[cfg(target_os = "fuchsia")]
6393pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
6394
6395#[cfg(target_os = "fuchsia")]
6396impl fidl::endpoints::ServiceProxy for ServiceProxy {
6397    type Service = ServiceMarker;
6398
6399    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
6400        Self(opener)
6401    }
6402}
6403
6404#[cfg(target_os = "fuchsia")]
6405impl ServiceProxy {
6406    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
6407        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
6408        self.connect_channel_to_device(server_end)?;
6409        Ok(proxy)
6410    }
6411
6412    /// Like `connect_to_device`, but returns a sync proxy.
6413    /// See [`Self::connect_to_device`] for more details.
6414    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
6415        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
6416        self.connect_channel_to_device(server_end)?;
6417        Ok(proxy)
6418    }
6419
6420    /// Like `connect_to_device`, but accepts a server end.
6421    /// See [`Self::connect_to_device`] for more details.
6422    pub fn connect_channel_to_device(
6423        &self,
6424        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
6425    ) -> Result<(), fidl::Error> {
6426        self.0.open_member("device", server_end.into_channel())
6427    }
6428    pub fn connect_to_device_topology(
6429        &self,
6430    ) -> Result<fidl_fuchsia_device_fs::TopologicalPathProxy, fidl::Error> {
6431        let (proxy, server_end) =
6432            fidl::endpoints::create_proxy::<fidl_fuchsia_device_fs::TopologicalPathMarker>();
6433        self.connect_channel_to_device_topology(server_end)?;
6434        Ok(proxy)
6435    }
6436
6437    /// Like `connect_to_device_topology`, but returns a sync proxy.
6438    /// See [`Self::connect_to_device_topology`] for more details.
6439    pub fn connect_to_device_topology_sync(
6440        &self,
6441    ) -> Result<fidl_fuchsia_device_fs::TopologicalPathSynchronousProxy, fidl::Error> {
6442        let (proxy, server_end) =
6443            fidl::endpoints::create_sync_proxy::<fidl_fuchsia_device_fs::TopologicalPathMarker>();
6444        self.connect_channel_to_device_topology(server_end)?;
6445        Ok(proxy)
6446    }
6447
6448    /// Like `connect_to_device_topology`, but accepts a server end.
6449    /// See [`Self::connect_to_device_topology`] for more details.
6450    pub fn connect_channel_to_device_topology(
6451        &self,
6452        server_end: fidl::endpoints::ServerEnd<fidl_fuchsia_device_fs::TopologicalPathMarker>,
6453    ) -> Result<(), fidl::Error> {
6454        self.0.open_member("device_topology", server_end.into_channel())
6455    }
6456
6457    pub fn instance_name(&self) -> &str {
6458        self.0.instance_name()
6459    }
6460}
6461
6462mod internal {
6463    use super::*;
6464
6465    impl fidl::encoding::ResourceTypeMarker for DeviceCloneRequest {
6466        type Borrowed<'a> = &'a mut Self;
6467        fn take_or_borrow<'a>(
6468            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6469        ) -> Self::Borrowed<'a> {
6470            value
6471        }
6472    }
6473
6474    unsafe impl fidl::encoding::TypeMarker for DeviceCloneRequest {
6475        type Owned = Self;
6476
6477        #[inline(always)]
6478        fn inline_align(_context: fidl::encoding::Context) -> usize {
6479            4
6480        }
6481
6482        #[inline(always)]
6483        fn inline_size(_context: fidl::encoding::Context) -> usize {
6484            4
6485        }
6486    }
6487
6488    unsafe impl
6489        fidl::encoding::Encode<DeviceCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6490        for &mut DeviceCloneRequest
6491    {
6492        #[inline]
6493        unsafe fn encode(
6494            self,
6495            encoder: &mut fidl::encoding::Encoder<
6496                '_,
6497                fidl::encoding::DefaultFuchsiaResourceDialect,
6498            >,
6499            offset: usize,
6500            _depth: fidl::encoding::Depth,
6501        ) -> fidl::Result<()> {
6502            encoder.debug_check_bounds::<DeviceCloneRequest>(offset);
6503            // Delegate to tuple encoding.
6504            fidl::encoding::Encode::<DeviceCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6505                (
6506                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.device),
6507                ),
6508                encoder, offset, _depth
6509            )
6510        }
6511    }
6512    unsafe impl<
6513        T0: fidl::encoding::Encode<
6514                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
6515                fidl::encoding::DefaultFuchsiaResourceDialect,
6516            >,
6517    > fidl::encoding::Encode<DeviceCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6518        for (T0,)
6519    {
6520        #[inline]
6521        unsafe fn encode(
6522            self,
6523            encoder: &mut fidl::encoding::Encoder<
6524                '_,
6525                fidl::encoding::DefaultFuchsiaResourceDialect,
6526            >,
6527            offset: usize,
6528            depth: fidl::encoding::Depth,
6529        ) -> fidl::Result<()> {
6530            encoder.debug_check_bounds::<DeviceCloneRequest>(offset);
6531            // Zero out padding regions. There's no need to apply masks
6532            // because the unmasked parts will be overwritten by fields.
6533            // Write the fields.
6534            self.0.encode(encoder, offset + 0, depth)?;
6535            Ok(())
6536        }
6537    }
6538
6539    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6540        for DeviceCloneRequest
6541    {
6542        #[inline(always)]
6543        fn new_empty() -> Self {
6544            Self {
6545                device: fidl::new_empty!(
6546                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
6547                    fidl::encoding::DefaultFuchsiaResourceDialect
6548                ),
6549            }
6550        }
6551
6552        #[inline]
6553        unsafe fn decode(
6554            &mut self,
6555            decoder: &mut fidl::encoding::Decoder<
6556                '_,
6557                fidl::encoding::DefaultFuchsiaResourceDialect,
6558            >,
6559            offset: usize,
6560            _depth: fidl::encoding::Depth,
6561        ) -> fidl::Result<()> {
6562            decoder.debug_check_bounds::<Self>(offset);
6563            // Verify that padding bytes are zero.
6564            fidl::decode!(
6565                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
6566                fidl::encoding::DefaultFuchsiaResourceDialect,
6567                &mut self.device,
6568                decoder,
6569                offset + 0,
6570                _depth
6571            )?;
6572            Ok(())
6573        }
6574    }
6575
6576    impl fidl::encoding::ResourceTypeMarker for DeviceGetPortRequest {
6577        type Borrowed<'a> = &'a mut Self;
6578        fn take_or_borrow<'a>(
6579            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6580        ) -> Self::Borrowed<'a> {
6581            value
6582        }
6583    }
6584
6585    unsafe impl fidl::encoding::TypeMarker for DeviceGetPortRequest {
6586        type Owned = Self;
6587
6588        #[inline(always)]
6589        fn inline_align(_context: fidl::encoding::Context) -> usize {
6590            4
6591        }
6592
6593        #[inline(always)]
6594        fn inline_size(_context: fidl::encoding::Context) -> usize {
6595            8
6596        }
6597    }
6598
6599    unsafe impl
6600        fidl::encoding::Encode<DeviceGetPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6601        for &mut DeviceGetPortRequest
6602    {
6603        #[inline]
6604        unsafe fn encode(
6605            self,
6606            encoder: &mut fidl::encoding::Encoder<
6607                '_,
6608                fidl::encoding::DefaultFuchsiaResourceDialect,
6609            >,
6610            offset: usize,
6611            _depth: fidl::encoding::Depth,
6612        ) -> fidl::Result<()> {
6613            encoder.debug_check_bounds::<DeviceGetPortRequest>(offset);
6614            // Delegate to tuple encoding.
6615            fidl::encoding::Encode::<DeviceGetPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6616                (
6617                    <PortId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
6618                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.port),
6619                ),
6620                encoder, offset, _depth
6621            )
6622        }
6623    }
6624    unsafe impl<
6625        T0: fidl::encoding::Encode<PortId, fidl::encoding::DefaultFuchsiaResourceDialect>,
6626        T1: fidl::encoding::Encode<
6627                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
6628                fidl::encoding::DefaultFuchsiaResourceDialect,
6629            >,
6630    >
6631        fidl::encoding::Encode<DeviceGetPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6632        for (T0, T1)
6633    {
6634        #[inline]
6635        unsafe fn encode(
6636            self,
6637            encoder: &mut fidl::encoding::Encoder<
6638                '_,
6639                fidl::encoding::DefaultFuchsiaResourceDialect,
6640            >,
6641            offset: usize,
6642            depth: fidl::encoding::Depth,
6643        ) -> fidl::Result<()> {
6644            encoder.debug_check_bounds::<DeviceGetPortRequest>(offset);
6645            // Zero out padding regions. There's no need to apply masks
6646            // because the unmasked parts will be overwritten by fields.
6647            unsafe {
6648                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
6649                (ptr as *mut u32).write_unaligned(0);
6650            }
6651            // Write the fields.
6652            self.0.encode(encoder, offset + 0, depth)?;
6653            self.1.encode(encoder, offset + 4, depth)?;
6654            Ok(())
6655        }
6656    }
6657
6658    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6659        for DeviceGetPortRequest
6660    {
6661        #[inline(always)]
6662        fn new_empty() -> Self {
6663            Self {
6664                id: fidl::new_empty!(PortId, fidl::encoding::DefaultFuchsiaResourceDialect),
6665                port: fidl::new_empty!(
6666                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
6667                    fidl::encoding::DefaultFuchsiaResourceDialect
6668                ),
6669            }
6670        }
6671
6672        #[inline]
6673        unsafe fn decode(
6674            &mut self,
6675            decoder: &mut fidl::encoding::Decoder<
6676                '_,
6677                fidl::encoding::DefaultFuchsiaResourceDialect,
6678            >,
6679            offset: usize,
6680            _depth: fidl::encoding::Depth,
6681        ) -> fidl::Result<()> {
6682            decoder.debug_check_bounds::<Self>(offset);
6683            // Verify that padding bytes are zero.
6684            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
6685            let padval = unsafe { (ptr as *const u32).read_unaligned() };
6686            let mask = 0xffff0000u32;
6687            let maskedval = padval & mask;
6688            if maskedval != 0 {
6689                return Err(fidl::Error::NonZeroPadding {
6690                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
6691                });
6692            }
6693            fidl::decode!(
6694                PortId,
6695                fidl::encoding::DefaultFuchsiaResourceDialect,
6696                &mut self.id,
6697                decoder,
6698                offset + 0,
6699                _depth
6700            )?;
6701            fidl::decode!(
6702                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
6703                fidl::encoding::DefaultFuchsiaResourceDialect,
6704                &mut self.port,
6705                decoder,
6706                offset + 4,
6707                _depth
6708            )?;
6709            Ok(())
6710        }
6711    }
6712
6713    impl fidl::encoding::ResourceTypeMarker for DeviceGetPortWatcherRequest {
6714        type Borrowed<'a> = &'a mut Self;
6715        fn take_or_borrow<'a>(
6716            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6717        ) -> Self::Borrowed<'a> {
6718            value
6719        }
6720    }
6721
6722    unsafe impl fidl::encoding::TypeMarker for DeviceGetPortWatcherRequest {
6723        type Owned = Self;
6724
6725        #[inline(always)]
6726        fn inline_align(_context: fidl::encoding::Context) -> usize {
6727            4
6728        }
6729
6730        #[inline(always)]
6731        fn inline_size(_context: fidl::encoding::Context) -> usize {
6732            4
6733        }
6734    }
6735
6736    unsafe impl
6737        fidl::encoding::Encode<
6738            DeviceGetPortWatcherRequest,
6739            fidl::encoding::DefaultFuchsiaResourceDialect,
6740        > for &mut DeviceGetPortWatcherRequest
6741    {
6742        #[inline]
6743        unsafe fn encode(
6744            self,
6745            encoder: &mut fidl::encoding::Encoder<
6746                '_,
6747                fidl::encoding::DefaultFuchsiaResourceDialect,
6748            >,
6749            offset: usize,
6750            _depth: fidl::encoding::Depth,
6751        ) -> fidl::Result<()> {
6752            encoder.debug_check_bounds::<DeviceGetPortWatcherRequest>(offset);
6753            // Delegate to tuple encoding.
6754            fidl::encoding::Encode::<DeviceGetPortWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6755                (
6756                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
6757                ),
6758                encoder, offset, _depth
6759            )
6760        }
6761    }
6762    unsafe impl<
6763        T0: fidl::encoding::Encode<
6764                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortWatcherMarker>>,
6765                fidl::encoding::DefaultFuchsiaResourceDialect,
6766            >,
6767    >
6768        fidl::encoding::Encode<
6769            DeviceGetPortWatcherRequest,
6770            fidl::encoding::DefaultFuchsiaResourceDialect,
6771        > for (T0,)
6772    {
6773        #[inline]
6774        unsafe fn encode(
6775            self,
6776            encoder: &mut fidl::encoding::Encoder<
6777                '_,
6778                fidl::encoding::DefaultFuchsiaResourceDialect,
6779            >,
6780            offset: usize,
6781            depth: fidl::encoding::Depth,
6782        ) -> fidl::Result<()> {
6783            encoder.debug_check_bounds::<DeviceGetPortWatcherRequest>(offset);
6784            // Zero out padding regions. There's no need to apply masks
6785            // because the unmasked parts will be overwritten by fields.
6786            // Write the fields.
6787            self.0.encode(encoder, offset + 0, depth)?;
6788            Ok(())
6789        }
6790    }
6791
6792    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6793        for DeviceGetPortWatcherRequest
6794    {
6795        #[inline(always)]
6796        fn new_empty() -> Self {
6797            Self {
6798                watcher: fidl::new_empty!(
6799                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortWatcherMarker>>,
6800                    fidl::encoding::DefaultFuchsiaResourceDialect
6801                ),
6802            }
6803        }
6804
6805        #[inline]
6806        unsafe fn decode(
6807            &mut self,
6808            decoder: &mut fidl::encoding::Decoder<
6809                '_,
6810                fidl::encoding::DefaultFuchsiaResourceDialect,
6811            >,
6812            offset: usize,
6813            _depth: fidl::encoding::Depth,
6814        ) -> fidl::Result<()> {
6815            decoder.debug_check_bounds::<Self>(offset);
6816            // Verify that padding bytes are zero.
6817            fidl::decode!(
6818                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortWatcherMarker>>,
6819                fidl::encoding::DefaultFuchsiaResourceDialect,
6820                &mut self.watcher,
6821                decoder,
6822                offset + 0,
6823                _depth
6824            )?;
6825            Ok(())
6826        }
6827    }
6828
6829    impl fidl::encoding::ResourceTypeMarker for DeviceOpenSessionRequest {
6830        type Borrowed<'a> = &'a mut Self;
6831        fn take_or_borrow<'a>(
6832            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6833        ) -> Self::Borrowed<'a> {
6834            value
6835        }
6836    }
6837
6838    unsafe impl fidl::encoding::TypeMarker for DeviceOpenSessionRequest {
6839        type Owned = Self;
6840
6841        #[inline(always)]
6842        fn inline_align(_context: fidl::encoding::Context) -> usize {
6843            8
6844        }
6845
6846        #[inline(always)]
6847        fn inline_size(_context: fidl::encoding::Context) -> usize {
6848            32
6849        }
6850    }
6851
6852    unsafe impl
6853        fidl::encoding::Encode<
6854            DeviceOpenSessionRequest,
6855            fidl::encoding::DefaultFuchsiaResourceDialect,
6856        > for &mut DeviceOpenSessionRequest
6857    {
6858        #[inline]
6859        unsafe fn encode(
6860            self,
6861            encoder: &mut fidl::encoding::Encoder<
6862                '_,
6863                fidl::encoding::DefaultFuchsiaResourceDialect,
6864            >,
6865            offset: usize,
6866            _depth: fidl::encoding::Depth,
6867        ) -> fidl::Result<()> {
6868            encoder.debug_check_bounds::<DeviceOpenSessionRequest>(offset);
6869            // Delegate to tuple encoding.
6870            fidl::encoding::Encode::<
6871                DeviceOpenSessionRequest,
6872                fidl::encoding::DefaultFuchsiaResourceDialect,
6873            >::encode(
6874                (
6875                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
6876                        &self.session_name,
6877                    ),
6878                    <SessionInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6879                        &mut self.session_info,
6880                    ),
6881                ),
6882                encoder,
6883                offset,
6884                _depth,
6885            )
6886        }
6887    }
6888    unsafe impl<
6889        T0: fidl::encoding::Encode<
6890                fidl::encoding::BoundedString<64>,
6891                fidl::encoding::DefaultFuchsiaResourceDialect,
6892            >,
6893        T1: fidl::encoding::Encode<SessionInfo, fidl::encoding::DefaultFuchsiaResourceDialect>,
6894    >
6895        fidl::encoding::Encode<
6896            DeviceOpenSessionRequest,
6897            fidl::encoding::DefaultFuchsiaResourceDialect,
6898        > for (T0, T1)
6899    {
6900        #[inline]
6901        unsafe fn encode(
6902            self,
6903            encoder: &mut fidl::encoding::Encoder<
6904                '_,
6905                fidl::encoding::DefaultFuchsiaResourceDialect,
6906            >,
6907            offset: usize,
6908            depth: fidl::encoding::Depth,
6909        ) -> fidl::Result<()> {
6910            encoder.debug_check_bounds::<DeviceOpenSessionRequest>(offset);
6911            // Zero out padding regions. There's no need to apply masks
6912            // because the unmasked parts will be overwritten by fields.
6913            // Write the fields.
6914            self.0.encode(encoder, offset + 0, depth)?;
6915            self.1.encode(encoder, offset + 16, depth)?;
6916            Ok(())
6917        }
6918    }
6919
6920    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6921        for DeviceOpenSessionRequest
6922    {
6923        #[inline(always)]
6924        fn new_empty() -> Self {
6925            Self {
6926                session_name: fidl::new_empty!(
6927                    fidl::encoding::BoundedString<64>,
6928                    fidl::encoding::DefaultFuchsiaResourceDialect
6929                ),
6930                session_info: fidl::new_empty!(
6931                    SessionInfo,
6932                    fidl::encoding::DefaultFuchsiaResourceDialect
6933                ),
6934            }
6935        }
6936
6937        #[inline]
6938        unsafe fn decode(
6939            &mut self,
6940            decoder: &mut fidl::encoding::Decoder<
6941                '_,
6942                fidl::encoding::DefaultFuchsiaResourceDialect,
6943            >,
6944            offset: usize,
6945            _depth: fidl::encoding::Depth,
6946        ) -> fidl::Result<()> {
6947            decoder.debug_check_bounds::<Self>(offset);
6948            // Verify that padding bytes are zero.
6949            fidl::decode!(
6950                fidl::encoding::BoundedString<64>,
6951                fidl::encoding::DefaultFuchsiaResourceDialect,
6952                &mut self.session_name,
6953                decoder,
6954                offset + 0,
6955                _depth
6956            )?;
6957            fidl::decode!(
6958                SessionInfo,
6959                fidl::encoding::DefaultFuchsiaResourceDialect,
6960                &mut self.session_info,
6961                decoder,
6962                offset + 16,
6963                _depth
6964            )?;
6965            Ok(())
6966        }
6967    }
6968
6969    impl fidl::encoding::ResourceTypeMarker for DeviceOpenSessionResponse {
6970        type Borrowed<'a> = &'a mut Self;
6971        fn take_or_borrow<'a>(
6972            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6973        ) -> Self::Borrowed<'a> {
6974            value
6975        }
6976    }
6977
6978    unsafe impl fidl::encoding::TypeMarker for DeviceOpenSessionResponse {
6979        type Owned = Self;
6980
6981        #[inline(always)]
6982        fn inline_align(_context: fidl::encoding::Context) -> usize {
6983            4
6984        }
6985
6986        #[inline(always)]
6987        fn inline_size(_context: fidl::encoding::Context) -> usize {
6988            12
6989        }
6990    }
6991
6992    unsafe impl
6993        fidl::encoding::Encode<
6994            DeviceOpenSessionResponse,
6995            fidl::encoding::DefaultFuchsiaResourceDialect,
6996        > for &mut DeviceOpenSessionResponse
6997    {
6998        #[inline]
6999        unsafe fn encode(
7000            self,
7001            encoder: &mut fidl::encoding::Encoder<
7002                '_,
7003                fidl::encoding::DefaultFuchsiaResourceDialect,
7004            >,
7005            offset: usize,
7006            _depth: fidl::encoding::Depth,
7007        ) -> fidl::Result<()> {
7008            encoder.debug_check_bounds::<DeviceOpenSessionResponse>(offset);
7009            // Delegate to tuple encoding.
7010            fidl::encoding::Encode::<DeviceOpenSessionResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7011                (
7012                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session),
7013                    <Fifos as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.fifos),
7014                ),
7015                encoder, offset, _depth
7016            )
7017        }
7018    }
7019    unsafe impl<
7020        T0: fidl::encoding::Encode<
7021                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionMarker>>,
7022                fidl::encoding::DefaultFuchsiaResourceDialect,
7023            >,
7024        T1: fidl::encoding::Encode<Fifos, fidl::encoding::DefaultFuchsiaResourceDialect>,
7025    >
7026        fidl::encoding::Encode<
7027            DeviceOpenSessionResponse,
7028            fidl::encoding::DefaultFuchsiaResourceDialect,
7029        > for (T0, T1)
7030    {
7031        #[inline]
7032        unsafe fn encode(
7033            self,
7034            encoder: &mut fidl::encoding::Encoder<
7035                '_,
7036                fidl::encoding::DefaultFuchsiaResourceDialect,
7037            >,
7038            offset: usize,
7039            depth: fidl::encoding::Depth,
7040        ) -> fidl::Result<()> {
7041            encoder.debug_check_bounds::<DeviceOpenSessionResponse>(offset);
7042            // Zero out padding regions. There's no need to apply masks
7043            // because the unmasked parts will be overwritten by fields.
7044            // Write the fields.
7045            self.0.encode(encoder, offset + 0, depth)?;
7046            self.1.encode(encoder, offset + 4, depth)?;
7047            Ok(())
7048        }
7049    }
7050
7051    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7052        for DeviceOpenSessionResponse
7053    {
7054        #[inline(always)]
7055        fn new_empty() -> Self {
7056            Self {
7057                session: fidl::new_empty!(
7058                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionMarker>>,
7059                    fidl::encoding::DefaultFuchsiaResourceDialect
7060                ),
7061                fifos: fidl::new_empty!(Fifos, fidl::encoding::DefaultFuchsiaResourceDialect),
7062            }
7063        }
7064
7065        #[inline]
7066        unsafe fn decode(
7067            &mut self,
7068            decoder: &mut fidl::encoding::Decoder<
7069                '_,
7070                fidl::encoding::DefaultFuchsiaResourceDialect,
7071            >,
7072            offset: usize,
7073            _depth: fidl::encoding::Depth,
7074        ) -> fidl::Result<()> {
7075            decoder.debug_check_bounds::<Self>(offset);
7076            // Verify that padding bytes are zero.
7077            fidl::decode!(
7078                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionMarker>>,
7079                fidl::encoding::DefaultFuchsiaResourceDialect,
7080                &mut self.session,
7081                decoder,
7082                offset + 0,
7083                _depth
7084            )?;
7085            fidl::decode!(
7086                Fifos,
7087                fidl::encoding::DefaultFuchsiaResourceDialect,
7088                &mut self.fifos,
7089                decoder,
7090                offset + 4,
7091                _depth
7092            )?;
7093            Ok(())
7094        }
7095    }
7096
7097    impl fidl::encoding::ResourceTypeMarker for Fifos {
7098        type Borrowed<'a> = &'a mut Self;
7099        fn take_or_borrow<'a>(
7100            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7101        ) -> Self::Borrowed<'a> {
7102            value
7103        }
7104    }
7105
7106    unsafe impl fidl::encoding::TypeMarker for Fifos {
7107        type Owned = Self;
7108
7109        #[inline(always)]
7110        fn inline_align(_context: fidl::encoding::Context) -> usize {
7111            4
7112        }
7113
7114        #[inline(always)]
7115        fn inline_size(_context: fidl::encoding::Context) -> usize {
7116            8
7117        }
7118    }
7119
7120    unsafe impl fidl::encoding::Encode<Fifos, fidl::encoding::DefaultFuchsiaResourceDialect>
7121        for &mut Fifos
7122    {
7123        #[inline]
7124        unsafe fn encode(
7125            self,
7126            encoder: &mut fidl::encoding::Encoder<
7127                '_,
7128                fidl::encoding::DefaultFuchsiaResourceDialect,
7129            >,
7130            offset: usize,
7131            _depth: fidl::encoding::Depth,
7132        ) -> fidl::Result<()> {
7133            encoder.debug_check_bounds::<Fifos>(offset);
7134            // Delegate to tuple encoding.
7135            fidl::encoding::Encode::<Fifos, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7136                (
7137                    <fidl::encoding::HandleType<
7138                        fidl::Fifo,
7139                        { fidl::ObjectType::FIFO.into_raw() },
7140                        2147483648,
7141                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7142                        &mut self.rx
7143                    ),
7144                    <fidl::encoding::HandleType<
7145                        fidl::Fifo,
7146                        { fidl::ObjectType::FIFO.into_raw() },
7147                        2147483648,
7148                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7149                        &mut self.tx
7150                    ),
7151                ),
7152                encoder,
7153                offset,
7154                _depth,
7155            )
7156        }
7157    }
7158    unsafe impl<
7159        T0: fidl::encoding::Encode<
7160                fidl::encoding::HandleType<
7161                    fidl::Fifo,
7162                    { fidl::ObjectType::FIFO.into_raw() },
7163                    2147483648,
7164                >,
7165                fidl::encoding::DefaultFuchsiaResourceDialect,
7166            >,
7167        T1: fidl::encoding::Encode<
7168                fidl::encoding::HandleType<
7169                    fidl::Fifo,
7170                    { fidl::ObjectType::FIFO.into_raw() },
7171                    2147483648,
7172                >,
7173                fidl::encoding::DefaultFuchsiaResourceDialect,
7174            >,
7175    > fidl::encoding::Encode<Fifos, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0, T1)
7176    {
7177        #[inline]
7178        unsafe fn encode(
7179            self,
7180            encoder: &mut fidl::encoding::Encoder<
7181                '_,
7182                fidl::encoding::DefaultFuchsiaResourceDialect,
7183            >,
7184            offset: usize,
7185            depth: fidl::encoding::Depth,
7186        ) -> fidl::Result<()> {
7187            encoder.debug_check_bounds::<Fifos>(offset);
7188            // Zero out padding regions. There's no need to apply masks
7189            // because the unmasked parts will be overwritten by fields.
7190            // Write the fields.
7191            self.0.encode(encoder, offset + 0, depth)?;
7192            self.1.encode(encoder, offset + 4, depth)?;
7193            Ok(())
7194        }
7195    }
7196
7197    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Fifos {
7198        #[inline(always)]
7199        fn new_empty() -> Self {
7200            Self {
7201                rx: fidl::new_empty!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
7202                tx: fidl::new_empty!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
7203            }
7204        }
7205
7206        #[inline]
7207        unsafe fn decode(
7208            &mut self,
7209            decoder: &mut fidl::encoding::Decoder<
7210                '_,
7211                fidl::encoding::DefaultFuchsiaResourceDialect,
7212            >,
7213            offset: usize,
7214            _depth: fidl::encoding::Depth,
7215        ) -> fidl::Result<()> {
7216            decoder.debug_check_bounds::<Self>(offset);
7217            // Verify that padding bytes are zero.
7218            fidl::decode!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.rx, decoder, offset + 0, _depth)?;
7219            fidl::decode!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.tx, decoder, offset + 4, _depth)?;
7220            Ok(())
7221        }
7222    }
7223
7224    impl fidl::encoding::ResourceTypeMarker for PortCloneRequest {
7225        type Borrowed<'a> = &'a mut Self;
7226        fn take_or_borrow<'a>(
7227            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7228        ) -> Self::Borrowed<'a> {
7229            value
7230        }
7231    }
7232
7233    unsafe impl fidl::encoding::TypeMarker for PortCloneRequest {
7234        type Owned = Self;
7235
7236        #[inline(always)]
7237        fn inline_align(_context: fidl::encoding::Context) -> usize {
7238            4
7239        }
7240
7241        #[inline(always)]
7242        fn inline_size(_context: fidl::encoding::Context) -> usize {
7243            4
7244        }
7245    }
7246
7247    unsafe impl
7248        fidl::encoding::Encode<PortCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
7249        for &mut PortCloneRequest
7250    {
7251        #[inline]
7252        unsafe fn encode(
7253            self,
7254            encoder: &mut fidl::encoding::Encoder<
7255                '_,
7256                fidl::encoding::DefaultFuchsiaResourceDialect,
7257            >,
7258            offset: usize,
7259            _depth: fidl::encoding::Depth,
7260        ) -> fidl::Result<()> {
7261            encoder.debug_check_bounds::<PortCloneRequest>(offset);
7262            // Delegate to tuple encoding.
7263            fidl::encoding::Encode::<PortCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7264                (
7265                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.port),
7266                ),
7267                encoder, offset, _depth
7268            )
7269        }
7270    }
7271    unsafe impl<
7272        T0: fidl::encoding::Encode<
7273                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
7274                fidl::encoding::DefaultFuchsiaResourceDialect,
7275            >,
7276    > fidl::encoding::Encode<PortCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
7277        for (T0,)
7278    {
7279        #[inline]
7280        unsafe fn encode(
7281            self,
7282            encoder: &mut fidl::encoding::Encoder<
7283                '_,
7284                fidl::encoding::DefaultFuchsiaResourceDialect,
7285            >,
7286            offset: usize,
7287            depth: fidl::encoding::Depth,
7288        ) -> fidl::Result<()> {
7289            encoder.debug_check_bounds::<PortCloneRequest>(offset);
7290            // Zero out padding regions. There's no need to apply masks
7291            // because the unmasked parts will be overwritten by fields.
7292            // Write the fields.
7293            self.0.encode(encoder, offset + 0, depth)?;
7294            Ok(())
7295        }
7296    }
7297
7298    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7299        for PortCloneRequest
7300    {
7301        #[inline(always)]
7302        fn new_empty() -> Self {
7303            Self {
7304                port: fidl::new_empty!(
7305                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
7306                    fidl::encoding::DefaultFuchsiaResourceDialect
7307                ),
7308            }
7309        }
7310
7311        #[inline]
7312        unsafe fn decode(
7313            &mut self,
7314            decoder: &mut fidl::encoding::Decoder<
7315                '_,
7316                fidl::encoding::DefaultFuchsiaResourceDialect,
7317            >,
7318            offset: usize,
7319            _depth: fidl::encoding::Depth,
7320        ) -> fidl::Result<()> {
7321            decoder.debug_check_bounds::<Self>(offset);
7322            // Verify that padding bytes are zero.
7323            fidl::decode!(
7324                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
7325                fidl::encoding::DefaultFuchsiaResourceDialect,
7326                &mut self.port,
7327                decoder,
7328                offset + 0,
7329                _depth
7330            )?;
7331            Ok(())
7332        }
7333    }
7334
7335    impl fidl::encoding::ResourceTypeMarker for PortGetDeviceRequest {
7336        type Borrowed<'a> = &'a mut Self;
7337        fn take_or_borrow<'a>(
7338            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7339        ) -> Self::Borrowed<'a> {
7340            value
7341        }
7342    }
7343
7344    unsafe impl fidl::encoding::TypeMarker for PortGetDeviceRequest {
7345        type Owned = Self;
7346
7347        #[inline(always)]
7348        fn inline_align(_context: fidl::encoding::Context) -> usize {
7349            4
7350        }
7351
7352        #[inline(always)]
7353        fn inline_size(_context: fidl::encoding::Context) -> usize {
7354            4
7355        }
7356    }
7357
7358    unsafe impl
7359        fidl::encoding::Encode<PortGetDeviceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
7360        for &mut PortGetDeviceRequest
7361    {
7362        #[inline]
7363        unsafe fn encode(
7364            self,
7365            encoder: &mut fidl::encoding::Encoder<
7366                '_,
7367                fidl::encoding::DefaultFuchsiaResourceDialect,
7368            >,
7369            offset: usize,
7370            _depth: fidl::encoding::Depth,
7371        ) -> fidl::Result<()> {
7372            encoder.debug_check_bounds::<PortGetDeviceRequest>(offset);
7373            // Delegate to tuple encoding.
7374            fidl::encoding::Encode::<PortGetDeviceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7375                (
7376                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.device),
7377                ),
7378                encoder, offset, _depth
7379            )
7380        }
7381    }
7382    unsafe impl<
7383        T0: fidl::encoding::Encode<
7384                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
7385                fidl::encoding::DefaultFuchsiaResourceDialect,
7386            >,
7387    >
7388        fidl::encoding::Encode<PortGetDeviceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
7389        for (T0,)
7390    {
7391        #[inline]
7392        unsafe fn encode(
7393            self,
7394            encoder: &mut fidl::encoding::Encoder<
7395                '_,
7396                fidl::encoding::DefaultFuchsiaResourceDialect,
7397            >,
7398            offset: usize,
7399            depth: fidl::encoding::Depth,
7400        ) -> fidl::Result<()> {
7401            encoder.debug_check_bounds::<PortGetDeviceRequest>(offset);
7402            // Zero out padding regions. There's no need to apply masks
7403            // because the unmasked parts will be overwritten by fields.
7404            // Write the fields.
7405            self.0.encode(encoder, offset + 0, depth)?;
7406            Ok(())
7407        }
7408    }
7409
7410    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7411        for PortGetDeviceRequest
7412    {
7413        #[inline(always)]
7414        fn new_empty() -> Self {
7415            Self {
7416                device: fidl::new_empty!(
7417                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
7418                    fidl::encoding::DefaultFuchsiaResourceDialect
7419                ),
7420            }
7421        }
7422
7423        #[inline]
7424        unsafe fn decode(
7425            &mut self,
7426            decoder: &mut fidl::encoding::Decoder<
7427                '_,
7428                fidl::encoding::DefaultFuchsiaResourceDialect,
7429            >,
7430            offset: usize,
7431            _depth: fidl::encoding::Depth,
7432        ) -> fidl::Result<()> {
7433            decoder.debug_check_bounds::<Self>(offset);
7434            // Verify that padding bytes are zero.
7435            fidl::decode!(
7436                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
7437                fidl::encoding::DefaultFuchsiaResourceDialect,
7438                &mut self.device,
7439                decoder,
7440                offset + 0,
7441                _depth
7442            )?;
7443            Ok(())
7444        }
7445    }
7446
7447    impl fidl::encoding::ResourceTypeMarker for PortGetDiagnosticsRequest {
7448        type Borrowed<'a> = &'a mut Self;
7449        fn take_or_borrow<'a>(
7450            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7451        ) -> Self::Borrowed<'a> {
7452            value
7453        }
7454    }
7455
7456    unsafe impl fidl::encoding::TypeMarker for PortGetDiagnosticsRequest {
7457        type Owned = Self;
7458
7459        #[inline(always)]
7460        fn inline_align(_context: fidl::encoding::Context) -> usize {
7461            4
7462        }
7463
7464        #[inline(always)]
7465        fn inline_size(_context: fidl::encoding::Context) -> usize {
7466            4
7467        }
7468    }
7469
7470    unsafe impl
7471        fidl::encoding::Encode<
7472            PortGetDiagnosticsRequest,
7473            fidl::encoding::DefaultFuchsiaResourceDialect,
7474        > for &mut PortGetDiagnosticsRequest
7475    {
7476        #[inline]
7477        unsafe fn encode(
7478            self,
7479            encoder: &mut fidl::encoding::Encoder<
7480                '_,
7481                fidl::encoding::DefaultFuchsiaResourceDialect,
7482            >,
7483            offset: usize,
7484            _depth: fidl::encoding::Depth,
7485        ) -> fidl::Result<()> {
7486            encoder.debug_check_bounds::<PortGetDiagnosticsRequest>(offset);
7487            // Delegate to tuple encoding.
7488            fidl::encoding::Encode::<PortGetDiagnosticsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7489                (
7490                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiagnosticsMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.diagnostics),
7491                ),
7492                encoder, offset, _depth
7493            )
7494        }
7495    }
7496    unsafe impl<
7497        T0: fidl::encoding::Encode<
7498                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiagnosticsMarker>>,
7499                fidl::encoding::DefaultFuchsiaResourceDialect,
7500            >,
7501    >
7502        fidl::encoding::Encode<
7503            PortGetDiagnosticsRequest,
7504            fidl::encoding::DefaultFuchsiaResourceDialect,
7505        > for (T0,)
7506    {
7507        #[inline]
7508        unsafe fn encode(
7509            self,
7510            encoder: &mut fidl::encoding::Encoder<
7511                '_,
7512                fidl::encoding::DefaultFuchsiaResourceDialect,
7513            >,
7514            offset: usize,
7515            depth: fidl::encoding::Depth,
7516        ) -> fidl::Result<()> {
7517            encoder.debug_check_bounds::<PortGetDiagnosticsRequest>(offset);
7518            // Zero out padding regions. There's no need to apply masks
7519            // because the unmasked parts will be overwritten by fields.
7520            // Write the fields.
7521            self.0.encode(encoder, offset + 0, depth)?;
7522            Ok(())
7523        }
7524    }
7525
7526    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7527        for PortGetDiagnosticsRequest
7528    {
7529        #[inline(always)]
7530        fn new_empty() -> Self {
7531            Self {
7532                diagnostics: fidl::new_empty!(
7533                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiagnosticsMarker>>,
7534                    fidl::encoding::DefaultFuchsiaResourceDialect
7535                ),
7536            }
7537        }
7538
7539        #[inline]
7540        unsafe fn decode(
7541            &mut self,
7542            decoder: &mut fidl::encoding::Decoder<
7543                '_,
7544                fidl::encoding::DefaultFuchsiaResourceDialect,
7545            >,
7546            offset: usize,
7547            _depth: fidl::encoding::Depth,
7548        ) -> fidl::Result<()> {
7549            decoder.debug_check_bounds::<Self>(offset);
7550            // Verify that padding bytes are zero.
7551            fidl::decode!(
7552                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DiagnosticsMarker>>,
7553                fidl::encoding::DefaultFuchsiaResourceDialect,
7554                &mut self.diagnostics,
7555                decoder,
7556                offset + 0,
7557                _depth
7558            )?;
7559            Ok(())
7560        }
7561    }
7562
7563    impl fidl::encoding::ResourceTypeMarker for PortGetIdentityResponse {
7564        type Borrowed<'a> = &'a mut Self;
7565        fn take_or_borrow<'a>(
7566            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7567        ) -> Self::Borrowed<'a> {
7568            value
7569        }
7570    }
7571
7572    unsafe impl fidl::encoding::TypeMarker for PortGetIdentityResponse {
7573        type Owned = Self;
7574
7575        #[inline(always)]
7576        fn inline_align(_context: fidl::encoding::Context) -> usize {
7577            4
7578        }
7579
7580        #[inline(always)]
7581        fn inline_size(_context: fidl::encoding::Context) -> usize {
7582            4
7583        }
7584    }
7585
7586    unsafe impl
7587        fidl::encoding::Encode<
7588            PortGetIdentityResponse,
7589            fidl::encoding::DefaultFuchsiaResourceDialect,
7590        > for &mut PortGetIdentityResponse
7591    {
7592        #[inline]
7593        unsafe fn encode(
7594            self,
7595            encoder: &mut fidl::encoding::Encoder<
7596                '_,
7597                fidl::encoding::DefaultFuchsiaResourceDialect,
7598            >,
7599            offset: usize,
7600            _depth: fidl::encoding::Depth,
7601        ) -> fidl::Result<()> {
7602            encoder.debug_check_bounds::<PortGetIdentityResponse>(offset);
7603            // Delegate to tuple encoding.
7604            fidl::encoding::Encode::<
7605                PortGetIdentityResponse,
7606                fidl::encoding::DefaultFuchsiaResourceDialect,
7607            >::encode(
7608                (<fidl::encoding::HandleType<
7609                    fidl::Event,
7610                    { fidl::ObjectType::EVENT.into_raw() },
7611                    3,
7612                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7613                    &mut self.event
7614                ),),
7615                encoder,
7616                offset,
7617                _depth,
7618            )
7619        }
7620    }
7621    unsafe impl<
7622        T0: fidl::encoding::Encode<
7623                fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>,
7624                fidl::encoding::DefaultFuchsiaResourceDialect,
7625            >,
7626    >
7627        fidl::encoding::Encode<
7628            PortGetIdentityResponse,
7629            fidl::encoding::DefaultFuchsiaResourceDialect,
7630        > for (T0,)
7631    {
7632        #[inline]
7633        unsafe fn encode(
7634            self,
7635            encoder: &mut fidl::encoding::Encoder<
7636                '_,
7637                fidl::encoding::DefaultFuchsiaResourceDialect,
7638            >,
7639            offset: usize,
7640            depth: fidl::encoding::Depth,
7641        ) -> fidl::Result<()> {
7642            encoder.debug_check_bounds::<PortGetIdentityResponse>(offset);
7643            // Zero out padding regions. There's no need to apply masks
7644            // because the unmasked parts will be overwritten by fields.
7645            // Write the fields.
7646            self.0.encode(encoder, offset + 0, depth)?;
7647            Ok(())
7648        }
7649    }
7650
7651    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7652        for PortGetIdentityResponse
7653    {
7654        #[inline(always)]
7655        fn new_empty() -> Self {
7656            Self {
7657                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>, fidl::encoding::DefaultFuchsiaResourceDialect),
7658            }
7659        }
7660
7661        #[inline]
7662        unsafe fn decode(
7663            &mut self,
7664            decoder: &mut fidl::encoding::Decoder<
7665                '_,
7666                fidl::encoding::DefaultFuchsiaResourceDialect,
7667            >,
7668            offset: usize,
7669            _depth: fidl::encoding::Depth,
7670        ) -> fidl::Result<()> {
7671            decoder.debug_check_bounds::<Self>(offset);
7672            // Verify that padding bytes are zero.
7673            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
7674            Ok(())
7675        }
7676    }
7677
7678    impl fidl::encoding::ResourceTypeMarker for PortGetMacRequest {
7679        type Borrowed<'a> = &'a mut Self;
7680        fn take_or_borrow<'a>(
7681            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7682        ) -> Self::Borrowed<'a> {
7683            value
7684        }
7685    }
7686
7687    unsafe impl fidl::encoding::TypeMarker for PortGetMacRequest {
7688        type Owned = Self;
7689
7690        #[inline(always)]
7691        fn inline_align(_context: fidl::encoding::Context) -> usize {
7692            4
7693        }
7694
7695        #[inline(always)]
7696        fn inline_size(_context: fidl::encoding::Context) -> usize {
7697            4
7698        }
7699    }
7700
7701    unsafe impl
7702        fidl::encoding::Encode<PortGetMacRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
7703        for &mut PortGetMacRequest
7704    {
7705        #[inline]
7706        unsafe fn encode(
7707            self,
7708            encoder: &mut fidl::encoding::Encoder<
7709                '_,
7710                fidl::encoding::DefaultFuchsiaResourceDialect,
7711            >,
7712            offset: usize,
7713            _depth: fidl::encoding::Depth,
7714        ) -> fidl::Result<()> {
7715            encoder.debug_check_bounds::<PortGetMacRequest>(offset);
7716            // Delegate to tuple encoding.
7717            fidl::encoding::Encode::<PortGetMacRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7718                (
7719                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MacAddressingMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.mac),
7720                ),
7721                encoder, offset, _depth
7722            )
7723        }
7724    }
7725    unsafe impl<
7726        T0: fidl::encoding::Encode<
7727                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MacAddressingMarker>>,
7728                fidl::encoding::DefaultFuchsiaResourceDialect,
7729            >,
7730    > fidl::encoding::Encode<PortGetMacRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
7731        for (T0,)
7732    {
7733        #[inline]
7734        unsafe fn encode(
7735            self,
7736            encoder: &mut fidl::encoding::Encoder<
7737                '_,
7738                fidl::encoding::DefaultFuchsiaResourceDialect,
7739            >,
7740            offset: usize,
7741            depth: fidl::encoding::Depth,
7742        ) -> fidl::Result<()> {
7743            encoder.debug_check_bounds::<PortGetMacRequest>(offset);
7744            // Zero out padding regions. There's no need to apply masks
7745            // because the unmasked parts will be overwritten by fields.
7746            // Write the fields.
7747            self.0.encode(encoder, offset + 0, depth)?;
7748            Ok(())
7749        }
7750    }
7751
7752    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7753        for PortGetMacRequest
7754    {
7755        #[inline(always)]
7756        fn new_empty() -> Self {
7757            Self {
7758                mac: fidl::new_empty!(
7759                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MacAddressingMarker>>,
7760                    fidl::encoding::DefaultFuchsiaResourceDialect
7761                ),
7762            }
7763        }
7764
7765        #[inline]
7766        unsafe fn decode(
7767            &mut self,
7768            decoder: &mut fidl::encoding::Decoder<
7769                '_,
7770                fidl::encoding::DefaultFuchsiaResourceDialect,
7771            >,
7772            offset: usize,
7773            _depth: fidl::encoding::Depth,
7774        ) -> fidl::Result<()> {
7775            decoder.debug_check_bounds::<Self>(offset);
7776            // Verify that padding bytes are zero.
7777            fidl::decode!(
7778                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MacAddressingMarker>>,
7779                fidl::encoding::DefaultFuchsiaResourceDialect,
7780                &mut self.mac,
7781                decoder,
7782                offset + 0,
7783                _depth
7784            )?;
7785            Ok(())
7786        }
7787    }
7788
7789    impl fidl::encoding::ResourceTypeMarker for PortGetPowerDependencyTokenResponse {
7790        type Borrowed<'a> = &'a mut Self;
7791        fn take_or_borrow<'a>(
7792            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7793        ) -> Self::Borrowed<'a> {
7794            value
7795        }
7796    }
7797
7798    unsafe impl fidl::encoding::TypeMarker for PortGetPowerDependencyTokenResponse {
7799        type Owned = Self;
7800
7801        #[inline(always)]
7802        fn inline_align(_context: fidl::encoding::Context) -> usize {
7803            4
7804        }
7805
7806        #[inline(always)]
7807        fn inline_size(_context: fidl::encoding::Context) -> usize {
7808            4
7809        }
7810    }
7811
7812    unsafe impl
7813        fidl::encoding::Encode<
7814            PortGetPowerDependencyTokenResponse,
7815            fidl::encoding::DefaultFuchsiaResourceDialect,
7816        > for &mut PortGetPowerDependencyTokenResponse
7817    {
7818        #[inline]
7819        unsafe fn encode(
7820            self,
7821            encoder: &mut fidl::encoding::Encoder<
7822                '_,
7823                fidl::encoding::DefaultFuchsiaResourceDialect,
7824            >,
7825            offset: usize,
7826            _depth: fidl::encoding::Depth,
7827        ) -> fidl::Result<()> {
7828            encoder.debug_check_bounds::<PortGetPowerDependencyTokenResponse>(offset);
7829            // Delegate to tuple encoding.
7830            fidl::encoding::Encode::<
7831                PortGetPowerDependencyTokenResponse,
7832                fidl::encoding::DefaultFuchsiaResourceDialect,
7833            >::encode(
7834                (<fidl::encoding::Optional<
7835                    fidl::encoding::HandleType<
7836                        fidl::Event,
7837                        { fidl::ObjectType::EVENT.into_raw() },
7838                        2147483648,
7839                    >,
7840                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7841                    &mut self.token
7842                ),),
7843                encoder,
7844                offset,
7845                _depth,
7846            )
7847        }
7848    }
7849    unsafe impl<
7850        T0: fidl::encoding::Encode<
7851                fidl::encoding::Optional<
7852                    fidl::encoding::HandleType<
7853                        fidl::Event,
7854                        { fidl::ObjectType::EVENT.into_raw() },
7855                        2147483648,
7856                    >,
7857                >,
7858                fidl::encoding::DefaultFuchsiaResourceDialect,
7859            >,
7860    >
7861        fidl::encoding::Encode<
7862            PortGetPowerDependencyTokenResponse,
7863            fidl::encoding::DefaultFuchsiaResourceDialect,
7864        > for (T0,)
7865    {
7866        #[inline]
7867        unsafe fn encode(
7868            self,
7869            encoder: &mut fidl::encoding::Encoder<
7870                '_,
7871                fidl::encoding::DefaultFuchsiaResourceDialect,
7872            >,
7873            offset: usize,
7874            depth: fidl::encoding::Depth,
7875        ) -> fidl::Result<()> {
7876            encoder.debug_check_bounds::<PortGetPowerDependencyTokenResponse>(offset);
7877            // Zero out padding regions. There's no need to apply masks
7878            // because the unmasked parts will be overwritten by fields.
7879            // Write the fields.
7880            self.0.encode(encoder, offset + 0, depth)?;
7881            Ok(())
7882        }
7883    }
7884
7885    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7886        for PortGetPowerDependencyTokenResponse
7887    {
7888        #[inline(always)]
7889        fn new_empty() -> Self {
7890            Self {
7891                token: fidl::new_empty!(
7892                    fidl::encoding::Optional<
7893                        fidl::encoding::HandleType<
7894                            fidl::Event,
7895                            { fidl::ObjectType::EVENT.into_raw() },
7896                            2147483648,
7897                        >,
7898                    >,
7899                    fidl::encoding::DefaultFuchsiaResourceDialect
7900                ),
7901            }
7902        }
7903
7904        #[inline]
7905        unsafe fn decode(
7906            &mut self,
7907            decoder: &mut fidl::encoding::Decoder<
7908                '_,
7909                fidl::encoding::DefaultFuchsiaResourceDialect,
7910            >,
7911            offset: usize,
7912            _depth: fidl::encoding::Depth,
7913        ) -> fidl::Result<()> {
7914            decoder.debug_check_bounds::<Self>(offset);
7915            // Verify that padding bytes are zero.
7916            fidl::decode!(
7917                fidl::encoding::Optional<
7918                    fidl::encoding::HandleType<
7919                        fidl::Event,
7920                        { fidl::ObjectType::EVENT.into_raw() },
7921                        2147483648,
7922                    >,
7923                >,
7924                fidl::encoding::DefaultFuchsiaResourceDialect,
7925                &mut self.token,
7926                decoder,
7927                offset + 0,
7928                _depth
7929            )?;
7930            Ok(())
7931        }
7932    }
7933
7934    impl fidl::encoding::ResourceTypeMarker for PortGetStatusWatcherRequest {
7935        type Borrowed<'a> = &'a mut Self;
7936        fn take_or_borrow<'a>(
7937            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7938        ) -> Self::Borrowed<'a> {
7939            value
7940        }
7941    }
7942
7943    unsafe impl fidl::encoding::TypeMarker for PortGetStatusWatcherRequest {
7944        type Owned = Self;
7945
7946        #[inline(always)]
7947        fn inline_align(_context: fidl::encoding::Context) -> usize {
7948            4
7949        }
7950
7951        #[inline(always)]
7952        fn inline_size(_context: fidl::encoding::Context) -> usize {
7953            8
7954        }
7955    }
7956
7957    unsafe impl
7958        fidl::encoding::Encode<
7959            PortGetStatusWatcherRequest,
7960            fidl::encoding::DefaultFuchsiaResourceDialect,
7961        > for &mut PortGetStatusWatcherRequest
7962    {
7963        #[inline]
7964        unsafe fn encode(
7965            self,
7966            encoder: &mut fidl::encoding::Encoder<
7967                '_,
7968                fidl::encoding::DefaultFuchsiaResourceDialect,
7969            >,
7970            offset: usize,
7971            _depth: fidl::encoding::Depth,
7972        ) -> fidl::Result<()> {
7973            encoder.debug_check_bounds::<PortGetStatusWatcherRequest>(offset);
7974            // Delegate to tuple encoding.
7975            fidl::encoding::Encode::<PortGetStatusWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7976                (
7977                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StatusWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
7978                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer),
7979                ),
7980                encoder, offset, _depth
7981            )
7982        }
7983    }
7984    unsafe impl<
7985        T0: fidl::encoding::Encode<
7986                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StatusWatcherMarker>>,
7987                fidl::encoding::DefaultFuchsiaResourceDialect,
7988            >,
7989        T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
7990    >
7991        fidl::encoding::Encode<
7992            PortGetStatusWatcherRequest,
7993            fidl::encoding::DefaultFuchsiaResourceDialect,
7994        > for (T0, T1)
7995    {
7996        #[inline]
7997        unsafe fn encode(
7998            self,
7999            encoder: &mut fidl::encoding::Encoder<
8000                '_,
8001                fidl::encoding::DefaultFuchsiaResourceDialect,
8002            >,
8003            offset: usize,
8004            depth: fidl::encoding::Depth,
8005        ) -> fidl::Result<()> {
8006            encoder.debug_check_bounds::<PortGetStatusWatcherRequest>(offset);
8007            // Zero out padding regions. There's no need to apply masks
8008            // because the unmasked parts will be overwritten by fields.
8009            // Write the fields.
8010            self.0.encode(encoder, offset + 0, depth)?;
8011            self.1.encode(encoder, offset + 4, depth)?;
8012            Ok(())
8013        }
8014    }
8015
8016    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8017        for PortGetStatusWatcherRequest
8018    {
8019        #[inline(always)]
8020        fn new_empty() -> Self {
8021            Self {
8022                watcher: fidl::new_empty!(
8023                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StatusWatcherMarker>>,
8024                    fidl::encoding::DefaultFuchsiaResourceDialect
8025                ),
8026                buffer: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
8027            }
8028        }
8029
8030        #[inline]
8031        unsafe fn decode(
8032            &mut self,
8033            decoder: &mut fidl::encoding::Decoder<
8034                '_,
8035                fidl::encoding::DefaultFuchsiaResourceDialect,
8036            >,
8037            offset: usize,
8038            _depth: fidl::encoding::Depth,
8039        ) -> fidl::Result<()> {
8040            decoder.debug_check_bounds::<Self>(offset);
8041            // Verify that padding bytes are zero.
8042            fidl::decode!(
8043                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StatusWatcherMarker>>,
8044                fidl::encoding::DefaultFuchsiaResourceDialect,
8045                &mut self.watcher,
8046                decoder,
8047                offset + 0,
8048                _depth
8049            )?;
8050            fidl::decode!(
8051                u32,
8052                fidl::encoding::DefaultFuchsiaResourceDialect,
8053                &mut self.buffer,
8054                decoder,
8055                offset + 4,
8056                _depth
8057            )?;
8058            Ok(())
8059        }
8060    }
8061
8062    impl fidl::encoding::ResourceTypeMarker for SessionRegisterForTxRequest {
8063        type Borrowed<'a> = &'a mut Self;
8064        fn take_or_borrow<'a>(
8065            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8066        ) -> Self::Borrowed<'a> {
8067            value
8068        }
8069    }
8070
8071    unsafe impl fidl::encoding::TypeMarker for SessionRegisterForTxRequest {
8072        type Owned = Self;
8073
8074        #[inline(always)]
8075        fn inline_align(_context: fidl::encoding::Context) -> usize {
8076            8
8077        }
8078
8079        #[inline(always)]
8080        fn inline_size(_context: fidl::encoding::Context) -> usize {
8081            16
8082        }
8083    }
8084
8085    unsafe impl
8086        fidl::encoding::Encode<
8087            SessionRegisterForTxRequest,
8088            fidl::encoding::DefaultFuchsiaResourceDialect,
8089        > for &mut SessionRegisterForTxRequest
8090    {
8091        #[inline]
8092        unsafe fn encode(
8093            self,
8094            encoder: &mut fidl::encoding::Encoder<
8095                '_,
8096                fidl::encoding::DefaultFuchsiaResourceDialect,
8097            >,
8098            offset: usize,
8099            _depth: fidl::encoding::Depth,
8100        ) -> fidl::Result<()> {
8101            encoder.debug_check_bounds::<SessionRegisterForTxRequest>(offset);
8102            // Delegate to tuple encoding.
8103            fidl::encoding::Encode::<
8104                SessionRegisterForTxRequest,
8105                fidl::encoding::DefaultFuchsiaResourceDialect,
8106            >::encode(
8107                (<fidl::encoding::Vector<u8, 32> as fidl::encoding::ValueTypeMarker>::borrow(
8108                    &self.vmos,
8109                ),),
8110                encoder,
8111                offset,
8112                _depth,
8113            )
8114        }
8115    }
8116    unsafe impl<
8117        T0: fidl::encoding::Encode<
8118                fidl::encoding::Vector<u8, 32>,
8119                fidl::encoding::DefaultFuchsiaResourceDialect,
8120            >,
8121    >
8122        fidl::encoding::Encode<
8123            SessionRegisterForTxRequest,
8124            fidl::encoding::DefaultFuchsiaResourceDialect,
8125        > for (T0,)
8126    {
8127        #[inline]
8128        unsafe fn encode(
8129            self,
8130            encoder: &mut fidl::encoding::Encoder<
8131                '_,
8132                fidl::encoding::DefaultFuchsiaResourceDialect,
8133            >,
8134            offset: usize,
8135            depth: fidl::encoding::Depth,
8136        ) -> fidl::Result<()> {
8137            encoder.debug_check_bounds::<SessionRegisterForTxRequest>(offset);
8138            // Zero out padding regions. There's no need to apply masks
8139            // because the unmasked parts will be overwritten by fields.
8140            // Write the fields.
8141            self.0.encode(encoder, offset + 0, depth)?;
8142            Ok(())
8143        }
8144    }
8145
8146    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8147        for SessionRegisterForTxRequest
8148    {
8149        #[inline(always)]
8150        fn new_empty() -> Self {
8151            Self {
8152                vmos: fidl::new_empty!(fidl::encoding::Vector<u8, 32>, fidl::encoding::DefaultFuchsiaResourceDialect),
8153            }
8154        }
8155
8156        #[inline]
8157        unsafe fn decode(
8158            &mut self,
8159            decoder: &mut fidl::encoding::Decoder<
8160                '_,
8161                fidl::encoding::DefaultFuchsiaResourceDialect,
8162            >,
8163            offset: usize,
8164            _depth: fidl::encoding::Depth,
8165        ) -> fidl::Result<()> {
8166            decoder.debug_check_bounds::<Self>(offset);
8167            // Verify that padding bytes are zero.
8168            fidl::decode!(fidl::encoding::Vector<u8, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmos, decoder, offset + 0, _depth)?;
8169            Ok(())
8170        }
8171    }
8172
8173    impl fidl::encoding::ResourceTypeMarker for SessionUnregisterForTxRequest {
8174        type Borrowed<'a> = &'a mut Self;
8175        fn take_or_borrow<'a>(
8176            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8177        ) -> Self::Borrowed<'a> {
8178            value
8179        }
8180    }
8181
8182    unsafe impl fidl::encoding::TypeMarker for SessionUnregisterForTxRequest {
8183        type Owned = Self;
8184
8185        #[inline(always)]
8186        fn inline_align(_context: fidl::encoding::Context) -> usize {
8187            8
8188        }
8189
8190        #[inline(always)]
8191        fn inline_size(_context: fidl::encoding::Context) -> usize {
8192            16
8193        }
8194    }
8195
8196    unsafe impl
8197        fidl::encoding::Encode<
8198            SessionUnregisterForTxRequest,
8199            fidl::encoding::DefaultFuchsiaResourceDialect,
8200        > for &mut SessionUnregisterForTxRequest
8201    {
8202        #[inline]
8203        unsafe fn encode(
8204            self,
8205            encoder: &mut fidl::encoding::Encoder<
8206                '_,
8207                fidl::encoding::DefaultFuchsiaResourceDialect,
8208            >,
8209            offset: usize,
8210            _depth: fidl::encoding::Depth,
8211        ) -> fidl::Result<()> {
8212            encoder.debug_check_bounds::<SessionUnregisterForTxRequest>(offset);
8213            // Delegate to tuple encoding.
8214            fidl::encoding::Encode::<
8215                SessionUnregisterForTxRequest,
8216                fidl::encoding::DefaultFuchsiaResourceDialect,
8217            >::encode(
8218                (<fidl::encoding::Vector<u8, 32> as fidl::encoding::ValueTypeMarker>::borrow(
8219                    &self.vmos,
8220                ),),
8221                encoder,
8222                offset,
8223                _depth,
8224            )
8225        }
8226    }
8227    unsafe impl<
8228        T0: fidl::encoding::Encode<
8229                fidl::encoding::Vector<u8, 32>,
8230                fidl::encoding::DefaultFuchsiaResourceDialect,
8231            >,
8232    >
8233        fidl::encoding::Encode<
8234            SessionUnregisterForTxRequest,
8235            fidl::encoding::DefaultFuchsiaResourceDialect,
8236        > for (T0,)
8237    {
8238        #[inline]
8239        unsafe fn encode(
8240            self,
8241            encoder: &mut fidl::encoding::Encoder<
8242                '_,
8243                fidl::encoding::DefaultFuchsiaResourceDialect,
8244            >,
8245            offset: usize,
8246            depth: fidl::encoding::Depth,
8247        ) -> fidl::Result<()> {
8248            encoder.debug_check_bounds::<SessionUnregisterForTxRequest>(offset);
8249            // Zero out padding regions. There's no need to apply masks
8250            // because the unmasked parts will be overwritten by fields.
8251            // Write the fields.
8252            self.0.encode(encoder, offset + 0, depth)?;
8253            Ok(())
8254        }
8255    }
8256
8257    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8258        for SessionUnregisterForTxRequest
8259    {
8260        #[inline(always)]
8261        fn new_empty() -> Self {
8262            Self {
8263                vmos: fidl::new_empty!(fidl::encoding::Vector<u8, 32>, fidl::encoding::DefaultFuchsiaResourceDialect),
8264            }
8265        }
8266
8267        #[inline]
8268        unsafe fn decode(
8269            &mut self,
8270            decoder: &mut fidl::encoding::Decoder<
8271                '_,
8272                fidl::encoding::DefaultFuchsiaResourceDialect,
8273            >,
8274            offset: usize,
8275            _depth: fidl::encoding::Depth,
8276        ) -> fidl::Result<()> {
8277            decoder.debug_check_bounds::<Self>(offset);
8278            // Verify that padding bytes are zero.
8279            fidl::decode!(fidl::encoding::Vector<u8, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmos, decoder, offset + 0, _depth)?;
8280            Ok(())
8281        }
8282    }
8283
8284    impl fidl::encoding::ResourceTypeMarker for SessionWatchDelegatedRxLeaseResponse {
8285        type Borrowed<'a> = &'a mut Self;
8286        fn take_or_borrow<'a>(
8287            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8288        ) -> Self::Borrowed<'a> {
8289            value
8290        }
8291    }
8292
8293    unsafe impl fidl::encoding::TypeMarker for SessionWatchDelegatedRxLeaseResponse {
8294        type Owned = Self;
8295
8296        #[inline(always)]
8297        fn inline_align(_context: fidl::encoding::Context) -> usize {
8298            8
8299        }
8300
8301        #[inline(always)]
8302        fn inline_size(_context: fidl::encoding::Context) -> usize {
8303            16
8304        }
8305    }
8306
8307    unsafe impl
8308        fidl::encoding::Encode<
8309            SessionWatchDelegatedRxLeaseResponse,
8310            fidl::encoding::DefaultFuchsiaResourceDialect,
8311        > for &mut SessionWatchDelegatedRxLeaseResponse
8312    {
8313        #[inline]
8314        unsafe fn encode(
8315            self,
8316            encoder: &mut fidl::encoding::Encoder<
8317                '_,
8318                fidl::encoding::DefaultFuchsiaResourceDialect,
8319            >,
8320            offset: usize,
8321            _depth: fidl::encoding::Depth,
8322        ) -> fidl::Result<()> {
8323            encoder.debug_check_bounds::<SessionWatchDelegatedRxLeaseResponse>(offset);
8324            // Delegate to tuple encoding.
8325            fidl::encoding::Encode::<
8326                SessionWatchDelegatedRxLeaseResponse,
8327                fidl::encoding::DefaultFuchsiaResourceDialect,
8328            >::encode(
8329                (<DelegatedRxLease as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8330                    &mut self.lease,
8331                ),),
8332                encoder,
8333                offset,
8334                _depth,
8335            )
8336        }
8337    }
8338    unsafe impl<
8339        T0: fidl::encoding::Encode<DelegatedRxLease, fidl::encoding::DefaultFuchsiaResourceDialect>,
8340    >
8341        fidl::encoding::Encode<
8342            SessionWatchDelegatedRxLeaseResponse,
8343            fidl::encoding::DefaultFuchsiaResourceDialect,
8344        > for (T0,)
8345    {
8346        #[inline]
8347        unsafe fn encode(
8348            self,
8349            encoder: &mut fidl::encoding::Encoder<
8350                '_,
8351                fidl::encoding::DefaultFuchsiaResourceDialect,
8352            >,
8353            offset: usize,
8354            depth: fidl::encoding::Depth,
8355        ) -> fidl::Result<()> {
8356            encoder.debug_check_bounds::<SessionWatchDelegatedRxLeaseResponse>(offset);
8357            // Zero out padding regions. There's no need to apply masks
8358            // because the unmasked parts will be overwritten by fields.
8359            // Write the fields.
8360            self.0.encode(encoder, offset + 0, depth)?;
8361            Ok(())
8362        }
8363    }
8364
8365    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8366        for SessionWatchDelegatedRxLeaseResponse
8367    {
8368        #[inline(always)]
8369        fn new_empty() -> Self {
8370            Self {
8371                lease: fidl::new_empty!(
8372                    DelegatedRxLease,
8373                    fidl::encoding::DefaultFuchsiaResourceDialect
8374                ),
8375            }
8376        }
8377
8378        #[inline]
8379        unsafe fn decode(
8380            &mut self,
8381            decoder: &mut fidl::encoding::Decoder<
8382                '_,
8383                fidl::encoding::DefaultFuchsiaResourceDialect,
8384            >,
8385            offset: usize,
8386            _depth: fidl::encoding::Depth,
8387        ) -> fidl::Result<()> {
8388            decoder.debug_check_bounds::<Self>(offset);
8389            // Verify that padding bytes are zero.
8390            fidl::decode!(
8391                DelegatedRxLease,
8392                fidl::encoding::DefaultFuchsiaResourceDialect,
8393                &mut self.lease,
8394                decoder,
8395                offset + 0,
8396                _depth
8397            )?;
8398            Ok(())
8399        }
8400    }
8401
8402    impl DataVmo {
8403        #[inline(always)]
8404        fn max_ordinal_present(&self) -> u64 {
8405            if let Some(_) = self.num_rx_buffers {
8406                return 3;
8407            }
8408            if let Some(_) = self.vmo {
8409                return 2;
8410            }
8411            if let Some(_) = self.id {
8412                return 1;
8413            }
8414            0
8415        }
8416    }
8417
8418    impl fidl::encoding::ResourceTypeMarker for DataVmo {
8419        type Borrowed<'a> = &'a mut Self;
8420        fn take_or_borrow<'a>(
8421            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8422        ) -> Self::Borrowed<'a> {
8423            value
8424        }
8425    }
8426
8427    unsafe impl fidl::encoding::TypeMarker for DataVmo {
8428        type Owned = Self;
8429
8430        #[inline(always)]
8431        fn inline_align(_context: fidl::encoding::Context) -> usize {
8432            8
8433        }
8434
8435        #[inline(always)]
8436        fn inline_size(_context: fidl::encoding::Context) -> usize {
8437            16
8438        }
8439    }
8440
8441    unsafe impl fidl::encoding::Encode<DataVmo, fidl::encoding::DefaultFuchsiaResourceDialect>
8442        for &mut DataVmo
8443    {
8444        unsafe fn encode(
8445            self,
8446            encoder: &mut fidl::encoding::Encoder<
8447                '_,
8448                fidl::encoding::DefaultFuchsiaResourceDialect,
8449            >,
8450            offset: usize,
8451            mut depth: fidl::encoding::Depth,
8452        ) -> fidl::Result<()> {
8453            encoder.debug_check_bounds::<DataVmo>(offset);
8454            // Vector header
8455            let max_ordinal: u64 = self.max_ordinal_present();
8456            encoder.write_num(max_ordinal, offset);
8457            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8458            // Calling encoder.out_of_line_offset(0) is not allowed.
8459            if max_ordinal == 0 {
8460                return Ok(());
8461            }
8462            depth.increment()?;
8463            let envelope_size = 8;
8464            let bytes_len = max_ordinal as usize * envelope_size;
8465            #[allow(unused_variables)]
8466            let offset = encoder.out_of_line_offset(bytes_len);
8467            let mut _prev_end_offset: usize = 0;
8468            if 1 > max_ordinal {
8469                return Ok(());
8470            }
8471
8472            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8473            // are envelope_size bytes.
8474            let cur_offset: usize = (1 - 1) * envelope_size;
8475
8476            // Zero reserved fields.
8477            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8478
8479            // Safety:
8480            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8481            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8482            //   envelope_size bytes, there is always sufficient room.
8483            fidl::encoding::encode_in_envelope_optional::<
8484                u8,
8485                fidl::encoding::DefaultFuchsiaResourceDialect,
8486            >(
8487                self.id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
8488                encoder,
8489                offset + cur_offset,
8490                depth,
8491            )?;
8492
8493            _prev_end_offset = cur_offset + envelope_size;
8494            if 2 > max_ordinal {
8495                return Ok(());
8496            }
8497
8498            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8499            // are envelope_size bytes.
8500            let cur_offset: usize = (2 - 1) * envelope_size;
8501
8502            // Zero reserved fields.
8503            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8504
8505            // Safety:
8506            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8507            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8508            //   envelope_size bytes, there is always sufficient room.
8509            fidl::encoding::encode_in_envelope_optional::<
8510                fidl::encoding::HandleType<
8511                    fidl::Vmo,
8512                    { fidl::ObjectType::VMO.into_raw() },
8513                    2147483648,
8514                >,
8515                fidl::encoding::DefaultFuchsiaResourceDialect,
8516            >(
8517                self.vmo.as_mut().map(
8518                    <fidl::encoding::HandleType<
8519                        fidl::Vmo,
8520                        { fidl::ObjectType::VMO.into_raw() },
8521                        2147483648,
8522                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
8523                ),
8524                encoder,
8525                offset + cur_offset,
8526                depth,
8527            )?;
8528
8529            _prev_end_offset = cur_offset + envelope_size;
8530            if 3 > max_ordinal {
8531                return Ok(());
8532            }
8533
8534            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8535            // are envelope_size bytes.
8536            let cur_offset: usize = (3 - 1) * envelope_size;
8537
8538            // Zero reserved fields.
8539            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8540
8541            // Safety:
8542            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8543            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8544            //   envelope_size bytes, there is always sufficient room.
8545            fidl::encoding::encode_in_envelope_optional::<
8546                u16,
8547                fidl::encoding::DefaultFuchsiaResourceDialect,
8548            >(
8549                self.num_rx_buffers.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
8550                encoder,
8551                offset + cur_offset,
8552                depth,
8553            )?;
8554
8555            _prev_end_offset = cur_offset + envelope_size;
8556
8557            Ok(())
8558        }
8559    }
8560
8561    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for DataVmo {
8562        #[inline(always)]
8563        fn new_empty() -> Self {
8564            Self::default()
8565        }
8566
8567        unsafe fn decode(
8568            &mut self,
8569            decoder: &mut fidl::encoding::Decoder<
8570                '_,
8571                fidl::encoding::DefaultFuchsiaResourceDialect,
8572            >,
8573            offset: usize,
8574            mut depth: fidl::encoding::Depth,
8575        ) -> fidl::Result<()> {
8576            decoder.debug_check_bounds::<Self>(offset);
8577            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8578                None => return Err(fidl::Error::NotNullable),
8579                Some(len) => len,
8580            };
8581            // Calling decoder.out_of_line_offset(0) is not allowed.
8582            if len == 0 {
8583                return Ok(());
8584            };
8585            depth.increment()?;
8586            let envelope_size = 8;
8587            let bytes_len = len * envelope_size;
8588            let offset = decoder.out_of_line_offset(bytes_len)?;
8589            // Decode the envelope for each type.
8590            let mut _next_ordinal_to_read = 0;
8591            let mut next_offset = offset;
8592            let end_offset = offset + bytes_len;
8593            _next_ordinal_to_read += 1;
8594            if next_offset >= end_offset {
8595                return Ok(());
8596            }
8597
8598            // Decode unknown envelopes for gaps in ordinals.
8599            while _next_ordinal_to_read < 1 {
8600                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8601                _next_ordinal_to_read += 1;
8602                next_offset += envelope_size;
8603            }
8604
8605            let next_out_of_line = decoder.next_out_of_line();
8606            let handles_before = decoder.remaining_handles();
8607            if let Some((inlined, num_bytes, num_handles)) =
8608                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8609            {
8610                let member_inline_size =
8611                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8612                if inlined != (member_inline_size <= 4) {
8613                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8614                }
8615                let inner_offset;
8616                let mut inner_depth = depth.clone();
8617                if inlined {
8618                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8619                    inner_offset = next_offset;
8620                } else {
8621                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8622                    inner_depth.increment()?;
8623                }
8624                let val_ref = self.id.get_or_insert_with(|| {
8625                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
8626                });
8627                fidl::decode!(
8628                    u8,
8629                    fidl::encoding::DefaultFuchsiaResourceDialect,
8630                    val_ref,
8631                    decoder,
8632                    inner_offset,
8633                    inner_depth
8634                )?;
8635                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8636                {
8637                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8638                }
8639                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8640                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8641                }
8642            }
8643
8644            next_offset += envelope_size;
8645            _next_ordinal_to_read += 1;
8646            if next_offset >= end_offset {
8647                return Ok(());
8648            }
8649
8650            // Decode unknown envelopes for gaps in ordinals.
8651            while _next_ordinal_to_read < 2 {
8652                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8653                _next_ordinal_to_read += 1;
8654                next_offset += envelope_size;
8655            }
8656
8657            let next_out_of_line = decoder.next_out_of_line();
8658            let handles_before = decoder.remaining_handles();
8659            if let Some((inlined, num_bytes, num_handles)) =
8660                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8661            {
8662                let member_inline_size = <fidl::encoding::HandleType<
8663                    fidl::Vmo,
8664                    { fidl::ObjectType::VMO.into_raw() },
8665                    2147483648,
8666                > as fidl::encoding::TypeMarker>::inline_size(
8667                    decoder.context
8668                );
8669                if inlined != (member_inline_size <= 4) {
8670                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8671                }
8672                let inner_offset;
8673                let mut inner_depth = depth.clone();
8674                if inlined {
8675                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8676                    inner_offset = next_offset;
8677                } else {
8678                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8679                    inner_depth.increment()?;
8680                }
8681                let val_ref =
8682                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
8683                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
8684                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8685                {
8686                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8687                }
8688                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8689                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8690                }
8691            }
8692
8693            next_offset += envelope_size;
8694            _next_ordinal_to_read += 1;
8695            if next_offset >= end_offset {
8696                return Ok(());
8697            }
8698
8699            // Decode unknown envelopes for gaps in ordinals.
8700            while _next_ordinal_to_read < 3 {
8701                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8702                _next_ordinal_to_read += 1;
8703                next_offset += envelope_size;
8704            }
8705
8706            let next_out_of_line = decoder.next_out_of_line();
8707            let handles_before = decoder.remaining_handles();
8708            if let Some((inlined, num_bytes, num_handles)) =
8709                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8710            {
8711                let member_inline_size =
8712                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8713                if inlined != (member_inline_size <= 4) {
8714                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8715                }
8716                let inner_offset;
8717                let mut inner_depth = depth.clone();
8718                if inlined {
8719                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8720                    inner_offset = next_offset;
8721                } else {
8722                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8723                    inner_depth.increment()?;
8724                }
8725                let val_ref = self.num_rx_buffers.get_or_insert_with(|| {
8726                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
8727                });
8728                fidl::decode!(
8729                    u16,
8730                    fidl::encoding::DefaultFuchsiaResourceDialect,
8731                    val_ref,
8732                    decoder,
8733                    inner_offset,
8734                    inner_depth
8735                )?;
8736                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8737                {
8738                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8739                }
8740                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8741                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8742                }
8743            }
8744
8745            next_offset += envelope_size;
8746
8747            // Decode the remaining unknown envelopes.
8748            while next_offset < end_offset {
8749                _next_ordinal_to_read += 1;
8750                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8751                next_offset += envelope_size;
8752            }
8753
8754            Ok(())
8755        }
8756    }
8757
8758    impl DelegatedRxLease {
8759        #[inline(always)]
8760        fn max_ordinal_present(&self) -> u64 {
8761            if let Some(_) = self.handle {
8762                return 2;
8763            }
8764            if let Some(_) = self.hold_until_frame {
8765                return 1;
8766            }
8767            0
8768        }
8769    }
8770
8771    impl fidl::encoding::ResourceTypeMarker for DelegatedRxLease {
8772        type Borrowed<'a> = &'a mut Self;
8773        fn take_or_borrow<'a>(
8774            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8775        ) -> Self::Borrowed<'a> {
8776            value
8777        }
8778    }
8779
8780    unsafe impl fidl::encoding::TypeMarker for DelegatedRxLease {
8781        type Owned = Self;
8782
8783        #[inline(always)]
8784        fn inline_align(_context: fidl::encoding::Context) -> usize {
8785            8
8786        }
8787
8788        #[inline(always)]
8789        fn inline_size(_context: fidl::encoding::Context) -> usize {
8790            16
8791        }
8792    }
8793
8794    unsafe impl
8795        fidl::encoding::Encode<DelegatedRxLease, fidl::encoding::DefaultFuchsiaResourceDialect>
8796        for &mut DelegatedRxLease
8797    {
8798        unsafe fn encode(
8799            self,
8800            encoder: &mut fidl::encoding::Encoder<
8801                '_,
8802                fidl::encoding::DefaultFuchsiaResourceDialect,
8803            >,
8804            offset: usize,
8805            mut depth: fidl::encoding::Depth,
8806        ) -> fidl::Result<()> {
8807            encoder.debug_check_bounds::<DelegatedRxLease>(offset);
8808            // Vector header
8809            let max_ordinal: u64 = self.max_ordinal_present();
8810            encoder.write_num(max_ordinal, offset);
8811            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8812            // Calling encoder.out_of_line_offset(0) is not allowed.
8813            if max_ordinal == 0 {
8814                return Ok(());
8815            }
8816            depth.increment()?;
8817            let envelope_size = 8;
8818            let bytes_len = max_ordinal as usize * envelope_size;
8819            #[allow(unused_variables)]
8820            let offset = encoder.out_of_line_offset(bytes_len);
8821            let mut _prev_end_offset: usize = 0;
8822            if 1 > max_ordinal {
8823                return Ok(());
8824            }
8825
8826            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8827            // are envelope_size bytes.
8828            let cur_offset: usize = (1 - 1) * envelope_size;
8829
8830            // Zero reserved fields.
8831            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8832
8833            // Safety:
8834            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8835            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8836            //   envelope_size bytes, there is always sufficient room.
8837            fidl::encoding::encode_in_envelope_optional::<
8838                u64,
8839                fidl::encoding::DefaultFuchsiaResourceDialect,
8840            >(
8841                self.hold_until_frame
8842                    .as_ref()
8843                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
8844                encoder,
8845                offset + cur_offset,
8846                depth,
8847            )?;
8848
8849            _prev_end_offset = cur_offset + envelope_size;
8850            if 2 > max_ordinal {
8851                return Ok(());
8852            }
8853
8854            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8855            // are envelope_size bytes.
8856            let cur_offset: usize = (2 - 1) * envelope_size;
8857
8858            // Zero reserved fields.
8859            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8860
8861            // Safety:
8862            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8863            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8864            //   envelope_size bytes, there is always sufficient room.
8865            fidl::encoding::encode_in_envelope_optional::<
8866                DelegatedRxLeaseHandle,
8867                fidl::encoding::DefaultFuchsiaResourceDialect,
8868            >(
8869                self.handle.as_mut().map(
8870                    <DelegatedRxLeaseHandle as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
8871                ),
8872                encoder,
8873                offset + cur_offset,
8874                depth,
8875            )?;
8876
8877            _prev_end_offset = cur_offset + envelope_size;
8878
8879            Ok(())
8880        }
8881    }
8882
8883    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8884        for DelegatedRxLease
8885    {
8886        #[inline(always)]
8887        fn new_empty() -> Self {
8888            Self::default()
8889        }
8890
8891        unsafe fn decode(
8892            &mut self,
8893            decoder: &mut fidl::encoding::Decoder<
8894                '_,
8895                fidl::encoding::DefaultFuchsiaResourceDialect,
8896            >,
8897            offset: usize,
8898            mut depth: fidl::encoding::Depth,
8899        ) -> fidl::Result<()> {
8900            decoder.debug_check_bounds::<Self>(offset);
8901            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8902                None => return Err(fidl::Error::NotNullable),
8903                Some(len) => len,
8904            };
8905            // Calling decoder.out_of_line_offset(0) is not allowed.
8906            if len == 0 {
8907                return Ok(());
8908            };
8909            depth.increment()?;
8910            let envelope_size = 8;
8911            let bytes_len = len * envelope_size;
8912            let offset = decoder.out_of_line_offset(bytes_len)?;
8913            // Decode the envelope for each type.
8914            let mut _next_ordinal_to_read = 0;
8915            let mut next_offset = offset;
8916            let end_offset = offset + bytes_len;
8917            _next_ordinal_to_read += 1;
8918            if next_offset >= end_offset {
8919                return Ok(());
8920            }
8921
8922            // Decode unknown envelopes for gaps in ordinals.
8923            while _next_ordinal_to_read < 1 {
8924                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8925                _next_ordinal_to_read += 1;
8926                next_offset += envelope_size;
8927            }
8928
8929            let next_out_of_line = decoder.next_out_of_line();
8930            let handles_before = decoder.remaining_handles();
8931            if let Some((inlined, num_bytes, num_handles)) =
8932                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8933            {
8934                let member_inline_size =
8935                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8936                if inlined != (member_inline_size <= 4) {
8937                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8938                }
8939                let inner_offset;
8940                let mut inner_depth = depth.clone();
8941                if inlined {
8942                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8943                    inner_offset = next_offset;
8944                } else {
8945                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8946                    inner_depth.increment()?;
8947                }
8948                let val_ref = self.hold_until_frame.get_or_insert_with(|| {
8949                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
8950                });
8951                fidl::decode!(
8952                    u64,
8953                    fidl::encoding::DefaultFuchsiaResourceDialect,
8954                    val_ref,
8955                    decoder,
8956                    inner_offset,
8957                    inner_depth
8958                )?;
8959                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8960                {
8961                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8962                }
8963                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8964                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8965                }
8966            }
8967
8968            next_offset += envelope_size;
8969            _next_ordinal_to_read += 1;
8970            if next_offset >= end_offset {
8971                return Ok(());
8972            }
8973
8974            // Decode unknown envelopes for gaps in ordinals.
8975            while _next_ordinal_to_read < 2 {
8976                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8977                _next_ordinal_to_read += 1;
8978                next_offset += envelope_size;
8979            }
8980
8981            let next_out_of_line = decoder.next_out_of_line();
8982            let handles_before = decoder.remaining_handles();
8983            if let Some((inlined, num_bytes, num_handles)) =
8984                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8985            {
8986                let member_inline_size =
8987                    <DelegatedRxLeaseHandle as fidl::encoding::TypeMarker>::inline_size(
8988                        decoder.context,
8989                    );
8990                if inlined != (member_inline_size <= 4) {
8991                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8992                }
8993                let inner_offset;
8994                let mut inner_depth = depth.clone();
8995                if inlined {
8996                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8997                    inner_offset = next_offset;
8998                } else {
8999                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9000                    inner_depth.increment()?;
9001                }
9002                let val_ref = self.handle.get_or_insert_with(|| {
9003                    fidl::new_empty!(
9004                        DelegatedRxLeaseHandle,
9005                        fidl::encoding::DefaultFuchsiaResourceDialect
9006                    )
9007                });
9008                fidl::decode!(
9009                    DelegatedRxLeaseHandle,
9010                    fidl::encoding::DefaultFuchsiaResourceDialect,
9011                    val_ref,
9012                    decoder,
9013                    inner_offset,
9014                    inner_depth
9015                )?;
9016                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9017                {
9018                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9019                }
9020                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9021                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9022                }
9023            }
9024
9025            next_offset += envelope_size;
9026
9027            // Decode the remaining unknown envelopes.
9028            while next_offset < end_offset {
9029                _next_ordinal_to_read += 1;
9030                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9031                next_offset += envelope_size;
9032            }
9033
9034            Ok(())
9035        }
9036    }
9037
9038    impl SessionInfo {
9039        #[inline(always)]
9040        fn max_ordinal_present(&self) -> u64 {
9041            if let Some(_) = self.options {
9042                return 6;
9043            }
9044            if let Some(_) = self.descriptor_count {
9045                return 5;
9046            }
9047            if let Some(_) = self.descriptor_length {
9048                return 4;
9049            }
9050            if let Some(_) = self.descriptor_version {
9051                return 3;
9052            }
9053            if let Some(_) = self.data {
9054                return 2;
9055            }
9056            if let Some(_) = self.descriptors {
9057                return 1;
9058            }
9059            0
9060        }
9061    }
9062
9063    impl fidl::encoding::ResourceTypeMarker for SessionInfo {
9064        type Borrowed<'a> = &'a mut Self;
9065        fn take_or_borrow<'a>(
9066            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9067        ) -> Self::Borrowed<'a> {
9068            value
9069        }
9070    }
9071
9072    unsafe impl fidl::encoding::TypeMarker for SessionInfo {
9073        type Owned = Self;
9074
9075        #[inline(always)]
9076        fn inline_align(_context: fidl::encoding::Context) -> usize {
9077            8
9078        }
9079
9080        #[inline(always)]
9081        fn inline_size(_context: fidl::encoding::Context) -> usize {
9082            16
9083        }
9084    }
9085
9086    unsafe impl fidl::encoding::Encode<SessionInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
9087        for &mut SessionInfo
9088    {
9089        unsafe fn encode(
9090            self,
9091            encoder: &mut fidl::encoding::Encoder<
9092                '_,
9093                fidl::encoding::DefaultFuchsiaResourceDialect,
9094            >,
9095            offset: usize,
9096            mut depth: fidl::encoding::Depth,
9097        ) -> fidl::Result<()> {
9098            encoder.debug_check_bounds::<SessionInfo>(offset);
9099            // Vector header
9100            let max_ordinal: u64 = self.max_ordinal_present();
9101            encoder.write_num(max_ordinal, offset);
9102            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9103            // Calling encoder.out_of_line_offset(0) is not allowed.
9104            if max_ordinal == 0 {
9105                return Ok(());
9106            }
9107            depth.increment()?;
9108            let envelope_size = 8;
9109            let bytes_len = max_ordinal as usize * envelope_size;
9110            #[allow(unused_variables)]
9111            let offset = encoder.out_of_line_offset(bytes_len);
9112            let mut _prev_end_offset: usize = 0;
9113            if 1 > max_ordinal {
9114                return Ok(());
9115            }
9116
9117            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9118            // are envelope_size bytes.
9119            let cur_offset: usize = (1 - 1) * envelope_size;
9120
9121            // Zero reserved fields.
9122            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9123
9124            // Safety:
9125            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9126            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9127            //   envelope_size bytes, there is always sufficient room.
9128            fidl::encoding::encode_in_envelope_optional::<
9129                fidl::encoding::HandleType<
9130                    fidl::Vmo,
9131                    { fidl::ObjectType::VMO.into_raw() },
9132                    2147483648,
9133                >,
9134                fidl::encoding::DefaultFuchsiaResourceDialect,
9135            >(
9136                self.descriptors.as_mut().map(
9137                    <fidl::encoding::HandleType<
9138                        fidl::Vmo,
9139                        { fidl::ObjectType::VMO.into_raw() },
9140                        2147483648,
9141                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
9142                ),
9143                encoder,
9144                offset + cur_offset,
9145                depth,
9146            )?;
9147
9148            _prev_end_offset = cur_offset + envelope_size;
9149            if 2 > max_ordinal {
9150                return Ok(());
9151            }
9152
9153            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9154            // are envelope_size bytes.
9155            let cur_offset: usize = (2 - 1) * envelope_size;
9156
9157            // Zero reserved fields.
9158            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9159
9160            // Safety:
9161            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9162            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9163            //   envelope_size bytes, there is always sufficient room.
9164            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<DataVmo, 32>, fidl::encoding::DefaultFuchsiaResourceDialect>(
9165            self.data.as_mut().map(<fidl::encoding::Vector<DataVmo, 32> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
9166            encoder, offset + cur_offset, depth
9167        )?;
9168
9169            _prev_end_offset = cur_offset + envelope_size;
9170            if 3 > max_ordinal {
9171                return Ok(());
9172            }
9173
9174            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9175            // are envelope_size bytes.
9176            let cur_offset: usize = (3 - 1) * envelope_size;
9177
9178            // Zero reserved fields.
9179            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9180
9181            // Safety:
9182            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9183            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9184            //   envelope_size bytes, there is always sufficient room.
9185            fidl::encoding::encode_in_envelope_optional::<
9186                u8,
9187                fidl::encoding::DefaultFuchsiaResourceDialect,
9188            >(
9189                self.descriptor_version
9190                    .as_ref()
9191                    .map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
9192                encoder,
9193                offset + cur_offset,
9194                depth,
9195            )?;
9196
9197            _prev_end_offset = cur_offset + envelope_size;
9198            if 4 > max_ordinal {
9199                return Ok(());
9200            }
9201
9202            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9203            // are envelope_size bytes.
9204            let cur_offset: usize = (4 - 1) * envelope_size;
9205
9206            // Zero reserved fields.
9207            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9208
9209            // Safety:
9210            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9211            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9212            //   envelope_size bytes, there is always sufficient room.
9213            fidl::encoding::encode_in_envelope_optional::<
9214                u8,
9215                fidl::encoding::DefaultFuchsiaResourceDialect,
9216            >(
9217                self.descriptor_length
9218                    .as_ref()
9219                    .map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
9220                encoder,
9221                offset + cur_offset,
9222                depth,
9223            )?;
9224
9225            _prev_end_offset = cur_offset + envelope_size;
9226            if 5 > max_ordinal {
9227                return Ok(());
9228            }
9229
9230            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9231            // are envelope_size bytes.
9232            let cur_offset: usize = (5 - 1) * envelope_size;
9233
9234            // Zero reserved fields.
9235            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9236
9237            // Safety:
9238            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9239            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9240            //   envelope_size bytes, there is always sufficient room.
9241            fidl::encoding::encode_in_envelope_optional::<
9242                u16,
9243                fidl::encoding::DefaultFuchsiaResourceDialect,
9244            >(
9245                self.descriptor_count
9246                    .as_ref()
9247                    .map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
9248                encoder,
9249                offset + cur_offset,
9250                depth,
9251            )?;
9252
9253            _prev_end_offset = cur_offset + envelope_size;
9254            if 6 > max_ordinal {
9255                return Ok(());
9256            }
9257
9258            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9259            // are envelope_size bytes.
9260            let cur_offset: usize = (6 - 1) * envelope_size;
9261
9262            // Zero reserved fields.
9263            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9264
9265            // Safety:
9266            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9267            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9268            //   envelope_size bytes, there is always sufficient room.
9269            fidl::encoding::encode_in_envelope_optional::<
9270                SessionFlags,
9271                fidl::encoding::DefaultFuchsiaResourceDialect,
9272            >(
9273                self.options
9274                    .as_ref()
9275                    .map(<SessionFlags as fidl::encoding::ValueTypeMarker>::borrow),
9276                encoder,
9277                offset + cur_offset,
9278                depth,
9279            )?;
9280
9281            _prev_end_offset = cur_offset + envelope_size;
9282
9283            Ok(())
9284        }
9285    }
9286
9287    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for SessionInfo {
9288        #[inline(always)]
9289        fn new_empty() -> Self {
9290            Self::default()
9291        }
9292
9293        unsafe fn decode(
9294            &mut self,
9295            decoder: &mut fidl::encoding::Decoder<
9296                '_,
9297                fidl::encoding::DefaultFuchsiaResourceDialect,
9298            >,
9299            offset: usize,
9300            mut depth: fidl::encoding::Depth,
9301        ) -> fidl::Result<()> {
9302            decoder.debug_check_bounds::<Self>(offset);
9303            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9304                None => return Err(fidl::Error::NotNullable),
9305                Some(len) => len,
9306            };
9307            // Calling decoder.out_of_line_offset(0) is not allowed.
9308            if len == 0 {
9309                return Ok(());
9310            };
9311            depth.increment()?;
9312            let envelope_size = 8;
9313            let bytes_len = len * envelope_size;
9314            let offset = decoder.out_of_line_offset(bytes_len)?;
9315            // Decode the envelope for each type.
9316            let mut _next_ordinal_to_read = 0;
9317            let mut next_offset = offset;
9318            let end_offset = offset + bytes_len;
9319            _next_ordinal_to_read += 1;
9320            if next_offset >= end_offset {
9321                return Ok(());
9322            }
9323
9324            // Decode unknown envelopes for gaps in ordinals.
9325            while _next_ordinal_to_read < 1 {
9326                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9327                _next_ordinal_to_read += 1;
9328                next_offset += envelope_size;
9329            }
9330
9331            let next_out_of_line = decoder.next_out_of_line();
9332            let handles_before = decoder.remaining_handles();
9333            if let Some((inlined, num_bytes, num_handles)) =
9334                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9335            {
9336                let member_inline_size = <fidl::encoding::HandleType<
9337                    fidl::Vmo,
9338                    { fidl::ObjectType::VMO.into_raw() },
9339                    2147483648,
9340                > as fidl::encoding::TypeMarker>::inline_size(
9341                    decoder.context
9342                );
9343                if inlined != (member_inline_size <= 4) {
9344                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9345                }
9346                let inner_offset;
9347                let mut inner_depth = depth.clone();
9348                if inlined {
9349                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9350                    inner_offset = next_offset;
9351                } else {
9352                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9353                    inner_depth.increment()?;
9354                }
9355                let val_ref =
9356                self.descriptors.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
9357                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
9358                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9359                {
9360                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9361                }
9362                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9363                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9364                }
9365            }
9366
9367            next_offset += envelope_size;
9368            _next_ordinal_to_read += 1;
9369            if next_offset >= end_offset {
9370                return Ok(());
9371            }
9372
9373            // Decode unknown envelopes for gaps in ordinals.
9374            while _next_ordinal_to_read < 2 {
9375                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9376                _next_ordinal_to_read += 1;
9377                next_offset += envelope_size;
9378            }
9379
9380            let next_out_of_line = decoder.next_out_of_line();
9381            let handles_before = decoder.remaining_handles();
9382            if let Some((inlined, num_bytes, num_handles)) =
9383                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9384            {
9385                let member_inline_size = <fidl::encoding::Vector<DataVmo, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9386                if inlined != (member_inline_size <= 4) {
9387                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9388                }
9389                let inner_offset;
9390                let mut inner_depth = depth.clone();
9391                if inlined {
9392                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9393                    inner_offset = next_offset;
9394                } else {
9395                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9396                    inner_depth.increment()?;
9397                }
9398                let val_ref =
9399                self.data.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<DataVmo, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
9400                fidl::decode!(fidl::encoding::Vector<DataVmo, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
9401                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9402                {
9403                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9404                }
9405                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9406                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9407                }
9408            }
9409
9410            next_offset += envelope_size;
9411            _next_ordinal_to_read += 1;
9412            if next_offset >= end_offset {
9413                return Ok(());
9414            }
9415
9416            // Decode unknown envelopes for gaps in ordinals.
9417            while _next_ordinal_to_read < 3 {
9418                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9419                _next_ordinal_to_read += 1;
9420                next_offset += envelope_size;
9421            }
9422
9423            let next_out_of_line = decoder.next_out_of_line();
9424            let handles_before = decoder.remaining_handles();
9425            if let Some((inlined, num_bytes, num_handles)) =
9426                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9427            {
9428                let member_inline_size =
9429                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9430                if inlined != (member_inline_size <= 4) {
9431                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9432                }
9433                let inner_offset;
9434                let mut inner_depth = depth.clone();
9435                if inlined {
9436                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9437                    inner_offset = next_offset;
9438                } else {
9439                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9440                    inner_depth.increment()?;
9441                }
9442                let val_ref = self.descriptor_version.get_or_insert_with(|| {
9443                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
9444                });
9445                fidl::decode!(
9446                    u8,
9447                    fidl::encoding::DefaultFuchsiaResourceDialect,
9448                    val_ref,
9449                    decoder,
9450                    inner_offset,
9451                    inner_depth
9452                )?;
9453                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9454                {
9455                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9456                }
9457                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9458                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9459                }
9460            }
9461
9462            next_offset += envelope_size;
9463            _next_ordinal_to_read += 1;
9464            if next_offset >= end_offset {
9465                return Ok(());
9466            }
9467
9468            // Decode unknown envelopes for gaps in ordinals.
9469            while _next_ordinal_to_read < 4 {
9470                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9471                _next_ordinal_to_read += 1;
9472                next_offset += envelope_size;
9473            }
9474
9475            let next_out_of_line = decoder.next_out_of_line();
9476            let handles_before = decoder.remaining_handles();
9477            if let Some((inlined, num_bytes, num_handles)) =
9478                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9479            {
9480                let member_inline_size =
9481                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9482                if inlined != (member_inline_size <= 4) {
9483                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9484                }
9485                let inner_offset;
9486                let mut inner_depth = depth.clone();
9487                if inlined {
9488                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9489                    inner_offset = next_offset;
9490                } else {
9491                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9492                    inner_depth.increment()?;
9493                }
9494                let val_ref = self.descriptor_length.get_or_insert_with(|| {
9495                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
9496                });
9497                fidl::decode!(
9498                    u8,
9499                    fidl::encoding::DefaultFuchsiaResourceDialect,
9500                    val_ref,
9501                    decoder,
9502                    inner_offset,
9503                    inner_depth
9504                )?;
9505                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9506                {
9507                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9508                }
9509                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9510                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9511                }
9512            }
9513
9514            next_offset += envelope_size;
9515            _next_ordinal_to_read += 1;
9516            if next_offset >= end_offset {
9517                return Ok(());
9518            }
9519
9520            // Decode unknown envelopes for gaps in ordinals.
9521            while _next_ordinal_to_read < 5 {
9522                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9523                _next_ordinal_to_read += 1;
9524                next_offset += envelope_size;
9525            }
9526
9527            let next_out_of_line = decoder.next_out_of_line();
9528            let handles_before = decoder.remaining_handles();
9529            if let Some((inlined, num_bytes, num_handles)) =
9530                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9531            {
9532                let member_inline_size =
9533                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9534                if inlined != (member_inline_size <= 4) {
9535                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9536                }
9537                let inner_offset;
9538                let mut inner_depth = depth.clone();
9539                if inlined {
9540                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9541                    inner_offset = next_offset;
9542                } else {
9543                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9544                    inner_depth.increment()?;
9545                }
9546                let val_ref = self.descriptor_count.get_or_insert_with(|| {
9547                    fidl::new_empty!(u16, fidl::encoding::DefaultFuchsiaResourceDialect)
9548                });
9549                fidl::decode!(
9550                    u16,
9551                    fidl::encoding::DefaultFuchsiaResourceDialect,
9552                    val_ref,
9553                    decoder,
9554                    inner_offset,
9555                    inner_depth
9556                )?;
9557                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9558                {
9559                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9560                }
9561                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9562                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9563                }
9564            }
9565
9566            next_offset += envelope_size;
9567            _next_ordinal_to_read += 1;
9568            if next_offset >= end_offset {
9569                return Ok(());
9570            }
9571
9572            // Decode unknown envelopes for gaps in ordinals.
9573            while _next_ordinal_to_read < 6 {
9574                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9575                _next_ordinal_to_read += 1;
9576                next_offset += envelope_size;
9577            }
9578
9579            let next_out_of_line = decoder.next_out_of_line();
9580            let handles_before = decoder.remaining_handles();
9581            if let Some((inlined, num_bytes, num_handles)) =
9582                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9583            {
9584                let member_inline_size =
9585                    <SessionFlags as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9586                if inlined != (member_inline_size <= 4) {
9587                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9588                }
9589                let inner_offset;
9590                let mut inner_depth = depth.clone();
9591                if inlined {
9592                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9593                    inner_offset = next_offset;
9594                } else {
9595                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9596                    inner_depth.increment()?;
9597                }
9598                let val_ref = self.options.get_or_insert_with(|| {
9599                    fidl::new_empty!(SessionFlags, fidl::encoding::DefaultFuchsiaResourceDialect)
9600                });
9601                fidl::decode!(
9602                    SessionFlags,
9603                    fidl::encoding::DefaultFuchsiaResourceDialect,
9604                    val_ref,
9605                    decoder,
9606                    inner_offset,
9607                    inner_depth
9608                )?;
9609                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9610                {
9611                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9612                }
9613                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9614                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9615                }
9616            }
9617
9618            next_offset += envelope_size;
9619
9620            // Decode the remaining unknown envelopes.
9621            while next_offset < end_offset {
9622                _next_ordinal_to_read += 1;
9623                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9624                next_offset += envelope_size;
9625            }
9626
9627            Ok(())
9628        }
9629    }
9630
9631    impl fidl::encoding::ResourceTypeMarker for DelegatedRxLeaseHandle {
9632        type Borrowed<'a> = &'a mut Self;
9633        fn take_or_borrow<'a>(
9634            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9635        ) -> Self::Borrowed<'a> {
9636            value
9637        }
9638    }
9639
9640    unsafe impl fidl::encoding::TypeMarker for DelegatedRxLeaseHandle {
9641        type Owned = Self;
9642
9643        #[inline(always)]
9644        fn inline_align(_context: fidl::encoding::Context) -> usize {
9645            8
9646        }
9647
9648        #[inline(always)]
9649        fn inline_size(_context: fidl::encoding::Context) -> usize {
9650            16
9651        }
9652    }
9653
9654    unsafe impl
9655        fidl::encoding::Encode<
9656            DelegatedRxLeaseHandle,
9657            fidl::encoding::DefaultFuchsiaResourceDialect,
9658        > for &mut DelegatedRxLeaseHandle
9659    {
9660        #[inline]
9661        unsafe fn encode(
9662            self,
9663            encoder: &mut fidl::encoding::Encoder<
9664                '_,
9665                fidl::encoding::DefaultFuchsiaResourceDialect,
9666            >,
9667            offset: usize,
9668            _depth: fidl::encoding::Depth,
9669        ) -> fidl::Result<()> {
9670            encoder.debug_check_bounds::<DelegatedRxLeaseHandle>(offset);
9671            encoder.write_num::<u64>(self.ordinal(), offset);
9672            match self {
9673                DelegatedRxLeaseHandle::Channel(ref mut val) => {
9674                    fidl::encoding::encode_in_envelope::<
9675                        fidl::encoding::HandleType<
9676                            fidl::Channel,
9677                            { fidl::ObjectType::CHANNEL.into_raw() },
9678                            2147483648,
9679                        >,
9680                        fidl::encoding::DefaultFuchsiaResourceDialect,
9681                    >(
9682                        <fidl::encoding::HandleType<
9683                            fidl::Channel,
9684                            { fidl::ObjectType::CHANNEL.into_raw() },
9685                            2147483648,
9686                        > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9687                            val
9688                        ),
9689                        encoder,
9690                        offset + 8,
9691                        _depth,
9692                    )
9693                }
9694                DelegatedRxLeaseHandle::Eventpair(ref mut val) => {
9695                    fidl::encoding::encode_in_envelope::<
9696                        fidl::encoding::HandleType<
9697                            fidl::EventPair,
9698                            { fidl::ObjectType::EVENTPAIR.into_raw() },
9699                            16387,
9700                        >,
9701                        fidl::encoding::DefaultFuchsiaResourceDialect,
9702                    >(
9703                        <fidl::encoding::HandleType<
9704                            fidl::EventPair,
9705                            { fidl::ObjectType::EVENTPAIR.into_raw() },
9706                            16387,
9707                        > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9708                            val
9709                        ),
9710                        encoder,
9711                        offset + 8,
9712                        _depth,
9713                    )
9714                }
9715                DelegatedRxLeaseHandle::__SourceBreaking { .. } => {
9716                    Err(fidl::Error::UnknownUnionTag)
9717                }
9718            }
9719        }
9720    }
9721
9722    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9723        for DelegatedRxLeaseHandle
9724    {
9725        #[inline(always)]
9726        fn new_empty() -> Self {
9727            Self::__SourceBreaking { unknown_ordinal: 0 }
9728        }
9729
9730        #[inline]
9731        unsafe fn decode(
9732            &mut self,
9733            decoder: &mut fidl::encoding::Decoder<
9734                '_,
9735                fidl::encoding::DefaultFuchsiaResourceDialect,
9736            >,
9737            offset: usize,
9738            mut depth: fidl::encoding::Depth,
9739        ) -> fidl::Result<()> {
9740            decoder.debug_check_bounds::<Self>(offset);
9741            #[allow(unused_variables)]
9742            let next_out_of_line = decoder.next_out_of_line();
9743            let handles_before = decoder.remaining_handles();
9744            let (ordinal, inlined, num_bytes, num_handles) =
9745                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
9746
9747            let member_inline_size = match ordinal {
9748                1 => <fidl::encoding::HandleType<
9749                    fidl::Channel,
9750                    { fidl::ObjectType::CHANNEL.into_raw() },
9751                    2147483648,
9752                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
9753                2 => <fidl::encoding::HandleType<
9754                    fidl::EventPair,
9755                    { fidl::ObjectType::EVENTPAIR.into_raw() },
9756                    16387,
9757                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
9758                0 => return Err(fidl::Error::UnknownUnionTag),
9759                _ => num_bytes as usize,
9760            };
9761
9762            if inlined != (member_inline_size <= 4) {
9763                return Err(fidl::Error::InvalidInlineBitInEnvelope);
9764            }
9765            let _inner_offset;
9766            if inlined {
9767                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
9768                _inner_offset = offset + 8;
9769            } else {
9770                depth.increment()?;
9771                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9772            }
9773            match ordinal {
9774                1 => {
9775                    #[allow(irrefutable_let_patterns)]
9776                    if let DelegatedRxLeaseHandle::Channel(_) = self {
9777                        // Do nothing, read the value into the object
9778                    } else {
9779                        // Initialize `self` to the right variant
9780                        *self = DelegatedRxLeaseHandle::Channel(
9781                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9782                        );
9783                    }
9784                    #[allow(irrefutable_let_patterns)]
9785                    if let DelegatedRxLeaseHandle::Channel(ref mut val) = self {
9786                        fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
9787                    } else {
9788                        unreachable!()
9789                    }
9790                }
9791                2 => {
9792                    #[allow(irrefutable_let_patterns)]
9793                    if let DelegatedRxLeaseHandle::Eventpair(_) = self {
9794                        // Do nothing, read the value into the object
9795                    } else {
9796                        // Initialize `self` to the right variant
9797                        *self = DelegatedRxLeaseHandle::Eventpair(
9798                            fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
9799                        );
9800                    }
9801                    #[allow(irrefutable_let_patterns)]
9802                    if let DelegatedRxLeaseHandle::Eventpair(ref mut val) = self {
9803                        fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
9804                    } else {
9805                        unreachable!()
9806                    }
9807                }
9808                #[allow(deprecated)]
9809                ordinal => {
9810                    for _ in 0..num_handles {
9811                        decoder.drop_next_handle()?;
9812                    }
9813                    *self = DelegatedRxLeaseHandle::__SourceBreaking { unknown_ordinal: ordinal };
9814                }
9815            }
9816            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
9817                return Err(fidl::Error::InvalidNumBytesInEnvelope);
9818            }
9819            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9820                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9821            }
9822            Ok(())
9823        }
9824    }
9825}