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