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