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