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    pub fn r#get_power_dependency_token(
2398        &self,
2399    ) -> fidl::client::QueryResponseFut<
2400        Option<fdomain_client::Event>,
2401        fdomain_client::fidl::FDomainResourceDialect,
2402    > {
2403        PortProxyInterface::r#get_power_dependency_token(self)
2404    }
2405}
2406
2407impl PortProxyInterface for PortProxy {
2408    type GetInfoResponseFut =
2409        fidl::client::QueryResponseFut<PortInfo, fdomain_client::fidl::FDomainResourceDialect>;
2410    fn r#get_info(&self) -> Self::GetInfoResponseFut {
2411        fn _decode(
2412            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2413        ) -> Result<PortInfo, fidl::Error> {
2414            let _response = fidl::client::decode_transaction_body::<
2415                PortGetInfoResponse,
2416                fdomain_client::fidl::FDomainResourceDialect,
2417                0x276cf65feb554ebd,
2418            >(_buf?)?;
2419            Ok(_response.info)
2420        }
2421        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PortInfo>(
2422            (),
2423            0x276cf65feb554ebd,
2424            fidl::encoding::DynamicFlags::empty(),
2425            _decode,
2426        )
2427    }
2428
2429    type GetStatusResponseFut =
2430        fidl::client::QueryResponseFut<PortStatus, fdomain_client::fidl::FDomainResourceDialect>;
2431    fn r#get_status(&self) -> Self::GetStatusResponseFut {
2432        fn _decode(
2433            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2434        ) -> Result<PortStatus, fidl::Error> {
2435            let _response = fidl::client::decode_transaction_body::<
2436                PortGetStatusResponse,
2437                fdomain_client::fidl::FDomainResourceDialect,
2438                0x4235650aacca60b2,
2439            >(_buf?)?;
2440            Ok(_response.status)
2441        }
2442        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PortStatus>(
2443            (),
2444            0x4235650aacca60b2,
2445            fidl::encoding::DynamicFlags::empty(),
2446            _decode,
2447        )
2448    }
2449
2450    fn r#get_status_watcher(
2451        &self,
2452        mut watcher: fdomain_client::fidl::ServerEnd<StatusWatcherMarker>,
2453        mut buffer: u32,
2454    ) -> Result<(), fidl::Error> {
2455        self.client.send::<PortGetStatusWatcherRequest>(
2456            (watcher, buffer),
2457            0x65511ab81c1bd8d4,
2458            fidl::encoding::DynamicFlags::empty(),
2459        )
2460    }
2461
2462    fn r#get_mac(
2463        &self,
2464        mut mac: fdomain_client::fidl::ServerEnd<MacAddressingMarker>,
2465    ) -> Result<(), fidl::Error> {
2466        self.client.send::<PortGetMacRequest>(
2467            (mac,),
2468            0x2c6ec2988aefc0f6,
2469            fidl::encoding::DynamicFlags::empty(),
2470        )
2471    }
2472
2473    fn r#get_device(
2474        &self,
2475        mut device: fdomain_client::fidl::ServerEnd<DeviceMarker>,
2476    ) -> Result<(), fidl::Error> {
2477        self.client.send::<PortGetDeviceRequest>(
2478            (device,),
2479            0x7de34747235d2d80,
2480            fidl::encoding::DynamicFlags::empty(),
2481        )
2482    }
2483
2484    fn r#clone(
2485        &self,
2486        mut port: fdomain_client::fidl::ServerEnd<PortMarker>,
2487    ) -> Result<(), fidl::Error> {
2488        self.client.send::<PortCloneRequest>(
2489            (port,),
2490            0x4e4764150b4942d3,
2491            fidl::encoding::DynamicFlags::empty(),
2492        )
2493    }
2494
2495    type GetCountersResponseFut = fidl::client::QueryResponseFut<
2496        PortGetCountersResponse,
2497        fdomain_client::fidl::FDomainResourceDialect,
2498    >;
2499    fn r#get_counters(&self) -> Self::GetCountersResponseFut {
2500        fn _decode(
2501            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2502        ) -> Result<PortGetCountersResponse, fidl::Error> {
2503            let _response = fidl::client::decode_transaction_body::<
2504                PortGetCountersResponse,
2505                fdomain_client::fidl::FDomainResourceDialect,
2506                0x6a213b03c4fcbbac,
2507            >(_buf?)?;
2508            Ok(_response)
2509        }
2510        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PortGetCountersResponse>(
2511            (),
2512            0x6a213b03c4fcbbac,
2513            fidl::encoding::DynamicFlags::empty(),
2514            _decode,
2515        )
2516    }
2517
2518    fn r#get_diagnostics(
2519        &self,
2520        mut diagnostics: fdomain_client::fidl::ServerEnd<DiagnosticsMarker>,
2521    ) -> Result<(), fidl::Error> {
2522        self.client.send::<PortGetDiagnosticsRequest>(
2523            (diagnostics,),
2524            0x381faa4ed75e399c,
2525            fidl::encoding::DynamicFlags::empty(),
2526        )
2527    }
2528
2529    type GetIdentityResponseFut = fidl::client::QueryResponseFut<
2530        fdomain_client::Event,
2531        fdomain_client::fidl::FDomainResourceDialect,
2532    >;
2533    fn r#get_identity(&self) -> Self::GetIdentityResponseFut {
2534        fn _decode(
2535            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2536        ) -> Result<fdomain_client::Event, fidl::Error> {
2537            let _response = fidl::client::decode_transaction_body::<
2538                PortGetIdentityResponse,
2539                fdomain_client::fidl::FDomainResourceDialect,
2540                0x75134ce0bc114e5a,
2541            >(_buf?)?;
2542            Ok(_response.event)
2543        }
2544        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fdomain_client::Event>(
2545            (),
2546            0x75134ce0bc114e5a,
2547            fidl::encoding::DynamicFlags::empty(),
2548            _decode,
2549        )
2550    }
2551
2552    type GetPowerDependencyTokenResponseFut = fidl::client::QueryResponseFut<
2553        Option<fdomain_client::Event>,
2554        fdomain_client::fidl::FDomainResourceDialect,
2555    >;
2556    fn r#get_power_dependency_token(&self) -> Self::GetPowerDependencyTokenResponseFut {
2557        fn _decode(
2558            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2559        ) -> Result<Option<fdomain_client::Event>, fidl::Error> {
2560            let _response = fidl::client::decode_transaction_body::<
2561                PortGetPowerDependencyTokenResponse,
2562                fdomain_client::fidl::FDomainResourceDialect,
2563                0x7bec1da6ec2476ed,
2564            >(_buf?)?;
2565            Ok(_response.token)
2566        }
2567        self.client
2568            .send_query_and_decode::<fidl::encoding::EmptyPayload, Option<fdomain_client::Event>>(
2569                (),
2570                0x7bec1da6ec2476ed,
2571                fidl::encoding::DynamicFlags::empty(),
2572                _decode,
2573            )
2574    }
2575}
2576
2577pub struct PortEventStream {
2578    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
2579}
2580
2581impl std::marker::Unpin for PortEventStream {}
2582
2583impl futures::stream::FusedStream for PortEventStream {
2584    fn is_terminated(&self) -> bool {
2585        self.event_receiver.is_terminated()
2586    }
2587}
2588
2589impl futures::Stream for PortEventStream {
2590    type Item = Result<PortEvent, fidl::Error>;
2591
2592    fn poll_next(
2593        mut self: std::pin::Pin<&mut Self>,
2594        cx: &mut std::task::Context<'_>,
2595    ) -> std::task::Poll<Option<Self::Item>> {
2596        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2597            &mut self.event_receiver,
2598            cx
2599        )?) {
2600            Some(buf) => std::task::Poll::Ready(Some(PortEvent::decode(buf))),
2601            None => std::task::Poll::Ready(None),
2602        }
2603    }
2604}
2605
2606#[derive(Debug)]
2607pub enum PortEvent {}
2608
2609impl PortEvent {
2610    /// Decodes a message buffer as a [`PortEvent`].
2611    fn decode(
2612        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2613    ) -> Result<PortEvent, fidl::Error> {
2614        let (bytes, _handles) = buf.split_mut();
2615        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2616        debug_assert_eq!(tx_header.tx_id, 0);
2617        match tx_header.ordinal {
2618            _ => Err(fidl::Error::UnknownOrdinal {
2619                ordinal: tx_header.ordinal,
2620                protocol_name: <PortMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2621            }),
2622        }
2623    }
2624}
2625
2626/// A Stream of incoming requests for fuchsia.hardware.network/Port.
2627pub struct PortRequestStream {
2628    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2629    is_terminated: bool,
2630}
2631
2632impl std::marker::Unpin for PortRequestStream {}
2633
2634impl futures::stream::FusedStream for PortRequestStream {
2635    fn is_terminated(&self) -> bool {
2636        self.is_terminated
2637    }
2638}
2639
2640impl fdomain_client::fidl::RequestStream for PortRequestStream {
2641    type Protocol = PortMarker;
2642    type ControlHandle = PortControlHandle;
2643
2644    fn from_channel(channel: fdomain_client::Channel) -> Self {
2645        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2646    }
2647
2648    fn control_handle(&self) -> Self::ControlHandle {
2649        PortControlHandle { inner: self.inner.clone() }
2650    }
2651
2652    fn into_inner(
2653        self,
2654    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
2655    {
2656        (self.inner, self.is_terminated)
2657    }
2658
2659    fn from_inner(
2660        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2661        is_terminated: bool,
2662    ) -> Self {
2663        Self { inner, is_terminated }
2664    }
2665}
2666
2667impl futures::Stream for PortRequestStream {
2668    type Item = Result<PortRequest, fidl::Error>;
2669
2670    fn poll_next(
2671        mut self: std::pin::Pin<&mut Self>,
2672        cx: &mut std::task::Context<'_>,
2673    ) -> std::task::Poll<Option<Self::Item>> {
2674        let this = &mut *self;
2675        if this.inner.check_shutdown(cx) {
2676            this.is_terminated = true;
2677            return std::task::Poll::Ready(None);
2678        }
2679        if this.is_terminated {
2680            panic!("polled PortRequestStream after completion");
2681        }
2682        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
2683            |bytes, handles| {
2684                match this.inner.channel().read_etc(cx, bytes, handles) {
2685                    std::task::Poll::Ready(Ok(())) => {}
2686                    std::task::Poll::Pending => return std::task::Poll::Pending,
2687                    std::task::Poll::Ready(Err(None)) => {
2688                        this.is_terminated = true;
2689                        return std::task::Poll::Ready(None);
2690                    }
2691                    std::task::Poll::Ready(Err(Some(e))) => {
2692                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2693                            e.into(),
2694                        ))));
2695                    }
2696                }
2697
2698                // A message has been received from the channel
2699                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2700
2701                std::task::Poll::Ready(Some(match header.ordinal {
2702                    0x276cf65feb554ebd => {
2703                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2704                        let mut req = fidl::new_empty!(
2705                            fidl::encoding::EmptyPayload,
2706                            fdomain_client::fidl::FDomainResourceDialect
2707                        );
2708                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2709                        let control_handle = PortControlHandle { inner: this.inner.clone() };
2710                        Ok(PortRequest::GetInfo {
2711                            responder: PortGetInfoResponder {
2712                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2713                                tx_id: header.tx_id,
2714                            },
2715                        })
2716                    }
2717                    0x4235650aacca60b2 => {
2718                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2719                        let mut req = fidl::new_empty!(
2720                            fidl::encoding::EmptyPayload,
2721                            fdomain_client::fidl::FDomainResourceDialect
2722                        );
2723                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2724                        let control_handle = PortControlHandle { inner: this.inner.clone() };
2725                        Ok(PortRequest::GetStatus {
2726                            responder: PortGetStatusResponder {
2727                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2728                                tx_id: header.tx_id,
2729                            },
2730                        })
2731                    }
2732                    0x65511ab81c1bd8d4 => {
2733                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2734                        let mut req = fidl::new_empty!(
2735                            PortGetStatusWatcherRequest,
2736                            fdomain_client::fidl::FDomainResourceDialect
2737                        );
2738                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<PortGetStatusWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
2739                        let control_handle = PortControlHandle { inner: this.inner.clone() };
2740                        Ok(PortRequest::GetStatusWatcher {
2741                            watcher: req.watcher,
2742                            buffer: req.buffer,
2743
2744                            control_handle,
2745                        })
2746                    }
2747                    0x2c6ec2988aefc0f6 => {
2748                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2749                        let mut req = fidl::new_empty!(
2750                            PortGetMacRequest,
2751                            fdomain_client::fidl::FDomainResourceDialect
2752                        );
2753                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<PortGetMacRequest>(&header, _body_bytes, handles, &mut req)?;
2754                        let control_handle = PortControlHandle { inner: this.inner.clone() };
2755                        Ok(PortRequest::GetMac { mac: req.mac, control_handle })
2756                    }
2757                    0x7de34747235d2d80 => {
2758                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2759                        let mut req = fidl::new_empty!(
2760                            PortGetDeviceRequest,
2761                            fdomain_client::fidl::FDomainResourceDialect
2762                        );
2763                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<PortGetDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
2764                        let control_handle = PortControlHandle { inner: this.inner.clone() };
2765                        Ok(PortRequest::GetDevice { device: req.device, control_handle })
2766                    }
2767                    0x4e4764150b4942d3 => {
2768                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2769                        let mut req = fidl::new_empty!(
2770                            PortCloneRequest,
2771                            fdomain_client::fidl::FDomainResourceDialect
2772                        );
2773                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<PortCloneRequest>(&header, _body_bytes, handles, &mut req)?;
2774                        let control_handle = PortControlHandle { inner: this.inner.clone() };
2775                        Ok(PortRequest::Clone { port: req.port, control_handle })
2776                    }
2777                    0x6a213b03c4fcbbac => {
2778                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2779                        let mut req = fidl::new_empty!(
2780                            fidl::encoding::EmptyPayload,
2781                            fdomain_client::fidl::FDomainResourceDialect
2782                        );
2783                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2784                        let control_handle = PortControlHandle { inner: this.inner.clone() };
2785                        Ok(PortRequest::GetCounters {
2786                            responder: PortGetCountersResponder {
2787                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2788                                tx_id: header.tx_id,
2789                            },
2790                        })
2791                    }
2792                    0x381faa4ed75e399c => {
2793                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2794                        let mut req = fidl::new_empty!(
2795                            PortGetDiagnosticsRequest,
2796                            fdomain_client::fidl::FDomainResourceDialect
2797                        );
2798                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<PortGetDiagnosticsRequest>(&header, _body_bytes, handles, &mut req)?;
2799                        let control_handle = PortControlHandle { inner: this.inner.clone() };
2800                        Ok(PortRequest::GetDiagnostics {
2801                            diagnostics: req.diagnostics,
2802
2803                            control_handle,
2804                        })
2805                    }
2806                    0x75134ce0bc114e5a => {
2807                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2808                        let mut req = fidl::new_empty!(
2809                            fidl::encoding::EmptyPayload,
2810                            fdomain_client::fidl::FDomainResourceDialect
2811                        );
2812                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2813                        let control_handle = PortControlHandle { inner: this.inner.clone() };
2814                        Ok(PortRequest::GetIdentity {
2815                            responder: PortGetIdentityResponder {
2816                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2817                                tx_id: header.tx_id,
2818                            },
2819                        })
2820                    }
2821                    0x7bec1da6ec2476ed => {
2822                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2823                        let mut req = fidl::new_empty!(
2824                            fidl::encoding::EmptyPayload,
2825                            fdomain_client::fidl::FDomainResourceDialect
2826                        );
2827                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2828                        let control_handle = PortControlHandle { inner: this.inner.clone() };
2829                        Ok(PortRequest::GetPowerDependencyToken {
2830                            responder: PortGetPowerDependencyTokenResponder {
2831                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2832                                tx_id: header.tx_id,
2833                            },
2834                        })
2835                    }
2836                    _ => Err(fidl::Error::UnknownOrdinal {
2837                        ordinal: header.ordinal,
2838                        protocol_name:
2839                            <PortMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2840                    }),
2841                }))
2842            },
2843        )
2844    }
2845}
2846
2847/// A logical port belonging to a [`Device`].
2848#[derive(Debug)]
2849pub enum PortRequest {
2850    /// Obtain information about port.
2851    ///
2852    /// - response `info` port information.
2853    GetInfo { responder: PortGetInfoResponder },
2854    /// Obtain the operating port status.
2855    ///
2856    /// - response `status` snapshot of port's current status.
2857    GetStatus { responder: PortGetStatusResponder },
2858    /// Connects to a [`StatusWatcher`] to observe port status changes.
2859    ///
2860    /// + request `watcher` handle to the status watcher.
2861    /// + request `buffer` the number of status changes that the client requests
2862    /// to be stored by `StatusWatcher`. Values are capped at
2863    /// [`MAX_STATUS_BUFFER`]. A value of 0 or 1 causes the `StatusWatcher` to
2864    /// not keep any buffers on status changed. Clients that need to observe all
2865    /// changes to status (as opposed to only the current state) are encouraged
2866    /// to set a buffer value larger than 1, so that all edges can be observed.
2867    /// If `StatusWatcher`'s internal queue is filled and new status changes
2868    /// occur, the oldest samples will be dropped to make room for new ones.
2869    GetStatusWatcher {
2870        watcher: fdomain_client::fidl::ServerEnd<StatusWatcherMarker>,
2871        buffer: u32,
2872        control_handle: PortControlHandle,
2873    },
2874    /// Connects to a [`MacAddressing`] associated with the port.
2875    ///
2876    /// + request `mac` mac handle. Closed with `ZX_ERR_NOT_SUPPORTED` if this
2877    /// port does not support mac addressing.
2878    GetMac {
2879        mac: fdomain_client::fidl::ServerEnd<MacAddressingMarker>,
2880        control_handle: PortControlHandle,
2881    },
2882    /// Connects to the [`Device`] this port belongs to.
2883    ///
2884    /// + request `device` grants access to the parent device.
2885    GetDevice {
2886        device: fdomain_client::fidl::ServerEnd<DeviceMarker>,
2887        control_handle: PortControlHandle,
2888    },
2889    /// Establishes a new connection to this port.
2890    ///
2891    /// + request `port` the server end for the new connection.
2892    Clone { port: fdomain_client::fidl::ServerEnd<PortMarker>, control_handle: PortControlHandle },
2893    /// Retrieves a snapshot of traffic counters on this port.
2894    GetCounters { responder: PortGetCountersResponder },
2895    /// Grants access to [`Diagnostics`] for this port.
2896    ///
2897    /// + request `diagnostics` grants access to diagnostics information.
2898    GetDiagnostics {
2899        diagnostics: fdomain_client::fidl::ServerEnd<DiagnosticsMarker>,
2900        control_handle: PortControlHandle,
2901    },
2902    /// Retrieves a unique event handle that is always associated only with
2903    /// this port.
2904    ///
2905    /// This event may be used to uniquely identify a specific port instance
2906    /// across different APIs in the system.
2907    GetIdentity { responder: PortGetIdentityResponder },
2908    /// Gets the Power Broker dependency token for this port's power element.
2909    ///
2910    /// The token exposes two levels: `0` (off) and `1` (on). Clients lease
2911    /// level `1` whenever the port's datapath is required and hold the lease
2912    /// for as long as it is required. Drivers are free to internally
2913    /// power-manage a leased-but-idle port so long as it's invisible to upper
2914    /// layers.
2915    ///
2916    /// The token is fixed for the lifetime of the port.
2917    ///
2918    /// - response `token` absent if this port does not participate in power
2919    ///   management.
2920    GetPowerDependencyToken { responder: PortGetPowerDependencyTokenResponder },
2921}
2922
2923impl PortRequest {
2924    #[allow(irrefutable_let_patterns)]
2925    pub fn into_get_info(self) -> Option<(PortGetInfoResponder)> {
2926        if let PortRequest::GetInfo { responder } = self { Some((responder)) } else { None }
2927    }
2928
2929    #[allow(irrefutable_let_patterns)]
2930    pub fn into_get_status(self) -> Option<(PortGetStatusResponder)> {
2931        if let PortRequest::GetStatus { responder } = self { Some((responder)) } else { None }
2932    }
2933
2934    #[allow(irrefutable_let_patterns)]
2935    pub fn into_get_status_watcher(
2936        self,
2937    ) -> Option<(fdomain_client::fidl::ServerEnd<StatusWatcherMarker>, u32, PortControlHandle)>
2938    {
2939        if let PortRequest::GetStatusWatcher { watcher, buffer, control_handle } = self {
2940            Some((watcher, buffer, control_handle))
2941        } else {
2942            None
2943        }
2944    }
2945
2946    #[allow(irrefutable_let_patterns)]
2947    pub fn into_get_mac(
2948        self,
2949    ) -> Option<(fdomain_client::fidl::ServerEnd<MacAddressingMarker>, PortControlHandle)> {
2950        if let PortRequest::GetMac { mac, control_handle } = self {
2951            Some((mac, control_handle))
2952        } else {
2953            None
2954        }
2955    }
2956
2957    #[allow(irrefutable_let_patterns)]
2958    pub fn into_get_device(
2959        self,
2960    ) -> Option<(fdomain_client::fidl::ServerEnd<DeviceMarker>, PortControlHandle)> {
2961        if let PortRequest::GetDevice { device, control_handle } = self {
2962            Some((device, control_handle))
2963        } else {
2964            None
2965        }
2966    }
2967
2968    #[allow(irrefutable_let_patterns)]
2969    pub fn into_clone(
2970        self,
2971    ) -> Option<(fdomain_client::fidl::ServerEnd<PortMarker>, PortControlHandle)> {
2972        if let PortRequest::Clone { port, control_handle } = self {
2973            Some((port, control_handle))
2974        } else {
2975            None
2976        }
2977    }
2978
2979    #[allow(irrefutable_let_patterns)]
2980    pub fn into_get_counters(self) -> Option<(PortGetCountersResponder)> {
2981        if let PortRequest::GetCounters { responder } = self { Some((responder)) } else { None }
2982    }
2983
2984    #[allow(irrefutable_let_patterns)]
2985    pub fn into_get_diagnostics(
2986        self,
2987    ) -> Option<(fdomain_client::fidl::ServerEnd<DiagnosticsMarker>, PortControlHandle)> {
2988        if let PortRequest::GetDiagnostics { diagnostics, control_handle } = self {
2989            Some((diagnostics, control_handle))
2990        } else {
2991            None
2992        }
2993    }
2994
2995    #[allow(irrefutable_let_patterns)]
2996    pub fn into_get_identity(self) -> Option<(PortGetIdentityResponder)> {
2997        if let PortRequest::GetIdentity { responder } = self { Some((responder)) } else { None }
2998    }
2999
3000    #[allow(irrefutable_let_patterns)]
3001    pub fn into_get_power_dependency_token(self) -> Option<(PortGetPowerDependencyTokenResponder)> {
3002        if let PortRequest::GetPowerDependencyToken { responder } = self {
3003            Some((responder))
3004        } else {
3005            None
3006        }
3007    }
3008
3009    /// Name of the method defined in FIDL
3010    pub fn method_name(&self) -> &'static str {
3011        match *self {
3012            PortRequest::GetInfo { .. } => "get_info",
3013            PortRequest::GetStatus { .. } => "get_status",
3014            PortRequest::GetStatusWatcher { .. } => "get_status_watcher",
3015            PortRequest::GetMac { .. } => "get_mac",
3016            PortRequest::GetDevice { .. } => "get_device",
3017            PortRequest::Clone { .. } => "clone",
3018            PortRequest::GetCounters { .. } => "get_counters",
3019            PortRequest::GetDiagnostics { .. } => "get_diagnostics",
3020            PortRequest::GetIdentity { .. } => "get_identity",
3021            PortRequest::GetPowerDependencyToken { .. } => "get_power_dependency_token",
3022        }
3023    }
3024}
3025
3026#[derive(Debug, Clone)]
3027pub struct PortControlHandle {
3028    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3029}
3030
3031impl PortControlHandle {
3032    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3033        self.inner.shutdown_with_epitaph(status.into())
3034    }
3035}
3036
3037impl fdomain_client::fidl::ControlHandle for PortControlHandle {
3038    fn shutdown(&self) {
3039        self.inner.shutdown()
3040    }
3041
3042    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3043        self.inner.shutdown_with_epitaph(status)
3044    }
3045
3046    fn is_closed(&self) -> bool {
3047        self.inner.channel().is_closed()
3048    }
3049    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
3050        self.inner.channel().on_closed()
3051    }
3052}
3053
3054impl PortControlHandle {}
3055
3056#[must_use = "FIDL methods require a response to be sent"]
3057#[derive(Debug)]
3058pub struct PortGetInfoResponder {
3059    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3060    tx_id: u32,
3061}
3062
3063/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3064/// if the responder is dropped without sending a response, so that the client
3065/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3066impl std::ops::Drop for PortGetInfoResponder {
3067    fn drop(&mut self) {
3068        self.control_handle.shutdown();
3069        // Safety: drops once, never accessed again
3070        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3071    }
3072}
3073
3074impl fdomain_client::fidl::Responder for PortGetInfoResponder {
3075    type ControlHandle = PortControlHandle;
3076
3077    fn control_handle(&self) -> &PortControlHandle {
3078        &self.control_handle
3079    }
3080
3081    fn drop_without_shutdown(mut self) {
3082        // Safety: drops once, never accessed again due to mem::forget
3083        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3084        // Prevent Drop from running (which would shut down the channel)
3085        std::mem::forget(self);
3086    }
3087}
3088
3089impl PortGetInfoResponder {
3090    /// Sends a response to the FIDL transaction.
3091    ///
3092    /// Sets the channel to shutdown if an error occurs.
3093    pub fn send(self, mut info: &PortInfo) -> Result<(), fidl::Error> {
3094        let _result = self.send_raw(info);
3095        if _result.is_err() {
3096            self.control_handle.shutdown();
3097        }
3098        self.drop_without_shutdown();
3099        _result
3100    }
3101
3102    /// Similar to "send" but does not shutdown the channel if an error occurs.
3103    pub fn send_no_shutdown_on_err(self, mut info: &PortInfo) -> Result<(), fidl::Error> {
3104        let _result = self.send_raw(info);
3105        self.drop_without_shutdown();
3106        _result
3107    }
3108
3109    fn send_raw(&self, mut info: &PortInfo) -> Result<(), fidl::Error> {
3110        self.control_handle.inner.send::<PortGetInfoResponse>(
3111            (info,),
3112            self.tx_id,
3113            0x276cf65feb554ebd,
3114            fidl::encoding::DynamicFlags::empty(),
3115        )
3116    }
3117}
3118
3119#[must_use = "FIDL methods require a response to be sent"]
3120#[derive(Debug)]
3121pub struct PortGetStatusResponder {
3122    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3123    tx_id: u32,
3124}
3125
3126/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3127/// if the responder is dropped without sending a response, so that the client
3128/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3129impl std::ops::Drop for PortGetStatusResponder {
3130    fn drop(&mut self) {
3131        self.control_handle.shutdown();
3132        // Safety: drops once, never accessed again
3133        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3134    }
3135}
3136
3137impl fdomain_client::fidl::Responder for PortGetStatusResponder {
3138    type ControlHandle = PortControlHandle;
3139
3140    fn control_handle(&self) -> &PortControlHandle {
3141        &self.control_handle
3142    }
3143
3144    fn drop_without_shutdown(mut self) {
3145        // Safety: drops once, never accessed again due to mem::forget
3146        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3147        // Prevent Drop from running (which would shut down the channel)
3148        std::mem::forget(self);
3149    }
3150}
3151
3152impl PortGetStatusResponder {
3153    /// Sends a response to the FIDL transaction.
3154    ///
3155    /// Sets the channel to shutdown if an error occurs.
3156    pub fn send(self, mut status: &PortStatus) -> Result<(), fidl::Error> {
3157        let _result = self.send_raw(status);
3158        if _result.is_err() {
3159            self.control_handle.shutdown();
3160        }
3161        self.drop_without_shutdown();
3162        _result
3163    }
3164
3165    /// Similar to "send" but does not shutdown the channel if an error occurs.
3166    pub fn send_no_shutdown_on_err(self, mut status: &PortStatus) -> Result<(), fidl::Error> {
3167        let _result = self.send_raw(status);
3168        self.drop_without_shutdown();
3169        _result
3170    }
3171
3172    fn send_raw(&self, mut status: &PortStatus) -> Result<(), fidl::Error> {
3173        self.control_handle.inner.send::<PortGetStatusResponse>(
3174            (status,),
3175            self.tx_id,
3176            0x4235650aacca60b2,
3177            fidl::encoding::DynamicFlags::empty(),
3178        )
3179    }
3180}
3181
3182#[must_use = "FIDL methods require a response to be sent"]
3183#[derive(Debug)]
3184pub struct PortGetCountersResponder {
3185    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3186    tx_id: u32,
3187}
3188
3189/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3190/// if the responder is dropped without sending a response, so that the client
3191/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3192impl std::ops::Drop for PortGetCountersResponder {
3193    fn drop(&mut self) {
3194        self.control_handle.shutdown();
3195        // Safety: drops once, never accessed again
3196        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3197    }
3198}
3199
3200impl fdomain_client::fidl::Responder for PortGetCountersResponder {
3201    type ControlHandle = PortControlHandle;
3202
3203    fn control_handle(&self) -> &PortControlHandle {
3204        &self.control_handle
3205    }
3206
3207    fn drop_without_shutdown(mut self) {
3208        // Safety: drops once, never accessed again due to mem::forget
3209        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3210        // Prevent Drop from running (which would shut down the channel)
3211        std::mem::forget(self);
3212    }
3213}
3214
3215impl PortGetCountersResponder {
3216    /// Sends a response to the FIDL transaction.
3217    ///
3218    /// Sets the channel to shutdown if an error occurs.
3219    pub fn send(self, mut payload: &PortGetCountersResponse) -> Result<(), fidl::Error> {
3220        let _result = self.send_raw(payload);
3221        if _result.is_err() {
3222            self.control_handle.shutdown();
3223        }
3224        self.drop_without_shutdown();
3225        _result
3226    }
3227
3228    /// Similar to "send" but does not shutdown the channel if an error occurs.
3229    pub fn send_no_shutdown_on_err(
3230        self,
3231        mut payload: &PortGetCountersResponse,
3232    ) -> Result<(), fidl::Error> {
3233        let _result = self.send_raw(payload);
3234        self.drop_without_shutdown();
3235        _result
3236    }
3237
3238    fn send_raw(&self, mut payload: &PortGetCountersResponse) -> Result<(), fidl::Error> {
3239        self.control_handle.inner.send::<PortGetCountersResponse>(
3240            payload,
3241            self.tx_id,
3242            0x6a213b03c4fcbbac,
3243            fidl::encoding::DynamicFlags::empty(),
3244        )
3245    }
3246}
3247
3248#[must_use = "FIDL methods require a response to be sent"]
3249#[derive(Debug)]
3250pub struct PortGetIdentityResponder {
3251    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3252    tx_id: u32,
3253}
3254
3255/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3256/// if the responder is dropped without sending a response, so that the client
3257/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3258impl std::ops::Drop for PortGetIdentityResponder {
3259    fn drop(&mut self) {
3260        self.control_handle.shutdown();
3261        // Safety: drops once, never accessed again
3262        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3263    }
3264}
3265
3266impl fdomain_client::fidl::Responder for PortGetIdentityResponder {
3267    type ControlHandle = PortControlHandle;
3268
3269    fn control_handle(&self) -> &PortControlHandle {
3270        &self.control_handle
3271    }
3272
3273    fn drop_without_shutdown(mut self) {
3274        // Safety: drops once, never accessed again due to mem::forget
3275        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3276        // Prevent Drop from running (which would shut down the channel)
3277        std::mem::forget(self);
3278    }
3279}
3280
3281impl PortGetIdentityResponder {
3282    /// Sends a response to the FIDL transaction.
3283    ///
3284    /// Sets the channel to shutdown if an error occurs.
3285    pub fn send(self, mut event: fdomain_client::Event) -> Result<(), fidl::Error> {
3286        let _result = self.send_raw(event);
3287        if _result.is_err() {
3288            self.control_handle.shutdown();
3289        }
3290        self.drop_without_shutdown();
3291        _result
3292    }
3293
3294    /// Similar to "send" but does not shutdown the channel if an error occurs.
3295    pub fn send_no_shutdown_on_err(
3296        self,
3297        mut event: fdomain_client::Event,
3298    ) -> Result<(), fidl::Error> {
3299        let _result = self.send_raw(event);
3300        self.drop_without_shutdown();
3301        _result
3302    }
3303
3304    fn send_raw(&self, mut event: fdomain_client::Event) -> Result<(), fidl::Error> {
3305        self.control_handle.inner.send::<PortGetIdentityResponse>(
3306            (event,),
3307            self.tx_id,
3308            0x75134ce0bc114e5a,
3309            fidl::encoding::DynamicFlags::empty(),
3310        )
3311    }
3312}
3313
3314#[must_use = "FIDL methods require a response to be sent"]
3315#[derive(Debug)]
3316pub struct PortGetPowerDependencyTokenResponder {
3317    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3318    tx_id: u32,
3319}
3320
3321/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3322/// if the responder is dropped without sending a response, so that the client
3323/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3324impl std::ops::Drop for PortGetPowerDependencyTokenResponder {
3325    fn drop(&mut self) {
3326        self.control_handle.shutdown();
3327        // Safety: drops once, never accessed again
3328        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3329    }
3330}
3331
3332impl fdomain_client::fidl::Responder for PortGetPowerDependencyTokenResponder {
3333    type ControlHandle = PortControlHandle;
3334
3335    fn control_handle(&self) -> &PortControlHandle {
3336        &self.control_handle
3337    }
3338
3339    fn drop_without_shutdown(mut self) {
3340        // Safety: drops once, never accessed again due to mem::forget
3341        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3342        // Prevent Drop from running (which would shut down the channel)
3343        std::mem::forget(self);
3344    }
3345}
3346
3347impl PortGetPowerDependencyTokenResponder {
3348    /// Sends a response to the FIDL transaction.
3349    ///
3350    /// Sets the channel to shutdown if an error occurs.
3351    pub fn send(self, mut token: Option<fdomain_client::Event>) -> Result<(), fidl::Error> {
3352        let _result = self.send_raw(token);
3353        if _result.is_err() {
3354            self.control_handle.shutdown();
3355        }
3356        self.drop_without_shutdown();
3357        _result
3358    }
3359
3360    /// Similar to "send" but does not shutdown the channel if an error occurs.
3361    pub fn send_no_shutdown_on_err(
3362        self,
3363        mut token: Option<fdomain_client::Event>,
3364    ) -> Result<(), fidl::Error> {
3365        let _result = self.send_raw(token);
3366        self.drop_without_shutdown();
3367        _result
3368    }
3369
3370    fn send_raw(&self, mut token: Option<fdomain_client::Event>) -> Result<(), fidl::Error> {
3371        self.control_handle.inner.send::<PortGetPowerDependencyTokenResponse>(
3372            (token,),
3373            self.tx_id,
3374            0x7bec1da6ec2476ed,
3375            fidl::encoding::DynamicFlags::empty(),
3376        )
3377    }
3378}
3379
3380#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3381pub struct PortWatcherMarker;
3382
3383impl fdomain_client::fidl::ProtocolMarker for PortWatcherMarker {
3384    type Proxy = PortWatcherProxy;
3385    type RequestStream = PortWatcherRequestStream;
3386
3387    const DEBUG_NAME: &'static str = "(anonymous) PortWatcher";
3388}
3389
3390pub trait PortWatcherProxyInterface: Send + Sync {
3391    type WatchResponseFut: std::future::Future<Output = Result<DevicePortEvent, fidl::Error>> + Send;
3392    fn r#watch(&self) -> Self::WatchResponseFut;
3393}
3394
3395#[derive(Debug, Clone)]
3396pub struct PortWatcherProxy {
3397    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
3398}
3399
3400impl fdomain_client::fidl::Proxy for PortWatcherProxy {
3401    type Protocol = PortWatcherMarker;
3402
3403    fn from_channel(inner: fdomain_client::Channel) -> Self {
3404        Self::new(inner)
3405    }
3406
3407    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
3408        self.client.into_channel().map_err(|client| Self { client })
3409    }
3410
3411    fn as_channel(&self) -> &fdomain_client::Channel {
3412        self.client.as_channel()
3413    }
3414}
3415
3416impl PortWatcherProxy {
3417    /// Create a new Proxy for fuchsia.hardware.network/PortWatcher.
3418    pub fn new(channel: fdomain_client::Channel) -> Self {
3419        let protocol_name = <PortWatcherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
3420        Self { client: fidl::client::Client::new(channel, protocol_name) }
3421    }
3422
3423    /// Get a Stream of events from the remote end of the protocol.
3424    ///
3425    /// # Panics
3426    ///
3427    /// Panics if the event stream was already taken.
3428    pub fn take_event_stream(&self) -> PortWatcherEventStream {
3429        PortWatcherEventStream { event_receiver: self.client.take_event_receiver() }
3430    }
3431
3432    /// Get the next port event.
3433    ///
3434    /// The first N calls return [`DevicePortEvent.existing`] where N is the
3435    /// number of ports present on the device at the time of the watcher's
3436    /// creation. The next call returns [`DevicePortEvent.idle`] to indicate the
3437    /// end of existing ports. Subsequent calls block until a port is added
3438    /// ([`DevicePortEvent.added`]) or removed ([`DevicePortEvent.removed`]).
3439    ///
3440    /// The server closes the `PortWatcher` channel with `ZX_ERR_CANCELED` if
3441    /// the number of unread events reaches a server-selected limit that is at
3442    /// least two times [`MAX_PORTS`]. Clients are encouraged to maintain a
3443    /// hanging call to `Watch` at all times to avoid triggering this condition.
3444    ///
3445    /// - response `event` next port event.
3446    pub fn r#watch(
3447        &self,
3448    ) -> fidl::client::QueryResponseFut<DevicePortEvent, fdomain_client::fidl::FDomainResourceDialect>
3449    {
3450        PortWatcherProxyInterface::r#watch(self)
3451    }
3452}
3453
3454impl PortWatcherProxyInterface for PortWatcherProxy {
3455    type WatchResponseFut = fidl::client::QueryResponseFut<
3456        DevicePortEvent,
3457        fdomain_client::fidl::FDomainResourceDialect,
3458    >;
3459    fn r#watch(&self) -> Self::WatchResponseFut {
3460        fn _decode(
3461            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3462        ) -> Result<DevicePortEvent, fidl::Error> {
3463            let _response = fidl::client::decode_transaction_body::<
3464                PortWatcherWatchResponse,
3465                fdomain_client::fidl::FDomainResourceDialect,
3466                0x3e87244b74fff55e,
3467            >(_buf?)?;
3468            Ok(_response.event)
3469        }
3470        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DevicePortEvent>(
3471            (),
3472            0x3e87244b74fff55e,
3473            fidl::encoding::DynamicFlags::empty(),
3474            _decode,
3475        )
3476    }
3477}
3478
3479pub struct PortWatcherEventStream {
3480    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
3481}
3482
3483impl std::marker::Unpin for PortWatcherEventStream {}
3484
3485impl futures::stream::FusedStream for PortWatcherEventStream {
3486    fn is_terminated(&self) -> bool {
3487        self.event_receiver.is_terminated()
3488    }
3489}
3490
3491impl futures::Stream for PortWatcherEventStream {
3492    type Item = Result<PortWatcherEvent, fidl::Error>;
3493
3494    fn poll_next(
3495        mut self: std::pin::Pin<&mut Self>,
3496        cx: &mut std::task::Context<'_>,
3497    ) -> std::task::Poll<Option<Self::Item>> {
3498        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3499            &mut self.event_receiver,
3500            cx
3501        )?) {
3502            Some(buf) => std::task::Poll::Ready(Some(PortWatcherEvent::decode(buf))),
3503            None => std::task::Poll::Ready(None),
3504        }
3505    }
3506}
3507
3508#[derive(Debug)]
3509pub enum PortWatcherEvent {}
3510
3511impl PortWatcherEvent {
3512    /// Decodes a message buffer as a [`PortWatcherEvent`].
3513    fn decode(
3514        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3515    ) -> Result<PortWatcherEvent, fidl::Error> {
3516        let (bytes, _handles) = buf.split_mut();
3517        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3518        debug_assert_eq!(tx_header.tx_id, 0);
3519        match tx_header.ordinal {
3520            _ => Err(fidl::Error::UnknownOrdinal {
3521                ordinal: tx_header.ordinal,
3522                protocol_name:
3523                    <PortWatcherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
3524            }),
3525        }
3526    }
3527}
3528
3529/// A Stream of incoming requests for fuchsia.hardware.network/PortWatcher.
3530pub struct PortWatcherRequestStream {
3531    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3532    is_terminated: bool,
3533}
3534
3535impl std::marker::Unpin for PortWatcherRequestStream {}
3536
3537impl futures::stream::FusedStream for PortWatcherRequestStream {
3538    fn is_terminated(&self) -> bool {
3539        self.is_terminated
3540    }
3541}
3542
3543impl fdomain_client::fidl::RequestStream for PortWatcherRequestStream {
3544    type Protocol = PortWatcherMarker;
3545    type ControlHandle = PortWatcherControlHandle;
3546
3547    fn from_channel(channel: fdomain_client::Channel) -> Self {
3548        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3549    }
3550
3551    fn control_handle(&self) -> Self::ControlHandle {
3552        PortWatcherControlHandle { inner: self.inner.clone() }
3553    }
3554
3555    fn into_inner(
3556        self,
3557    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
3558    {
3559        (self.inner, self.is_terminated)
3560    }
3561
3562    fn from_inner(
3563        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3564        is_terminated: bool,
3565    ) -> Self {
3566        Self { inner, is_terminated }
3567    }
3568}
3569
3570impl futures::Stream for PortWatcherRequestStream {
3571    type Item = Result<PortWatcherRequest, fidl::Error>;
3572
3573    fn poll_next(
3574        mut self: std::pin::Pin<&mut Self>,
3575        cx: &mut std::task::Context<'_>,
3576    ) -> std::task::Poll<Option<Self::Item>> {
3577        let this = &mut *self;
3578        if this.inner.check_shutdown(cx) {
3579            this.is_terminated = true;
3580            return std::task::Poll::Ready(None);
3581        }
3582        if this.is_terminated {
3583            panic!("polled PortWatcherRequestStream after completion");
3584        }
3585        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
3586            |bytes, handles| {
3587                match this.inner.channel().read_etc(cx, bytes, handles) {
3588                    std::task::Poll::Ready(Ok(())) => {}
3589                    std::task::Poll::Pending => return std::task::Poll::Pending,
3590                    std::task::Poll::Ready(Err(None)) => {
3591                        this.is_terminated = true;
3592                        return std::task::Poll::Ready(None);
3593                    }
3594                    std::task::Poll::Ready(Err(Some(e))) => {
3595                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3596                            e.into(),
3597                        ))));
3598                    }
3599                }
3600
3601                // A message has been received from the channel
3602                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3603
3604                std::task::Poll::Ready(Some(match header.ordinal {
3605                    0x3e87244b74fff55e => {
3606                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3607                        let mut req = fidl::new_empty!(
3608                            fidl::encoding::EmptyPayload,
3609                            fdomain_client::fidl::FDomainResourceDialect
3610                        );
3611                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3612                        let control_handle = PortWatcherControlHandle { inner: this.inner.clone() };
3613                        Ok(PortWatcherRequest::Watch {
3614                            responder: PortWatcherWatchResponder {
3615                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3616                                tx_id: header.tx_id,
3617                            },
3618                        })
3619                    }
3620                    _ => Err(fidl::Error::UnknownOrdinal {
3621                        ordinal: header.ordinal,
3622                        protocol_name:
3623                            <PortWatcherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
3624                    }),
3625                }))
3626            },
3627        )
3628    }
3629}
3630
3631/// Provides iteration over and updates for ports attached to a device.
3632#[derive(Debug)]
3633pub enum PortWatcherRequest {
3634    /// Get the next port event.
3635    ///
3636    /// The first N calls return [`DevicePortEvent.existing`] where N is the
3637    /// number of ports present on the device at the time of the watcher's
3638    /// creation. The next call returns [`DevicePortEvent.idle`] to indicate the
3639    /// end of existing ports. Subsequent calls block until a port is added
3640    /// ([`DevicePortEvent.added`]) or removed ([`DevicePortEvent.removed`]).
3641    ///
3642    /// The server closes the `PortWatcher` channel with `ZX_ERR_CANCELED` if
3643    /// the number of unread events reaches a server-selected limit that is at
3644    /// least two times [`MAX_PORTS`]. Clients are encouraged to maintain a
3645    /// hanging call to `Watch` at all times to avoid triggering this condition.
3646    ///
3647    /// - response `event` next port event.
3648    Watch { responder: PortWatcherWatchResponder },
3649}
3650
3651impl PortWatcherRequest {
3652    #[allow(irrefutable_let_patterns)]
3653    pub fn into_watch(self) -> Option<(PortWatcherWatchResponder)> {
3654        if let PortWatcherRequest::Watch { responder } = self { Some((responder)) } else { None }
3655    }
3656
3657    /// Name of the method defined in FIDL
3658    pub fn method_name(&self) -> &'static str {
3659        match *self {
3660            PortWatcherRequest::Watch { .. } => "watch",
3661        }
3662    }
3663}
3664
3665#[derive(Debug, Clone)]
3666pub struct PortWatcherControlHandle {
3667    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3668}
3669
3670impl PortWatcherControlHandle {
3671    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3672        self.inner.shutdown_with_epitaph(status.into())
3673    }
3674}
3675
3676impl fdomain_client::fidl::ControlHandle for PortWatcherControlHandle {
3677    fn shutdown(&self) {
3678        self.inner.shutdown()
3679    }
3680
3681    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3682        self.inner.shutdown_with_epitaph(status)
3683    }
3684
3685    fn is_closed(&self) -> bool {
3686        self.inner.channel().is_closed()
3687    }
3688    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
3689        self.inner.channel().on_closed()
3690    }
3691}
3692
3693impl PortWatcherControlHandle {}
3694
3695#[must_use = "FIDL methods require a response to be sent"]
3696#[derive(Debug)]
3697pub struct PortWatcherWatchResponder {
3698    control_handle: std::mem::ManuallyDrop<PortWatcherControlHandle>,
3699    tx_id: u32,
3700}
3701
3702/// Set the the channel to be shutdown (see [`PortWatcherControlHandle::shutdown`])
3703/// if the responder is dropped without sending a response, so that the client
3704/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3705impl std::ops::Drop for PortWatcherWatchResponder {
3706    fn drop(&mut self) {
3707        self.control_handle.shutdown();
3708        // Safety: drops once, never accessed again
3709        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3710    }
3711}
3712
3713impl fdomain_client::fidl::Responder for PortWatcherWatchResponder {
3714    type ControlHandle = PortWatcherControlHandle;
3715
3716    fn control_handle(&self) -> &PortWatcherControlHandle {
3717        &self.control_handle
3718    }
3719
3720    fn drop_without_shutdown(mut self) {
3721        // Safety: drops once, never accessed again due to mem::forget
3722        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3723        // Prevent Drop from running (which would shut down the channel)
3724        std::mem::forget(self);
3725    }
3726}
3727
3728impl PortWatcherWatchResponder {
3729    /// Sends a response to the FIDL transaction.
3730    ///
3731    /// Sets the channel to shutdown if an error occurs.
3732    pub fn send(self, mut event: &DevicePortEvent) -> Result<(), fidl::Error> {
3733        let _result = self.send_raw(event);
3734        if _result.is_err() {
3735            self.control_handle.shutdown();
3736        }
3737        self.drop_without_shutdown();
3738        _result
3739    }
3740
3741    /// Similar to "send" but does not shutdown the channel if an error occurs.
3742    pub fn send_no_shutdown_on_err(self, mut event: &DevicePortEvent) -> Result<(), fidl::Error> {
3743        let _result = self.send_raw(event);
3744        self.drop_without_shutdown();
3745        _result
3746    }
3747
3748    fn send_raw(&self, mut event: &DevicePortEvent) -> Result<(), fidl::Error> {
3749        self.control_handle.inner.send::<PortWatcherWatchResponse>(
3750            (event,),
3751            self.tx_id,
3752            0x3e87244b74fff55e,
3753            fidl::encoding::DynamicFlags::empty(),
3754        )
3755    }
3756}
3757
3758#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3759pub struct SessionMarker;
3760
3761impl fdomain_client::fidl::ProtocolMarker for SessionMarker {
3762    type Proxy = SessionProxy;
3763    type RequestStream = SessionRequestStream;
3764
3765    const DEBUG_NAME: &'static str = "(anonymous) Session";
3766}
3767pub type SessionAttachResult = Result<(), i32>;
3768pub type SessionDetachResult = Result<(), i32>;
3769
3770pub trait SessionProxyInterface: Send + Sync {
3771    type AttachResponseFut: std::future::Future<Output = Result<SessionAttachResult, fidl::Error>>
3772        + Send;
3773    fn r#attach(&self, port: &PortId, rx_frames: &[FrameType]) -> Self::AttachResponseFut;
3774    type DetachResponseFut: std::future::Future<Output = Result<SessionDetachResult, fidl::Error>>
3775        + Send;
3776    fn r#detach(&self, port: &PortId) -> Self::DetachResponseFut;
3777    fn r#close(&self) -> Result<(), fidl::Error>;
3778    type WatchDelegatedRxLeaseResponseFut: std::future::Future<Output = Result<DelegatedRxLease, fidl::Error>>
3779        + Send;
3780    fn r#watch_delegated_rx_lease(&self) -> Self::WatchDelegatedRxLeaseResponseFut;
3781    type RegisterForTxResponseFut: std::future::Future<Output = Result<(u8, i32), fidl::Error>>
3782        + Send;
3783    fn r#register_for_tx(&self, vmos: &[u8]) -> Self::RegisterForTxResponseFut;
3784    type UnregisterForTxResponseFut: std::future::Future<Output = Result<(u8, i32), fidl::Error>>
3785        + Send;
3786    fn r#unregister_for_tx(&self, vmos: &[u8]) -> Self::UnregisterForTxResponseFut;
3787}
3788
3789#[derive(Debug, Clone)]
3790pub struct SessionProxy {
3791    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
3792}
3793
3794impl fdomain_client::fidl::Proxy for SessionProxy {
3795    type Protocol = SessionMarker;
3796
3797    fn from_channel(inner: fdomain_client::Channel) -> Self {
3798        Self::new(inner)
3799    }
3800
3801    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
3802        self.client.into_channel().map_err(|client| Self { client })
3803    }
3804
3805    fn as_channel(&self) -> &fdomain_client::Channel {
3806        self.client.as_channel()
3807    }
3808}
3809
3810impl SessionProxy {
3811    /// Create a new Proxy for fuchsia.hardware.network/Session.
3812    pub fn new(channel: fdomain_client::Channel) -> Self {
3813        let protocol_name = <SessionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
3814        Self { client: fidl::client::Client::new(channel, protocol_name) }
3815    }
3816
3817    /// Get a Stream of events from the remote end of the protocol.
3818    ///
3819    /// # Panics
3820    ///
3821    /// Panics if the event stream was already taken.
3822    pub fn take_event_stream(&self) -> SessionEventStream {
3823        SessionEventStream { event_receiver: self.client.take_event_receiver() }
3824    }
3825
3826    /// Attaches the session to `port`.
3827    ///
3828    /// Once attached, the session starts to receive the subscribed frames over
3829    /// the data FIFOs and it may send frames destined to the specified `port`.
3830    ///
3831    /// + request `port` port to subscribe to.
3832    /// + request `rx_frames` Frame types of interest on the port.
3833    /// * error `ZX_ERR_NOT_FOUND` if `port` is not valid.
3834    /// * error `ZX_ERR_INVALID_ARGS` if `rx_frames` is not a subset of the
3835    /// port's supported frames.
3836    /// * error `ZX_ERR_ALREADY_BOUND` if `port` is already attached.
3837    pub fn r#attach(
3838        &self,
3839        mut port: &PortId,
3840        mut rx_frames: &[FrameType],
3841    ) -> fidl::client::QueryResponseFut<
3842        SessionAttachResult,
3843        fdomain_client::fidl::FDomainResourceDialect,
3844    > {
3845        SessionProxyInterface::r#attach(self, port, rx_frames)
3846    }
3847
3848    /// Detaches the session from `port`.
3849    ///
3850    /// Once detached, the session stops receiving frames from `port`. Frames
3851    /// sent to a detached port may be returned with an error. It is not
3852    /// necessary to call `Detach` on ports that are removed from the device,
3853    /// doing so causes `ZX_ERR_NOT_FOUND` to be returned.
3854    ///
3855    /// + request `port` port to subscribe to.
3856    /// * error `ZX_ERR_NOT_FOUND` if the session is not currently attached to
3857    /// the port.
3858    pub fn r#detach(
3859        &self,
3860        mut port: &PortId,
3861    ) -> fidl::client::QueryResponseFut<
3862        SessionDetachResult,
3863        fdomain_client::fidl::FDomainResourceDialect,
3864    > {
3865        SessionProxyInterface::r#detach(self, port)
3866    }
3867
3868    /// Cleanly closes a session.
3869    ///
3870    /// This will cause the session to send a `ZX_ERR_CANCELLED` epitaph and
3871    /// proceed to close the Session channel. Clients may only assume that they
3872    /// own all the buffers that are currently owned by the session (sent over
3873    /// either the rx or tx FIFOs) once the epitaph is received. Closing the rx
3874    /// or tx FIFO is equivalent to calling `Close`.
3875    pub fn r#close(&self) -> Result<(), fidl::Error> {
3876        SessionProxyInterface::r#close(self)
3877    }
3878
3879    /// Watchers for delegated receive wakeup leases.
3880    ///
3881    /// Calls block until a lease is delegated by the device. If a call to
3882    /// `WatchDelegatedRxLease` is made while a previous call is blocking, the
3883    /// session is closed with `ZX_ERR_BAD_STATE`. Will never yield any values
3884    /// for sessions created without [`SessionFlags.RECEIVE_RX_POWER_LEASES`].
3885    ///
3886    /// Given a single lease is assumed sufficient to keep the system awake, the
3887    /// server only keeps a single lease in its buffer. If a new delegated lease
3888    /// becomes available and the client hasn't popped the previous one with a
3889    /// call to `WatchDelegatedRxLease`, the server drops the previously pending
3890    /// lease.
3891    ///
3892    /// See [`DelegatedRxLease`] for how to handle delegated leases.
3893    pub fn r#watch_delegated_rx_lease(
3894        &self,
3895    ) -> fidl::client::QueryResponseFut<
3896        DelegatedRxLease,
3897        fdomain_client::fidl::FDomainResourceDialect,
3898    > {
3899        SessionProxyInterface::r#watch_delegated_rx_lease(self)
3900    }
3901
3902    /// Asks the network device to register the VMO for Tx.
3903    ///
3904    /// The network device prepares the VMOs in order and stops at the first
3905    /// error if any. It returns how many VMOs have been prepared alongside with
3906    /// the first error encountered. Note that network-device itself does not
3907    /// try to release earlier VMOs for a later error. It is up to the client
3908    /// how to recover from an error.
3909    ///
3910    /// * error `ZX_ERR_NOT_FOUND` if any of the VmoId is unknown.
3911    /// * error other zx status that can be reported by the driver.
3912    pub fn r#register_for_tx(
3913        &self,
3914        mut vmos: &[u8],
3915    ) -> fidl::client::QueryResponseFut<(u8, i32), fdomain_client::fidl::FDomainResourceDialect>
3916    {
3917        SessionProxyInterface::r#register_for_tx(self, vmos)
3918    }
3919
3920    /// Tells the device that the client will no longer use the VMO for Tx,
3921    /// if the VMO is also unused for Rx, the device is free to release it
3922    /// at the implementation driver.
3923    ///
3924    /// The network device processes the VMOs in order and stops at the first
3925    /// error if any. It returns how many VMOs have been marked as unused for Tx
3926    /// alongside with the first error encountered. Note that network-device
3927    /// itself does not try to re-register earlier VMOs for a later error. It is
3928    /// up to the client how to recover from an error.
3929    ///
3930    /// * error `ZX_ERR_NOT_FOUND` if any of the VmoId is unknown.
3931    /// * error other zx status that can be reported by the driver.
3932    pub fn r#unregister_for_tx(
3933        &self,
3934        mut vmos: &[u8],
3935    ) -> fidl::client::QueryResponseFut<(u8, i32), fdomain_client::fidl::FDomainResourceDialect>
3936    {
3937        SessionProxyInterface::r#unregister_for_tx(self, vmos)
3938    }
3939}
3940
3941impl SessionProxyInterface for SessionProxy {
3942    type AttachResponseFut = fidl::client::QueryResponseFut<
3943        SessionAttachResult,
3944        fdomain_client::fidl::FDomainResourceDialect,
3945    >;
3946    fn r#attach(&self, mut port: &PortId, mut rx_frames: &[FrameType]) -> Self::AttachResponseFut {
3947        fn _decode(
3948            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3949        ) -> Result<SessionAttachResult, fidl::Error> {
3950            let _response = fidl::client::decode_transaction_body::<
3951                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3952                fdomain_client::fidl::FDomainResourceDialect,
3953                0x1e89c9013e201379,
3954            >(_buf?)?;
3955            Ok(_response.map(|x| x))
3956        }
3957        self.client.send_query_and_decode::<SessionAttachRequest, SessionAttachResult>(
3958            (port, rx_frames),
3959            0x1e89c9013e201379,
3960            fidl::encoding::DynamicFlags::empty(),
3961            _decode,
3962        )
3963    }
3964
3965    type DetachResponseFut = fidl::client::QueryResponseFut<
3966        SessionDetachResult,
3967        fdomain_client::fidl::FDomainResourceDialect,
3968    >;
3969    fn r#detach(&self, mut port: &PortId) -> Self::DetachResponseFut {
3970        fn _decode(
3971            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3972        ) -> Result<SessionDetachResult, fidl::Error> {
3973            let _response = fidl::client::decode_transaction_body::<
3974                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3975                fdomain_client::fidl::FDomainResourceDialect,
3976                0x68c40cf8fb549867,
3977            >(_buf?)?;
3978            Ok(_response.map(|x| x))
3979        }
3980        self.client.send_query_and_decode::<SessionDetachRequest, SessionDetachResult>(
3981            (port,),
3982            0x68c40cf8fb549867,
3983            fidl::encoding::DynamicFlags::empty(),
3984            _decode,
3985        )
3986    }
3987
3988    fn r#close(&self) -> Result<(), fidl::Error> {
3989        self.client.send::<fidl::encoding::EmptyPayload>(
3990            (),
3991            0x393d5070394a92f6,
3992            fidl::encoding::DynamicFlags::empty(),
3993        )
3994    }
3995
3996    type WatchDelegatedRxLeaseResponseFut = fidl::client::QueryResponseFut<
3997        DelegatedRxLease,
3998        fdomain_client::fidl::FDomainResourceDialect,
3999    >;
4000    fn r#watch_delegated_rx_lease(&self) -> Self::WatchDelegatedRxLeaseResponseFut {
4001        fn _decode(
4002            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4003        ) -> Result<DelegatedRxLease, fidl::Error> {
4004            let _response = fidl::client::decode_transaction_body::<
4005                SessionWatchDelegatedRxLeaseResponse,
4006                fdomain_client::fidl::FDomainResourceDialect,
4007                0x764d823ee64803b5,
4008            >(_buf?)?;
4009            Ok(_response.lease)
4010        }
4011        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DelegatedRxLease>(
4012            (),
4013            0x764d823ee64803b5,
4014            fidl::encoding::DynamicFlags::empty(),
4015            _decode,
4016        )
4017    }
4018
4019    type RegisterForTxResponseFut =
4020        fidl::client::QueryResponseFut<(u8, i32), fdomain_client::fidl::FDomainResourceDialect>;
4021    fn r#register_for_tx(&self, mut vmos: &[u8]) -> Self::RegisterForTxResponseFut {
4022        fn _decode(
4023            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4024        ) -> Result<(u8, i32), fidl::Error> {
4025            let _response = fidl::client::decode_transaction_body::<
4026                SessionRegisterForTxResponse,
4027                fdomain_client::fidl::FDomainResourceDialect,
4028                0x36321799ce2a081a,
4029            >(_buf?)?;
4030            Ok((_response.successful, _response.status))
4031        }
4032        self.client.send_query_and_decode::<SessionRegisterForTxRequest, (u8, i32)>(
4033            (vmos,),
4034            0x36321799ce2a081a,
4035            fidl::encoding::DynamicFlags::empty(),
4036            _decode,
4037        )
4038    }
4039
4040    type UnregisterForTxResponseFut =
4041        fidl::client::QueryResponseFut<(u8, i32), fdomain_client::fidl::FDomainResourceDialect>;
4042    fn r#unregister_for_tx(&self, mut vmos: &[u8]) -> Self::UnregisterForTxResponseFut {
4043        fn _decode(
4044            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4045        ) -> Result<(u8, i32), fidl::Error> {
4046            let _response = fidl::client::decode_transaction_body::<
4047                SessionUnregisterForTxResponse,
4048                fdomain_client::fidl::FDomainResourceDialect,
4049                0x3e76b16030d62796,
4050            >(_buf?)?;
4051            Ok((_response.successful, _response.status))
4052        }
4053        self.client.send_query_and_decode::<SessionUnregisterForTxRequest, (u8, i32)>(
4054            (vmos,),
4055            0x3e76b16030d62796,
4056            fidl::encoding::DynamicFlags::empty(),
4057            _decode,
4058        )
4059    }
4060}
4061
4062pub struct SessionEventStream {
4063    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
4064}
4065
4066impl std::marker::Unpin for SessionEventStream {}
4067
4068impl futures::stream::FusedStream for SessionEventStream {
4069    fn is_terminated(&self) -> bool {
4070        self.event_receiver.is_terminated()
4071    }
4072}
4073
4074impl futures::Stream for SessionEventStream {
4075    type Item = Result<SessionEvent, fidl::Error>;
4076
4077    fn poll_next(
4078        mut self: std::pin::Pin<&mut Self>,
4079        cx: &mut std::task::Context<'_>,
4080    ) -> std::task::Poll<Option<Self::Item>> {
4081        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4082            &mut self.event_receiver,
4083            cx
4084        )?) {
4085            Some(buf) => std::task::Poll::Ready(Some(SessionEvent::decode(buf))),
4086            None => std::task::Poll::Ready(None),
4087        }
4088    }
4089}
4090
4091#[derive(Debug)]
4092pub enum SessionEvent {}
4093
4094impl SessionEvent {
4095    /// Decodes a message buffer as a [`SessionEvent`].
4096    fn decode(
4097        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4098    ) -> Result<SessionEvent, fidl::Error> {
4099        let (bytes, _handles) = buf.split_mut();
4100        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4101        debug_assert_eq!(tx_header.tx_id, 0);
4102        match tx_header.ordinal {
4103            _ => Err(fidl::Error::UnknownOrdinal {
4104                ordinal: tx_header.ordinal,
4105                protocol_name: <SessionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
4106            }),
4107        }
4108    }
4109}
4110
4111/// A Stream of incoming requests for fuchsia.hardware.network/Session.
4112pub struct SessionRequestStream {
4113    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4114    is_terminated: bool,
4115}
4116
4117impl std::marker::Unpin for SessionRequestStream {}
4118
4119impl futures::stream::FusedStream for SessionRequestStream {
4120    fn is_terminated(&self) -> bool {
4121        self.is_terminated
4122    }
4123}
4124
4125impl fdomain_client::fidl::RequestStream for SessionRequestStream {
4126    type Protocol = SessionMarker;
4127    type ControlHandle = SessionControlHandle;
4128
4129    fn from_channel(channel: fdomain_client::Channel) -> Self {
4130        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4131    }
4132
4133    fn control_handle(&self) -> Self::ControlHandle {
4134        SessionControlHandle { inner: self.inner.clone() }
4135    }
4136
4137    fn into_inner(
4138        self,
4139    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
4140    {
4141        (self.inner, self.is_terminated)
4142    }
4143
4144    fn from_inner(
4145        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4146        is_terminated: bool,
4147    ) -> Self {
4148        Self { inner, is_terminated }
4149    }
4150}
4151
4152impl futures::Stream for SessionRequestStream {
4153    type Item = Result<SessionRequest, fidl::Error>;
4154
4155    fn poll_next(
4156        mut self: std::pin::Pin<&mut Self>,
4157        cx: &mut std::task::Context<'_>,
4158    ) -> std::task::Poll<Option<Self::Item>> {
4159        let this = &mut *self;
4160        if this.inner.check_shutdown(cx) {
4161            this.is_terminated = true;
4162            return std::task::Poll::Ready(None);
4163        }
4164        if this.is_terminated {
4165            panic!("polled SessionRequestStream after completion");
4166        }
4167        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
4168            |bytes, handles| {
4169                match this.inner.channel().read_etc(cx, bytes, handles) {
4170                    std::task::Poll::Ready(Ok(())) => {}
4171                    std::task::Poll::Pending => return std::task::Poll::Pending,
4172                    std::task::Poll::Ready(Err(None)) => {
4173                        this.is_terminated = true;
4174                        return std::task::Poll::Ready(None);
4175                    }
4176                    std::task::Poll::Ready(Err(Some(e))) => {
4177                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4178                            e.into(),
4179                        ))));
4180                    }
4181                }
4182
4183                // A message has been received from the channel
4184                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4185
4186                std::task::Poll::Ready(Some(match header.ordinal {
4187                    0x1e89c9013e201379 => {
4188                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4189                        let mut req = fidl::new_empty!(
4190                            SessionAttachRequest,
4191                            fdomain_client::fidl::FDomainResourceDialect
4192                        );
4193                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SessionAttachRequest>(&header, _body_bytes, handles, &mut req)?;
4194                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
4195                        Ok(SessionRequest::Attach {
4196                            port: req.port,
4197                            rx_frames: req.rx_frames,
4198
4199                            responder: SessionAttachResponder {
4200                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4201                                tx_id: header.tx_id,
4202                            },
4203                        })
4204                    }
4205                    0x68c40cf8fb549867 => {
4206                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4207                        let mut req = fidl::new_empty!(
4208                            SessionDetachRequest,
4209                            fdomain_client::fidl::FDomainResourceDialect
4210                        );
4211                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SessionDetachRequest>(&header, _body_bytes, handles, &mut req)?;
4212                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
4213                        Ok(SessionRequest::Detach {
4214                            port: req.port,
4215
4216                            responder: SessionDetachResponder {
4217                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4218                                tx_id: header.tx_id,
4219                            },
4220                        })
4221                    }
4222                    0x393d5070394a92f6 => {
4223                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4224                        let mut req = fidl::new_empty!(
4225                            fidl::encoding::EmptyPayload,
4226                            fdomain_client::fidl::FDomainResourceDialect
4227                        );
4228                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4229                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
4230                        Ok(SessionRequest::Close { control_handle })
4231                    }
4232                    0x764d823ee64803b5 => {
4233                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4234                        let mut req = fidl::new_empty!(
4235                            fidl::encoding::EmptyPayload,
4236                            fdomain_client::fidl::FDomainResourceDialect
4237                        );
4238                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4239                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
4240                        Ok(SessionRequest::WatchDelegatedRxLease {
4241                            responder: SessionWatchDelegatedRxLeaseResponder {
4242                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4243                                tx_id: header.tx_id,
4244                            },
4245                        })
4246                    }
4247                    0x36321799ce2a081a => {
4248                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4249                        let mut req = fidl::new_empty!(
4250                            SessionRegisterForTxRequest,
4251                            fdomain_client::fidl::FDomainResourceDialect
4252                        );
4253                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SessionRegisterForTxRequest>(&header, _body_bytes, handles, &mut req)?;
4254                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
4255                        Ok(SessionRequest::RegisterForTx {
4256                            vmos: req.vmos,
4257
4258                            responder: SessionRegisterForTxResponder {
4259                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4260                                tx_id: header.tx_id,
4261                            },
4262                        })
4263                    }
4264                    0x3e76b16030d62796 => {
4265                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4266                        let mut req = fidl::new_empty!(
4267                            SessionUnregisterForTxRequest,
4268                            fdomain_client::fidl::FDomainResourceDialect
4269                        );
4270                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SessionUnregisterForTxRequest>(&header, _body_bytes, handles, &mut req)?;
4271                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
4272                        Ok(SessionRequest::UnregisterForTx {
4273                            vmos: req.vmos,
4274
4275                            responder: SessionUnregisterForTxResponder {
4276                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4277                                tx_id: header.tx_id,
4278                            },
4279                        })
4280                    }
4281                    _ => Err(fidl::Error::UnknownOrdinal {
4282                        ordinal: header.ordinal,
4283                        protocol_name:
4284                            <SessionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
4285                    }),
4286                }))
4287            },
4288        )
4289    }
4290}
4291
4292/// Represents a session with a Network device.
4293///
4294/// A session has a data plane and a control plane. The `Session` protocol
4295/// represents the control plane of the session and the FIFOs and VMOs exchanged
4296/// during the [`Device.OpenSession`] call are the data plane. Lifetime of the
4297/// session is controlled by a `Session` protocol handle.
4298///
4299/// Sessions must attach to ports of interest to start receiving and sending
4300/// data. Sessions are always created with no ports attached.
4301///
4302/// If a port is destroyed from the underlying device, it is automatically
4303/// detached from the session.
4304///
4305/// Inbound traffic is dispatched to all open sessions. Devices typically
4306/// operate with a single primary session, see [`SessionFlags.PRIMARY`]. Each
4307/// additional open session to the same device causes data copy overhead on the
4308/// device's data path.
4309///
4310/// The session is closed with an error epitaph if an invalid buffer descriptor
4311/// is sent over either the tx or rx FIFOs. Invalid descriptors include:
4312///    - Descriptor index larger than [`SessionInfo.descriptor_count`].
4313///    - Descriptor chains larger than [`MAX_DESCRIPTOR_CHAIN`].
4314///    - rx buffers smaller than [`Info.min_rx_buffer_length`].
4315///    - tx buffers smaller than [`Info.min_tx_buffer_length`].
4316///    - tx buffers not respecting [`Info.min_tx_buffer_head`] or
4317///      [`Info.min_tx_buffer_tail`].
4318#[derive(Debug)]
4319pub enum SessionRequest {
4320    /// Attaches the session to `port`.
4321    ///
4322    /// Once attached, the session starts to receive the subscribed frames over
4323    /// the data FIFOs and it may send frames destined to the specified `port`.
4324    ///
4325    /// + request `port` port to subscribe to.
4326    /// + request `rx_frames` Frame types of interest on the port.
4327    /// * error `ZX_ERR_NOT_FOUND` if `port` is not valid.
4328    /// * error `ZX_ERR_INVALID_ARGS` if `rx_frames` is not a subset of the
4329    /// port's supported frames.
4330    /// * error `ZX_ERR_ALREADY_BOUND` if `port` is already attached.
4331    Attach { port: PortId, rx_frames: Vec<FrameType>, responder: SessionAttachResponder },
4332    /// Detaches the session from `port`.
4333    ///
4334    /// Once detached, the session stops receiving frames from `port`. Frames
4335    /// sent to a detached port may be returned with an error. It is not
4336    /// necessary to call `Detach` on ports that are removed from the device,
4337    /// doing so causes `ZX_ERR_NOT_FOUND` to be returned.
4338    ///
4339    /// + request `port` port to subscribe to.
4340    /// * error `ZX_ERR_NOT_FOUND` if the session is not currently attached to
4341    /// the port.
4342    Detach { port: PortId, responder: SessionDetachResponder },
4343    /// Cleanly closes a session.
4344    ///
4345    /// This will cause the session to send a `ZX_ERR_CANCELLED` epitaph and
4346    /// proceed to close the Session channel. Clients may only assume that they
4347    /// own all the buffers that are currently owned by the session (sent over
4348    /// either the rx or tx FIFOs) once the epitaph is received. Closing the rx
4349    /// or tx FIFO is equivalent to calling `Close`.
4350    Close { control_handle: SessionControlHandle },
4351    /// Watchers for delegated receive wakeup leases.
4352    ///
4353    /// Calls block until a lease is delegated by the device. If a call to
4354    /// `WatchDelegatedRxLease` is made while a previous call is blocking, the
4355    /// session is closed with `ZX_ERR_BAD_STATE`. Will never yield any values
4356    /// for sessions created without [`SessionFlags.RECEIVE_RX_POWER_LEASES`].
4357    ///
4358    /// Given a single lease is assumed sufficient to keep the system awake, the
4359    /// server only keeps a single lease in its buffer. If a new delegated lease
4360    /// becomes available and the client hasn't popped the previous one with a
4361    /// call to `WatchDelegatedRxLease`, the server drops the previously pending
4362    /// lease.
4363    ///
4364    /// See [`DelegatedRxLease`] for how to handle delegated leases.
4365    WatchDelegatedRxLease { responder: SessionWatchDelegatedRxLeaseResponder },
4366    /// Asks the network device to register the VMO for Tx.
4367    ///
4368    /// The network device prepares the VMOs in order and stops at the first
4369    /// error if any. It returns how many VMOs have been prepared alongside with
4370    /// the first error encountered. Note that network-device itself does not
4371    /// try to release earlier VMOs for a later error. It is up to the client
4372    /// how to recover from an error.
4373    ///
4374    /// * error `ZX_ERR_NOT_FOUND` if any of the VmoId is unknown.
4375    /// * error other zx status that can be reported by the driver.
4376    RegisterForTx { vmos: Vec<u8>, responder: SessionRegisterForTxResponder },
4377    /// Tells the device that the client will no longer use the VMO for Tx,
4378    /// if the VMO is also unused for Rx, the device is free to release it
4379    /// at the implementation driver.
4380    ///
4381    /// The network device processes the VMOs in order and stops at the first
4382    /// error if any. It returns how many VMOs have been marked as unused for Tx
4383    /// alongside with the first error encountered. Note that network-device
4384    /// itself does not try to re-register earlier VMOs for a later error. It is
4385    /// up to the client how to recover from an error.
4386    ///
4387    /// * error `ZX_ERR_NOT_FOUND` if any of the VmoId is unknown.
4388    /// * error other zx status that can be reported by the driver.
4389    UnregisterForTx { vmos: Vec<u8>, responder: SessionUnregisterForTxResponder },
4390}
4391
4392impl SessionRequest {
4393    #[allow(irrefutable_let_patterns)]
4394    pub fn into_attach(self) -> Option<(PortId, Vec<FrameType>, SessionAttachResponder)> {
4395        if let SessionRequest::Attach { port, rx_frames, responder } = self {
4396            Some((port, rx_frames, responder))
4397        } else {
4398            None
4399        }
4400    }
4401
4402    #[allow(irrefutable_let_patterns)]
4403    pub fn into_detach(self) -> Option<(PortId, SessionDetachResponder)> {
4404        if let SessionRequest::Detach { port, responder } = self {
4405            Some((port, responder))
4406        } else {
4407            None
4408        }
4409    }
4410
4411    #[allow(irrefutable_let_patterns)]
4412    pub fn into_close(self) -> Option<(SessionControlHandle)> {
4413        if let SessionRequest::Close { control_handle } = self {
4414            Some((control_handle))
4415        } else {
4416            None
4417        }
4418    }
4419
4420    #[allow(irrefutable_let_patterns)]
4421    pub fn into_watch_delegated_rx_lease(self) -> Option<(SessionWatchDelegatedRxLeaseResponder)> {
4422        if let SessionRequest::WatchDelegatedRxLease { responder } = self {
4423            Some((responder))
4424        } else {
4425            None
4426        }
4427    }
4428
4429    #[allow(irrefutable_let_patterns)]
4430    pub fn into_register_for_tx(self) -> Option<(Vec<u8>, SessionRegisterForTxResponder)> {
4431        if let SessionRequest::RegisterForTx { vmos, responder } = self {
4432            Some((vmos, responder))
4433        } else {
4434            None
4435        }
4436    }
4437
4438    #[allow(irrefutable_let_patterns)]
4439    pub fn into_unregister_for_tx(self) -> Option<(Vec<u8>, SessionUnregisterForTxResponder)> {
4440        if let SessionRequest::UnregisterForTx { vmos, responder } = self {
4441            Some((vmos, responder))
4442        } else {
4443            None
4444        }
4445    }
4446
4447    /// Name of the method defined in FIDL
4448    pub fn method_name(&self) -> &'static str {
4449        match *self {
4450            SessionRequest::Attach { .. } => "attach",
4451            SessionRequest::Detach { .. } => "detach",
4452            SessionRequest::Close { .. } => "close",
4453            SessionRequest::WatchDelegatedRxLease { .. } => "watch_delegated_rx_lease",
4454            SessionRequest::RegisterForTx { .. } => "register_for_tx",
4455            SessionRequest::UnregisterForTx { .. } => "unregister_for_tx",
4456        }
4457    }
4458}
4459
4460#[derive(Debug, Clone)]
4461pub struct SessionControlHandle {
4462    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4463}
4464
4465impl SessionControlHandle {
4466    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4467        self.inner.shutdown_with_epitaph(status.into())
4468    }
4469}
4470
4471impl fdomain_client::fidl::ControlHandle for SessionControlHandle {
4472    fn shutdown(&self) {
4473        self.inner.shutdown()
4474    }
4475
4476    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4477        self.inner.shutdown_with_epitaph(status)
4478    }
4479
4480    fn is_closed(&self) -> bool {
4481        self.inner.channel().is_closed()
4482    }
4483    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
4484        self.inner.channel().on_closed()
4485    }
4486}
4487
4488impl SessionControlHandle {}
4489
4490#[must_use = "FIDL methods require a response to be sent"]
4491#[derive(Debug)]
4492pub struct SessionAttachResponder {
4493    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
4494    tx_id: u32,
4495}
4496
4497/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
4498/// if the responder is dropped without sending a response, so that the client
4499/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4500impl std::ops::Drop for SessionAttachResponder {
4501    fn drop(&mut self) {
4502        self.control_handle.shutdown();
4503        // Safety: drops once, never accessed again
4504        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4505    }
4506}
4507
4508impl fdomain_client::fidl::Responder for SessionAttachResponder {
4509    type ControlHandle = SessionControlHandle;
4510
4511    fn control_handle(&self) -> &SessionControlHandle {
4512        &self.control_handle
4513    }
4514
4515    fn drop_without_shutdown(mut self) {
4516        // Safety: drops once, never accessed again due to mem::forget
4517        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4518        // Prevent Drop from running (which would shut down the channel)
4519        std::mem::forget(self);
4520    }
4521}
4522
4523impl SessionAttachResponder {
4524    /// Sends a response to the FIDL transaction.
4525    ///
4526    /// Sets the channel to shutdown if an error occurs.
4527    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4528        let _result = self.send_raw(result);
4529        if _result.is_err() {
4530            self.control_handle.shutdown();
4531        }
4532        self.drop_without_shutdown();
4533        _result
4534    }
4535
4536    /// Similar to "send" but does not shutdown the channel if an error occurs.
4537    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4538        let _result = self.send_raw(result);
4539        self.drop_without_shutdown();
4540        _result
4541    }
4542
4543    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4544        self.control_handle
4545            .inner
4546            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4547                result,
4548                self.tx_id,
4549                0x1e89c9013e201379,
4550                fidl::encoding::DynamicFlags::empty(),
4551            )
4552    }
4553}
4554
4555#[must_use = "FIDL methods require a response to be sent"]
4556#[derive(Debug)]
4557pub struct SessionDetachResponder {
4558    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
4559    tx_id: u32,
4560}
4561
4562/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
4563/// if the responder is dropped without sending a response, so that the client
4564/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4565impl std::ops::Drop for SessionDetachResponder {
4566    fn drop(&mut self) {
4567        self.control_handle.shutdown();
4568        // Safety: drops once, never accessed again
4569        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4570    }
4571}
4572
4573impl fdomain_client::fidl::Responder for SessionDetachResponder {
4574    type ControlHandle = SessionControlHandle;
4575
4576    fn control_handle(&self) -> &SessionControlHandle {
4577        &self.control_handle
4578    }
4579
4580    fn drop_without_shutdown(mut self) {
4581        // Safety: drops once, never accessed again due to mem::forget
4582        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4583        // Prevent Drop from running (which would shut down the channel)
4584        std::mem::forget(self);
4585    }
4586}
4587
4588impl SessionDetachResponder {
4589    /// Sends a response to the FIDL transaction.
4590    ///
4591    /// Sets the channel to shutdown if an error occurs.
4592    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4593        let _result = self.send_raw(result);
4594        if _result.is_err() {
4595            self.control_handle.shutdown();
4596        }
4597        self.drop_without_shutdown();
4598        _result
4599    }
4600
4601    /// Similar to "send" but does not shutdown the channel if an error occurs.
4602    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4603        let _result = self.send_raw(result);
4604        self.drop_without_shutdown();
4605        _result
4606    }
4607
4608    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4609        self.control_handle
4610            .inner
4611            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4612                result,
4613                self.tx_id,
4614                0x68c40cf8fb549867,
4615                fidl::encoding::DynamicFlags::empty(),
4616            )
4617    }
4618}
4619
4620#[must_use = "FIDL methods require a response to be sent"]
4621#[derive(Debug)]
4622pub struct SessionWatchDelegatedRxLeaseResponder {
4623    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
4624    tx_id: u32,
4625}
4626
4627/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
4628/// if the responder is dropped without sending a response, so that the client
4629/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4630impl std::ops::Drop for SessionWatchDelegatedRxLeaseResponder {
4631    fn drop(&mut self) {
4632        self.control_handle.shutdown();
4633        // Safety: drops once, never accessed again
4634        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4635    }
4636}
4637
4638impl fdomain_client::fidl::Responder for SessionWatchDelegatedRxLeaseResponder {
4639    type ControlHandle = SessionControlHandle;
4640
4641    fn control_handle(&self) -> &SessionControlHandle {
4642        &self.control_handle
4643    }
4644
4645    fn drop_without_shutdown(mut self) {
4646        // Safety: drops once, never accessed again due to mem::forget
4647        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4648        // Prevent Drop from running (which would shut down the channel)
4649        std::mem::forget(self);
4650    }
4651}
4652
4653impl SessionWatchDelegatedRxLeaseResponder {
4654    /// Sends a response to the FIDL transaction.
4655    ///
4656    /// Sets the channel to shutdown if an error occurs.
4657    pub fn send(self, mut lease: DelegatedRxLease) -> Result<(), fidl::Error> {
4658        let _result = self.send_raw(lease);
4659        if _result.is_err() {
4660            self.control_handle.shutdown();
4661        }
4662        self.drop_without_shutdown();
4663        _result
4664    }
4665
4666    /// Similar to "send" but does not shutdown the channel if an error occurs.
4667    pub fn send_no_shutdown_on_err(self, mut lease: DelegatedRxLease) -> Result<(), fidl::Error> {
4668        let _result = self.send_raw(lease);
4669        self.drop_without_shutdown();
4670        _result
4671    }
4672
4673    fn send_raw(&self, mut lease: DelegatedRxLease) -> Result<(), fidl::Error> {
4674        self.control_handle.inner.send::<SessionWatchDelegatedRxLeaseResponse>(
4675            (&mut lease,),
4676            self.tx_id,
4677            0x764d823ee64803b5,
4678            fidl::encoding::DynamicFlags::empty(),
4679        )
4680    }
4681}
4682
4683#[must_use = "FIDL methods require a response to be sent"]
4684#[derive(Debug)]
4685pub struct SessionRegisterForTxResponder {
4686    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
4687    tx_id: u32,
4688}
4689
4690/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
4691/// if the responder is dropped without sending a response, so that the client
4692/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4693impl std::ops::Drop for SessionRegisterForTxResponder {
4694    fn drop(&mut self) {
4695        self.control_handle.shutdown();
4696        // Safety: drops once, never accessed again
4697        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4698    }
4699}
4700
4701impl fdomain_client::fidl::Responder for SessionRegisterForTxResponder {
4702    type ControlHandle = SessionControlHandle;
4703
4704    fn control_handle(&self) -> &SessionControlHandle {
4705        &self.control_handle
4706    }
4707
4708    fn drop_without_shutdown(mut self) {
4709        // Safety: drops once, never accessed again due to mem::forget
4710        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4711        // Prevent Drop from running (which would shut down the channel)
4712        std::mem::forget(self);
4713    }
4714}
4715
4716impl SessionRegisterForTxResponder {
4717    /// Sends a response to the FIDL transaction.
4718    ///
4719    /// Sets the channel to shutdown if an error occurs.
4720    pub fn send(self, mut successful: u8, mut status: i32) -> Result<(), fidl::Error> {
4721        let _result = self.send_raw(successful, status);
4722        if _result.is_err() {
4723            self.control_handle.shutdown();
4724        }
4725        self.drop_without_shutdown();
4726        _result
4727    }
4728
4729    /// Similar to "send" but does not shutdown the channel if an error occurs.
4730    pub fn send_no_shutdown_on_err(
4731        self,
4732        mut successful: u8,
4733        mut status: i32,
4734    ) -> Result<(), fidl::Error> {
4735        let _result = self.send_raw(successful, status);
4736        self.drop_without_shutdown();
4737        _result
4738    }
4739
4740    fn send_raw(&self, mut successful: u8, mut status: i32) -> Result<(), fidl::Error> {
4741        self.control_handle.inner.send::<SessionRegisterForTxResponse>(
4742            (successful, status),
4743            self.tx_id,
4744            0x36321799ce2a081a,
4745            fidl::encoding::DynamicFlags::empty(),
4746        )
4747    }
4748}
4749
4750#[must_use = "FIDL methods require a response to be sent"]
4751#[derive(Debug)]
4752pub struct SessionUnregisterForTxResponder {
4753    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
4754    tx_id: u32,
4755}
4756
4757/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
4758/// if the responder is dropped without sending a response, so that the client
4759/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4760impl std::ops::Drop for SessionUnregisterForTxResponder {
4761    fn drop(&mut self) {
4762        self.control_handle.shutdown();
4763        // Safety: drops once, never accessed again
4764        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4765    }
4766}
4767
4768impl fdomain_client::fidl::Responder for SessionUnregisterForTxResponder {
4769    type ControlHandle = SessionControlHandle;
4770
4771    fn control_handle(&self) -> &SessionControlHandle {
4772        &self.control_handle
4773    }
4774
4775    fn drop_without_shutdown(mut self) {
4776        // Safety: drops once, never accessed again due to mem::forget
4777        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4778        // Prevent Drop from running (which would shut down the channel)
4779        std::mem::forget(self);
4780    }
4781}
4782
4783impl SessionUnregisterForTxResponder {
4784    /// Sends a response to the FIDL transaction.
4785    ///
4786    /// Sets the channel to shutdown if an error occurs.
4787    pub fn send(self, mut successful: u8, mut status: i32) -> Result<(), fidl::Error> {
4788        let _result = self.send_raw(successful, status);
4789        if _result.is_err() {
4790            self.control_handle.shutdown();
4791        }
4792        self.drop_without_shutdown();
4793        _result
4794    }
4795
4796    /// Similar to "send" but does not shutdown the channel if an error occurs.
4797    pub fn send_no_shutdown_on_err(
4798        self,
4799        mut successful: u8,
4800        mut status: i32,
4801    ) -> Result<(), fidl::Error> {
4802        let _result = self.send_raw(successful, status);
4803        self.drop_without_shutdown();
4804        _result
4805    }
4806
4807    fn send_raw(&self, mut successful: u8, mut status: i32) -> Result<(), fidl::Error> {
4808        self.control_handle.inner.send::<SessionUnregisterForTxResponse>(
4809            (successful, status),
4810            self.tx_id,
4811            0x3e76b16030d62796,
4812            fidl::encoding::DynamicFlags::empty(),
4813        )
4814    }
4815}
4816
4817#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4818pub struct StatusWatcherMarker;
4819
4820impl fdomain_client::fidl::ProtocolMarker for StatusWatcherMarker {
4821    type Proxy = StatusWatcherProxy;
4822    type RequestStream = StatusWatcherRequestStream;
4823
4824    const DEBUG_NAME: &'static str = "(anonymous) StatusWatcher";
4825}
4826
4827pub trait StatusWatcherProxyInterface: Send + Sync {
4828    type WatchStatusResponseFut: std::future::Future<Output = Result<PortStatus, fidl::Error>>
4829        + Send;
4830    fn r#watch_status(&self) -> Self::WatchStatusResponseFut;
4831}
4832
4833#[derive(Debug, Clone)]
4834pub struct StatusWatcherProxy {
4835    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
4836}
4837
4838impl fdomain_client::fidl::Proxy for StatusWatcherProxy {
4839    type Protocol = StatusWatcherMarker;
4840
4841    fn from_channel(inner: fdomain_client::Channel) -> Self {
4842        Self::new(inner)
4843    }
4844
4845    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
4846        self.client.into_channel().map_err(|client| Self { client })
4847    }
4848
4849    fn as_channel(&self) -> &fdomain_client::Channel {
4850        self.client.as_channel()
4851    }
4852}
4853
4854impl StatusWatcherProxy {
4855    /// Create a new Proxy for fuchsia.hardware.network/StatusWatcher.
4856    pub fn new(channel: fdomain_client::Channel) -> Self {
4857        let protocol_name =
4858            <StatusWatcherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
4859        Self { client: fidl::client::Client::new(channel, protocol_name) }
4860    }
4861
4862    /// Get a Stream of events from the remote end of the protocol.
4863    ///
4864    /// # Panics
4865    ///
4866    /// Panics if the event stream was already taken.
4867    pub fn take_event_stream(&self) -> StatusWatcherEventStream {
4868        StatusWatcherEventStream { event_receiver: self.client.take_event_receiver() }
4869    }
4870
4871    /// `WatchStatus` blocks until the port's status has changed.
4872    ///
4873    /// The first call to `WatchStatus` returns immediately with the current
4874    /// port status, subsequent calls complete when the port status differs from
4875    /// the last one that was returned through this `StatusWatcher`.
4876    ///
4877    /// If `StatusWatcher` was created with a buffer value larger than 1,
4878    /// `WatchStatus` may return a queued status change, depending on how many
4879    /// status changed happened since the last call to `WatchStatus`.
4880    ///
4881    /// - response `device_status` the most recent port status.
4882    pub fn r#watch_status(
4883        &self,
4884    ) -> fidl::client::QueryResponseFut<PortStatus, fdomain_client::fidl::FDomainResourceDialect>
4885    {
4886        StatusWatcherProxyInterface::r#watch_status(self)
4887    }
4888}
4889
4890impl StatusWatcherProxyInterface for StatusWatcherProxy {
4891    type WatchStatusResponseFut =
4892        fidl::client::QueryResponseFut<PortStatus, fdomain_client::fidl::FDomainResourceDialect>;
4893    fn r#watch_status(&self) -> Self::WatchStatusResponseFut {
4894        fn _decode(
4895            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4896        ) -> Result<PortStatus, fidl::Error> {
4897            let _response = fidl::client::decode_transaction_body::<
4898                StatusWatcherWatchStatusResponse,
4899                fdomain_client::fidl::FDomainResourceDialect,
4900                0x1369a8125c0862b9,
4901            >(_buf?)?;
4902            Ok(_response.port_status)
4903        }
4904        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PortStatus>(
4905            (),
4906            0x1369a8125c0862b9,
4907            fidl::encoding::DynamicFlags::empty(),
4908            _decode,
4909        )
4910    }
4911}
4912
4913pub struct StatusWatcherEventStream {
4914    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
4915}
4916
4917impl std::marker::Unpin for StatusWatcherEventStream {}
4918
4919impl futures::stream::FusedStream for StatusWatcherEventStream {
4920    fn is_terminated(&self) -> bool {
4921        self.event_receiver.is_terminated()
4922    }
4923}
4924
4925impl futures::Stream for StatusWatcherEventStream {
4926    type Item = Result<StatusWatcherEvent, fidl::Error>;
4927
4928    fn poll_next(
4929        mut self: std::pin::Pin<&mut Self>,
4930        cx: &mut std::task::Context<'_>,
4931    ) -> std::task::Poll<Option<Self::Item>> {
4932        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4933            &mut self.event_receiver,
4934            cx
4935        )?) {
4936            Some(buf) => std::task::Poll::Ready(Some(StatusWatcherEvent::decode(buf))),
4937            None => std::task::Poll::Ready(None),
4938        }
4939    }
4940}
4941
4942#[derive(Debug)]
4943pub enum StatusWatcherEvent {}
4944
4945impl StatusWatcherEvent {
4946    /// Decodes a message buffer as a [`StatusWatcherEvent`].
4947    fn decode(
4948        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4949    ) -> Result<StatusWatcherEvent, fidl::Error> {
4950        let (bytes, _handles) = buf.split_mut();
4951        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4952        debug_assert_eq!(tx_header.tx_id, 0);
4953        match tx_header.ordinal {
4954            _ => Err(fidl::Error::UnknownOrdinal {
4955                ordinal: tx_header.ordinal,
4956                protocol_name:
4957                    <StatusWatcherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
4958            }),
4959        }
4960    }
4961}
4962
4963/// A Stream of incoming requests for fuchsia.hardware.network/StatusWatcher.
4964pub struct StatusWatcherRequestStream {
4965    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4966    is_terminated: bool,
4967}
4968
4969impl std::marker::Unpin for StatusWatcherRequestStream {}
4970
4971impl futures::stream::FusedStream for StatusWatcherRequestStream {
4972    fn is_terminated(&self) -> bool {
4973        self.is_terminated
4974    }
4975}
4976
4977impl fdomain_client::fidl::RequestStream for StatusWatcherRequestStream {
4978    type Protocol = StatusWatcherMarker;
4979    type ControlHandle = StatusWatcherControlHandle;
4980
4981    fn from_channel(channel: fdomain_client::Channel) -> Self {
4982        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4983    }
4984
4985    fn control_handle(&self) -> Self::ControlHandle {
4986        StatusWatcherControlHandle { inner: self.inner.clone() }
4987    }
4988
4989    fn into_inner(
4990        self,
4991    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
4992    {
4993        (self.inner, self.is_terminated)
4994    }
4995
4996    fn from_inner(
4997        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4998        is_terminated: bool,
4999    ) -> Self {
5000        Self { inner, is_terminated }
5001    }
5002}
5003
5004impl futures::Stream for StatusWatcherRequestStream {
5005    type Item = Result<StatusWatcherRequest, fidl::Error>;
5006
5007    fn poll_next(
5008        mut self: std::pin::Pin<&mut Self>,
5009        cx: &mut std::task::Context<'_>,
5010    ) -> std::task::Poll<Option<Self::Item>> {
5011        let this = &mut *self;
5012        if this.inner.check_shutdown(cx) {
5013            this.is_terminated = true;
5014            return std::task::Poll::Ready(None);
5015        }
5016        if this.is_terminated {
5017            panic!("polled StatusWatcherRequestStream after completion");
5018        }
5019        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
5020            |bytes, handles| {
5021                match this.inner.channel().read_etc(cx, bytes, handles) {
5022                    std::task::Poll::Ready(Ok(())) => {}
5023                    std::task::Poll::Pending => return std::task::Poll::Pending,
5024                    std::task::Poll::Ready(Err(None)) => {
5025                        this.is_terminated = true;
5026                        return std::task::Poll::Ready(None);
5027                    }
5028                    std::task::Poll::Ready(Err(Some(e))) => {
5029                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5030                            e.into(),
5031                        ))));
5032                    }
5033                }
5034
5035                // A message has been received from the channel
5036                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5037
5038                std::task::Poll::Ready(Some(match header.ordinal {
5039                0x1369a8125c0862b9 => {
5040                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5041                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5042                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5043                    let control_handle = StatusWatcherControlHandle {
5044                        inner: this.inner.clone(),
5045                    };
5046                    Ok(StatusWatcherRequest::WatchStatus {
5047                        responder: StatusWatcherWatchStatusResponder {
5048                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5049                            tx_id: header.tx_id,
5050                        },
5051                    })
5052                }
5053                _ => Err(fidl::Error::UnknownOrdinal {
5054                    ordinal: header.ordinal,
5055                    protocol_name: <StatusWatcherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
5056                }),
5057            }))
5058            },
5059        )
5060    }
5061}
5062
5063/// Provides a way to receive updates on port status changes.
5064#[derive(Debug)]
5065pub enum StatusWatcherRequest {
5066    /// `WatchStatus` blocks until the port's status has changed.
5067    ///
5068    /// The first call to `WatchStatus` returns immediately with the current
5069    /// port status, subsequent calls complete when the port status differs from
5070    /// the last one that was returned through this `StatusWatcher`.
5071    ///
5072    /// If `StatusWatcher` was created with a buffer value larger than 1,
5073    /// `WatchStatus` may return a queued status change, depending on how many
5074    /// status changed happened since the last call to `WatchStatus`.
5075    ///
5076    /// - response `device_status` the most recent port status.
5077    WatchStatus { responder: StatusWatcherWatchStatusResponder },
5078}
5079
5080impl StatusWatcherRequest {
5081    #[allow(irrefutable_let_patterns)]
5082    pub fn into_watch_status(self) -> Option<(StatusWatcherWatchStatusResponder)> {
5083        if let StatusWatcherRequest::WatchStatus { responder } = self {
5084            Some((responder))
5085        } else {
5086            None
5087        }
5088    }
5089
5090    /// Name of the method defined in FIDL
5091    pub fn method_name(&self) -> &'static str {
5092        match *self {
5093            StatusWatcherRequest::WatchStatus { .. } => "watch_status",
5094        }
5095    }
5096}
5097
5098#[derive(Debug, Clone)]
5099pub struct StatusWatcherControlHandle {
5100    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5101}
5102
5103impl StatusWatcherControlHandle {
5104    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
5105        self.inner.shutdown_with_epitaph(status.into())
5106    }
5107}
5108
5109impl fdomain_client::fidl::ControlHandle for StatusWatcherControlHandle {
5110    fn shutdown(&self) {
5111        self.inner.shutdown()
5112    }
5113
5114    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
5115        self.inner.shutdown_with_epitaph(status)
5116    }
5117
5118    fn is_closed(&self) -> bool {
5119        self.inner.channel().is_closed()
5120    }
5121    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
5122        self.inner.channel().on_closed()
5123    }
5124}
5125
5126impl StatusWatcherControlHandle {}
5127
5128#[must_use = "FIDL methods require a response to be sent"]
5129#[derive(Debug)]
5130pub struct StatusWatcherWatchStatusResponder {
5131    control_handle: std::mem::ManuallyDrop<StatusWatcherControlHandle>,
5132    tx_id: u32,
5133}
5134
5135/// Set the the channel to be shutdown (see [`StatusWatcherControlHandle::shutdown`])
5136/// if the responder is dropped without sending a response, so that the client
5137/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5138impl std::ops::Drop for StatusWatcherWatchStatusResponder {
5139    fn drop(&mut self) {
5140        self.control_handle.shutdown();
5141        // Safety: drops once, never accessed again
5142        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5143    }
5144}
5145
5146impl fdomain_client::fidl::Responder for StatusWatcherWatchStatusResponder {
5147    type ControlHandle = StatusWatcherControlHandle;
5148
5149    fn control_handle(&self) -> &StatusWatcherControlHandle {
5150        &self.control_handle
5151    }
5152
5153    fn drop_without_shutdown(mut self) {
5154        // Safety: drops once, never accessed again due to mem::forget
5155        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5156        // Prevent Drop from running (which would shut down the channel)
5157        std::mem::forget(self);
5158    }
5159}
5160
5161impl StatusWatcherWatchStatusResponder {
5162    /// Sends a response to the FIDL transaction.
5163    ///
5164    /// Sets the channel to shutdown if an error occurs.
5165    pub fn send(self, mut port_status: &PortStatus) -> Result<(), fidl::Error> {
5166        let _result = self.send_raw(port_status);
5167        if _result.is_err() {
5168            self.control_handle.shutdown();
5169        }
5170        self.drop_without_shutdown();
5171        _result
5172    }
5173
5174    /// Similar to "send" but does not shutdown the channel if an error occurs.
5175    pub fn send_no_shutdown_on_err(self, mut port_status: &PortStatus) -> Result<(), fidl::Error> {
5176        let _result = self.send_raw(port_status);
5177        self.drop_without_shutdown();
5178        _result
5179    }
5180
5181    fn send_raw(&self, mut port_status: &PortStatus) -> Result<(), fidl::Error> {
5182        self.control_handle.inner.send::<StatusWatcherWatchStatusResponse>(
5183            (port_status,),
5184            self.tx_id,
5185            0x1369a8125c0862b9,
5186            fidl::encoding::DynamicFlags::empty(),
5187        )
5188    }
5189}
5190
5191mod internal {
5192    use super::*;
5193
5194    impl fidl::encoding::ResourceTypeMarker for DeviceCloneRequest {
5195        type Borrowed<'a> = &'a mut Self;
5196        fn take_or_borrow<'a>(
5197            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5198        ) -> Self::Borrowed<'a> {
5199            value
5200        }
5201    }
5202
5203    unsafe impl fidl::encoding::TypeMarker for DeviceCloneRequest {
5204        type Owned = Self;
5205
5206        #[inline(always)]
5207        fn inline_align(_context: fidl::encoding::Context) -> usize {
5208            4
5209        }
5210
5211        #[inline(always)]
5212        fn inline_size(_context: fidl::encoding::Context) -> usize {
5213            4
5214        }
5215    }
5216
5217    unsafe impl
5218        fidl::encoding::Encode<DeviceCloneRequest, fdomain_client::fidl::FDomainResourceDialect>
5219        for &mut DeviceCloneRequest
5220    {
5221        #[inline]
5222        unsafe fn encode(
5223            self,
5224            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5225            offset: usize,
5226            _depth: fidl::encoding::Depth,
5227        ) -> fidl::Result<()> {
5228            encoder.debug_check_bounds::<DeviceCloneRequest>(offset);
5229            // Delegate to tuple encoding.
5230            fidl::encoding::Encode::<DeviceCloneRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
5231                (
5232                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.device),
5233                ),
5234                encoder, offset, _depth
5235            )
5236        }
5237    }
5238    unsafe impl<
5239        T0: fidl::encoding::Encode<
5240                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<DeviceMarker>>,
5241                fdomain_client::fidl::FDomainResourceDialect,
5242            >,
5243    > fidl::encoding::Encode<DeviceCloneRequest, fdomain_client::fidl::FDomainResourceDialect>
5244        for (T0,)
5245    {
5246        #[inline]
5247        unsafe fn encode(
5248            self,
5249            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5250            offset: usize,
5251            depth: fidl::encoding::Depth,
5252        ) -> fidl::Result<()> {
5253            encoder.debug_check_bounds::<DeviceCloneRequest>(offset);
5254            // Zero out padding regions. There's no need to apply masks
5255            // because the unmasked parts will be overwritten by fields.
5256            // Write the fields.
5257            self.0.encode(encoder, offset + 0, depth)?;
5258            Ok(())
5259        }
5260    }
5261
5262    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
5263        for DeviceCloneRequest
5264    {
5265        #[inline(always)]
5266        fn new_empty() -> Self {
5267            Self {
5268                device: fidl::new_empty!(
5269                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<DeviceMarker>>,
5270                    fdomain_client::fidl::FDomainResourceDialect
5271                ),
5272            }
5273        }
5274
5275        #[inline]
5276        unsafe fn decode(
5277            &mut self,
5278            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5279            offset: usize,
5280            _depth: fidl::encoding::Depth,
5281        ) -> fidl::Result<()> {
5282            decoder.debug_check_bounds::<Self>(offset);
5283            // Verify that padding bytes are zero.
5284            fidl::decode!(
5285                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<DeviceMarker>>,
5286                fdomain_client::fidl::FDomainResourceDialect,
5287                &mut self.device,
5288                decoder,
5289                offset + 0,
5290                _depth
5291            )?;
5292            Ok(())
5293        }
5294    }
5295
5296    impl fidl::encoding::ResourceTypeMarker for DeviceGetPortRequest {
5297        type Borrowed<'a> = &'a mut Self;
5298        fn take_or_borrow<'a>(
5299            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5300        ) -> Self::Borrowed<'a> {
5301            value
5302        }
5303    }
5304
5305    unsafe impl fidl::encoding::TypeMarker for DeviceGetPortRequest {
5306        type Owned = Self;
5307
5308        #[inline(always)]
5309        fn inline_align(_context: fidl::encoding::Context) -> usize {
5310            4
5311        }
5312
5313        #[inline(always)]
5314        fn inline_size(_context: fidl::encoding::Context) -> usize {
5315            8
5316        }
5317    }
5318
5319    unsafe impl
5320        fidl::encoding::Encode<DeviceGetPortRequest, fdomain_client::fidl::FDomainResourceDialect>
5321        for &mut DeviceGetPortRequest
5322    {
5323        #[inline]
5324        unsafe fn encode(
5325            self,
5326            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5327            offset: usize,
5328            _depth: fidl::encoding::Depth,
5329        ) -> fidl::Result<()> {
5330            encoder.debug_check_bounds::<DeviceGetPortRequest>(offset);
5331            // Delegate to tuple encoding.
5332            fidl::encoding::Encode::<DeviceGetPortRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
5333                (
5334                    <PortId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
5335                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<PortMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.port),
5336                ),
5337                encoder, offset, _depth
5338            )
5339        }
5340    }
5341    unsafe impl<
5342        T0: fidl::encoding::Encode<PortId, fdomain_client::fidl::FDomainResourceDialect>,
5343        T1: fidl::encoding::Encode<
5344                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<PortMarker>>,
5345                fdomain_client::fidl::FDomainResourceDialect,
5346            >,
5347    > fidl::encoding::Encode<DeviceGetPortRequest, fdomain_client::fidl::FDomainResourceDialect>
5348        for (T0, T1)
5349    {
5350        #[inline]
5351        unsafe fn encode(
5352            self,
5353            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5354            offset: usize,
5355            depth: fidl::encoding::Depth,
5356        ) -> fidl::Result<()> {
5357            encoder.debug_check_bounds::<DeviceGetPortRequest>(offset);
5358            // Zero out padding regions. There's no need to apply masks
5359            // because the unmasked parts will be overwritten by fields.
5360            unsafe {
5361                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
5362                (ptr as *mut u32).write_unaligned(0);
5363            }
5364            // Write the fields.
5365            self.0.encode(encoder, offset + 0, depth)?;
5366            self.1.encode(encoder, offset + 4, depth)?;
5367            Ok(())
5368        }
5369    }
5370
5371    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
5372        for DeviceGetPortRequest
5373    {
5374        #[inline(always)]
5375        fn new_empty() -> Self {
5376            Self {
5377                id: fidl::new_empty!(PortId, fdomain_client::fidl::FDomainResourceDialect),
5378                port: fidl::new_empty!(
5379                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<PortMarker>>,
5380                    fdomain_client::fidl::FDomainResourceDialect
5381                ),
5382            }
5383        }
5384
5385        #[inline]
5386        unsafe fn decode(
5387            &mut self,
5388            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5389            offset: usize,
5390            _depth: fidl::encoding::Depth,
5391        ) -> fidl::Result<()> {
5392            decoder.debug_check_bounds::<Self>(offset);
5393            // Verify that padding bytes are zero.
5394            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
5395            let padval = unsafe { (ptr as *const u32).read_unaligned() };
5396            let mask = 0xffff0000u32;
5397            let maskedval = padval & mask;
5398            if maskedval != 0 {
5399                return Err(fidl::Error::NonZeroPadding {
5400                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
5401                });
5402            }
5403            fidl::decode!(
5404                PortId,
5405                fdomain_client::fidl::FDomainResourceDialect,
5406                &mut self.id,
5407                decoder,
5408                offset + 0,
5409                _depth
5410            )?;
5411            fidl::decode!(
5412                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<PortMarker>>,
5413                fdomain_client::fidl::FDomainResourceDialect,
5414                &mut self.port,
5415                decoder,
5416                offset + 4,
5417                _depth
5418            )?;
5419            Ok(())
5420        }
5421    }
5422
5423    impl fidl::encoding::ResourceTypeMarker for DeviceGetPortWatcherRequest {
5424        type Borrowed<'a> = &'a mut Self;
5425        fn take_or_borrow<'a>(
5426            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5427        ) -> Self::Borrowed<'a> {
5428            value
5429        }
5430    }
5431
5432    unsafe impl fidl::encoding::TypeMarker for DeviceGetPortWatcherRequest {
5433        type Owned = Self;
5434
5435        #[inline(always)]
5436        fn inline_align(_context: fidl::encoding::Context) -> usize {
5437            4
5438        }
5439
5440        #[inline(always)]
5441        fn inline_size(_context: fidl::encoding::Context) -> usize {
5442            4
5443        }
5444    }
5445
5446    unsafe impl
5447        fidl::encoding::Encode<
5448            DeviceGetPortWatcherRequest,
5449            fdomain_client::fidl::FDomainResourceDialect,
5450        > for &mut DeviceGetPortWatcherRequest
5451    {
5452        #[inline]
5453        unsafe fn encode(
5454            self,
5455            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5456            offset: usize,
5457            _depth: fidl::encoding::Depth,
5458        ) -> fidl::Result<()> {
5459            encoder.debug_check_bounds::<DeviceGetPortWatcherRequest>(offset);
5460            // Delegate to tuple encoding.
5461            fidl::encoding::Encode::<DeviceGetPortWatcherRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
5462                (
5463                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<PortWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
5464                ),
5465                encoder, offset, _depth
5466            )
5467        }
5468    }
5469    unsafe impl<
5470        T0: fidl::encoding::Encode<
5471                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<PortWatcherMarker>>,
5472                fdomain_client::fidl::FDomainResourceDialect,
5473            >,
5474    >
5475        fidl::encoding::Encode<
5476            DeviceGetPortWatcherRequest,
5477            fdomain_client::fidl::FDomainResourceDialect,
5478        > for (T0,)
5479    {
5480        #[inline]
5481        unsafe fn encode(
5482            self,
5483            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5484            offset: usize,
5485            depth: fidl::encoding::Depth,
5486        ) -> fidl::Result<()> {
5487            encoder.debug_check_bounds::<DeviceGetPortWatcherRequest>(offset);
5488            // Zero out padding regions. There's no need to apply masks
5489            // because the unmasked parts will be overwritten by fields.
5490            // Write the fields.
5491            self.0.encode(encoder, offset + 0, depth)?;
5492            Ok(())
5493        }
5494    }
5495
5496    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
5497        for DeviceGetPortWatcherRequest
5498    {
5499        #[inline(always)]
5500        fn new_empty() -> Self {
5501            Self {
5502                watcher: fidl::new_empty!(
5503                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<PortWatcherMarker>>,
5504                    fdomain_client::fidl::FDomainResourceDialect
5505                ),
5506            }
5507        }
5508
5509        #[inline]
5510        unsafe fn decode(
5511            &mut self,
5512            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5513            offset: usize,
5514            _depth: fidl::encoding::Depth,
5515        ) -> fidl::Result<()> {
5516            decoder.debug_check_bounds::<Self>(offset);
5517            // Verify that padding bytes are zero.
5518            fidl::decode!(
5519                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<PortWatcherMarker>>,
5520                fdomain_client::fidl::FDomainResourceDialect,
5521                &mut self.watcher,
5522                decoder,
5523                offset + 0,
5524                _depth
5525            )?;
5526            Ok(())
5527        }
5528    }
5529
5530    impl fidl::encoding::ResourceTypeMarker for DeviceOpenSessionRequest {
5531        type Borrowed<'a> = &'a mut Self;
5532        fn take_or_borrow<'a>(
5533            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5534        ) -> Self::Borrowed<'a> {
5535            value
5536        }
5537    }
5538
5539    unsafe impl fidl::encoding::TypeMarker for DeviceOpenSessionRequest {
5540        type Owned = Self;
5541
5542        #[inline(always)]
5543        fn inline_align(_context: fidl::encoding::Context) -> usize {
5544            8
5545        }
5546
5547        #[inline(always)]
5548        fn inline_size(_context: fidl::encoding::Context) -> usize {
5549            32
5550        }
5551    }
5552
5553    unsafe impl
5554        fidl::encoding::Encode<
5555            DeviceOpenSessionRequest,
5556            fdomain_client::fidl::FDomainResourceDialect,
5557        > for &mut DeviceOpenSessionRequest
5558    {
5559        #[inline]
5560        unsafe fn encode(
5561            self,
5562            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5563            offset: usize,
5564            _depth: fidl::encoding::Depth,
5565        ) -> fidl::Result<()> {
5566            encoder.debug_check_bounds::<DeviceOpenSessionRequest>(offset);
5567            // Delegate to tuple encoding.
5568            fidl::encoding::Encode::<
5569                DeviceOpenSessionRequest,
5570                fdomain_client::fidl::FDomainResourceDialect,
5571            >::encode(
5572                (
5573                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
5574                        &self.session_name,
5575                    ),
5576                    <SessionInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5577                        &mut self.session_info,
5578                    ),
5579                ),
5580                encoder,
5581                offset,
5582                _depth,
5583            )
5584        }
5585    }
5586    unsafe impl<
5587        T0: fidl::encoding::Encode<
5588                fidl::encoding::BoundedString<64>,
5589                fdomain_client::fidl::FDomainResourceDialect,
5590            >,
5591        T1: fidl::encoding::Encode<SessionInfo, fdomain_client::fidl::FDomainResourceDialect>,
5592    >
5593        fidl::encoding::Encode<
5594            DeviceOpenSessionRequest,
5595            fdomain_client::fidl::FDomainResourceDialect,
5596        > for (T0, T1)
5597    {
5598        #[inline]
5599        unsafe fn encode(
5600            self,
5601            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5602            offset: usize,
5603            depth: fidl::encoding::Depth,
5604        ) -> fidl::Result<()> {
5605            encoder.debug_check_bounds::<DeviceOpenSessionRequest>(offset);
5606            // Zero out padding regions. There's no need to apply masks
5607            // because the unmasked parts will be overwritten by fields.
5608            // Write the fields.
5609            self.0.encode(encoder, offset + 0, depth)?;
5610            self.1.encode(encoder, offset + 16, depth)?;
5611            Ok(())
5612        }
5613    }
5614
5615    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
5616        for DeviceOpenSessionRequest
5617    {
5618        #[inline(always)]
5619        fn new_empty() -> Self {
5620            Self {
5621                session_name: fidl::new_empty!(
5622                    fidl::encoding::BoundedString<64>,
5623                    fdomain_client::fidl::FDomainResourceDialect
5624                ),
5625                session_info: fidl::new_empty!(
5626                    SessionInfo,
5627                    fdomain_client::fidl::FDomainResourceDialect
5628                ),
5629            }
5630        }
5631
5632        #[inline]
5633        unsafe fn decode(
5634            &mut self,
5635            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5636            offset: usize,
5637            _depth: fidl::encoding::Depth,
5638        ) -> fidl::Result<()> {
5639            decoder.debug_check_bounds::<Self>(offset);
5640            // Verify that padding bytes are zero.
5641            fidl::decode!(
5642                fidl::encoding::BoundedString<64>,
5643                fdomain_client::fidl::FDomainResourceDialect,
5644                &mut self.session_name,
5645                decoder,
5646                offset + 0,
5647                _depth
5648            )?;
5649            fidl::decode!(
5650                SessionInfo,
5651                fdomain_client::fidl::FDomainResourceDialect,
5652                &mut self.session_info,
5653                decoder,
5654                offset + 16,
5655                _depth
5656            )?;
5657            Ok(())
5658        }
5659    }
5660
5661    impl fidl::encoding::ResourceTypeMarker for DeviceOpenSessionResponse {
5662        type Borrowed<'a> = &'a mut Self;
5663        fn take_or_borrow<'a>(
5664            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5665        ) -> Self::Borrowed<'a> {
5666            value
5667        }
5668    }
5669
5670    unsafe impl fidl::encoding::TypeMarker for DeviceOpenSessionResponse {
5671        type Owned = Self;
5672
5673        #[inline(always)]
5674        fn inline_align(_context: fidl::encoding::Context) -> usize {
5675            4
5676        }
5677
5678        #[inline(always)]
5679        fn inline_size(_context: fidl::encoding::Context) -> usize {
5680            12
5681        }
5682    }
5683
5684    unsafe impl
5685        fidl::encoding::Encode<
5686            DeviceOpenSessionResponse,
5687            fdomain_client::fidl::FDomainResourceDialect,
5688        > for &mut DeviceOpenSessionResponse
5689    {
5690        #[inline]
5691        unsafe fn encode(
5692            self,
5693            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5694            offset: usize,
5695            _depth: fidl::encoding::Depth,
5696        ) -> fidl::Result<()> {
5697            encoder.debug_check_bounds::<DeviceOpenSessionResponse>(offset);
5698            // Delegate to tuple encoding.
5699            fidl::encoding::Encode::<DeviceOpenSessionResponse, fdomain_client::fidl::FDomainResourceDialect>::encode(
5700                (
5701                    <fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<SessionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session),
5702                    <Fifos as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.fifos),
5703                ),
5704                encoder, offset, _depth
5705            )
5706        }
5707    }
5708    unsafe impl<
5709        T0: fidl::encoding::Encode<
5710                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<SessionMarker>>,
5711                fdomain_client::fidl::FDomainResourceDialect,
5712            >,
5713        T1: fidl::encoding::Encode<Fifos, fdomain_client::fidl::FDomainResourceDialect>,
5714    >
5715        fidl::encoding::Encode<
5716            DeviceOpenSessionResponse,
5717            fdomain_client::fidl::FDomainResourceDialect,
5718        > for (T0, T1)
5719    {
5720        #[inline]
5721        unsafe fn encode(
5722            self,
5723            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5724            offset: usize,
5725            depth: fidl::encoding::Depth,
5726        ) -> fidl::Result<()> {
5727            encoder.debug_check_bounds::<DeviceOpenSessionResponse>(offset);
5728            // Zero out padding regions. There's no need to apply masks
5729            // because the unmasked parts will be overwritten by fields.
5730            // Write the fields.
5731            self.0.encode(encoder, offset + 0, depth)?;
5732            self.1.encode(encoder, offset + 4, depth)?;
5733            Ok(())
5734        }
5735    }
5736
5737    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
5738        for DeviceOpenSessionResponse
5739    {
5740        #[inline(always)]
5741        fn new_empty() -> Self {
5742            Self {
5743                session: fidl::new_empty!(
5744                    fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<SessionMarker>>,
5745                    fdomain_client::fidl::FDomainResourceDialect
5746                ),
5747                fifos: fidl::new_empty!(Fifos, fdomain_client::fidl::FDomainResourceDialect),
5748            }
5749        }
5750
5751        #[inline]
5752        unsafe fn decode(
5753            &mut self,
5754            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5755            offset: usize,
5756            _depth: fidl::encoding::Depth,
5757        ) -> fidl::Result<()> {
5758            decoder.debug_check_bounds::<Self>(offset);
5759            // Verify that padding bytes are zero.
5760            fidl::decode!(
5761                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<SessionMarker>>,
5762                fdomain_client::fidl::FDomainResourceDialect,
5763                &mut self.session,
5764                decoder,
5765                offset + 0,
5766                _depth
5767            )?;
5768            fidl::decode!(
5769                Fifos,
5770                fdomain_client::fidl::FDomainResourceDialect,
5771                &mut self.fifos,
5772                decoder,
5773                offset + 4,
5774                _depth
5775            )?;
5776            Ok(())
5777        }
5778    }
5779
5780    impl fidl::encoding::ResourceTypeMarker for Fifos {
5781        type Borrowed<'a> = &'a mut Self;
5782        fn take_or_borrow<'a>(
5783            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5784        ) -> Self::Borrowed<'a> {
5785            value
5786        }
5787    }
5788
5789    unsafe impl fidl::encoding::TypeMarker for Fifos {
5790        type Owned = Self;
5791
5792        #[inline(always)]
5793        fn inline_align(_context: fidl::encoding::Context) -> usize {
5794            4
5795        }
5796
5797        #[inline(always)]
5798        fn inline_size(_context: fidl::encoding::Context) -> usize {
5799            8
5800        }
5801    }
5802
5803    unsafe impl fidl::encoding::Encode<Fifos, fdomain_client::fidl::FDomainResourceDialect>
5804        for &mut Fifos
5805    {
5806        #[inline]
5807        unsafe fn encode(
5808            self,
5809            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5810            offset: usize,
5811            _depth: fidl::encoding::Depth,
5812        ) -> fidl::Result<()> {
5813            encoder.debug_check_bounds::<Fifos>(offset);
5814            // Delegate to tuple encoding.
5815            fidl::encoding::Encode::<Fifos, fdomain_client::fidl::FDomainResourceDialect>::encode(
5816                (
5817                    <fidl::encoding::HandleType<
5818                        fdomain_client::Fifo,
5819                        { fidl::ObjectType::FIFO.into_raw() },
5820                        2147483648,
5821                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5822                        &mut self.rx
5823                    ),
5824                    <fidl::encoding::HandleType<
5825                        fdomain_client::Fifo,
5826                        { fidl::ObjectType::FIFO.into_raw() },
5827                        2147483648,
5828                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5829                        &mut self.tx
5830                    ),
5831                ),
5832                encoder,
5833                offset,
5834                _depth,
5835            )
5836        }
5837    }
5838    unsafe impl<
5839        T0: fidl::encoding::Encode<
5840                fidl::encoding::HandleType<
5841                    fdomain_client::Fifo,
5842                    { fidl::ObjectType::FIFO.into_raw() },
5843                    2147483648,
5844                >,
5845                fdomain_client::fidl::FDomainResourceDialect,
5846            >,
5847        T1: fidl::encoding::Encode<
5848                fidl::encoding::HandleType<
5849                    fdomain_client::Fifo,
5850                    { fidl::ObjectType::FIFO.into_raw() },
5851                    2147483648,
5852                >,
5853                fdomain_client::fidl::FDomainResourceDialect,
5854            >,
5855    > fidl::encoding::Encode<Fifos, fdomain_client::fidl::FDomainResourceDialect> for (T0, T1)
5856    {
5857        #[inline]
5858        unsafe fn encode(
5859            self,
5860            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5861            offset: usize,
5862            depth: fidl::encoding::Depth,
5863        ) -> fidl::Result<()> {
5864            encoder.debug_check_bounds::<Fifos>(offset);
5865            // Zero out padding regions. There's no need to apply masks
5866            // because the unmasked parts will be overwritten by fields.
5867            // Write the fields.
5868            self.0.encode(encoder, offset + 0, depth)?;
5869            self.1.encode(encoder, offset + 4, depth)?;
5870            Ok(())
5871        }
5872    }
5873
5874    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for Fifos {
5875        #[inline(always)]
5876        fn new_empty() -> Self {
5877            Self {
5878                rx: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
5879                tx: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
5880            }
5881        }
5882
5883        #[inline]
5884        unsafe fn decode(
5885            &mut self,
5886            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5887            offset: usize,
5888            _depth: fidl::encoding::Depth,
5889        ) -> fidl::Result<()> {
5890            decoder.debug_check_bounds::<Self>(offset);
5891            // Verify that padding bytes are zero.
5892            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)?;
5893            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)?;
5894            Ok(())
5895        }
5896    }
5897
5898    impl fidl::encoding::ResourceTypeMarker for PortCloneRequest {
5899        type Borrowed<'a> = &'a mut Self;
5900        fn take_or_borrow<'a>(
5901            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5902        ) -> Self::Borrowed<'a> {
5903            value
5904        }
5905    }
5906
5907    unsafe impl fidl::encoding::TypeMarker for PortCloneRequest {
5908        type Owned = Self;
5909
5910        #[inline(always)]
5911        fn inline_align(_context: fidl::encoding::Context) -> usize {
5912            4
5913        }
5914
5915        #[inline(always)]
5916        fn inline_size(_context: fidl::encoding::Context) -> usize {
5917            4
5918        }
5919    }
5920
5921    unsafe impl
5922        fidl::encoding::Encode<PortCloneRequest, fdomain_client::fidl::FDomainResourceDialect>
5923        for &mut PortCloneRequest
5924    {
5925        #[inline]
5926        unsafe fn encode(
5927            self,
5928            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5929            offset: usize,
5930            _depth: fidl::encoding::Depth,
5931        ) -> fidl::Result<()> {
5932            encoder.debug_check_bounds::<PortCloneRequest>(offset);
5933            // Delegate to tuple encoding.
5934            fidl::encoding::Encode::<PortCloneRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
5935                (
5936                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<PortMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.port),
5937                ),
5938                encoder, offset, _depth
5939            )
5940        }
5941    }
5942    unsafe impl<
5943        T0: fidl::encoding::Encode<
5944                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<PortMarker>>,
5945                fdomain_client::fidl::FDomainResourceDialect,
5946            >,
5947    > fidl::encoding::Encode<PortCloneRequest, fdomain_client::fidl::FDomainResourceDialect>
5948        for (T0,)
5949    {
5950        #[inline]
5951        unsafe fn encode(
5952            self,
5953            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5954            offset: usize,
5955            depth: fidl::encoding::Depth,
5956        ) -> fidl::Result<()> {
5957            encoder.debug_check_bounds::<PortCloneRequest>(offset);
5958            // Zero out padding regions. There's no need to apply masks
5959            // because the unmasked parts will be overwritten by fields.
5960            // Write the fields.
5961            self.0.encode(encoder, offset + 0, depth)?;
5962            Ok(())
5963        }
5964    }
5965
5966    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
5967        for PortCloneRequest
5968    {
5969        #[inline(always)]
5970        fn new_empty() -> Self {
5971            Self {
5972                port: fidl::new_empty!(
5973                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<PortMarker>>,
5974                    fdomain_client::fidl::FDomainResourceDialect
5975                ),
5976            }
5977        }
5978
5979        #[inline]
5980        unsafe fn decode(
5981            &mut self,
5982            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
5983            offset: usize,
5984            _depth: fidl::encoding::Depth,
5985        ) -> fidl::Result<()> {
5986            decoder.debug_check_bounds::<Self>(offset);
5987            // Verify that padding bytes are zero.
5988            fidl::decode!(
5989                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<PortMarker>>,
5990                fdomain_client::fidl::FDomainResourceDialect,
5991                &mut self.port,
5992                decoder,
5993                offset + 0,
5994                _depth
5995            )?;
5996            Ok(())
5997        }
5998    }
5999
6000    impl fidl::encoding::ResourceTypeMarker for PortGetDeviceRequest {
6001        type Borrowed<'a> = &'a mut Self;
6002        fn take_or_borrow<'a>(
6003            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6004        ) -> Self::Borrowed<'a> {
6005            value
6006        }
6007    }
6008
6009    unsafe impl fidl::encoding::TypeMarker for PortGetDeviceRequest {
6010        type Owned = Self;
6011
6012        #[inline(always)]
6013        fn inline_align(_context: fidl::encoding::Context) -> usize {
6014            4
6015        }
6016
6017        #[inline(always)]
6018        fn inline_size(_context: fidl::encoding::Context) -> usize {
6019            4
6020        }
6021    }
6022
6023    unsafe impl
6024        fidl::encoding::Encode<PortGetDeviceRequest, fdomain_client::fidl::FDomainResourceDialect>
6025        for &mut PortGetDeviceRequest
6026    {
6027        #[inline]
6028        unsafe fn encode(
6029            self,
6030            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6031            offset: usize,
6032            _depth: fidl::encoding::Depth,
6033        ) -> fidl::Result<()> {
6034            encoder.debug_check_bounds::<PortGetDeviceRequest>(offset);
6035            // Delegate to tuple encoding.
6036            fidl::encoding::Encode::<PortGetDeviceRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
6037                (
6038                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.device),
6039                ),
6040                encoder, offset, _depth
6041            )
6042        }
6043    }
6044    unsafe impl<
6045        T0: fidl::encoding::Encode<
6046                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<DeviceMarker>>,
6047                fdomain_client::fidl::FDomainResourceDialect,
6048            >,
6049    > fidl::encoding::Encode<PortGetDeviceRequest, fdomain_client::fidl::FDomainResourceDialect>
6050        for (T0,)
6051    {
6052        #[inline]
6053        unsafe fn encode(
6054            self,
6055            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6056            offset: usize,
6057            depth: fidl::encoding::Depth,
6058        ) -> fidl::Result<()> {
6059            encoder.debug_check_bounds::<PortGetDeviceRequest>(offset);
6060            // Zero out padding regions. There's no need to apply masks
6061            // because the unmasked parts will be overwritten by fields.
6062            // Write the fields.
6063            self.0.encode(encoder, offset + 0, depth)?;
6064            Ok(())
6065        }
6066    }
6067
6068    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
6069        for PortGetDeviceRequest
6070    {
6071        #[inline(always)]
6072        fn new_empty() -> Self {
6073            Self {
6074                device: fidl::new_empty!(
6075                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<DeviceMarker>>,
6076                    fdomain_client::fidl::FDomainResourceDialect
6077                ),
6078            }
6079        }
6080
6081        #[inline]
6082        unsafe fn decode(
6083            &mut self,
6084            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6085            offset: usize,
6086            _depth: fidl::encoding::Depth,
6087        ) -> fidl::Result<()> {
6088            decoder.debug_check_bounds::<Self>(offset);
6089            // Verify that padding bytes are zero.
6090            fidl::decode!(
6091                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<DeviceMarker>>,
6092                fdomain_client::fidl::FDomainResourceDialect,
6093                &mut self.device,
6094                decoder,
6095                offset + 0,
6096                _depth
6097            )?;
6098            Ok(())
6099        }
6100    }
6101
6102    impl fidl::encoding::ResourceTypeMarker for PortGetDiagnosticsRequest {
6103        type Borrowed<'a> = &'a mut Self;
6104        fn take_or_borrow<'a>(
6105            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6106        ) -> Self::Borrowed<'a> {
6107            value
6108        }
6109    }
6110
6111    unsafe impl fidl::encoding::TypeMarker for PortGetDiagnosticsRequest {
6112        type Owned = Self;
6113
6114        #[inline(always)]
6115        fn inline_align(_context: fidl::encoding::Context) -> usize {
6116            4
6117        }
6118
6119        #[inline(always)]
6120        fn inline_size(_context: fidl::encoding::Context) -> usize {
6121            4
6122        }
6123    }
6124
6125    unsafe impl
6126        fidl::encoding::Encode<
6127            PortGetDiagnosticsRequest,
6128            fdomain_client::fidl::FDomainResourceDialect,
6129        > for &mut PortGetDiagnosticsRequest
6130    {
6131        #[inline]
6132        unsafe fn encode(
6133            self,
6134            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6135            offset: usize,
6136            _depth: fidl::encoding::Depth,
6137        ) -> fidl::Result<()> {
6138            encoder.debug_check_bounds::<PortGetDiagnosticsRequest>(offset);
6139            // Delegate to tuple encoding.
6140            fidl::encoding::Encode::<PortGetDiagnosticsRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
6141                (
6142                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<DiagnosticsMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.diagnostics),
6143                ),
6144                encoder, offset, _depth
6145            )
6146        }
6147    }
6148    unsafe impl<
6149        T0: fidl::encoding::Encode<
6150                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<DiagnosticsMarker>>,
6151                fdomain_client::fidl::FDomainResourceDialect,
6152            >,
6153    >
6154        fidl::encoding::Encode<
6155            PortGetDiagnosticsRequest,
6156            fdomain_client::fidl::FDomainResourceDialect,
6157        > for (T0,)
6158    {
6159        #[inline]
6160        unsafe fn encode(
6161            self,
6162            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6163            offset: usize,
6164            depth: fidl::encoding::Depth,
6165        ) -> fidl::Result<()> {
6166            encoder.debug_check_bounds::<PortGetDiagnosticsRequest>(offset);
6167            // Zero out padding regions. There's no need to apply masks
6168            // because the unmasked parts will be overwritten by fields.
6169            // Write the fields.
6170            self.0.encode(encoder, offset + 0, depth)?;
6171            Ok(())
6172        }
6173    }
6174
6175    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
6176        for PortGetDiagnosticsRequest
6177    {
6178        #[inline(always)]
6179        fn new_empty() -> Self {
6180            Self {
6181                diagnostics: fidl::new_empty!(
6182                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<DiagnosticsMarker>>,
6183                    fdomain_client::fidl::FDomainResourceDialect
6184                ),
6185            }
6186        }
6187
6188        #[inline]
6189        unsafe fn decode(
6190            &mut self,
6191            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6192            offset: usize,
6193            _depth: fidl::encoding::Depth,
6194        ) -> fidl::Result<()> {
6195            decoder.debug_check_bounds::<Self>(offset);
6196            // Verify that padding bytes are zero.
6197            fidl::decode!(
6198                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<DiagnosticsMarker>>,
6199                fdomain_client::fidl::FDomainResourceDialect,
6200                &mut self.diagnostics,
6201                decoder,
6202                offset + 0,
6203                _depth
6204            )?;
6205            Ok(())
6206        }
6207    }
6208
6209    impl fidl::encoding::ResourceTypeMarker for PortGetIdentityResponse {
6210        type Borrowed<'a> = &'a mut Self;
6211        fn take_or_borrow<'a>(
6212            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6213        ) -> Self::Borrowed<'a> {
6214            value
6215        }
6216    }
6217
6218    unsafe impl fidl::encoding::TypeMarker for PortGetIdentityResponse {
6219        type Owned = Self;
6220
6221        #[inline(always)]
6222        fn inline_align(_context: fidl::encoding::Context) -> usize {
6223            4
6224        }
6225
6226        #[inline(always)]
6227        fn inline_size(_context: fidl::encoding::Context) -> usize {
6228            4
6229        }
6230    }
6231
6232    unsafe impl
6233        fidl::encoding::Encode<
6234            PortGetIdentityResponse,
6235            fdomain_client::fidl::FDomainResourceDialect,
6236        > for &mut PortGetIdentityResponse
6237    {
6238        #[inline]
6239        unsafe fn encode(
6240            self,
6241            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6242            offset: usize,
6243            _depth: fidl::encoding::Depth,
6244        ) -> fidl::Result<()> {
6245            encoder.debug_check_bounds::<PortGetIdentityResponse>(offset);
6246            // Delegate to tuple encoding.
6247            fidl::encoding::Encode::<
6248                PortGetIdentityResponse,
6249                fdomain_client::fidl::FDomainResourceDialect,
6250            >::encode(
6251                (<fidl::encoding::HandleType<
6252                    fdomain_client::Event,
6253                    { fidl::ObjectType::EVENT.into_raw() },
6254                    3,
6255                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6256                    &mut self.event
6257                ),),
6258                encoder,
6259                offset,
6260                _depth,
6261            )
6262        }
6263    }
6264    unsafe impl<
6265        T0: fidl::encoding::Encode<
6266                fidl::encoding::HandleType<
6267                    fdomain_client::Event,
6268                    { fidl::ObjectType::EVENT.into_raw() },
6269                    3,
6270                >,
6271                fdomain_client::fidl::FDomainResourceDialect,
6272            >,
6273    >
6274        fidl::encoding::Encode<
6275            PortGetIdentityResponse,
6276            fdomain_client::fidl::FDomainResourceDialect,
6277        > for (T0,)
6278    {
6279        #[inline]
6280        unsafe fn encode(
6281            self,
6282            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6283            offset: usize,
6284            depth: fidl::encoding::Depth,
6285        ) -> fidl::Result<()> {
6286            encoder.debug_check_bounds::<PortGetIdentityResponse>(offset);
6287            // Zero out padding regions. There's no need to apply masks
6288            // because the unmasked parts will be overwritten by fields.
6289            // Write the fields.
6290            self.0.encode(encoder, offset + 0, depth)?;
6291            Ok(())
6292        }
6293    }
6294
6295    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
6296        for PortGetIdentityResponse
6297    {
6298        #[inline(always)]
6299        fn new_empty() -> Self {
6300            Self {
6301                event: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 3>, fdomain_client::fidl::FDomainResourceDialect),
6302            }
6303        }
6304
6305        #[inline]
6306        unsafe fn decode(
6307            &mut self,
6308            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6309            offset: usize,
6310            _depth: fidl::encoding::Depth,
6311        ) -> fidl::Result<()> {
6312            decoder.debug_check_bounds::<Self>(offset);
6313            // Verify that padding bytes are zero.
6314            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)?;
6315            Ok(())
6316        }
6317    }
6318
6319    impl fidl::encoding::ResourceTypeMarker for PortGetMacRequest {
6320        type Borrowed<'a> = &'a mut Self;
6321        fn take_or_borrow<'a>(
6322            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6323        ) -> Self::Borrowed<'a> {
6324            value
6325        }
6326    }
6327
6328    unsafe impl fidl::encoding::TypeMarker for PortGetMacRequest {
6329        type Owned = Self;
6330
6331        #[inline(always)]
6332        fn inline_align(_context: fidl::encoding::Context) -> usize {
6333            4
6334        }
6335
6336        #[inline(always)]
6337        fn inline_size(_context: fidl::encoding::Context) -> usize {
6338            4
6339        }
6340    }
6341
6342    unsafe impl
6343        fidl::encoding::Encode<PortGetMacRequest, fdomain_client::fidl::FDomainResourceDialect>
6344        for &mut PortGetMacRequest
6345    {
6346        #[inline]
6347        unsafe fn encode(
6348            self,
6349            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6350            offset: usize,
6351            _depth: fidl::encoding::Depth,
6352        ) -> fidl::Result<()> {
6353            encoder.debug_check_bounds::<PortGetMacRequest>(offset);
6354            // Delegate to tuple encoding.
6355            fidl::encoding::Encode::<PortGetMacRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
6356                (
6357                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<MacAddressingMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.mac),
6358                ),
6359                encoder, offset, _depth
6360            )
6361        }
6362    }
6363    unsafe impl<
6364        T0: fidl::encoding::Encode<
6365                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<MacAddressingMarker>>,
6366                fdomain_client::fidl::FDomainResourceDialect,
6367            >,
6368    > fidl::encoding::Encode<PortGetMacRequest, fdomain_client::fidl::FDomainResourceDialect>
6369        for (T0,)
6370    {
6371        #[inline]
6372        unsafe fn encode(
6373            self,
6374            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6375            offset: usize,
6376            depth: fidl::encoding::Depth,
6377        ) -> fidl::Result<()> {
6378            encoder.debug_check_bounds::<PortGetMacRequest>(offset);
6379            // Zero out padding regions. There's no need to apply masks
6380            // because the unmasked parts will be overwritten by fields.
6381            // Write the fields.
6382            self.0.encode(encoder, offset + 0, depth)?;
6383            Ok(())
6384        }
6385    }
6386
6387    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
6388        for PortGetMacRequest
6389    {
6390        #[inline(always)]
6391        fn new_empty() -> Self {
6392            Self {
6393                mac: fidl::new_empty!(
6394                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<MacAddressingMarker>>,
6395                    fdomain_client::fidl::FDomainResourceDialect
6396                ),
6397            }
6398        }
6399
6400        #[inline]
6401        unsafe fn decode(
6402            &mut self,
6403            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6404            offset: usize,
6405            _depth: fidl::encoding::Depth,
6406        ) -> fidl::Result<()> {
6407            decoder.debug_check_bounds::<Self>(offset);
6408            // Verify that padding bytes are zero.
6409            fidl::decode!(
6410                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<MacAddressingMarker>>,
6411                fdomain_client::fidl::FDomainResourceDialect,
6412                &mut self.mac,
6413                decoder,
6414                offset + 0,
6415                _depth
6416            )?;
6417            Ok(())
6418        }
6419    }
6420
6421    impl fidl::encoding::ResourceTypeMarker for PortGetPowerDependencyTokenResponse {
6422        type Borrowed<'a> = &'a mut Self;
6423        fn take_or_borrow<'a>(
6424            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6425        ) -> Self::Borrowed<'a> {
6426            value
6427        }
6428    }
6429
6430    unsafe impl fidl::encoding::TypeMarker for PortGetPowerDependencyTokenResponse {
6431        type Owned = Self;
6432
6433        #[inline(always)]
6434        fn inline_align(_context: fidl::encoding::Context) -> usize {
6435            4
6436        }
6437
6438        #[inline(always)]
6439        fn inline_size(_context: fidl::encoding::Context) -> usize {
6440            4
6441        }
6442    }
6443
6444    unsafe impl
6445        fidl::encoding::Encode<
6446            PortGetPowerDependencyTokenResponse,
6447            fdomain_client::fidl::FDomainResourceDialect,
6448        > for &mut PortGetPowerDependencyTokenResponse
6449    {
6450        #[inline]
6451        unsafe fn encode(
6452            self,
6453            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6454            offset: usize,
6455            _depth: fidl::encoding::Depth,
6456        ) -> fidl::Result<()> {
6457            encoder.debug_check_bounds::<PortGetPowerDependencyTokenResponse>(offset);
6458            // Delegate to tuple encoding.
6459            fidl::encoding::Encode::<
6460                PortGetPowerDependencyTokenResponse,
6461                fdomain_client::fidl::FDomainResourceDialect,
6462            >::encode(
6463                (<fidl::encoding::Optional<
6464                    fidl::encoding::HandleType<
6465                        fdomain_client::Event,
6466                        { fidl::ObjectType::EVENT.into_raw() },
6467                        2147483648,
6468                    >,
6469                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6470                    &mut self.token
6471                ),),
6472                encoder,
6473                offset,
6474                _depth,
6475            )
6476        }
6477    }
6478    unsafe impl<
6479        T0: fidl::encoding::Encode<
6480                fidl::encoding::Optional<
6481                    fidl::encoding::HandleType<
6482                        fdomain_client::Event,
6483                        { fidl::ObjectType::EVENT.into_raw() },
6484                        2147483648,
6485                    >,
6486                >,
6487                fdomain_client::fidl::FDomainResourceDialect,
6488            >,
6489    >
6490        fidl::encoding::Encode<
6491            PortGetPowerDependencyTokenResponse,
6492            fdomain_client::fidl::FDomainResourceDialect,
6493        > for (T0,)
6494    {
6495        #[inline]
6496        unsafe fn encode(
6497            self,
6498            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6499            offset: usize,
6500            depth: fidl::encoding::Depth,
6501        ) -> fidl::Result<()> {
6502            encoder.debug_check_bounds::<PortGetPowerDependencyTokenResponse>(offset);
6503            // Zero out padding regions. There's no need to apply masks
6504            // because the unmasked parts will be overwritten by fields.
6505            // Write the fields.
6506            self.0.encode(encoder, offset + 0, depth)?;
6507            Ok(())
6508        }
6509    }
6510
6511    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
6512        for PortGetPowerDependencyTokenResponse
6513    {
6514        #[inline(always)]
6515        fn new_empty() -> Self {
6516            Self {
6517                token: fidl::new_empty!(
6518                    fidl::encoding::Optional<
6519                        fidl::encoding::HandleType<
6520                            fdomain_client::Event,
6521                            { fidl::ObjectType::EVENT.into_raw() },
6522                            2147483648,
6523                        >,
6524                    >,
6525                    fdomain_client::fidl::FDomainResourceDialect
6526                ),
6527            }
6528        }
6529
6530        #[inline]
6531        unsafe fn decode(
6532            &mut self,
6533            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6534            offset: usize,
6535            _depth: fidl::encoding::Depth,
6536        ) -> fidl::Result<()> {
6537            decoder.debug_check_bounds::<Self>(offset);
6538            // Verify that padding bytes are zero.
6539            fidl::decode!(
6540                fidl::encoding::Optional<
6541                    fidl::encoding::HandleType<
6542                        fdomain_client::Event,
6543                        { fidl::ObjectType::EVENT.into_raw() },
6544                        2147483648,
6545                    >,
6546                >,
6547                fdomain_client::fidl::FDomainResourceDialect,
6548                &mut self.token,
6549                decoder,
6550                offset + 0,
6551                _depth
6552            )?;
6553            Ok(())
6554        }
6555    }
6556
6557    impl fidl::encoding::ResourceTypeMarker for PortGetStatusWatcherRequest {
6558        type Borrowed<'a> = &'a mut Self;
6559        fn take_or_borrow<'a>(
6560            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6561        ) -> Self::Borrowed<'a> {
6562            value
6563        }
6564    }
6565
6566    unsafe impl fidl::encoding::TypeMarker for PortGetStatusWatcherRequest {
6567        type Owned = Self;
6568
6569        #[inline(always)]
6570        fn inline_align(_context: fidl::encoding::Context) -> usize {
6571            4
6572        }
6573
6574        #[inline(always)]
6575        fn inline_size(_context: fidl::encoding::Context) -> usize {
6576            8
6577        }
6578    }
6579
6580    unsafe impl
6581        fidl::encoding::Encode<
6582            PortGetStatusWatcherRequest,
6583            fdomain_client::fidl::FDomainResourceDialect,
6584        > for &mut PortGetStatusWatcherRequest
6585    {
6586        #[inline]
6587        unsafe fn encode(
6588            self,
6589            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6590            offset: usize,
6591            _depth: fidl::encoding::Depth,
6592        ) -> fidl::Result<()> {
6593            encoder.debug_check_bounds::<PortGetStatusWatcherRequest>(offset);
6594            // Delegate to tuple encoding.
6595            fidl::encoding::Encode::<PortGetStatusWatcherRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
6596                (
6597                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<StatusWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
6598                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer),
6599                ),
6600                encoder, offset, _depth
6601            )
6602        }
6603    }
6604    unsafe impl<
6605        T0: fidl::encoding::Encode<
6606                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<StatusWatcherMarker>>,
6607                fdomain_client::fidl::FDomainResourceDialect,
6608            >,
6609        T1: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
6610    >
6611        fidl::encoding::Encode<
6612            PortGetStatusWatcherRequest,
6613            fdomain_client::fidl::FDomainResourceDialect,
6614        > for (T0, T1)
6615    {
6616        #[inline]
6617        unsafe fn encode(
6618            self,
6619            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6620            offset: usize,
6621            depth: fidl::encoding::Depth,
6622        ) -> fidl::Result<()> {
6623            encoder.debug_check_bounds::<PortGetStatusWatcherRequest>(offset);
6624            // Zero out padding regions. There's no need to apply masks
6625            // because the unmasked parts will be overwritten by fields.
6626            // Write the fields.
6627            self.0.encode(encoder, offset + 0, depth)?;
6628            self.1.encode(encoder, offset + 4, depth)?;
6629            Ok(())
6630        }
6631    }
6632
6633    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
6634        for PortGetStatusWatcherRequest
6635    {
6636        #[inline(always)]
6637        fn new_empty() -> Self {
6638            Self {
6639                watcher: fidl::new_empty!(
6640                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<StatusWatcherMarker>>,
6641                    fdomain_client::fidl::FDomainResourceDialect
6642                ),
6643                buffer: fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect),
6644            }
6645        }
6646
6647        #[inline]
6648        unsafe fn decode(
6649            &mut self,
6650            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6651            offset: usize,
6652            _depth: fidl::encoding::Depth,
6653        ) -> fidl::Result<()> {
6654            decoder.debug_check_bounds::<Self>(offset);
6655            // Verify that padding bytes are zero.
6656            fidl::decode!(
6657                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<StatusWatcherMarker>>,
6658                fdomain_client::fidl::FDomainResourceDialect,
6659                &mut self.watcher,
6660                decoder,
6661                offset + 0,
6662                _depth
6663            )?;
6664            fidl::decode!(
6665                u32,
6666                fdomain_client::fidl::FDomainResourceDialect,
6667                &mut self.buffer,
6668                decoder,
6669                offset + 4,
6670                _depth
6671            )?;
6672            Ok(())
6673        }
6674    }
6675
6676    impl fidl::encoding::ResourceTypeMarker for SessionRegisterForTxRequest {
6677        type Borrowed<'a> = &'a mut Self;
6678        fn take_or_borrow<'a>(
6679            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6680        ) -> Self::Borrowed<'a> {
6681            value
6682        }
6683    }
6684
6685    unsafe impl fidl::encoding::TypeMarker for SessionRegisterForTxRequest {
6686        type Owned = Self;
6687
6688        #[inline(always)]
6689        fn inline_align(_context: fidl::encoding::Context) -> usize {
6690            8
6691        }
6692
6693        #[inline(always)]
6694        fn inline_size(_context: fidl::encoding::Context) -> usize {
6695            16
6696        }
6697    }
6698
6699    unsafe impl
6700        fidl::encoding::Encode<
6701            SessionRegisterForTxRequest,
6702            fdomain_client::fidl::FDomainResourceDialect,
6703        > for &mut SessionRegisterForTxRequest
6704    {
6705        #[inline]
6706        unsafe fn encode(
6707            self,
6708            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6709            offset: usize,
6710            _depth: fidl::encoding::Depth,
6711        ) -> fidl::Result<()> {
6712            encoder.debug_check_bounds::<SessionRegisterForTxRequest>(offset);
6713            // Delegate to tuple encoding.
6714            fidl::encoding::Encode::<
6715                SessionRegisterForTxRequest,
6716                fdomain_client::fidl::FDomainResourceDialect,
6717            >::encode(
6718                (<fidl::encoding::Vector<u8, 32> as fidl::encoding::ValueTypeMarker>::borrow(
6719                    &self.vmos,
6720                ),),
6721                encoder,
6722                offset,
6723                _depth,
6724            )
6725        }
6726    }
6727    unsafe impl<
6728        T0: fidl::encoding::Encode<
6729                fidl::encoding::Vector<u8, 32>,
6730                fdomain_client::fidl::FDomainResourceDialect,
6731            >,
6732    >
6733        fidl::encoding::Encode<
6734            SessionRegisterForTxRequest,
6735            fdomain_client::fidl::FDomainResourceDialect,
6736        > for (T0,)
6737    {
6738        #[inline]
6739        unsafe fn encode(
6740            self,
6741            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6742            offset: usize,
6743            depth: fidl::encoding::Depth,
6744        ) -> fidl::Result<()> {
6745            encoder.debug_check_bounds::<SessionRegisterForTxRequest>(offset);
6746            // Zero out padding regions. There's no need to apply masks
6747            // because the unmasked parts will be overwritten by fields.
6748            // Write the fields.
6749            self.0.encode(encoder, offset + 0, depth)?;
6750            Ok(())
6751        }
6752    }
6753
6754    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
6755        for SessionRegisterForTxRequest
6756    {
6757        #[inline(always)]
6758        fn new_empty() -> Self {
6759            Self {
6760                vmos: fidl::new_empty!(fidl::encoding::Vector<u8, 32>, fdomain_client::fidl::FDomainResourceDialect),
6761            }
6762        }
6763
6764        #[inline]
6765        unsafe fn decode(
6766            &mut self,
6767            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6768            offset: usize,
6769            _depth: fidl::encoding::Depth,
6770        ) -> fidl::Result<()> {
6771            decoder.debug_check_bounds::<Self>(offset);
6772            // Verify that padding bytes are zero.
6773            fidl::decode!(fidl::encoding::Vector<u8, 32>, fdomain_client::fidl::FDomainResourceDialect, &mut self.vmos, decoder, offset + 0, _depth)?;
6774            Ok(())
6775        }
6776    }
6777
6778    impl fidl::encoding::ResourceTypeMarker for SessionUnregisterForTxRequest {
6779        type Borrowed<'a> = &'a mut Self;
6780        fn take_or_borrow<'a>(
6781            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6782        ) -> Self::Borrowed<'a> {
6783            value
6784        }
6785    }
6786
6787    unsafe impl fidl::encoding::TypeMarker for SessionUnregisterForTxRequest {
6788        type Owned = Self;
6789
6790        #[inline(always)]
6791        fn inline_align(_context: fidl::encoding::Context) -> usize {
6792            8
6793        }
6794
6795        #[inline(always)]
6796        fn inline_size(_context: fidl::encoding::Context) -> usize {
6797            16
6798        }
6799    }
6800
6801    unsafe impl
6802        fidl::encoding::Encode<
6803            SessionUnregisterForTxRequest,
6804            fdomain_client::fidl::FDomainResourceDialect,
6805        > for &mut SessionUnregisterForTxRequest
6806    {
6807        #[inline]
6808        unsafe fn encode(
6809            self,
6810            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6811            offset: usize,
6812            _depth: fidl::encoding::Depth,
6813        ) -> fidl::Result<()> {
6814            encoder.debug_check_bounds::<SessionUnregisterForTxRequest>(offset);
6815            // Delegate to tuple encoding.
6816            fidl::encoding::Encode::<
6817                SessionUnregisterForTxRequest,
6818                fdomain_client::fidl::FDomainResourceDialect,
6819            >::encode(
6820                (<fidl::encoding::Vector<u8, 32> as fidl::encoding::ValueTypeMarker>::borrow(
6821                    &self.vmos,
6822                ),),
6823                encoder,
6824                offset,
6825                _depth,
6826            )
6827        }
6828    }
6829    unsafe impl<
6830        T0: fidl::encoding::Encode<
6831                fidl::encoding::Vector<u8, 32>,
6832                fdomain_client::fidl::FDomainResourceDialect,
6833            >,
6834    >
6835        fidl::encoding::Encode<
6836            SessionUnregisterForTxRequest,
6837            fdomain_client::fidl::FDomainResourceDialect,
6838        > for (T0,)
6839    {
6840        #[inline]
6841        unsafe fn encode(
6842            self,
6843            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6844            offset: usize,
6845            depth: fidl::encoding::Depth,
6846        ) -> fidl::Result<()> {
6847            encoder.debug_check_bounds::<SessionUnregisterForTxRequest>(offset);
6848            // Zero out padding regions. There's no need to apply masks
6849            // because the unmasked parts will be overwritten by fields.
6850            // Write the fields.
6851            self.0.encode(encoder, offset + 0, depth)?;
6852            Ok(())
6853        }
6854    }
6855
6856    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
6857        for SessionUnregisterForTxRequest
6858    {
6859        #[inline(always)]
6860        fn new_empty() -> Self {
6861            Self {
6862                vmos: fidl::new_empty!(fidl::encoding::Vector<u8, 32>, fdomain_client::fidl::FDomainResourceDialect),
6863            }
6864        }
6865
6866        #[inline]
6867        unsafe fn decode(
6868            &mut self,
6869            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6870            offset: usize,
6871            _depth: fidl::encoding::Depth,
6872        ) -> fidl::Result<()> {
6873            decoder.debug_check_bounds::<Self>(offset);
6874            // Verify that padding bytes are zero.
6875            fidl::decode!(fidl::encoding::Vector<u8, 32>, fdomain_client::fidl::FDomainResourceDialect, &mut self.vmos, decoder, offset + 0, _depth)?;
6876            Ok(())
6877        }
6878    }
6879
6880    impl fidl::encoding::ResourceTypeMarker for SessionWatchDelegatedRxLeaseResponse {
6881        type Borrowed<'a> = &'a mut Self;
6882        fn take_or_borrow<'a>(
6883            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6884        ) -> Self::Borrowed<'a> {
6885            value
6886        }
6887    }
6888
6889    unsafe impl fidl::encoding::TypeMarker for SessionWatchDelegatedRxLeaseResponse {
6890        type Owned = Self;
6891
6892        #[inline(always)]
6893        fn inline_align(_context: fidl::encoding::Context) -> usize {
6894            8
6895        }
6896
6897        #[inline(always)]
6898        fn inline_size(_context: fidl::encoding::Context) -> usize {
6899            16
6900        }
6901    }
6902
6903    unsafe impl
6904        fidl::encoding::Encode<
6905            SessionWatchDelegatedRxLeaseResponse,
6906            fdomain_client::fidl::FDomainResourceDialect,
6907        > for &mut SessionWatchDelegatedRxLeaseResponse
6908    {
6909        #[inline]
6910        unsafe fn encode(
6911            self,
6912            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6913            offset: usize,
6914            _depth: fidl::encoding::Depth,
6915        ) -> fidl::Result<()> {
6916            encoder.debug_check_bounds::<SessionWatchDelegatedRxLeaseResponse>(offset);
6917            // Delegate to tuple encoding.
6918            fidl::encoding::Encode::<
6919                SessionWatchDelegatedRxLeaseResponse,
6920                fdomain_client::fidl::FDomainResourceDialect,
6921            >::encode(
6922                (<DelegatedRxLease as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6923                    &mut self.lease,
6924                ),),
6925                encoder,
6926                offset,
6927                _depth,
6928            )
6929        }
6930    }
6931    unsafe impl<
6932        T0: fidl::encoding::Encode<DelegatedRxLease, fdomain_client::fidl::FDomainResourceDialect>,
6933    >
6934        fidl::encoding::Encode<
6935            SessionWatchDelegatedRxLeaseResponse,
6936            fdomain_client::fidl::FDomainResourceDialect,
6937        > for (T0,)
6938    {
6939        #[inline]
6940        unsafe fn encode(
6941            self,
6942            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6943            offset: usize,
6944            depth: fidl::encoding::Depth,
6945        ) -> fidl::Result<()> {
6946            encoder.debug_check_bounds::<SessionWatchDelegatedRxLeaseResponse>(offset);
6947            // Zero out padding regions. There's no need to apply masks
6948            // because the unmasked parts will be overwritten by fields.
6949            // Write the fields.
6950            self.0.encode(encoder, offset + 0, depth)?;
6951            Ok(())
6952        }
6953    }
6954
6955    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
6956        for SessionWatchDelegatedRxLeaseResponse
6957    {
6958        #[inline(always)]
6959        fn new_empty() -> Self {
6960            Self {
6961                lease: fidl::new_empty!(
6962                    DelegatedRxLease,
6963                    fdomain_client::fidl::FDomainResourceDialect
6964                ),
6965            }
6966        }
6967
6968        #[inline]
6969        unsafe fn decode(
6970            &mut self,
6971            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
6972            offset: usize,
6973            _depth: fidl::encoding::Depth,
6974        ) -> fidl::Result<()> {
6975            decoder.debug_check_bounds::<Self>(offset);
6976            // Verify that padding bytes are zero.
6977            fidl::decode!(
6978                DelegatedRxLease,
6979                fdomain_client::fidl::FDomainResourceDialect,
6980                &mut self.lease,
6981                decoder,
6982                offset + 0,
6983                _depth
6984            )?;
6985            Ok(())
6986        }
6987    }
6988
6989    impl DataVmo {
6990        #[inline(always)]
6991        fn max_ordinal_present(&self) -> u64 {
6992            if let Some(_) = self.num_rx_buffers {
6993                return 3;
6994            }
6995            if let Some(_) = self.vmo {
6996                return 2;
6997            }
6998            if let Some(_) = self.id {
6999                return 1;
7000            }
7001            0
7002        }
7003    }
7004
7005    impl fidl::encoding::ResourceTypeMarker for DataVmo {
7006        type Borrowed<'a> = &'a mut Self;
7007        fn take_or_borrow<'a>(
7008            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7009        ) -> Self::Borrowed<'a> {
7010            value
7011        }
7012    }
7013
7014    unsafe impl fidl::encoding::TypeMarker for DataVmo {
7015        type Owned = Self;
7016
7017        #[inline(always)]
7018        fn inline_align(_context: fidl::encoding::Context) -> usize {
7019            8
7020        }
7021
7022        #[inline(always)]
7023        fn inline_size(_context: fidl::encoding::Context) -> usize {
7024            16
7025        }
7026    }
7027
7028    unsafe impl fidl::encoding::Encode<DataVmo, fdomain_client::fidl::FDomainResourceDialect>
7029        for &mut DataVmo
7030    {
7031        unsafe fn encode(
7032            self,
7033            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
7034            offset: usize,
7035            mut depth: fidl::encoding::Depth,
7036        ) -> fidl::Result<()> {
7037            encoder.debug_check_bounds::<DataVmo>(offset);
7038            // Vector header
7039            let max_ordinal: u64 = self.max_ordinal_present();
7040            encoder.write_num(max_ordinal, offset);
7041            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7042            // Calling encoder.out_of_line_offset(0) is not allowed.
7043            if max_ordinal == 0 {
7044                return Ok(());
7045            }
7046            depth.increment()?;
7047            let envelope_size = 8;
7048            let bytes_len = max_ordinal as usize * envelope_size;
7049            #[allow(unused_variables)]
7050            let offset = encoder.out_of_line_offset(bytes_len);
7051            let mut _prev_end_offset: usize = 0;
7052            if 1 > max_ordinal {
7053                return Ok(());
7054            }
7055
7056            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7057            // are envelope_size bytes.
7058            let cur_offset: usize = (1 - 1) * envelope_size;
7059
7060            // Zero reserved fields.
7061            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7062
7063            // Safety:
7064            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7065            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7066            //   envelope_size bytes, there is always sufficient room.
7067            fidl::encoding::encode_in_envelope_optional::<
7068                u8,
7069                fdomain_client::fidl::FDomainResourceDialect,
7070            >(
7071                self.id.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
7072                encoder,
7073                offset + cur_offset,
7074                depth,
7075            )?;
7076
7077            _prev_end_offset = cur_offset + envelope_size;
7078            if 2 > max_ordinal {
7079                return Ok(());
7080            }
7081
7082            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7083            // are envelope_size bytes.
7084            let cur_offset: usize = (2 - 1) * envelope_size;
7085
7086            // Zero reserved fields.
7087            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7088
7089            // Safety:
7090            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7091            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7092            //   envelope_size bytes, there is always sufficient room.
7093            fidl::encoding::encode_in_envelope_optional::<
7094                fidl::encoding::HandleType<
7095                    fdomain_client::Vmo,
7096                    { fidl::ObjectType::VMO.into_raw() },
7097                    2147483648,
7098                >,
7099                fdomain_client::fidl::FDomainResourceDialect,
7100            >(
7101                self.vmo.as_mut().map(
7102                    <fidl::encoding::HandleType<
7103                        fdomain_client::Vmo,
7104                        { fidl::ObjectType::VMO.into_raw() },
7105                        2147483648,
7106                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
7107                ),
7108                encoder,
7109                offset + cur_offset,
7110                depth,
7111            )?;
7112
7113            _prev_end_offset = cur_offset + envelope_size;
7114            if 3 > max_ordinal {
7115                return Ok(());
7116            }
7117
7118            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7119            // are envelope_size bytes.
7120            let cur_offset: usize = (3 - 1) * envelope_size;
7121
7122            // Zero reserved fields.
7123            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7124
7125            // Safety:
7126            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7127            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7128            //   envelope_size bytes, there is always sufficient room.
7129            fidl::encoding::encode_in_envelope_optional::<
7130                u16,
7131                fdomain_client::fidl::FDomainResourceDialect,
7132            >(
7133                self.num_rx_buffers.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
7134                encoder,
7135                offset + cur_offset,
7136                depth,
7137            )?;
7138
7139            _prev_end_offset = cur_offset + envelope_size;
7140
7141            Ok(())
7142        }
7143    }
7144
7145    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for DataVmo {
7146        #[inline(always)]
7147        fn new_empty() -> Self {
7148            Self::default()
7149        }
7150
7151        unsafe fn decode(
7152            &mut self,
7153            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
7154            offset: usize,
7155            mut depth: fidl::encoding::Depth,
7156        ) -> fidl::Result<()> {
7157            decoder.debug_check_bounds::<Self>(offset);
7158            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7159                None => return Err(fidl::Error::NotNullable),
7160                Some(len) => len,
7161            };
7162            // Calling decoder.out_of_line_offset(0) is not allowed.
7163            if len == 0 {
7164                return Ok(());
7165            };
7166            depth.increment()?;
7167            let envelope_size = 8;
7168            let bytes_len = len * envelope_size;
7169            let offset = decoder.out_of_line_offset(bytes_len)?;
7170            // Decode the envelope for each type.
7171            let mut _next_ordinal_to_read = 0;
7172            let mut next_offset = offset;
7173            let end_offset = offset + bytes_len;
7174            _next_ordinal_to_read += 1;
7175            if next_offset >= end_offset {
7176                return Ok(());
7177            }
7178
7179            // Decode unknown envelopes for gaps in ordinals.
7180            while _next_ordinal_to_read < 1 {
7181                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7182                _next_ordinal_to_read += 1;
7183                next_offset += envelope_size;
7184            }
7185
7186            let next_out_of_line = decoder.next_out_of_line();
7187            let handles_before = decoder.remaining_handles();
7188            if let Some((inlined, num_bytes, num_handles)) =
7189                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7190            {
7191                let member_inline_size =
7192                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7193                if inlined != (member_inline_size <= 4) {
7194                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7195                }
7196                let inner_offset;
7197                let mut inner_depth = depth.clone();
7198                if inlined {
7199                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7200                    inner_offset = next_offset;
7201                } else {
7202                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7203                    inner_depth.increment()?;
7204                }
7205                let val_ref = self.id.get_or_insert_with(|| {
7206                    fidl::new_empty!(u8, fdomain_client::fidl::FDomainResourceDialect)
7207                });
7208                fidl::decode!(
7209                    u8,
7210                    fdomain_client::fidl::FDomainResourceDialect,
7211                    val_ref,
7212                    decoder,
7213                    inner_offset,
7214                    inner_depth
7215                )?;
7216                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7217                {
7218                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7219                }
7220                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7221                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7222                }
7223            }
7224
7225            next_offset += envelope_size;
7226            _next_ordinal_to_read += 1;
7227            if next_offset >= end_offset {
7228                return Ok(());
7229            }
7230
7231            // Decode unknown envelopes for gaps in ordinals.
7232            while _next_ordinal_to_read < 2 {
7233                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7234                _next_ordinal_to_read += 1;
7235                next_offset += envelope_size;
7236            }
7237
7238            let next_out_of_line = decoder.next_out_of_line();
7239            let handles_before = decoder.remaining_handles();
7240            if let Some((inlined, num_bytes, num_handles)) =
7241                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7242            {
7243                let member_inline_size = <fidl::encoding::HandleType<
7244                    fdomain_client::Vmo,
7245                    { fidl::ObjectType::VMO.into_raw() },
7246                    2147483648,
7247                > as fidl::encoding::TypeMarker>::inline_size(
7248                    decoder.context
7249                );
7250                if inlined != (member_inline_size <= 4) {
7251                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7252                }
7253                let inner_offset;
7254                let mut inner_depth = depth.clone();
7255                if inlined {
7256                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7257                    inner_offset = next_offset;
7258                } else {
7259                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7260                    inner_depth.increment()?;
7261                }
7262                let val_ref =
7263                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));
7264                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)?;
7265                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7266                {
7267                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7268                }
7269                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7270                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7271                }
7272            }
7273
7274            next_offset += envelope_size;
7275            _next_ordinal_to_read += 1;
7276            if next_offset >= end_offset {
7277                return Ok(());
7278            }
7279
7280            // Decode unknown envelopes for gaps in ordinals.
7281            while _next_ordinal_to_read < 3 {
7282                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7283                _next_ordinal_to_read += 1;
7284                next_offset += envelope_size;
7285            }
7286
7287            let next_out_of_line = decoder.next_out_of_line();
7288            let handles_before = decoder.remaining_handles();
7289            if let Some((inlined, num_bytes, num_handles)) =
7290                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7291            {
7292                let member_inline_size =
7293                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7294                if inlined != (member_inline_size <= 4) {
7295                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7296                }
7297                let inner_offset;
7298                let mut inner_depth = depth.clone();
7299                if inlined {
7300                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7301                    inner_offset = next_offset;
7302                } else {
7303                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7304                    inner_depth.increment()?;
7305                }
7306                let val_ref = self.num_rx_buffers.get_or_insert_with(|| {
7307                    fidl::new_empty!(u16, fdomain_client::fidl::FDomainResourceDialect)
7308                });
7309                fidl::decode!(
7310                    u16,
7311                    fdomain_client::fidl::FDomainResourceDialect,
7312                    val_ref,
7313                    decoder,
7314                    inner_offset,
7315                    inner_depth
7316                )?;
7317                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7318                {
7319                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7320                }
7321                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7322                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7323                }
7324            }
7325
7326            next_offset += envelope_size;
7327
7328            // Decode the remaining unknown envelopes.
7329            while next_offset < end_offset {
7330                _next_ordinal_to_read += 1;
7331                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7332                next_offset += envelope_size;
7333            }
7334
7335            Ok(())
7336        }
7337    }
7338
7339    impl DelegatedRxLease {
7340        #[inline(always)]
7341        fn max_ordinal_present(&self) -> u64 {
7342            if let Some(_) = self.handle {
7343                return 2;
7344            }
7345            if let Some(_) = self.hold_until_frame {
7346                return 1;
7347            }
7348            0
7349        }
7350    }
7351
7352    impl fidl::encoding::ResourceTypeMarker for DelegatedRxLease {
7353        type Borrowed<'a> = &'a mut Self;
7354        fn take_or_borrow<'a>(
7355            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7356        ) -> Self::Borrowed<'a> {
7357            value
7358        }
7359    }
7360
7361    unsafe impl fidl::encoding::TypeMarker for DelegatedRxLease {
7362        type Owned = Self;
7363
7364        #[inline(always)]
7365        fn inline_align(_context: fidl::encoding::Context) -> usize {
7366            8
7367        }
7368
7369        #[inline(always)]
7370        fn inline_size(_context: fidl::encoding::Context) -> usize {
7371            16
7372        }
7373    }
7374
7375    unsafe impl
7376        fidl::encoding::Encode<DelegatedRxLease, fdomain_client::fidl::FDomainResourceDialect>
7377        for &mut DelegatedRxLease
7378    {
7379        unsafe fn encode(
7380            self,
7381            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
7382            offset: usize,
7383            mut depth: fidl::encoding::Depth,
7384        ) -> fidl::Result<()> {
7385            encoder.debug_check_bounds::<DelegatedRxLease>(offset);
7386            // Vector header
7387            let max_ordinal: u64 = self.max_ordinal_present();
7388            encoder.write_num(max_ordinal, offset);
7389            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7390            // Calling encoder.out_of_line_offset(0) is not allowed.
7391            if max_ordinal == 0 {
7392                return Ok(());
7393            }
7394            depth.increment()?;
7395            let envelope_size = 8;
7396            let bytes_len = max_ordinal as usize * envelope_size;
7397            #[allow(unused_variables)]
7398            let offset = encoder.out_of_line_offset(bytes_len);
7399            let mut _prev_end_offset: usize = 0;
7400            if 1 > max_ordinal {
7401                return Ok(());
7402            }
7403
7404            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7405            // are envelope_size bytes.
7406            let cur_offset: usize = (1 - 1) * envelope_size;
7407
7408            // Zero reserved fields.
7409            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7410
7411            // Safety:
7412            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7413            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7414            //   envelope_size bytes, there is always sufficient room.
7415            fidl::encoding::encode_in_envelope_optional::<
7416                u64,
7417                fdomain_client::fidl::FDomainResourceDialect,
7418            >(
7419                self.hold_until_frame
7420                    .as_ref()
7421                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
7422                encoder,
7423                offset + cur_offset,
7424                depth,
7425            )?;
7426
7427            _prev_end_offset = cur_offset + envelope_size;
7428            if 2 > max_ordinal {
7429                return Ok(());
7430            }
7431
7432            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7433            // are envelope_size bytes.
7434            let cur_offset: usize = (2 - 1) * envelope_size;
7435
7436            // Zero reserved fields.
7437            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7438
7439            // Safety:
7440            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7441            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7442            //   envelope_size bytes, there is always sufficient room.
7443            fidl::encoding::encode_in_envelope_optional::<
7444                DelegatedRxLeaseHandle,
7445                fdomain_client::fidl::FDomainResourceDialect,
7446            >(
7447                self.handle.as_mut().map(
7448                    <DelegatedRxLeaseHandle as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
7449                ),
7450                encoder,
7451                offset + cur_offset,
7452                depth,
7453            )?;
7454
7455            _prev_end_offset = cur_offset + envelope_size;
7456
7457            Ok(())
7458        }
7459    }
7460
7461    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
7462        for DelegatedRxLease
7463    {
7464        #[inline(always)]
7465        fn new_empty() -> Self {
7466            Self::default()
7467        }
7468
7469        unsafe fn decode(
7470            &mut self,
7471            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
7472            offset: usize,
7473            mut depth: fidl::encoding::Depth,
7474        ) -> fidl::Result<()> {
7475            decoder.debug_check_bounds::<Self>(offset);
7476            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7477                None => return Err(fidl::Error::NotNullable),
7478                Some(len) => len,
7479            };
7480            // Calling decoder.out_of_line_offset(0) is not allowed.
7481            if len == 0 {
7482                return Ok(());
7483            };
7484            depth.increment()?;
7485            let envelope_size = 8;
7486            let bytes_len = len * envelope_size;
7487            let offset = decoder.out_of_line_offset(bytes_len)?;
7488            // Decode the envelope for each type.
7489            let mut _next_ordinal_to_read = 0;
7490            let mut next_offset = offset;
7491            let end_offset = offset + bytes_len;
7492            _next_ordinal_to_read += 1;
7493            if next_offset >= end_offset {
7494                return Ok(());
7495            }
7496
7497            // Decode unknown envelopes for gaps in ordinals.
7498            while _next_ordinal_to_read < 1 {
7499                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7500                _next_ordinal_to_read += 1;
7501                next_offset += envelope_size;
7502            }
7503
7504            let next_out_of_line = decoder.next_out_of_line();
7505            let handles_before = decoder.remaining_handles();
7506            if let Some((inlined, num_bytes, num_handles)) =
7507                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7508            {
7509                let member_inline_size =
7510                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7511                if inlined != (member_inline_size <= 4) {
7512                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7513                }
7514                let inner_offset;
7515                let mut inner_depth = depth.clone();
7516                if inlined {
7517                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7518                    inner_offset = next_offset;
7519                } else {
7520                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7521                    inner_depth.increment()?;
7522                }
7523                let val_ref = self.hold_until_frame.get_or_insert_with(|| {
7524                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
7525                });
7526                fidl::decode!(
7527                    u64,
7528                    fdomain_client::fidl::FDomainResourceDialect,
7529                    val_ref,
7530                    decoder,
7531                    inner_offset,
7532                    inner_depth
7533                )?;
7534                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7535                {
7536                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7537                }
7538                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7539                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7540                }
7541            }
7542
7543            next_offset += envelope_size;
7544            _next_ordinal_to_read += 1;
7545            if next_offset >= end_offset {
7546                return Ok(());
7547            }
7548
7549            // Decode unknown envelopes for gaps in ordinals.
7550            while _next_ordinal_to_read < 2 {
7551                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7552                _next_ordinal_to_read += 1;
7553                next_offset += envelope_size;
7554            }
7555
7556            let next_out_of_line = decoder.next_out_of_line();
7557            let handles_before = decoder.remaining_handles();
7558            if let Some((inlined, num_bytes, num_handles)) =
7559                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7560            {
7561                let member_inline_size =
7562                    <DelegatedRxLeaseHandle as fidl::encoding::TypeMarker>::inline_size(
7563                        decoder.context,
7564                    );
7565                if inlined != (member_inline_size <= 4) {
7566                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7567                }
7568                let inner_offset;
7569                let mut inner_depth = depth.clone();
7570                if inlined {
7571                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7572                    inner_offset = next_offset;
7573                } else {
7574                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7575                    inner_depth.increment()?;
7576                }
7577                let val_ref = self.handle.get_or_insert_with(|| {
7578                    fidl::new_empty!(
7579                        DelegatedRxLeaseHandle,
7580                        fdomain_client::fidl::FDomainResourceDialect
7581                    )
7582                });
7583                fidl::decode!(
7584                    DelegatedRxLeaseHandle,
7585                    fdomain_client::fidl::FDomainResourceDialect,
7586                    val_ref,
7587                    decoder,
7588                    inner_offset,
7589                    inner_depth
7590                )?;
7591                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7592                {
7593                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7594                }
7595                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7596                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7597                }
7598            }
7599
7600            next_offset += envelope_size;
7601
7602            // Decode the remaining unknown envelopes.
7603            while next_offset < end_offset {
7604                _next_ordinal_to_read += 1;
7605                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7606                next_offset += envelope_size;
7607            }
7608
7609            Ok(())
7610        }
7611    }
7612
7613    impl SessionInfo {
7614        #[inline(always)]
7615        fn max_ordinal_present(&self) -> u64 {
7616            if let Some(_) = self.options {
7617                return 6;
7618            }
7619            if let Some(_) = self.descriptor_count {
7620                return 5;
7621            }
7622            if let Some(_) = self.descriptor_length {
7623                return 4;
7624            }
7625            if let Some(_) = self.descriptor_version {
7626                return 3;
7627            }
7628            if let Some(_) = self.data {
7629                return 2;
7630            }
7631            if let Some(_) = self.descriptors {
7632                return 1;
7633            }
7634            0
7635        }
7636    }
7637
7638    impl fidl::encoding::ResourceTypeMarker for SessionInfo {
7639        type Borrowed<'a> = &'a mut Self;
7640        fn take_or_borrow<'a>(
7641            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7642        ) -> Self::Borrowed<'a> {
7643            value
7644        }
7645    }
7646
7647    unsafe impl fidl::encoding::TypeMarker for SessionInfo {
7648        type Owned = Self;
7649
7650        #[inline(always)]
7651        fn inline_align(_context: fidl::encoding::Context) -> usize {
7652            8
7653        }
7654
7655        #[inline(always)]
7656        fn inline_size(_context: fidl::encoding::Context) -> usize {
7657            16
7658        }
7659    }
7660
7661    unsafe impl fidl::encoding::Encode<SessionInfo, fdomain_client::fidl::FDomainResourceDialect>
7662        for &mut SessionInfo
7663    {
7664        unsafe fn encode(
7665            self,
7666            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
7667            offset: usize,
7668            mut depth: fidl::encoding::Depth,
7669        ) -> fidl::Result<()> {
7670            encoder.debug_check_bounds::<SessionInfo>(offset);
7671            // Vector header
7672            let max_ordinal: u64 = self.max_ordinal_present();
7673            encoder.write_num(max_ordinal, offset);
7674            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7675            // Calling encoder.out_of_line_offset(0) is not allowed.
7676            if max_ordinal == 0 {
7677                return Ok(());
7678            }
7679            depth.increment()?;
7680            let envelope_size = 8;
7681            let bytes_len = max_ordinal as usize * envelope_size;
7682            #[allow(unused_variables)]
7683            let offset = encoder.out_of_line_offset(bytes_len);
7684            let mut _prev_end_offset: usize = 0;
7685            if 1 > max_ordinal {
7686                return Ok(());
7687            }
7688
7689            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7690            // are envelope_size bytes.
7691            let cur_offset: usize = (1 - 1) * envelope_size;
7692
7693            // Zero reserved fields.
7694            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7695
7696            // Safety:
7697            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7698            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7699            //   envelope_size bytes, there is always sufficient room.
7700            fidl::encoding::encode_in_envelope_optional::<
7701                fidl::encoding::HandleType<
7702                    fdomain_client::Vmo,
7703                    { fidl::ObjectType::VMO.into_raw() },
7704                    2147483648,
7705                >,
7706                fdomain_client::fidl::FDomainResourceDialect,
7707            >(
7708                self.descriptors.as_mut().map(
7709                    <fidl::encoding::HandleType<
7710                        fdomain_client::Vmo,
7711                        { fidl::ObjectType::VMO.into_raw() },
7712                        2147483648,
7713                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
7714                ),
7715                encoder,
7716                offset + cur_offset,
7717                depth,
7718            )?;
7719
7720            _prev_end_offset = cur_offset + envelope_size;
7721            if 2 > max_ordinal {
7722                return Ok(());
7723            }
7724
7725            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7726            // are envelope_size bytes.
7727            let cur_offset: usize = (2 - 1) * envelope_size;
7728
7729            // Zero reserved fields.
7730            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7731
7732            // Safety:
7733            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7734            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7735            //   envelope_size bytes, there is always sufficient room.
7736            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<DataVmo, 32>, fdomain_client::fidl::FDomainResourceDialect>(
7737            self.data.as_mut().map(<fidl::encoding::Vector<DataVmo, 32> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
7738            encoder, offset + cur_offset, depth
7739        )?;
7740
7741            _prev_end_offset = cur_offset + envelope_size;
7742            if 3 > max_ordinal {
7743                return Ok(());
7744            }
7745
7746            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7747            // are envelope_size bytes.
7748            let cur_offset: usize = (3 - 1) * envelope_size;
7749
7750            // Zero reserved fields.
7751            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7752
7753            // Safety:
7754            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7755            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7756            //   envelope_size bytes, there is always sufficient room.
7757            fidl::encoding::encode_in_envelope_optional::<
7758                u8,
7759                fdomain_client::fidl::FDomainResourceDialect,
7760            >(
7761                self.descriptor_version
7762                    .as_ref()
7763                    .map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
7764                encoder,
7765                offset + cur_offset,
7766                depth,
7767            )?;
7768
7769            _prev_end_offset = cur_offset + envelope_size;
7770            if 4 > max_ordinal {
7771                return Ok(());
7772            }
7773
7774            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7775            // are envelope_size bytes.
7776            let cur_offset: usize = (4 - 1) * envelope_size;
7777
7778            // Zero reserved fields.
7779            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7780
7781            // Safety:
7782            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7783            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7784            //   envelope_size bytes, there is always sufficient room.
7785            fidl::encoding::encode_in_envelope_optional::<
7786                u8,
7787                fdomain_client::fidl::FDomainResourceDialect,
7788            >(
7789                self.descriptor_length
7790                    .as_ref()
7791                    .map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
7792                encoder,
7793                offset + cur_offset,
7794                depth,
7795            )?;
7796
7797            _prev_end_offset = cur_offset + envelope_size;
7798            if 5 > max_ordinal {
7799                return Ok(());
7800            }
7801
7802            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7803            // are envelope_size bytes.
7804            let cur_offset: usize = (5 - 1) * envelope_size;
7805
7806            // Zero reserved fields.
7807            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7808
7809            // Safety:
7810            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7811            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7812            //   envelope_size bytes, there is always sufficient room.
7813            fidl::encoding::encode_in_envelope_optional::<
7814                u16,
7815                fdomain_client::fidl::FDomainResourceDialect,
7816            >(
7817                self.descriptor_count
7818                    .as_ref()
7819                    .map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
7820                encoder,
7821                offset + cur_offset,
7822                depth,
7823            )?;
7824
7825            _prev_end_offset = cur_offset + envelope_size;
7826            if 6 > max_ordinal {
7827                return Ok(());
7828            }
7829
7830            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7831            // are envelope_size bytes.
7832            let cur_offset: usize = (6 - 1) * envelope_size;
7833
7834            // Zero reserved fields.
7835            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7836
7837            // Safety:
7838            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7839            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7840            //   envelope_size bytes, there is always sufficient room.
7841            fidl::encoding::encode_in_envelope_optional::<
7842                SessionFlags,
7843                fdomain_client::fidl::FDomainResourceDialect,
7844            >(
7845                self.options
7846                    .as_ref()
7847                    .map(<SessionFlags as fidl::encoding::ValueTypeMarker>::borrow),
7848                encoder,
7849                offset + cur_offset,
7850                depth,
7851            )?;
7852
7853            _prev_end_offset = cur_offset + envelope_size;
7854
7855            Ok(())
7856        }
7857    }
7858
7859    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for SessionInfo {
7860        #[inline(always)]
7861        fn new_empty() -> Self {
7862            Self::default()
7863        }
7864
7865        unsafe fn decode(
7866            &mut self,
7867            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
7868            offset: usize,
7869            mut depth: fidl::encoding::Depth,
7870        ) -> fidl::Result<()> {
7871            decoder.debug_check_bounds::<Self>(offset);
7872            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7873                None => return Err(fidl::Error::NotNullable),
7874                Some(len) => len,
7875            };
7876            // Calling decoder.out_of_line_offset(0) is not allowed.
7877            if len == 0 {
7878                return Ok(());
7879            };
7880            depth.increment()?;
7881            let envelope_size = 8;
7882            let bytes_len = len * envelope_size;
7883            let offset = decoder.out_of_line_offset(bytes_len)?;
7884            // Decode the envelope for each type.
7885            let mut _next_ordinal_to_read = 0;
7886            let mut next_offset = offset;
7887            let end_offset = offset + bytes_len;
7888            _next_ordinal_to_read += 1;
7889            if next_offset >= end_offset {
7890                return Ok(());
7891            }
7892
7893            // Decode unknown envelopes for gaps in ordinals.
7894            while _next_ordinal_to_read < 1 {
7895                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7896                _next_ordinal_to_read += 1;
7897                next_offset += envelope_size;
7898            }
7899
7900            let next_out_of_line = decoder.next_out_of_line();
7901            let handles_before = decoder.remaining_handles();
7902            if let Some((inlined, num_bytes, num_handles)) =
7903                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7904            {
7905                let member_inline_size = <fidl::encoding::HandleType<
7906                    fdomain_client::Vmo,
7907                    { fidl::ObjectType::VMO.into_raw() },
7908                    2147483648,
7909                > as fidl::encoding::TypeMarker>::inline_size(
7910                    decoder.context
7911                );
7912                if inlined != (member_inline_size <= 4) {
7913                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7914                }
7915                let inner_offset;
7916                let mut inner_depth = depth.clone();
7917                if inlined {
7918                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7919                    inner_offset = next_offset;
7920                } else {
7921                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7922                    inner_depth.increment()?;
7923                }
7924                let val_ref =
7925                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));
7926                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)?;
7927                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7928                {
7929                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7930                }
7931                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7932                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7933                }
7934            }
7935
7936            next_offset += envelope_size;
7937            _next_ordinal_to_read += 1;
7938            if next_offset >= end_offset {
7939                return Ok(());
7940            }
7941
7942            // Decode unknown envelopes for gaps in ordinals.
7943            while _next_ordinal_to_read < 2 {
7944                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7945                _next_ordinal_to_read += 1;
7946                next_offset += envelope_size;
7947            }
7948
7949            let next_out_of_line = decoder.next_out_of_line();
7950            let handles_before = decoder.remaining_handles();
7951            if let Some((inlined, num_bytes, num_handles)) =
7952                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7953            {
7954                let member_inline_size = <fidl::encoding::Vector<DataVmo, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7955                if inlined != (member_inline_size <= 4) {
7956                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7957                }
7958                let inner_offset;
7959                let mut inner_depth = depth.clone();
7960                if inlined {
7961                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7962                    inner_offset = next_offset;
7963                } else {
7964                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7965                    inner_depth.increment()?;
7966                }
7967                let val_ref =
7968                self.data.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<DataVmo, 32>, fdomain_client::fidl::FDomainResourceDialect));
7969                fidl::decode!(fidl::encoding::Vector<DataVmo, 32>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
7970                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7971                {
7972                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7973                }
7974                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7975                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7976                }
7977            }
7978
7979            next_offset += envelope_size;
7980            _next_ordinal_to_read += 1;
7981            if next_offset >= end_offset {
7982                return Ok(());
7983            }
7984
7985            // Decode unknown envelopes for gaps in ordinals.
7986            while _next_ordinal_to_read < 3 {
7987                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7988                _next_ordinal_to_read += 1;
7989                next_offset += envelope_size;
7990            }
7991
7992            let next_out_of_line = decoder.next_out_of_line();
7993            let handles_before = decoder.remaining_handles();
7994            if let Some((inlined, num_bytes, num_handles)) =
7995                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7996            {
7997                let member_inline_size =
7998                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7999                if inlined != (member_inline_size <= 4) {
8000                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8001                }
8002                let inner_offset;
8003                let mut inner_depth = depth.clone();
8004                if inlined {
8005                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8006                    inner_offset = next_offset;
8007                } else {
8008                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8009                    inner_depth.increment()?;
8010                }
8011                let val_ref = self.descriptor_version.get_or_insert_with(|| {
8012                    fidl::new_empty!(u8, fdomain_client::fidl::FDomainResourceDialect)
8013                });
8014                fidl::decode!(
8015                    u8,
8016                    fdomain_client::fidl::FDomainResourceDialect,
8017                    val_ref,
8018                    decoder,
8019                    inner_offset,
8020                    inner_depth
8021                )?;
8022                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8023                {
8024                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8025                }
8026                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8027                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8028                }
8029            }
8030
8031            next_offset += envelope_size;
8032            _next_ordinal_to_read += 1;
8033            if next_offset >= end_offset {
8034                return Ok(());
8035            }
8036
8037            // Decode unknown envelopes for gaps in ordinals.
8038            while _next_ordinal_to_read < 4 {
8039                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8040                _next_ordinal_to_read += 1;
8041                next_offset += envelope_size;
8042            }
8043
8044            let next_out_of_line = decoder.next_out_of_line();
8045            let handles_before = decoder.remaining_handles();
8046            if let Some((inlined, num_bytes, num_handles)) =
8047                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8048            {
8049                let member_inline_size =
8050                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8051                if inlined != (member_inline_size <= 4) {
8052                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8053                }
8054                let inner_offset;
8055                let mut inner_depth = depth.clone();
8056                if inlined {
8057                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8058                    inner_offset = next_offset;
8059                } else {
8060                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8061                    inner_depth.increment()?;
8062                }
8063                let val_ref = self.descriptor_length.get_or_insert_with(|| {
8064                    fidl::new_empty!(u8, fdomain_client::fidl::FDomainResourceDialect)
8065                });
8066                fidl::decode!(
8067                    u8,
8068                    fdomain_client::fidl::FDomainResourceDialect,
8069                    val_ref,
8070                    decoder,
8071                    inner_offset,
8072                    inner_depth
8073                )?;
8074                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8075                {
8076                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8077                }
8078                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8079                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8080                }
8081            }
8082
8083            next_offset += envelope_size;
8084            _next_ordinal_to_read += 1;
8085            if next_offset >= end_offset {
8086                return Ok(());
8087            }
8088
8089            // Decode unknown envelopes for gaps in ordinals.
8090            while _next_ordinal_to_read < 5 {
8091                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8092                _next_ordinal_to_read += 1;
8093                next_offset += envelope_size;
8094            }
8095
8096            let next_out_of_line = decoder.next_out_of_line();
8097            let handles_before = decoder.remaining_handles();
8098            if let Some((inlined, num_bytes, num_handles)) =
8099                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8100            {
8101                let member_inline_size =
8102                    <u16 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8103                if inlined != (member_inline_size <= 4) {
8104                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8105                }
8106                let inner_offset;
8107                let mut inner_depth = depth.clone();
8108                if inlined {
8109                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8110                    inner_offset = next_offset;
8111                } else {
8112                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8113                    inner_depth.increment()?;
8114                }
8115                let val_ref = self.descriptor_count.get_or_insert_with(|| {
8116                    fidl::new_empty!(u16, fdomain_client::fidl::FDomainResourceDialect)
8117                });
8118                fidl::decode!(
8119                    u16,
8120                    fdomain_client::fidl::FDomainResourceDialect,
8121                    val_ref,
8122                    decoder,
8123                    inner_offset,
8124                    inner_depth
8125                )?;
8126                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8127                {
8128                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8129                }
8130                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8131                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8132                }
8133            }
8134
8135            next_offset += envelope_size;
8136            _next_ordinal_to_read += 1;
8137            if next_offset >= end_offset {
8138                return Ok(());
8139            }
8140
8141            // Decode unknown envelopes for gaps in ordinals.
8142            while _next_ordinal_to_read < 6 {
8143                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8144                _next_ordinal_to_read += 1;
8145                next_offset += envelope_size;
8146            }
8147
8148            let next_out_of_line = decoder.next_out_of_line();
8149            let handles_before = decoder.remaining_handles();
8150            if let Some((inlined, num_bytes, num_handles)) =
8151                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8152            {
8153                let member_inline_size =
8154                    <SessionFlags as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8155                if inlined != (member_inline_size <= 4) {
8156                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8157                }
8158                let inner_offset;
8159                let mut inner_depth = depth.clone();
8160                if inlined {
8161                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8162                    inner_offset = next_offset;
8163                } else {
8164                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8165                    inner_depth.increment()?;
8166                }
8167                let val_ref = self.options.get_or_insert_with(|| {
8168                    fidl::new_empty!(SessionFlags, fdomain_client::fidl::FDomainResourceDialect)
8169                });
8170                fidl::decode!(
8171                    SessionFlags,
8172                    fdomain_client::fidl::FDomainResourceDialect,
8173                    val_ref,
8174                    decoder,
8175                    inner_offset,
8176                    inner_depth
8177                )?;
8178                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8179                {
8180                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8181                }
8182                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8183                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8184                }
8185            }
8186
8187            next_offset += envelope_size;
8188
8189            // Decode the remaining unknown envelopes.
8190            while next_offset < end_offset {
8191                _next_ordinal_to_read += 1;
8192                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8193                next_offset += envelope_size;
8194            }
8195
8196            Ok(())
8197        }
8198    }
8199
8200    impl fidl::encoding::ResourceTypeMarker for DelegatedRxLeaseHandle {
8201        type Borrowed<'a> = &'a mut Self;
8202        fn take_or_borrow<'a>(
8203            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8204        ) -> Self::Borrowed<'a> {
8205            value
8206        }
8207    }
8208
8209    unsafe impl fidl::encoding::TypeMarker for DelegatedRxLeaseHandle {
8210        type Owned = Self;
8211
8212        #[inline(always)]
8213        fn inline_align(_context: fidl::encoding::Context) -> usize {
8214            8
8215        }
8216
8217        #[inline(always)]
8218        fn inline_size(_context: fidl::encoding::Context) -> usize {
8219            16
8220        }
8221    }
8222
8223    unsafe impl
8224        fidl::encoding::Encode<DelegatedRxLeaseHandle, fdomain_client::fidl::FDomainResourceDialect>
8225        for &mut DelegatedRxLeaseHandle
8226    {
8227        #[inline]
8228        unsafe fn encode(
8229            self,
8230            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
8231            offset: usize,
8232            _depth: fidl::encoding::Depth,
8233        ) -> fidl::Result<()> {
8234            encoder.debug_check_bounds::<DelegatedRxLeaseHandle>(offset);
8235            encoder.write_num::<u64>(self.ordinal(), offset);
8236            match self {
8237                DelegatedRxLeaseHandle::Channel(ref mut val) => {
8238                    fidl::encoding::encode_in_envelope::<
8239                        fidl::encoding::HandleType<
8240                            fdomain_client::Channel,
8241                            { fidl::ObjectType::CHANNEL.into_raw() },
8242                            2147483648,
8243                        >,
8244                        fdomain_client::fidl::FDomainResourceDialect,
8245                    >(
8246                        <fidl::encoding::HandleType<
8247                            fdomain_client::Channel,
8248                            { fidl::ObjectType::CHANNEL.into_raw() },
8249                            2147483648,
8250                        > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8251                            val
8252                        ),
8253                        encoder,
8254                        offset + 8,
8255                        _depth,
8256                    )
8257                }
8258                DelegatedRxLeaseHandle::Eventpair(ref mut val) => {
8259                    fidl::encoding::encode_in_envelope::<
8260                        fidl::encoding::HandleType<
8261                            fdomain_client::EventPair,
8262                            { fidl::ObjectType::EVENTPAIR.into_raw() },
8263                            16387,
8264                        >,
8265                        fdomain_client::fidl::FDomainResourceDialect,
8266                    >(
8267                        <fidl::encoding::HandleType<
8268                            fdomain_client::EventPair,
8269                            { fidl::ObjectType::EVENTPAIR.into_raw() },
8270                            16387,
8271                        > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8272                            val
8273                        ),
8274                        encoder,
8275                        offset + 8,
8276                        _depth,
8277                    )
8278                }
8279                DelegatedRxLeaseHandle::__SourceBreaking { .. } => {
8280                    Err(fidl::Error::UnknownUnionTag)
8281                }
8282            }
8283        }
8284    }
8285
8286    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
8287        for DelegatedRxLeaseHandle
8288    {
8289        #[inline(always)]
8290        fn new_empty() -> Self {
8291            Self::__SourceBreaking { unknown_ordinal: 0 }
8292        }
8293
8294        #[inline]
8295        unsafe fn decode(
8296            &mut self,
8297            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
8298            offset: usize,
8299            mut depth: fidl::encoding::Depth,
8300        ) -> fidl::Result<()> {
8301            decoder.debug_check_bounds::<Self>(offset);
8302            #[allow(unused_variables)]
8303            let next_out_of_line = decoder.next_out_of_line();
8304            let handles_before = decoder.remaining_handles();
8305            let (ordinal, inlined, num_bytes, num_handles) =
8306                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
8307
8308            let member_inline_size = match ordinal {
8309                1 => <fidl::encoding::HandleType<
8310                    fdomain_client::Channel,
8311                    { fidl::ObjectType::CHANNEL.into_raw() },
8312                    2147483648,
8313                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
8314                2 => <fidl::encoding::HandleType<
8315                    fdomain_client::EventPair,
8316                    { fidl::ObjectType::EVENTPAIR.into_raw() },
8317                    16387,
8318                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
8319                0 => return Err(fidl::Error::UnknownUnionTag),
8320                _ => num_bytes as usize,
8321            };
8322
8323            if inlined != (member_inline_size <= 4) {
8324                return Err(fidl::Error::InvalidInlineBitInEnvelope);
8325            }
8326            let _inner_offset;
8327            if inlined {
8328                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
8329                _inner_offset = offset + 8;
8330            } else {
8331                depth.increment()?;
8332                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8333            }
8334            match ordinal {
8335                1 => {
8336                    #[allow(irrefutable_let_patterns)]
8337                    if let DelegatedRxLeaseHandle::Channel(_) = self {
8338                        // Do nothing, read the value into the object
8339                    } else {
8340                        // Initialize `self` to the right variant
8341                        *self = DelegatedRxLeaseHandle::Channel(
8342                            fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
8343                        );
8344                    }
8345                    #[allow(irrefutable_let_patterns)]
8346                    if let DelegatedRxLeaseHandle::Channel(ref mut val) = self {
8347                        fidl::decode!(fidl::encoding::HandleType<fdomain_client::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val, decoder, _inner_offset, depth)?;
8348                    } else {
8349                        unreachable!()
8350                    }
8351                }
8352                2 => {
8353                    #[allow(irrefutable_let_patterns)]
8354                    if let DelegatedRxLeaseHandle::Eventpair(_) = self {
8355                        // Do nothing, read the value into the object
8356                    } else {
8357                        // Initialize `self` to the right variant
8358                        *self = DelegatedRxLeaseHandle::Eventpair(
8359                            fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fdomain_client::fidl::FDomainResourceDialect),
8360                        );
8361                    }
8362                    #[allow(irrefutable_let_patterns)]
8363                    if let DelegatedRxLeaseHandle::Eventpair(ref mut val) = self {
8364                        fidl::decode!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fdomain_client::fidl::FDomainResourceDialect, val, decoder, _inner_offset, depth)?;
8365                    } else {
8366                        unreachable!()
8367                    }
8368                }
8369                #[allow(deprecated)]
8370                ordinal => {
8371                    for _ in 0..num_handles {
8372                        decoder.drop_next_handle()?;
8373                    }
8374                    *self = DelegatedRxLeaseHandle::__SourceBreaking { unknown_ordinal: ordinal };
8375                }
8376            }
8377            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
8378                return Err(fidl::Error::InvalidNumBytesInEnvelope);
8379            }
8380            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8381                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8382            }
8383            Ok(())
8384        }
8385    }
8386}