Skip to main content

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