fidl_fuchsia_net_tun/
fidl_fuchsia_net_tun.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 fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_net_tun_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ControlCreateDeviceRequest {
16    pub config: DeviceConfig,
17    pub device: fidl::endpoints::ServerEnd<DeviceMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for ControlCreateDeviceRequest
22{
23}
24
25#[derive(Debug, PartialEq)]
26pub struct ControlCreatePairRequest {
27    pub config: DevicePairConfig,
28    pub device_pair: fidl::endpoints::ServerEnd<DevicePairMarker>,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ControlCreatePairRequest {}
32
33#[derive(Debug, PartialEq)]
34pub struct DeviceAddPortRequest {
35    pub config: DevicePortConfig,
36    pub port: fidl::endpoints::ServerEnd<PortMarker>,
37}
38
39impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceAddPortRequest {}
40
41#[derive(Debug, PartialEq)]
42pub struct DeviceDelegateRxLeaseRequest {
43    pub lease: fidl_fuchsia_hardware_network::DelegatedRxLease,
44}
45
46impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
47    for DeviceDelegateRxLeaseRequest
48{
49}
50
51#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
52pub struct DeviceGetDeviceRequest {
53    pub device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
54}
55
56impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceGetDeviceRequest {}
57
58#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
59pub struct DeviceGetSignalsResponse {
60    pub signals: fidl::EventPair,
61}
62
63impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceGetSignalsResponse {}
64
65#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
66pub struct DevicePairGetLeftPortRequest {
67    pub id: u8,
68    pub port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
69}
70
71impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
72    for DevicePairGetLeftPortRequest
73{
74}
75
76#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
77pub struct DevicePairGetLeftRequest {
78    pub device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
79}
80
81impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DevicePairGetLeftRequest {}
82
83#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
84pub struct DevicePairGetRightPortRequest {
85    pub id: u8,
86    pub port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
87}
88
89impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
90    for DevicePairGetRightPortRequest
91{
92}
93
94#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
95pub struct DevicePairGetRightRequest {
96    pub device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
97}
98
99impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DevicePairGetRightRequest {}
100
101#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
102pub struct PortGetPortRequest {
103    pub port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
104}
105
106impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PortGetPortRequest {}
107
108#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
109pub struct ControlMarker;
110
111impl fidl::endpoints::ProtocolMarker for ControlMarker {
112    type Proxy = ControlProxy;
113    type RequestStream = ControlRequestStream;
114    #[cfg(target_os = "fuchsia")]
115    type SynchronousProxy = ControlSynchronousProxy;
116
117    const DEBUG_NAME: &'static str = "fuchsia.net.tun.Control";
118}
119impl fidl::endpoints::DiscoverableProtocolMarker for ControlMarker {}
120
121pub trait ControlProxyInterface: Send + Sync {
122    fn r#create_device(
123        &self,
124        config: &DeviceConfig,
125        device: fidl::endpoints::ServerEnd<DeviceMarker>,
126    ) -> Result<(), fidl::Error>;
127    fn r#create_pair(
128        &self,
129        config: &DevicePairConfig,
130        device_pair: fidl::endpoints::ServerEnd<DevicePairMarker>,
131    ) -> Result<(), fidl::Error>;
132}
133#[derive(Debug)]
134#[cfg(target_os = "fuchsia")]
135pub struct ControlSynchronousProxy {
136    client: fidl::client::sync::Client,
137}
138
139#[cfg(target_os = "fuchsia")]
140impl fidl::endpoints::SynchronousProxy for ControlSynchronousProxy {
141    type Proxy = ControlProxy;
142    type Protocol = ControlMarker;
143
144    fn from_channel(inner: fidl::Channel) -> Self {
145        Self::new(inner)
146    }
147
148    fn into_channel(self) -> fidl::Channel {
149        self.client.into_channel()
150    }
151
152    fn as_channel(&self) -> &fidl::Channel {
153        self.client.as_channel()
154    }
155}
156
157#[cfg(target_os = "fuchsia")]
158impl ControlSynchronousProxy {
159    pub fn new(channel: fidl::Channel) -> Self {
160        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
161        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
162    }
163
164    pub fn into_channel(self) -> fidl::Channel {
165        self.client.into_channel()
166    }
167
168    /// Waits until an event arrives and returns it. It is safe for other
169    /// threads to make concurrent requests while waiting for an event.
170    pub fn wait_for_event(
171        &self,
172        deadline: zx::MonotonicInstant,
173    ) -> Result<ControlEvent, fidl::Error> {
174        ControlEvent::decode(self.client.wait_for_event(deadline)?)
175    }
176
177    /// Creates a `Device` with given `config`.
178    ///
179    /// + request `config` new device configuration.
180    /// + request `device` grants control over the device. Closed with an
181    /// epitaph if `config` is not valid.
182    pub fn r#create_device(
183        &self,
184        mut config: &DeviceConfig,
185        mut device: fidl::endpoints::ServerEnd<DeviceMarker>,
186    ) -> Result<(), fidl::Error> {
187        self.client.send::<ControlCreateDeviceRequest>(
188            (config, device),
189            0x2aace38c0c1cd187,
190            fidl::encoding::DynamicFlags::empty(),
191        )
192    }
193
194    /// Creates a `DevicePair` with given `config`.
195    ///
196    /// If `config` is not valid or the device could not be created,
197    /// `device_pair` is closed with an error epitaph.
198    ///
199    /// + request `config` new device pair configuration.
200    /// + request `device_pair` grants control over the device pair. Closed with
201    /// an epitaph if `config` is not valid.
202    pub fn r#create_pair(
203        &self,
204        mut config: &DevicePairConfig,
205        mut device_pair: fidl::endpoints::ServerEnd<DevicePairMarker>,
206    ) -> Result<(), fidl::Error> {
207        self.client.send::<ControlCreatePairRequest>(
208            (config, device_pair),
209            0x2c8884060cc29d18,
210            fidl::encoding::DynamicFlags::empty(),
211        )
212    }
213}
214
215#[derive(Debug, Clone)]
216pub struct ControlProxy {
217    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
218}
219
220impl fidl::endpoints::Proxy for ControlProxy {
221    type Protocol = ControlMarker;
222
223    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
224        Self::new(inner)
225    }
226
227    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
228        self.client.into_channel().map_err(|client| Self { client })
229    }
230
231    fn as_channel(&self) -> &::fidl::AsyncChannel {
232        self.client.as_channel()
233    }
234}
235
236impl ControlProxy {
237    /// Create a new Proxy for fuchsia.net.tun/Control.
238    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
239        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
240        Self { client: fidl::client::Client::new(channel, protocol_name) }
241    }
242
243    /// Get a Stream of events from the remote end of the protocol.
244    ///
245    /// # Panics
246    ///
247    /// Panics if the event stream was already taken.
248    pub fn take_event_stream(&self) -> ControlEventStream {
249        ControlEventStream { event_receiver: self.client.take_event_receiver() }
250    }
251
252    /// Creates a `Device` with given `config`.
253    ///
254    /// + request `config` new device configuration.
255    /// + request `device` grants control over the device. Closed with an
256    /// epitaph if `config` is not valid.
257    pub fn r#create_device(
258        &self,
259        mut config: &DeviceConfig,
260        mut device: fidl::endpoints::ServerEnd<DeviceMarker>,
261    ) -> Result<(), fidl::Error> {
262        ControlProxyInterface::r#create_device(self, config, device)
263    }
264
265    /// Creates a `DevicePair` with given `config`.
266    ///
267    /// If `config` is not valid or the device could not be created,
268    /// `device_pair` is closed with an error epitaph.
269    ///
270    /// + request `config` new device pair configuration.
271    /// + request `device_pair` grants control over the device pair. Closed with
272    /// an epitaph if `config` is not valid.
273    pub fn r#create_pair(
274        &self,
275        mut config: &DevicePairConfig,
276        mut device_pair: fidl::endpoints::ServerEnd<DevicePairMarker>,
277    ) -> Result<(), fidl::Error> {
278        ControlProxyInterface::r#create_pair(self, config, device_pair)
279    }
280}
281
282impl ControlProxyInterface for ControlProxy {
283    fn r#create_device(
284        &self,
285        mut config: &DeviceConfig,
286        mut device: fidl::endpoints::ServerEnd<DeviceMarker>,
287    ) -> Result<(), fidl::Error> {
288        self.client.send::<ControlCreateDeviceRequest>(
289            (config, device),
290            0x2aace38c0c1cd187,
291            fidl::encoding::DynamicFlags::empty(),
292        )
293    }
294
295    fn r#create_pair(
296        &self,
297        mut config: &DevicePairConfig,
298        mut device_pair: fidl::endpoints::ServerEnd<DevicePairMarker>,
299    ) -> Result<(), fidl::Error> {
300        self.client.send::<ControlCreatePairRequest>(
301            (config, device_pair),
302            0x2c8884060cc29d18,
303            fidl::encoding::DynamicFlags::empty(),
304        )
305    }
306}
307
308pub struct ControlEventStream {
309    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
310}
311
312impl std::marker::Unpin for ControlEventStream {}
313
314impl futures::stream::FusedStream for ControlEventStream {
315    fn is_terminated(&self) -> bool {
316        self.event_receiver.is_terminated()
317    }
318}
319
320impl futures::Stream for ControlEventStream {
321    type Item = Result<ControlEvent, fidl::Error>;
322
323    fn poll_next(
324        mut self: std::pin::Pin<&mut Self>,
325        cx: &mut std::task::Context<'_>,
326    ) -> std::task::Poll<Option<Self::Item>> {
327        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
328            &mut self.event_receiver,
329            cx
330        )?) {
331            Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
332            None => std::task::Poll::Ready(None),
333        }
334    }
335}
336
337#[derive(Debug)]
338pub enum ControlEvent {}
339
340impl ControlEvent {
341    /// Decodes a message buffer as a [`ControlEvent`].
342    fn decode(
343        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
344    ) -> Result<ControlEvent, fidl::Error> {
345        let (bytes, _handles) = buf.split_mut();
346        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
347        debug_assert_eq!(tx_header.tx_id, 0);
348        match tx_header.ordinal {
349            _ => Err(fidl::Error::UnknownOrdinal {
350                ordinal: tx_header.ordinal,
351                protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
352            }),
353        }
354    }
355}
356
357/// A Stream of incoming requests for fuchsia.net.tun/Control.
358pub struct ControlRequestStream {
359    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
360    is_terminated: bool,
361}
362
363impl std::marker::Unpin for ControlRequestStream {}
364
365impl futures::stream::FusedStream for ControlRequestStream {
366    fn is_terminated(&self) -> bool {
367        self.is_terminated
368    }
369}
370
371impl fidl::endpoints::RequestStream for ControlRequestStream {
372    type Protocol = ControlMarker;
373    type ControlHandle = ControlControlHandle;
374
375    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
376        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
377    }
378
379    fn control_handle(&self) -> Self::ControlHandle {
380        ControlControlHandle { inner: self.inner.clone() }
381    }
382
383    fn into_inner(
384        self,
385    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
386    {
387        (self.inner, self.is_terminated)
388    }
389
390    fn from_inner(
391        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
392        is_terminated: bool,
393    ) -> Self {
394        Self { inner, is_terminated }
395    }
396}
397
398impl futures::Stream for ControlRequestStream {
399    type Item = Result<ControlRequest, fidl::Error>;
400
401    fn poll_next(
402        mut self: std::pin::Pin<&mut Self>,
403        cx: &mut std::task::Context<'_>,
404    ) -> std::task::Poll<Option<Self::Item>> {
405        let this = &mut *self;
406        if this.inner.check_shutdown(cx) {
407            this.is_terminated = true;
408            return std::task::Poll::Ready(None);
409        }
410        if this.is_terminated {
411            panic!("polled ControlRequestStream after completion");
412        }
413        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
414            |bytes, handles| {
415                match this.inner.channel().read_etc(cx, bytes, handles) {
416                    std::task::Poll::Ready(Ok(())) => {}
417                    std::task::Poll::Pending => return std::task::Poll::Pending,
418                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
419                        this.is_terminated = true;
420                        return std::task::Poll::Ready(None);
421                    }
422                    std::task::Poll::Ready(Err(e)) => {
423                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
424                            e.into(),
425                        ))))
426                    }
427                }
428
429                // A message has been received from the channel
430                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
431
432                std::task::Poll::Ready(Some(match header.ordinal {
433                    0x2aace38c0c1cd187 => {
434                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
435                        let mut req = fidl::new_empty!(
436                            ControlCreateDeviceRequest,
437                            fidl::encoding::DefaultFuchsiaResourceDialect
438                        );
439                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlCreateDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
440                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
441                        Ok(ControlRequest::CreateDevice {
442                            config: req.config,
443                            device: req.device,
444
445                            control_handle,
446                        })
447                    }
448                    0x2c8884060cc29d18 => {
449                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
450                        let mut req = fidl::new_empty!(
451                            ControlCreatePairRequest,
452                            fidl::encoding::DefaultFuchsiaResourceDialect
453                        );
454                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlCreatePairRequest>(&header, _body_bytes, handles, &mut req)?;
455                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
456                        Ok(ControlRequest::CreatePair {
457                            config: req.config,
458                            device_pair: req.device_pair,
459
460                            control_handle,
461                        })
462                    }
463                    _ => Err(fidl::Error::UnknownOrdinal {
464                        ordinal: header.ordinal,
465                        protocol_name:
466                            <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
467                    }),
468                }))
469            },
470        )
471    }
472}
473
474/// Control interface.
475///
476/// `Control` allows creating an arbitrary number of `Device`s and
477/// `DevicePair`s.
478#[derive(Debug)]
479pub enum ControlRequest {
480    /// Creates a `Device` with given `config`.
481    ///
482    /// + request `config` new device configuration.
483    /// + request `device` grants control over the device. Closed with an
484    /// epitaph if `config` is not valid.
485    CreateDevice {
486        config: DeviceConfig,
487        device: fidl::endpoints::ServerEnd<DeviceMarker>,
488        control_handle: ControlControlHandle,
489    },
490    /// Creates a `DevicePair` with given `config`.
491    ///
492    /// If `config` is not valid or the device could not be created,
493    /// `device_pair` is closed with an error epitaph.
494    ///
495    /// + request `config` new device pair configuration.
496    /// + request `device_pair` grants control over the device pair. Closed with
497    /// an epitaph if `config` is not valid.
498    CreatePair {
499        config: DevicePairConfig,
500        device_pair: fidl::endpoints::ServerEnd<DevicePairMarker>,
501        control_handle: ControlControlHandle,
502    },
503}
504
505impl ControlRequest {
506    #[allow(irrefutable_let_patterns)]
507    pub fn into_create_device(
508        self,
509    ) -> Option<(DeviceConfig, fidl::endpoints::ServerEnd<DeviceMarker>, ControlControlHandle)>
510    {
511        if let ControlRequest::CreateDevice { config, device, control_handle } = self {
512            Some((config, device, control_handle))
513        } else {
514            None
515        }
516    }
517
518    #[allow(irrefutable_let_patterns)]
519    pub fn into_create_pair(
520        self,
521    ) -> Option<(
522        DevicePairConfig,
523        fidl::endpoints::ServerEnd<DevicePairMarker>,
524        ControlControlHandle,
525    )> {
526        if let ControlRequest::CreatePair { config, device_pair, control_handle } = self {
527            Some((config, device_pair, control_handle))
528        } else {
529            None
530        }
531    }
532
533    /// Name of the method defined in FIDL
534    pub fn method_name(&self) -> &'static str {
535        match *self {
536            ControlRequest::CreateDevice { .. } => "create_device",
537            ControlRequest::CreatePair { .. } => "create_pair",
538        }
539    }
540}
541
542#[derive(Debug, Clone)]
543pub struct ControlControlHandle {
544    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
545}
546
547impl fidl::endpoints::ControlHandle for ControlControlHandle {
548    fn shutdown(&self) {
549        self.inner.shutdown()
550    }
551    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
552        self.inner.shutdown_with_epitaph(status)
553    }
554
555    fn is_closed(&self) -> bool {
556        self.inner.channel().is_closed()
557    }
558    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
559        self.inner.channel().on_closed()
560    }
561
562    #[cfg(target_os = "fuchsia")]
563    fn signal_peer(
564        &self,
565        clear_mask: zx::Signals,
566        set_mask: zx::Signals,
567    ) -> Result<(), zx_status::Status> {
568        use fidl::Peered;
569        self.inner.channel().signal_peer(clear_mask, set_mask)
570    }
571}
572
573impl ControlControlHandle {}
574
575#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
576pub struct DeviceMarker;
577
578impl fidl::endpoints::ProtocolMarker for DeviceMarker {
579    type Proxy = DeviceProxy;
580    type RequestStream = DeviceRequestStream;
581    #[cfg(target_os = "fuchsia")]
582    type SynchronousProxy = DeviceSynchronousProxy;
583
584    const DEBUG_NAME: &'static str = "(anonymous) Device";
585}
586pub type DeviceWriteFrameResult = Result<(), i32>;
587pub type DeviceReadFrameResult = Result<Frame, i32>;
588
589pub trait DeviceProxyInterface: Send + Sync {
590    type WriteFrameResponseFut: std::future::Future<Output = Result<DeviceWriteFrameResult, fidl::Error>>
591        + Send;
592    fn r#write_frame(&self, frame: &Frame) -> Self::WriteFrameResponseFut;
593    type ReadFrameResponseFut: std::future::Future<Output = Result<DeviceReadFrameResult, fidl::Error>>
594        + Send;
595    fn r#read_frame(&self) -> Self::ReadFrameResponseFut;
596    type GetSignalsResponseFut: std::future::Future<Output = Result<fidl::EventPair, fidl::Error>>
597        + Send;
598    fn r#get_signals(&self) -> Self::GetSignalsResponseFut;
599    fn r#add_port(
600        &self,
601        config: &DevicePortConfig,
602        port: fidl::endpoints::ServerEnd<PortMarker>,
603    ) -> Result<(), fidl::Error>;
604    fn r#get_device(
605        &self,
606        device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
607    ) -> Result<(), fidl::Error>;
608    fn r#delegate_rx_lease(
609        &self,
610        lease: fidl_fuchsia_hardware_network::DelegatedRxLease,
611    ) -> Result<(), fidl::Error>;
612}
613#[derive(Debug)]
614#[cfg(target_os = "fuchsia")]
615pub struct DeviceSynchronousProxy {
616    client: fidl::client::sync::Client,
617}
618
619#[cfg(target_os = "fuchsia")]
620impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
621    type Proxy = DeviceProxy;
622    type Protocol = DeviceMarker;
623
624    fn from_channel(inner: fidl::Channel) -> Self {
625        Self::new(inner)
626    }
627
628    fn into_channel(self) -> fidl::Channel {
629        self.client.into_channel()
630    }
631
632    fn as_channel(&self) -> &fidl::Channel {
633        self.client.as_channel()
634    }
635}
636
637#[cfg(target_os = "fuchsia")]
638impl DeviceSynchronousProxy {
639    pub fn new(channel: fidl::Channel) -> Self {
640        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
641        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
642    }
643
644    pub fn into_channel(self) -> fidl::Channel {
645        self.client.into_channel()
646    }
647
648    /// Waits until an event arrives and returns it. It is safe for other
649    /// threads to make concurrent requests while waiting for an event.
650    pub fn wait_for_event(
651        &self,
652        deadline: zx::MonotonicInstant,
653    ) -> Result<DeviceEvent, fidl::Error> {
654        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
655    }
656
657    /// Writes a frame to the device (data coming from network-end).
658    ///
659    /// If the device was created with the
660    /// [`fuchsia.net.tun/DeviceConfig.blocking`] option set to `true`, calls to
661    /// `WriteFrame` block until there is one buffer available to fulfill the
662    /// request.
663    ///
664    /// + request `frame` inbound frame data and metadata.
665    /// * error `ZX_ERR_NOT_FOUND` if [`Frame.port`] references an unknown port.
666    /// * error `ZX_ERR_INVALID_ARGS` if `frame` is invalid.
667    /// * error `ZX_ERR_BAD_STATE` if the device is offline.
668    /// * error `ZX_ERR_BAD_STATE` if the device is offline.
669    /// * error `ZX_ERR_NO_RESOURCES` if more than
670    /// [`fuchsia.net.tun/MAX_PENDING_OPERATIONS`] calls to `WriteFrame` are
671    /// pending.
672    /// * error `ZX_ERR_SHOULD_WAIT` if `blocking` is set to `false` and there
673    /// are no buffers available to fulfill the request.
674    pub fn r#write_frame(
675        &self,
676        mut frame: &Frame,
677        ___deadline: zx::MonotonicInstant,
678    ) -> Result<DeviceWriteFrameResult, fidl::Error> {
679        let _response = self.client.send_query::<
680            DeviceWriteFrameRequest,
681            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
682        >(
683            (frame,),
684            0x2d19e24e149bf6db,
685            fidl::encoding::DynamicFlags::empty(),
686            ___deadline,
687        )?;
688        Ok(_response.map(|x| x))
689    }
690
691    /// Gets the next frame from the device (data coming from host-end).
692    ///
693    /// If the device was created with the
694    /// [`fuchsia.net.tun/DeviceConfig.blocking`] option set to `true`, calls to
695    /// `ReadFrame` block until there is a frame available to be read.
696    ///
697    /// - response `frame` outbound frame data and metadata.
698    /// * error `ZX_ERR_NO_RESOURCES` if more than
699    /// [`fuchsia.net.tun/MAX_PENDING_OPERATIONS`] calls to `ReadFrame` are
700    /// pending.
701    /// * error `ZX_ERR_SHOULD_WAIT` if `blocking` is set to `false` and there
702    /// are no frames to be read.
703    pub fn r#read_frame(
704        &self,
705        ___deadline: zx::MonotonicInstant,
706    ) -> Result<DeviceReadFrameResult, fidl::Error> {
707        let _response = self.client.send_query::<
708            fidl::encoding::EmptyPayload,
709            fidl::encoding::ResultType<DeviceReadFrameResponse, i32>,
710        >(
711            (),
712            0x6ebc56b8427e1571,
713            fidl::encoding::DynamicFlags::empty(),
714            ___deadline,
715        )?;
716        Ok(_response.map(|x| x.frame))
717    }
718
719    /// Retrieves signals eventpair.
720    ///
721    /// - response `signals` an eventpair that is signalled with
722    /// `SIGNAL_READABLE` and `SIGNAL_WRITABLE` when read and write buffers are
723    /// available, respectively.
724    pub fn r#get_signals(
725        &self,
726        ___deadline: zx::MonotonicInstant,
727    ) -> Result<fidl::EventPair, fidl::Error> {
728        let _response =
729            self.client.send_query::<fidl::encoding::EmptyPayload, DeviceGetSignalsResponse>(
730                (),
731                0x4d1ca50fc53606b9,
732                fidl::encoding::DynamicFlags::empty(),
733                ___deadline,
734            )?;
735        Ok(_response.signals)
736    }
737
738    /// Creates a new port on this device.
739    ///
740    /// + request `config` new port configuration.
741    /// + request `port` grants control over the port. Closed with an epitaph if
742    /// `config` is not valid.
743    pub fn r#add_port(
744        &self,
745        mut config: &DevicePortConfig,
746        mut port: fidl::endpoints::ServerEnd<PortMarker>,
747    ) -> Result<(), fidl::Error> {
748        self.client.send::<DeviceAddPortRequest>(
749            (config, port),
750            0x6b56b238f04ee3d4,
751            fidl::encoding::DynamicFlags::empty(),
752        )
753    }
754
755    /// Connects to the underlying device endpoint.
756    ///
757    /// + request `device` device handle.
758    pub fn r#get_device(
759        &self,
760        mut device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
761    ) -> Result<(), fidl::Error> {
762        self.client.send::<DeviceGetDeviceRequest>(
763            (device,),
764            0x2e8c81fdcdd99d26,
765            fidl::encoding::DynamicFlags::empty(),
766        )
767    }
768
769    /// Delegates an rx lease through the tun device.
770    ///
771    /// See documentation on [`fuchsia.hardware.network/DelegatedRxLease`] for
772    /// proper usage.
773    pub fn r#delegate_rx_lease(
774        &self,
775        mut lease: fidl_fuchsia_hardware_network::DelegatedRxLease,
776    ) -> Result<(), fidl::Error> {
777        self.client.send::<DeviceDelegateRxLeaseRequest>(
778            (&mut lease,),
779            0x660137a0e680b4c0,
780            fidl::encoding::DynamicFlags::empty(),
781        )
782    }
783}
784
785#[derive(Debug, Clone)]
786pub struct DeviceProxy {
787    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
788}
789
790impl fidl::endpoints::Proxy for DeviceProxy {
791    type Protocol = DeviceMarker;
792
793    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
794        Self::new(inner)
795    }
796
797    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
798        self.client.into_channel().map_err(|client| Self { client })
799    }
800
801    fn as_channel(&self) -> &::fidl::AsyncChannel {
802        self.client.as_channel()
803    }
804}
805
806impl DeviceProxy {
807    /// Create a new Proxy for fuchsia.net.tun/Device.
808    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
809        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
810        Self { client: fidl::client::Client::new(channel, protocol_name) }
811    }
812
813    /// Get a Stream of events from the remote end of the protocol.
814    ///
815    /// # Panics
816    ///
817    /// Panics if the event stream was already taken.
818    pub fn take_event_stream(&self) -> DeviceEventStream {
819        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
820    }
821
822    /// Writes a frame to the device (data coming from network-end).
823    ///
824    /// If the device was created with the
825    /// [`fuchsia.net.tun/DeviceConfig.blocking`] option set to `true`, calls to
826    /// `WriteFrame` block until there is one buffer available to fulfill the
827    /// request.
828    ///
829    /// + request `frame` inbound frame data and metadata.
830    /// * error `ZX_ERR_NOT_FOUND` if [`Frame.port`] references an unknown port.
831    /// * error `ZX_ERR_INVALID_ARGS` if `frame` is invalid.
832    /// * error `ZX_ERR_BAD_STATE` if the device is offline.
833    /// * error `ZX_ERR_BAD_STATE` if the device is offline.
834    /// * error `ZX_ERR_NO_RESOURCES` if more than
835    /// [`fuchsia.net.tun/MAX_PENDING_OPERATIONS`] calls to `WriteFrame` are
836    /// pending.
837    /// * error `ZX_ERR_SHOULD_WAIT` if `blocking` is set to `false` and there
838    /// are no buffers available to fulfill the request.
839    pub fn r#write_frame(
840        &self,
841        mut frame: &Frame,
842    ) -> fidl::client::QueryResponseFut<
843        DeviceWriteFrameResult,
844        fidl::encoding::DefaultFuchsiaResourceDialect,
845    > {
846        DeviceProxyInterface::r#write_frame(self, frame)
847    }
848
849    /// Gets the next frame from the device (data coming from host-end).
850    ///
851    /// If the device was created with the
852    /// [`fuchsia.net.tun/DeviceConfig.blocking`] option set to `true`, calls to
853    /// `ReadFrame` block until there is a frame available to be read.
854    ///
855    /// - response `frame` outbound frame data and metadata.
856    /// * error `ZX_ERR_NO_RESOURCES` if more than
857    /// [`fuchsia.net.tun/MAX_PENDING_OPERATIONS`] calls to `ReadFrame` are
858    /// pending.
859    /// * error `ZX_ERR_SHOULD_WAIT` if `blocking` is set to `false` and there
860    /// are no frames to be read.
861    pub fn r#read_frame(
862        &self,
863    ) -> fidl::client::QueryResponseFut<
864        DeviceReadFrameResult,
865        fidl::encoding::DefaultFuchsiaResourceDialect,
866    > {
867        DeviceProxyInterface::r#read_frame(self)
868    }
869
870    /// Retrieves signals eventpair.
871    ///
872    /// - response `signals` an eventpair that is signalled with
873    /// `SIGNAL_READABLE` and `SIGNAL_WRITABLE` when read and write buffers are
874    /// available, respectively.
875    pub fn r#get_signals(
876        &self,
877    ) -> fidl::client::QueryResponseFut<
878        fidl::EventPair,
879        fidl::encoding::DefaultFuchsiaResourceDialect,
880    > {
881        DeviceProxyInterface::r#get_signals(self)
882    }
883
884    /// Creates a new port on this device.
885    ///
886    /// + request `config` new port configuration.
887    /// + request `port` grants control over the port. Closed with an epitaph if
888    /// `config` is not valid.
889    pub fn r#add_port(
890        &self,
891        mut config: &DevicePortConfig,
892        mut port: fidl::endpoints::ServerEnd<PortMarker>,
893    ) -> Result<(), fidl::Error> {
894        DeviceProxyInterface::r#add_port(self, config, port)
895    }
896
897    /// Connects to the underlying device endpoint.
898    ///
899    /// + request `device` device handle.
900    pub fn r#get_device(
901        &self,
902        mut device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
903    ) -> Result<(), fidl::Error> {
904        DeviceProxyInterface::r#get_device(self, device)
905    }
906
907    /// Delegates an rx lease through the tun device.
908    ///
909    /// See documentation on [`fuchsia.hardware.network/DelegatedRxLease`] for
910    /// proper usage.
911    pub fn r#delegate_rx_lease(
912        &self,
913        mut lease: fidl_fuchsia_hardware_network::DelegatedRxLease,
914    ) -> Result<(), fidl::Error> {
915        DeviceProxyInterface::r#delegate_rx_lease(self, lease)
916    }
917}
918
919impl DeviceProxyInterface for DeviceProxy {
920    type WriteFrameResponseFut = fidl::client::QueryResponseFut<
921        DeviceWriteFrameResult,
922        fidl::encoding::DefaultFuchsiaResourceDialect,
923    >;
924    fn r#write_frame(&self, mut frame: &Frame) -> Self::WriteFrameResponseFut {
925        fn _decode(
926            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
927        ) -> Result<DeviceWriteFrameResult, fidl::Error> {
928            let _response = fidl::client::decode_transaction_body::<
929                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
930                fidl::encoding::DefaultFuchsiaResourceDialect,
931                0x2d19e24e149bf6db,
932            >(_buf?)?;
933            Ok(_response.map(|x| x))
934        }
935        self.client.send_query_and_decode::<DeviceWriteFrameRequest, DeviceWriteFrameResult>(
936            (frame,),
937            0x2d19e24e149bf6db,
938            fidl::encoding::DynamicFlags::empty(),
939            _decode,
940        )
941    }
942
943    type ReadFrameResponseFut = fidl::client::QueryResponseFut<
944        DeviceReadFrameResult,
945        fidl::encoding::DefaultFuchsiaResourceDialect,
946    >;
947    fn r#read_frame(&self) -> Self::ReadFrameResponseFut {
948        fn _decode(
949            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
950        ) -> Result<DeviceReadFrameResult, fidl::Error> {
951            let _response = fidl::client::decode_transaction_body::<
952                fidl::encoding::ResultType<DeviceReadFrameResponse, i32>,
953                fidl::encoding::DefaultFuchsiaResourceDialect,
954                0x6ebc56b8427e1571,
955            >(_buf?)?;
956            Ok(_response.map(|x| x.frame))
957        }
958        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceReadFrameResult>(
959            (),
960            0x6ebc56b8427e1571,
961            fidl::encoding::DynamicFlags::empty(),
962            _decode,
963        )
964    }
965
966    type GetSignalsResponseFut = fidl::client::QueryResponseFut<
967        fidl::EventPair,
968        fidl::encoding::DefaultFuchsiaResourceDialect,
969    >;
970    fn r#get_signals(&self) -> Self::GetSignalsResponseFut {
971        fn _decode(
972            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
973        ) -> Result<fidl::EventPair, fidl::Error> {
974            let _response = fidl::client::decode_transaction_body::<
975                DeviceGetSignalsResponse,
976                fidl::encoding::DefaultFuchsiaResourceDialect,
977                0x4d1ca50fc53606b9,
978            >(_buf?)?;
979            Ok(_response.signals)
980        }
981        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::EventPair>(
982            (),
983            0x4d1ca50fc53606b9,
984            fidl::encoding::DynamicFlags::empty(),
985            _decode,
986        )
987    }
988
989    fn r#add_port(
990        &self,
991        mut config: &DevicePortConfig,
992        mut port: fidl::endpoints::ServerEnd<PortMarker>,
993    ) -> Result<(), fidl::Error> {
994        self.client.send::<DeviceAddPortRequest>(
995            (config, port),
996            0x6b56b238f04ee3d4,
997            fidl::encoding::DynamicFlags::empty(),
998        )
999    }
1000
1001    fn r#get_device(
1002        &self,
1003        mut device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1004    ) -> Result<(), fidl::Error> {
1005        self.client.send::<DeviceGetDeviceRequest>(
1006            (device,),
1007            0x2e8c81fdcdd99d26,
1008            fidl::encoding::DynamicFlags::empty(),
1009        )
1010    }
1011
1012    fn r#delegate_rx_lease(
1013        &self,
1014        mut lease: fidl_fuchsia_hardware_network::DelegatedRxLease,
1015    ) -> Result<(), fidl::Error> {
1016        self.client.send::<DeviceDelegateRxLeaseRequest>(
1017            (&mut lease,),
1018            0x660137a0e680b4c0,
1019            fidl::encoding::DynamicFlags::empty(),
1020        )
1021    }
1022}
1023
1024pub struct DeviceEventStream {
1025    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1026}
1027
1028impl std::marker::Unpin for DeviceEventStream {}
1029
1030impl futures::stream::FusedStream for DeviceEventStream {
1031    fn is_terminated(&self) -> bool {
1032        self.event_receiver.is_terminated()
1033    }
1034}
1035
1036impl futures::Stream for DeviceEventStream {
1037    type Item = Result<DeviceEvent, fidl::Error>;
1038
1039    fn poll_next(
1040        mut self: std::pin::Pin<&mut Self>,
1041        cx: &mut std::task::Context<'_>,
1042    ) -> std::task::Poll<Option<Self::Item>> {
1043        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1044            &mut self.event_receiver,
1045            cx
1046        )?) {
1047            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
1048            None => std::task::Poll::Ready(None),
1049        }
1050    }
1051}
1052
1053#[derive(Debug)]
1054pub enum DeviceEvent {}
1055
1056impl DeviceEvent {
1057    /// Decodes a message buffer as a [`DeviceEvent`].
1058    fn decode(
1059        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1060    ) -> Result<DeviceEvent, fidl::Error> {
1061        let (bytes, _handles) = buf.split_mut();
1062        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1063        debug_assert_eq!(tx_header.tx_id, 0);
1064        match tx_header.ordinal {
1065            _ => Err(fidl::Error::UnknownOrdinal {
1066                ordinal: tx_header.ordinal,
1067                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1068            }),
1069        }
1070    }
1071}
1072
1073/// A Stream of incoming requests for fuchsia.net.tun/Device.
1074pub struct DeviceRequestStream {
1075    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1076    is_terminated: bool,
1077}
1078
1079impl std::marker::Unpin for DeviceRequestStream {}
1080
1081impl futures::stream::FusedStream for DeviceRequestStream {
1082    fn is_terminated(&self) -> bool {
1083        self.is_terminated
1084    }
1085}
1086
1087impl fidl::endpoints::RequestStream for DeviceRequestStream {
1088    type Protocol = DeviceMarker;
1089    type ControlHandle = DeviceControlHandle;
1090
1091    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1092        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1093    }
1094
1095    fn control_handle(&self) -> Self::ControlHandle {
1096        DeviceControlHandle { inner: self.inner.clone() }
1097    }
1098
1099    fn into_inner(
1100        self,
1101    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1102    {
1103        (self.inner, self.is_terminated)
1104    }
1105
1106    fn from_inner(
1107        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1108        is_terminated: bool,
1109    ) -> Self {
1110        Self { inner, is_terminated }
1111    }
1112}
1113
1114impl futures::Stream for DeviceRequestStream {
1115    type Item = Result<DeviceRequest, fidl::Error>;
1116
1117    fn poll_next(
1118        mut self: std::pin::Pin<&mut Self>,
1119        cx: &mut std::task::Context<'_>,
1120    ) -> std::task::Poll<Option<Self::Item>> {
1121        let this = &mut *self;
1122        if this.inner.check_shutdown(cx) {
1123            this.is_terminated = true;
1124            return std::task::Poll::Ready(None);
1125        }
1126        if this.is_terminated {
1127            panic!("polled DeviceRequestStream after completion");
1128        }
1129        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1130            |bytes, handles| {
1131                match this.inner.channel().read_etc(cx, bytes, handles) {
1132                    std::task::Poll::Ready(Ok(())) => {}
1133                    std::task::Poll::Pending => return std::task::Poll::Pending,
1134                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1135                        this.is_terminated = true;
1136                        return std::task::Poll::Ready(None);
1137                    }
1138                    std::task::Poll::Ready(Err(e)) => {
1139                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1140                            e.into(),
1141                        ))))
1142                    }
1143                }
1144
1145                // A message has been received from the channel
1146                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1147
1148                std::task::Poll::Ready(Some(match header.ordinal {
1149                    0x2d19e24e149bf6db => {
1150                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1151                        let mut req = fidl::new_empty!(
1152                            DeviceWriteFrameRequest,
1153                            fidl::encoding::DefaultFuchsiaResourceDialect
1154                        );
1155                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceWriteFrameRequest>(&header, _body_bytes, handles, &mut req)?;
1156                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1157                        Ok(DeviceRequest::WriteFrame {
1158                            frame: req.frame,
1159
1160                            responder: DeviceWriteFrameResponder {
1161                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1162                                tx_id: header.tx_id,
1163                            },
1164                        })
1165                    }
1166                    0x6ebc56b8427e1571 => {
1167                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1168                        let mut req = fidl::new_empty!(
1169                            fidl::encoding::EmptyPayload,
1170                            fidl::encoding::DefaultFuchsiaResourceDialect
1171                        );
1172                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1173                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1174                        Ok(DeviceRequest::ReadFrame {
1175                            responder: DeviceReadFrameResponder {
1176                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1177                                tx_id: header.tx_id,
1178                            },
1179                        })
1180                    }
1181                    0x4d1ca50fc53606b9 => {
1182                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1183                        let mut req = fidl::new_empty!(
1184                            fidl::encoding::EmptyPayload,
1185                            fidl::encoding::DefaultFuchsiaResourceDialect
1186                        );
1187                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1188                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1189                        Ok(DeviceRequest::GetSignals {
1190                            responder: DeviceGetSignalsResponder {
1191                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1192                                tx_id: header.tx_id,
1193                            },
1194                        })
1195                    }
1196                    0x6b56b238f04ee3d4 => {
1197                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1198                        let mut req = fidl::new_empty!(
1199                            DeviceAddPortRequest,
1200                            fidl::encoding::DefaultFuchsiaResourceDialect
1201                        );
1202                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceAddPortRequest>(&header, _body_bytes, handles, &mut req)?;
1203                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1204                        Ok(DeviceRequest::AddPort {
1205                            config: req.config,
1206                            port: req.port,
1207
1208                            control_handle,
1209                        })
1210                    }
1211                    0x2e8c81fdcdd99d26 => {
1212                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1213                        let mut req = fidl::new_empty!(
1214                            DeviceGetDeviceRequest,
1215                            fidl::encoding::DefaultFuchsiaResourceDialect
1216                        );
1217                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
1218                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1219                        Ok(DeviceRequest::GetDevice { device: req.device, control_handle })
1220                    }
1221                    0x660137a0e680b4c0 => {
1222                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1223                        let mut req = fidl::new_empty!(
1224                            DeviceDelegateRxLeaseRequest,
1225                            fidl::encoding::DefaultFuchsiaResourceDialect
1226                        );
1227                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceDelegateRxLeaseRequest>(&header, _body_bytes, handles, &mut req)?;
1228                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1229                        Ok(DeviceRequest::DelegateRxLease { lease: req.lease, control_handle })
1230                    }
1231                    _ => Err(fidl::Error::UnknownOrdinal {
1232                        ordinal: header.ordinal,
1233                        protocol_name:
1234                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1235                    }),
1236                }))
1237            },
1238        )
1239    }
1240}
1241
1242/// Provides control over the created device.
1243///
1244/// This protocol encodes the underlying object's lifetime in both directions;
1245/// the underlying object is alive iff both ends of the protocol are open. That
1246/// is:
1247///
1248/// - Closing the client end causes the object to be destroyed.
1249/// - Observing a closure of the server end indicates the object no longer
1250/// exists.
1251#[derive(Debug)]
1252pub enum DeviceRequest {
1253    /// Writes a frame to the device (data coming from network-end).
1254    ///
1255    /// If the device was created with the
1256    /// [`fuchsia.net.tun/DeviceConfig.blocking`] option set to `true`, calls to
1257    /// `WriteFrame` block until there is one buffer available to fulfill the
1258    /// request.
1259    ///
1260    /// + request `frame` inbound frame data and metadata.
1261    /// * error `ZX_ERR_NOT_FOUND` if [`Frame.port`] references an unknown port.
1262    /// * error `ZX_ERR_INVALID_ARGS` if `frame` is invalid.
1263    /// * error `ZX_ERR_BAD_STATE` if the device is offline.
1264    /// * error `ZX_ERR_BAD_STATE` if the device is offline.
1265    /// * error `ZX_ERR_NO_RESOURCES` if more than
1266    /// [`fuchsia.net.tun/MAX_PENDING_OPERATIONS`] calls to `WriteFrame` are
1267    /// pending.
1268    /// * error `ZX_ERR_SHOULD_WAIT` if `blocking` is set to `false` and there
1269    /// are no buffers available to fulfill the request.
1270    WriteFrame { frame: Frame, responder: DeviceWriteFrameResponder },
1271    /// Gets the next frame from the device (data coming from host-end).
1272    ///
1273    /// If the device was created with the
1274    /// [`fuchsia.net.tun/DeviceConfig.blocking`] option set to `true`, calls to
1275    /// `ReadFrame` block until there is a frame available to be read.
1276    ///
1277    /// - response `frame` outbound frame data and metadata.
1278    /// * error `ZX_ERR_NO_RESOURCES` if more than
1279    /// [`fuchsia.net.tun/MAX_PENDING_OPERATIONS`] calls to `ReadFrame` are
1280    /// pending.
1281    /// * error `ZX_ERR_SHOULD_WAIT` if `blocking` is set to `false` and there
1282    /// are no frames to be read.
1283    ReadFrame { responder: DeviceReadFrameResponder },
1284    /// Retrieves signals eventpair.
1285    ///
1286    /// - response `signals` an eventpair that is signalled with
1287    /// `SIGNAL_READABLE` and `SIGNAL_WRITABLE` when read and write buffers are
1288    /// available, respectively.
1289    GetSignals { responder: DeviceGetSignalsResponder },
1290    /// Creates a new port on this device.
1291    ///
1292    /// + request `config` new port configuration.
1293    /// + request `port` grants control over the port. Closed with an epitaph if
1294    /// `config` is not valid.
1295    AddPort {
1296        config: DevicePortConfig,
1297        port: fidl::endpoints::ServerEnd<PortMarker>,
1298        control_handle: DeviceControlHandle,
1299    },
1300    /// Connects to the underlying device endpoint.
1301    ///
1302    /// + request `device` device handle.
1303    GetDevice {
1304        device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1305        control_handle: DeviceControlHandle,
1306    },
1307    /// Delegates an rx lease through the tun device.
1308    ///
1309    /// See documentation on [`fuchsia.hardware.network/DelegatedRxLease`] for
1310    /// proper usage.
1311    DelegateRxLease {
1312        lease: fidl_fuchsia_hardware_network::DelegatedRxLease,
1313        control_handle: DeviceControlHandle,
1314    },
1315}
1316
1317impl DeviceRequest {
1318    #[allow(irrefutable_let_patterns)]
1319    pub fn into_write_frame(self) -> Option<(Frame, DeviceWriteFrameResponder)> {
1320        if let DeviceRequest::WriteFrame { frame, responder } = self {
1321            Some((frame, responder))
1322        } else {
1323            None
1324        }
1325    }
1326
1327    #[allow(irrefutable_let_patterns)]
1328    pub fn into_read_frame(self) -> Option<(DeviceReadFrameResponder)> {
1329        if let DeviceRequest::ReadFrame { responder } = self {
1330            Some((responder))
1331        } else {
1332            None
1333        }
1334    }
1335
1336    #[allow(irrefutable_let_patterns)]
1337    pub fn into_get_signals(self) -> Option<(DeviceGetSignalsResponder)> {
1338        if let DeviceRequest::GetSignals { responder } = self {
1339            Some((responder))
1340        } else {
1341            None
1342        }
1343    }
1344
1345    #[allow(irrefutable_let_patterns)]
1346    pub fn into_add_port(
1347        self,
1348    ) -> Option<(DevicePortConfig, fidl::endpoints::ServerEnd<PortMarker>, DeviceControlHandle)>
1349    {
1350        if let DeviceRequest::AddPort { config, port, control_handle } = self {
1351            Some((config, port, control_handle))
1352        } else {
1353            None
1354        }
1355    }
1356
1357    #[allow(irrefutable_let_patterns)]
1358    pub fn into_get_device(
1359        self,
1360    ) -> Option<(
1361        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1362        DeviceControlHandle,
1363    )> {
1364        if let DeviceRequest::GetDevice { device, control_handle } = self {
1365            Some((device, control_handle))
1366        } else {
1367            None
1368        }
1369    }
1370
1371    #[allow(irrefutable_let_patterns)]
1372    pub fn into_delegate_rx_lease(
1373        self,
1374    ) -> Option<(fidl_fuchsia_hardware_network::DelegatedRxLease, DeviceControlHandle)> {
1375        if let DeviceRequest::DelegateRxLease { lease, control_handle } = self {
1376            Some((lease, control_handle))
1377        } else {
1378            None
1379        }
1380    }
1381
1382    /// Name of the method defined in FIDL
1383    pub fn method_name(&self) -> &'static str {
1384        match *self {
1385            DeviceRequest::WriteFrame { .. } => "write_frame",
1386            DeviceRequest::ReadFrame { .. } => "read_frame",
1387            DeviceRequest::GetSignals { .. } => "get_signals",
1388            DeviceRequest::AddPort { .. } => "add_port",
1389            DeviceRequest::GetDevice { .. } => "get_device",
1390            DeviceRequest::DelegateRxLease { .. } => "delegate_rx_lease",
1391        }
1392    }
1393}
1394
1395#[derive(Debug, Clone)]
1396pub struct DeviceControlHandle {
1397    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1398}
1399
1400impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1401    fn shutdown(&self) {
1402        self.inner.shutdown()
1403    }
1404    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1405        self.inner.shutdown_with_epitaph(status)
1406    }
1407
1408    fn is_closed(&self) -> bool {
1409        self.inner.channel().is_closed()
1410    }
1411    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1412        self.inner.channel().on_closed()
1413    }
1414
1415    #[cfg(target_os = "fuchsia")]
1416    fn signal_peer(
1417        &self,
1418        clear_mask: zx::Signals,
1419        set_mask: zx::Signals,
1420    ) -> Result<(), zx_status::Status> {
1421        use fidl::Peered;
1422        self.inner.channel().signal_peer(clear_mask, set_mask)
1423    }
1424}
1425
1426impl DeviceControlHandle {}
1427
1428#[must_use = "FIDL methods require a response to be sent"]
1429#[derive(Debug)]
1430pub struct DeviceWriteFrameResponder {
1431    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1432    tx_id: u32,
1433}
1434
1435/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1436/// if the responder is dropped without sending a response, so that the client
1437/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1438impl std::ops::Drop for DeviceWriteFrameResponder {
1439    fn drop(&mut self) {
1440        self.control_handle.shutdown();
1441        // Safety: drops once, never accessed again
1442        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1443    }
1444}
1445
1446impl fidl::endpoints::Responder for DeviceWriteFrameResponder {
1447    type ControlHandle = DeviceControlHandle;
1448
1449    fn control_handle(&self) -> &DeviceControlHandle {
1450        &self.control_handle
1451    }
1452
1453    fn drop_without_shutdown(mut self) {
1454        // Safety: drops once, never accessed again due to mem::forget
1455        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1456        // Prevent Drop from running (which would shut down the channel)
1457        std::mem::forget(self);
1458    }
1459}
1460
1461impl DeviceWriteFrameResponder {
1462    /// Sends a response to the FIDL transaction.
1463    ///
1464    /// Sets the channel to shutdown if an error occurs.
1465    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1466        let _result = self.send_raw(result);
1467        if _result.is_err() {
1468            self.control_handle.shutdown();
1469        }
1470        self.drop_without_shutdown();
1471        _result
1472    }
1473
1474    /// Similar to "send" but does not shutdown the channel if an error occurs.
1475    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1476        let _result = self.send_raw(result);
1477        self.drop_without_shutdown();
1478        _result
1479    }
1480
1481    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1482        self.control_handle
1483            .inner
1484            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1485                result,
1486                self.tx_id,
1487                0x2d19e24e149bf6db,
1488                fidl::encoding::DynamicFlags::empty(),
1489            )
1490    }
1491}
1492
1493#[must_use = "FIDL methods require a response to be sent"]
1494#[derive(Debug)]
1495pub struct DeviceReadFrameResponder {
1496    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1497    tx_id: u32,
1498}
1499
1500/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1501/// if the responder is dropped without sending a response, so that the client
1502/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1503impl std::ops::Drop for DeviceReadFrameResponder {
1504    fn drop(&mut self) {
1505        self.control_handle.shutdown();
1506        // Safety: drops once, never accessed again
1507        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1508    }
1509}
1510
1511impl fidl::endpoints::Responder for DeviceReadFrameResponder {
1512    type ControlHandle = DeviceControlHandle;
1513
1514    fn control_handle(&self) -> &DeviceControlHandle {
1515        &self.control_handle
1516    }
1517
1518    fn drop_without_shutdown(mut self) {
1519        // Safety: drops once, never accessed again due to mem::forget
1520        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1521        // Prevent Drop from running (which would shut down the channel)
1522        std::mem::forget(self);
1523    }
1524}
1525
1526impl DeviceReadFrameResponder {
1527    /// Sends a response to the FIDL transaction.
1528    ///
1529    /// Sets the channel to shutdown if an error occurs.
1530    pub fn send(self, mut result: Result<&Frame, i32>) -> Result<(), fidl::Error> {
1531        let _result = self.send_raw(result);
1532        if _result.is_err() {
1533            self.control_handle.shutdown();
1534        }
1535        self.drop_without_shutdown();
1536        _result
1537    }
1538
1539    /// Similar to "send" but does not shutdown the channel if an error occurs.
1540    pub fn send_no_shutdown_on_err(
1541        self,
1542        mut result: Result<&Frame, i32>,
1543    ) -> Result<(), fidl::Error> {
1544        let _result = self.send_raw(result);
1545        self.drop_without_shutdown();
1546        _result
1547    }
1548
1549    fn send_raw(&self, mut result: Result<&Frame, i32>) -> Result<(), fidl::Error> {
1550        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceReadFrameResponse, i32>>(
1551            result.map(|frame| (frame,)),
1552            self.tx_id,
1553            0x6ebc56b8427e1571,
1554            fidl::encoding::DynamicFlags::empty(),
1555        )
1556    }
1557}
1558
1559#[must_use = "FIDL methods require a response to be sent"]
1560#[derive(Debug)]
1561pub struct DeviceGetSignalsResponder {
1562    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1563    tx_id: u32,
1564}
1565
1566/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1567/// if the responder is dropped without sending a response, so that the client
1568/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1569impl std::ops::Drop for DeviceGetSignalsResponder {
1570    fn drop(&mut self) {
1571        self.control_handle.shutdown();
1572        // Safety: drops once, never accessed again
1573        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1574    }
1575}
1576
1577impl fidl::endpoints::Responder for DeviceGetSignalsResponder {
1578    type ControlHandle = DeviceControlHandle;
1579
1580    fn control_handle(&self) -> &DeviceControlHandle {
1581        &self.control_handle
1582    }
1583
1584    fn drop_without_shutdown(mut self) {
1585        // Safety: drops once, never accessed again due to mem::forget
1586        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1587        // Prevent Drop from running (which would shut down the channel)
1588        std::mem::forget(self);
1589    }
1590}
1591
1592impl DeviceGetSignalsResponder {
1593    /// Sends a response to the FIDL transaction.
1594    ///
1595    /// Sets the channel to shutdown if an error occurs.
1596    pub fn send(self, mut signals: fidl::EventPair) -> Result<(), fidl::Error> {
1597        let _result = self.send_raw(signals);
1598        if _result.is_err() {
1599            self.control_handle.shutdown();
1600        }
1601        self.drop_without_shutdown();
1602        _result
1603    }
1604
1605    /// Similar to "send" but does not shutdown the channel if an error occurs.
1606    pub fn send_no_shutdown_on_err(self, mut signals: fidl::EventPair) -> Result<(), fidl::Error> {
1607        let _result = self.send_raw(signals);
1608        self.drop_without_shutdown();
1609        _result
1610    }
1611
1612    fn send_raw(&self, mut signals: fidl::EventPair) -> Result<(), fidl::Error> {
1613        self.control_handle.inner.send::<DeviceGetSignalsResponse>(
1614            (signals,),
1615            self.tx_id,
1616            0x4d1ca50fc53606b9,
1617            fidl::encoding::DynamicFlags::empty(),
1618        )
1619    }
1620}
1621
1622#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1623pub struct DevicePairMarker;
1624
1625impl fidl::endpoints::ProtocolMarker for DevicePairMarker {
1626    type Proxy = DevicePairProxy;
1627    type RequestStream = DevicePairRequestStream;
1628    #[cfg(target_os = "fuchsia")]
1629    type SynchronousProxy = DevicePairSynchronousProxy;
1630
1631    const DEBUG_NAME: &'static str = "(anonymous) DevicePair";
1632}
1633pub type DevicePairAddPortResult = Result<(), i32>;
1634pub type DevicePairRemovePortResult = Result<(), i32>;
1635
1636pub trait DevicePairProxyInterface: Send + Sync {
1637    type AddPortResponseFut: std::future::Future<Output = Result<DevicePairAddPortResult, fidl::Error>>
1638        + Send;
1639    fn r#add_port(&self, config: &DevicePairPortConfig) -> Self::AddPortResponseFut;
1640    type RemovePortResponseFut: std::future::Future<Output = Result<DevicePairRemovePortResult, fidl::Error>>
1641        + Send;
1642    fn r#remove_port(&self, id: u8) -> Self::RemovePortResponseFut;
1643    fn r#get_left(
1644        &self,
1645        device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1646    ) -> Result<(), fidl::Error>;
1647    fn r#get_right(
1648        &self,
1649        device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1650    ) -> Result<(), fidl::Error>;
1651    fn r#get_left_port(
1652        &self,
1653        id: u8,
1654        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1655    ) -> Result<(), fidl::Error>;
1656    fn r#get_right_port(
1657        &self,
1658        id: u8,
1659        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1660    ) -> Result<(), fidl::Error>;
1661}
1662#[derive(Debug)]
1663#[cfg(target_os = "fuchsia")]
1664pub struct DevicePairSynchronousProxy {
1665    client: fidl::client::sync::Client,
1666}
1667
1668#[cfg(target_os = "fuchsia")]
1669impl fidl::endpoints::SynchronousProxy for DevicePairSynchronousProxy {
1670    type Proxy = DevicePairProxy;
1671    type Protocol = DevicePairMarker;
1672
1673    fn from_channel(inner: fidl::Channel) -> Self {
1674        Self::new(inner)
1675    }
1676
1677    fn into_channel(self) -> fidl::Channel {
1678        self.client.into_channel()
1679    }
1680
1681    fn as_channel(&self) -> &fidl::Channel {
1682        self.client.as_channel()
1683    }
1684}
1685
1686#[cfg(target_os = "fuchsia")]
1687impl DevicePairSynchronousProxy {
1688    pub fn new(channel: fidl::Channel) -> Self {
1689        let protocol_name = <DevicePairMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1690        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1691    }
1692
1693    pub fn into_channel(self) -> fidl::Channel {
1694        self.client.into_channel()
1695    }
1696
1697    /// Waits until an event arrives and returns it. It is safe for other
1698    /// threads to make concurrent requests while waiting for an event.
1699    pub fn wait_for_event(
1700        &self,
1701        deadline: zx::MonotonicInstant,
1702    ) -> Result<DevicePairEvent, fidl::Error> {
1703        DevicePairEvent::decode(self.client.wait_for_event(deadline)?)
1704    }
1705
1706    /// Adds a logical port to this device pair.
1707    ///
1708    /// + request `config` port configuration.
1709    /// * error `ZX_ERR_INVALID_ARGS` if `config` is invalid.
1710    /// * error `ZX_ERR_ALREADY_EXISTS` if the provided port identifier is
1711    /// already in use.
1712    pub fn r#add_port(
1713        &self,
1714        mut config: &DevicePairPortConfig,
1715        ___deadline: zx::MonotonicInstant,
1716    ) -> Result<DevicePairAddPortResult, fidl::Error> {
1717        let _response = self.client.send_query::<
1718            DevicePairAddPortRequest,
1719            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1720        >(
1721            (config,),
1722            0x362f4856a075e1f8,
1723            fidl::encoding::DynamicFlags::empty(),
1724            ___deadline,
1725        )?;
1726        Ok(_response.map(|x| x))
1727    }
1728
1729    /// Removes a logical port created by
1730    /// [`fuchsia.net.tun/DevicePair.AddPort`].
1731    ///
1732    /// + request `id` identifier of the port to remove.
1733    /// * error `ZX_ERR_NOT_FOUND` if `id` does not map to an existing port.
1734    pub fn r#remove_port(
1735        &self,
1736        mut id: u8,
1737        ___deadline: zx::MonotonicInstant,
1738    ) -> Result<DevicePairRemovePortResult, fidl::Error> {
1739        let _response = self.client.send_query::<
1740            DevicePairRemovePortRequest,
1741            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1742        >(
1743            (id,),
1744            0x33bb45cc1d3fbe1e,
1745            fidl::encoding::DynamicFlags::empty(),
1746            ___deadline,
1747        )?;
1748        Ok(_response.map(|x| x))
1749    }
1750
1751    /// Connects to the underlying left device endpoint.
1752    ///
1753    /// + request `device` handle serve the left device endpoint on.
1754    pub fn r#get_left(
1755        &self,
1756        mut device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1757    ) -> Result<(), fidl::Error> {
1758        self.client.send::<DevicePairGetLeftRequest>(
1759            (device,),
1760            0x1357a771a6ccb303,
1761            fidl::encoding::DynamicFlags::empty(),
1762        )
1763    }
1764
1765    /// Connects to the underlying right device endpoint.
1766    ///
1767    /// + request `device` handle serve the right device endpoint on.
1768    pub fn r#get_right(
1769        &self,
1770        mut device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1771    ) -> Result<(), fidl::Error> {
1772        self.client.send::<DevicePairGetRightRequest>(
1773            (device,),
1774            0x45ebce063223b60f,
1775            fidl::encoding::DynamicFlags::empty(),
1776        )
1777    }
1778
1779    /// Connects to an underlying left port.
1780    ///
1781    /// + request `id` requested port identifier.
1782    /// + request `port` grants access to the requested port on the left device.
1783    pub fn r#get_left_port(
1784        &self,
1785        mut id: u8,
1786        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1787    ) -> Result<(), fidl::Error> {
1788        self.client.send::<DevicePairGetLeftPortRequest>(
1789            (id, port),
1790            0x6e3038d75096ab77,
1791            fidl::encoding::DynamicFlags::empty(),
1792        )
1793    }
1794
1795    /// Connects to an underlying right port.
1796    ///
1797    /// + request `id` requested port identifier.
1798    /// + request `port` grants access to the requested port on the right device.
1799    pub fn r#get_right_port(
1800        &self,
1801        mut id: u8,
1802        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1803    ) -> Result<(), fidl::Error> {
1804        self.client.send::<DevicePairGetRightPortRequest>(
1805            (id, port),
1806            0x7fc4716601eb987c,
1807            fidl::encoding::DynamicFlags::empty(),
1808        )
1809    }
1810}
1811
1812#[derive(Debug, Clone)]
1813pub struct DevicePairProxy {
1814    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1815}
1816
1817impl fidl::endpoints::Proxy for DevicePairProxy {
1818    type Protocol = DevicePairMarker;
1819
1820    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1821        Self::new(inner)
1822    }
1823
1824    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1825        self.client.into_channel().map_err(|client| Self { client })
1826    }
1827
1828    fn as_channel(&self) -> &::fidl::AsyncChannel {
1829        self.client.as_channel()
1830    }
1831}
1832
1833impl DevicePairProxy {
1834    /// Create a new Proxy for fuchsia.net.tun/DevicePair.
1835    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1836        let protocol_name = <DevicePairMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1837        Self { client: fidl::client::Client::new(channel, protocol_name) }
1838    }
1839
1840    /// Get a Stream of events from the remote end of the protocol.
1841    ///
1842    /// # Panics
1843    ///
1844    /// Panics if the event stream was already taken.
1845    pub fn take_event_stream(&self) -> DevicePairEventStream {
1846        DevicePairEventStream { event_receiver: self.client.take_event_receiver() }
1847    }
1848
1849    /// Adds a logical port to this device pair.
1850    ///
1851    /// + request `config` port configuration.
1852    /// * error `ZX_ERR_INVALID_ARGS` if `config` is invalid.
1853    /// * error `ZX_ERR_ALREADY_EXISTS` if the provided port identifier is
1854    /// already in use.
1855    pub fn r#add_port(
1856        &self,
1857        mut config: &DevicePairPortConfig,
1858    ) -> fidl::client::QueryResponseFut<
1859        DevicePairAddPortResult,
1860        fidl::encoding::DefaultFuchsiaResourceDialect,
1861    > {
1862        DevicePairProxyInterface::r#add_port(self, config)
1863    }
1864
1865    /// Removes a logical port created by
1866    /// [`fuchsia.net.tun/DevicePair.AddPort`].
1867    ///
1868    /// + request `id` identifier of the port to remove.
1869    /// * error `ZX_ERR_NOT_FOUND` if `id` does not map to an existing port.
1870    pub fn r#remove_port(
1871        &self,
1872        mut id: u8,
1873    ) -> fidl::client::QueryResponseFut<
1874        DevicePairRemovePortResult,
1875        fidl::encoding::DefaultFuchsiaResourceDialect,
1876    > {
1877        DevicePairProxyInterface::r#remove_port(self, id)
1878    }
1879
1880    /// Connects to the underlying left device endpoint.
1881    ///
1882    /// + request `device` handle serve the left device endpoint on.
1883    pub fn r#get_left(
1884        &self,
1885        mut device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1886    ) -> Result<(), fidl::Error> {
1887        DevicePairProxyInterface::r#get_left(self, device)
1888    }
1889
1890    /// Connects to the underlying right device endpoint.
1891    ///
1892    /// + request `device` handle serve the right device endpoint on.
1893    pub fn r#get_right(
1894        &self,
1895        mut device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1896    ) -> Result<(), fidl::Error> {
1897        DevicePairProxyInterface::r#get_right(self, device)
1898    }
1899
1900    /// Connects to an underlying left port.
1901    ///
1902    /// + request `id` requested port identifier.
1903    /// + request `port` grants access to the requested port on the left device.
1904    pub fn r#get_left_port(
1905        &self,
1906        mut id: u8,
1907        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1908    ) -> Result<(), fidl::Error> {
1909        DevicePairProxyInterface::r#get_left_port(self, id, port)
1910    }
1911
1912    /// Connects to an underlying right port.
1913    ///
1914    /// + request `id` requested port identifier.
1915    /// + request `port` grants access to the requested port on the right device.
1916    pub fn r#get_right_port(
1917        &self,
1918        mut id: u8,
1919        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1920    ) -> Result<(), fidl::Error> {
1921        DevicePairProxyInterface::r#get_right_port(self, id, port)
1922    }
1923}
1924
1925impl DevicePairProxyInterface for DevicePairProxy {
1926    type AddPortResponseFut = fidl::client::QueryResponseFut<
1927        DevicePairAddPortResult,
1928        fidl::encoding::DefaultFuchsiaResourceDialect,
1929    >;
1930    fn r#add_port(&self, mut config: &DevicePairPortConfig) -> Self::AddPortResponseFut {
1931        fn _decode(
1932            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1933        ) -> Result<DevicePairAddPortResult, fidl::Error> {
1934            let _response = fidl::client::decode_transaction_body::<
1935                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1936                fidl::encoding::DefaultFuchsiaResourceDialect,
1937                0x362f4856a075e1f8,
1938            >(_buf?)?;
1939            Ok(_response.map(|x| x))
1940        }
1941        self.client.send_query_and_decode::<DevicePairAddPortRequest, DevicePairAddPortResult>(
1942            (config,),
1943            0x362f4856a075e1f8,
1944            fidl::encoding::DynamicFlags::empty(),
1945            _decode,
1946        )
1947    }
1948
1949    type RemovePortResponseFut = fidl::client::QueryResponseFut<
1950        DevicePairRemovePortResult,
1951        fidl::encoding::DefaultFuchsiaResourceDialect,
1952    >;
1953    fn r#remove_port(&self, mut id: u8) -> Self::RemovePortResponseFut {
1954        fn _decode(
1955            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1956        ) -> Result<DevicePairRemovePortResult, fidl::Error> {
1957            let _response = fidl::client::decode_transaction_body::<
1958                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1959                fidl::encoding::DefaultFuchsiaResourceDialect,
1960                0x33bb45cc1d3fbe1e,
1961            >(_buf?)?;
1962            Ok(_response.map(|x| x))
1963        }
1964        self.client
1965            .send_query_and_decode::<DevicePairRemovePortRequest, DevicePairRemovePortResult>(
1966                (id,),
1967                0x33bb45cc1d3fbe1e,
1968                fidl::encoding::DynamicFlags::empty(),
1969                _decode,
1970            )
1971    }
1972
1973    fn r#get_left(
1974        &self,
1975        mut device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1976    ) -> Result<(), fidl::Error> {
1977        self.client.send::<DevicePairGetLeftRequest>(
1978            (device,),
1979            0x1357a771a6ccb303,
1980            fidl::encoding::DynamicFlags::empty(),
1981        )
1982    }
1983
1984    fn r#get_right(
1985        &self,
1986        mut device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1987    ) -> Result<(), fidl::Error> {
1988        self.client.send::<DevicePairGetRightRequest>(
1989            (device,),
1990            0x45ebce063223b60f,
1991            fidl::encoding::DynamicFlags::empty(),
1992        )
1993    }
1994
1995    fn r#get_left_port(
1996        &self,
1997        mut id: u8,
1998        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1999    ) -> Result<(), fidl::Error> {
2000        self.client.send::<DevicePairGetLeftPortRequest>(
2001            (id, port),
2002            0x6e3038d75096ab77,
2003            fidl::encoding::DynamicFlags::empty(),
2004        )
2005    }
2006
2007    fn r#get_right_port(
2008        &self,
2009        mut id: u8,
2010        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2011    ) -> Result<(), fidl::Error> {
2012        self.client.send::<DevicePairGetRightPortRequest>(
2013            (id, port),
2014            0x7fc4716601eb987c,
2015            fidl::encoding::DynamicFlags::empty(),
2016        )
2017    }
2018}
2019
2020pub struct DevicePairEventStream {
2021    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2022}
2023
2024impl std::marker::Unpin for DevicePairEventStream {}
2025
2026impl futures::stream::FusedStream for DevicePairEventStream {
2027    fn is_terminated(&self) -> bool {
2028        self.event_receiver.is_terminated()
2029    }
2030}
2031
2032impl futures::Stream for DevicePairEventStream {
2033    type Item = Result<DevicePairEvent, fidl::Error>;
2034
2035    fn poll_next(
2036        mut self: std::pin::Pin<&mut Self>,
2037        cx: &mut std::task::Context<'_>,
2038    ) -> std::task::Poll<Option<Self::Item>> {
2039        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2040            &mut self.event_receiver,
2041            cx
2042        )?) {
2043            Some(buf) => std::task::Poll::Ready(Some(DevicePairEvent::decode(buf))),
2044            None => std::task::Poll::Ready(None),
2045        }
2046    }
2047}
2048
2049#[derive(Debug)]
2050pub enum DevicePairEvent {}
2051
2052impl DevicePairEvent {
2053    /// Decodes a message buffer as a [`DevicePairEvent`].
2054    fn decode(
2055        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2056    ) -> Result<DevicePairEvent, fidl::Error> {
2057        let (bytes, _handles) = buf.split_mut();
2058        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2059        debug_assert_eq!(tx_header.tx_id, 0);
2060        match tx_header.ordinal {
2061            _ => Err(fidl::Error::UnknownOrdinal {
2062                ordinal: tx_header.ordinal,
2063                protocol_name: <DevicePairMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2064            }),
2065        }
2066    }
2067}
2068
2069/// A Stream of incoming requests for fuchsia.net.tun/DevicePair.
2070pub struct DevicePairRequestStream {
2071    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2072    is_terminated: bool,
2073}
2074
2075impl std::marker::Unpin for DevicePairRequestStream {}
2076
2077impl futures::stream::FusedStream for DevicePairRequestStream {
2078    fn is_terminated(&self) -> bool {
2079        self.is_terminated
2080    }
2081}
2082
2083impl fidl::endpoints::RequestStream for DevicePairRequestStream {
2084    type Protocol = DevicePairMarker;
2085    type ControlHandle = DevicePairControlHandle;
2086
2087    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2088        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2089    }
2090
2091    fn control_handle(&self) -> Self::ControlHandle {
2092        DevicePairControlHandle { inner: self.inner.clone() }
2093    }
2094
2095    fn into_inner(
2096        self,
2097    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2098    {
2099        (self.inner, self.is_terminated)
2100    }
2101
2102    fn from_inner(
2103        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2104        is_terminated: bool,
2105    ) -> Self {
2106        Self { inner, is_terminated }
2107    }
2108}
2109
2110impl futures::Stream for DevicePairRequestStream {
2111    type Item = Result<DevicePairRequest, fidl::Error>;
2112
2113    fn poll_next(
2114        mut self: std::pin::Pin<&mut Self>,
2115        cx: &mut std::task::Context<'_>,
2116    ) -> std::task::Poll<Option<Self::Item>> {
2117        let this = &mut *self;
2118        if this.inner.check_shutdown(cx) {
2119            this.is_terminated = true;
2120            return std::task::Poll::Ready(None);
2121        }
2122        if this.is_terminated {
2123            panic!("polled DevicePairRequestStream after completion");
2124        }
2125        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2126            |bytes, handles| {
2127                match this.inner.channel().read_etc(cx, bytes, handles) {
2128                    std::task::Poll::Ready(Ok(())) => {}
2129                    std::task::Poll::Pending => return std::task::Poll::Pending,
2130                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2131                        this.is_terminated = true;
2132                        return std::task::Poll::Ready(None);
2133                    }
2134                    std::task::Poll::Ready(Err(e)) => {
2135                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2136                            e.into(),
2137                        ))))
2138                    }
2139                }
2140
2141                // A message has been received from the channel
2142                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2143
2144                std::task::Poll::Ready(Some(match header.ordinal {
2145                    0x362f4856a075e1f8 => {
2146                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2147                        let mut req = fidl::new_empty!(
2148                            DevicePairAddPortRequest,
2149                            fidl::encoding::DefaultFuchsiaResourceDialect
2150                        );
2151                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevicePairAddPortRequest>(&header, _body_bytes, handles, &mut req)?;
2152                        let control_handle = DevicePairControlHandle { inner: this.inner.clone() };
2153                        Ok(DevicePairRequest::AddPort {
2154                            config: req.config,
2155
2156                            responder: DevicePairAddPortResponder {
2157                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2158                                tx_id: header.tx_id,
2159                            },
2160                        })
2161                    }
2162                    0x33bb45cc1d3fbe1e => {
2163                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2164                        let mut req = fidl::new_empty!(
2165                            DevicePairRemovePortRequest,
2166                            fidl::encoding::DefaultFuchsiaResourceDialect
2167                        );
2168                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevicePairRemovePortRequest>(&header, _body_bytes, handles, &mut req)?;
2169                        let control_handle = DevicePairControlHandle { inner: this.inner.clone() };
2170                        Ok(DevicePairRequest::RemovePort {
2171                            id: req.id,
2172
2173                            responder: DevicePairRemovePortResponder {
2174                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2175                                tx_id: header.tx_id,
2176                            },
2177                        })
2178                    }
2179                    0x1357a771a6ccb303 => {
2180                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2181                        let mut req = fidl::new_empty!(
2182                            DevicePairGetLeftRequest,
2183                            fidl::encoding::DefaultFuchsiaResourceDialect
2184                        );
2185                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevicePairGetLeftRequest>(&header, _body_bytes, handles, &mut req)?;
2186                        let control_handle = DevicePairControlHandle { inner: this.inner.clone() };
2187                        Ok(DevicePairRequest::GetLeft { device: req.device, control_handle })
2188                    }
2189                    0x45ebce063223b60f => {
2190                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2191                        let mut req = fidl::new_empty!(
2192                            DevicePairGetRightRequest,
2193                            fidl::encoding::DefaultFuchsiaResourceDialect
2194                        );
2195                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevicePairGetRightRequest>(&header, _body_bytes, handles, &mut req)?;
2196                        let control_handle = DevicePairControlHandle { inner: this.inner.clone() };
2197                        Ok(DevicePairRequest::GetRight { device: req.device, control_handle })
2198                    }
2199                    0x6e3038d75096ab77 => {
2200                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2201                        let mut req = fidl::new_empty!(
2202                            DevicePairGetLeftPortRequest,
2203                            fidl::encoding::DefaultFuchsiaResourceDialect
2204                        );
2205                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevicePairGetLeftPortRequest>(&header, _body_bytes, handles, &mut req)?;
2206                        let control_handle = DevicePairControlHandle { inner: this.inner.clone() };
2207                        Ok(DevicePairRequest::GetLeftPort {
2208                            id: req.id,
2209                            port: req.port,
2210
2211                            control_handle,
2212                        })
2213                    }
2214                    0x7fc4716601eb987c => {
2215                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2216                        let mut req = fidl::new_empty!(
2217                            DevicePairGetRightPortRequest,
2218                            fidl::encoding::DefaultFuchsiaResourceDialect
2219                        );
2220                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevicePairGetRightPortRequest>(&header, _body_bytes, handles, &mut req)?;
2221                        let control_handle = DevicePairControlHandle { inner: this.inner.clone() };
2222                        Ok(DevicePairRequest::GetRightPort {
2223                            id: req.id,
2224                            port: req.port,
2225
2226                            control_handle,
2227                        })
2228                    }
2229                    _ => Err(fidl::Error::UnknownOrdinal {
2230                        ordinal: header.ordinal,
2231                        protocol_name:
2232                            <DevicePairMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2233                    }),
2234                }))
2235            },
2236        )
2237    }
2238}
2239
2240/// Provides control over a pair of network devices.
2241///
2242/// A `DevicePair` is a simpler version of `Device` that "shorts" two network
2243/// device interfaces, named its "left" and "right" ends. The internal state of
2244/// a `DevicePair` is not accessible, like it is for `Device` and it provides a
2245/// more streamlined (and considerably faster) pair of
2246/// [`fuchsia.hardware.network/Device`]s. The transmit side of each port of the
2247/// left end is connected to the receive side of the port with the same
2248/// identifier on the right end, and vice-versa. A `DevicePair`'s port online
2249/// signal is handled internally (online if any of the ends has an active data
2250/// session). If MAC addresses are provided on creation, the only supported MAC
2251/// filtering mode is `PROMISCUOUS`.
2252///
2253/// This protocol encodes the underlying object's lifetime in both directions;
2254/// the underlying object is alive iff both ends of the protocol are open. That
2255/// is:
2256///
2257/// - Closing the client end causes the object to be destroyed.
2258/// - Observing a closure of the server end indicates the object no longer
2259/// exists.
2260#[derive(Debug)]
2261pub enum DevicePairRequest {
2262    /// Adds a logical port to this device pair.
2263    ///
2264    /// + request `config` port configuration.
2265    /// * error `ZX_ERR_INVALID_ARGS` if `config` is invalid.
2266    /// * error `ZX_ERR_ALREADY_EXISTS` if the provided port identifier is
2267    /// already in use.
2268    AddPort { config: DevicePairPortConfig, responder: DevicePairAddPortResponder },
2269    /// Removes a logical port created by
2270    /// [`fuchsia.net.tun/DevicePair.AddPort`].
2271    ///
2272    /// + request `id` identifier of the port to remove.
2273    /// * error `ZX_ERR_NOT_FOUND` if `id` does not map to an existing port.
2274    RemovePort { id: u8, responder: DevicePairRemovePortResponder },
2275    /// Connects to the underlying left device endpoint.
2276    ///
2277    /// + request `device` handle serve the left device endpoint on.
2278    GetLeft {
2279        device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
2280        control_handle: DevicePairControlHandle,
2281    },
2282    /// Connects to the underlying right device endpoint.
2283    ///
2284    /// + request `device` handle serve the right device endpoint on.
2285    GetRight {
2286        device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
2287        control_handle: DevicePairControlHandle,
2288    },
2289    /// Connects to an underlying left port.
2290    ///
2291    /// + request `id` requested port identifier.
2292    /// + request `port` grants access to the requested port on the left device.
2293    GetLeftPort {
2294        id: u8,
2295        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2296        control_handle: DevicePairControlHandle,
2297    },
2298    /// Connects to an underlying right port.
2299    ///
2300    /// + request `id` requested port identifier.
2301    /// + request `port` grants access to the requested port on the right device.
2302    GetRightPort {
2303        id: u8,
2304        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2305        control_handle: DevicePairControlHandle,
2306    },
2307}
2308
2309impl DevicePairRequest {
2310    #[allow(irrefutable_let_patterns)]
2311    pub fn into_add_port(self) -> Option<(DevicePairPortConfig, DevicePairAddPortResponder)> {
2312        if let DevicePairRequest::AddPort { config, responder } = self {
2313            Some((config, responder))
2314        } else {
2315            None
2316        }
2317    }
2318
2319    #[allow(irrefutable_let_patterns)]
2320    pub fn into_remove_port(self) -> Option<(u8, DevicePairRemovePortResponder)> {
2321        if let DevicePairRequest::RemovePort { id, responder } = self {
2322            Some((id, responder))
2323        } else {
2324            None
2325        }
2326    }
2327
2328    #[allow(irrefutable_let_patterns)]
2329    pub fn into_get_left(
2330        self,
2331    ) -> Option<(
2332        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
2333        DevicePairControlHandle,
2334    )> {
2335        if let DevicePairRequest::GetLeft { device, control_handle } = self {
2336            Some((device, control_handle))
2337        } else {
2338            None
2339        }
2340    }
2341
2342    #[allow(irrefutable_let_patterns)]
2343    pub fn into_get_right(
2344        self,
2345    ) -> Option<(
2346        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
2347        DevicePairControlHandle,
2348    )> {
2349        if let DevicePairRequest::GetRight { device, control_handle } = self {
2350            Some((device, control_handle))
2351        } else {
2352            None
2353        }
2354    }
2355
2356    #[allow(irrefutable_let_patterns)]
2357    pub fn into_get_left_port(
2358        self,
2359    ) -> Option<(
2360        u8,
2361        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2362        DevicePairControlHandle,
2363    )> {
2364        if let DevicePairRequest::GetLeftPort { id, port, control_handle } = self {
2365            Some((id, port, control_handle))
2366        } else {
2367            None
2368        }
2369    }
2370
2371    #[allow(irrefutable_let_patterns)]
2372    pub fn into_get_right_port(
2373        self,
2374    ) -> Option<(
2375        u8,
2376        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2377        DevicePairControlHandle,
2378    )> {
2379        if let DevicePairRequest::GetRightPort { id, port, control_handle } = self {
2380            Some((id, port, control_handle))
2381        } else {
2382            None
2383        }
2384    }
2385
2386    /// Name of the method defined in FIDL
2387    pub fn method_name(&self) -> &'static str {
2388        match *self {
2389            DevicePairRequest::AddPort { .. } => "add_port",
2390            DevicePairRequest::RemovePort { .. } => "remove_port",
2391            DevicePairRequest::GetLeft { .. } => "get_left",
2392            DevicePairRequest::GetRight { .. } => "get_right",
2393            DevicePairRequest::GetLeftPort { .. } => "get_left_port",
2394            DevicePairRequest::GetRightPort { .. } => "get_right_port",
2395        }
2396    }
2397}
2398
2399#[derive(Debug, Clone)]
2400pub struct DevicePairControlHandle {
2401    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2402}
2403
2404impl fidl::endpoints::ControlHandle for DevicePairControlHandle {
2405    fn shutdown(&self) {
2406        self.inner.shutdown()
2407    }
2408    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2409        self.inner.shutdown_with_epitaph(status)
2410    }
2411
2412    fn is_closed(&self) -> bool {
2413        self.inner.channel().is_closed()
2414    }
2415    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2416        self.inner.channel().on_closed()
2417    }
2418
2419    #[cfg(target_os = "fuchsia")]
2420    fn signal_peer(
2421        &self,
2422        clear_mask: zx::Signals,
2423        set_mask: zx::Signals,
2424    ) -> Result<(), zx_status::Status> {
2425        use fidl::Peered;
2426        self.inner.channel().signal_peer(clear_mask, set_mask)
2427    }
2428}
2429
2430impl DevicePairControlHandle {}
2431
2432#[must_use = "FIDL methods require a response to be sent"]
2433#[derive(Debug)]
2434pub struct DevicePairAddPortResponder {
2435    control_handle: std::mem::ManuallyDrop<DevicePairControlHandle>,
2436    tx_id: u32,
2437}
2438
2439/// Set the the channel to be shutdown (see [`DevicePairControlHandle::shutdown`])
2440/// if the responder is dropped without sending a response, so that the client
2441/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2442impl std::ops::Drop for DevicePairAddPortResponder {
2443    fn drop(&mut self) {
2444        self.control_handle.shutdown();
2445        // Safety: drops once, never accessed again
2446        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2447    }
2448}
2449
2450impl fidl::endpoints::Responder for DevicePairAddPortResponder {
2451    type ControlHandle = DevicePairControlHandle;
2452
2453    fn control_handle(&self) -> &DevicePairControlHandle {
2454        &self.control_handle
2455    }
2456
2457    fn drop_without_shutdown(mut self) {
2458        // Safety: drops once, never accessed again due to mem::forget
2459        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2460        // Prevent Drop from running (which would shut down the channel)
2461        std::mem::forget(self);
2462    }
2463}
2464
2465impl DevicePairAddPortResponder {
2466    /// Sends a response to the FIDL transaction.
2467    ///
2468    /// Sets the channel to shutdown if an error occurs.
2469    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2470        let _result = self.send_raw(result);
2471        if _result.is_err() {
2472            self.control_handle.shutdown();
2473        }
2474        self.drop_without_shutdown();
2475        _result
2476    }
2477
2478    /// Similar to "send" but does not shutdown the channel if an error occurs.
2479    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2480        let _result = self.send_raw(result);
2481        self.drop_without_shutdown();
2482        _result
2483    }
2484
2485    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2486        self.control_handle
2487            .inner
2488            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2489                result,
2490                self.tx_id,
2491                0x362f4856a075e1f8,
2492                fidl::encoding::DynamicFlags::empty(),
2493            )
2494    }
2495}
2496
2497#[must_use = "FIDL methods require a response to be sent"]
2498#[derive(Debug)]
2499pub struct DevicePairRemovePortResponder {
2500    control_handle: std::mem::ManuallyDrop<DevicePairControlHandle>,
2501    tx_id: u32,
2502}
2503
2504/// Set the the channel to be shutdown (see [`DevicePairControlHandle::shutdown`])
2505/// if the responder is dropped without sending a response, so that the client
2506/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2507impl std::ops::Drop for DevicePairRemovePortResponder {
2508    fn drop(&mut self) {
2509        self.control_handle.shutdown();
2510        // Safety: drops once, never accessed again
2511        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2512    }
2513}
2514
2515impl fidl::endpoints::Responder for DevicePairRemovePortResponder {
2516    type ControlHandle = DevicePairControlHandle;
2517
2518    fn control_handle(&self) -> &DevicePairControlHandle {
2519        &self.control_handle
2520    }
2521
2522    fn drop_without_shutdown(mut self) {
2523        // Safety: drops once, never accessed again due to mem::forget
2524        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2525        // Prevent Drop from running (which would shut down the channel)
2526        std::mem::forget(self);
2527    }
2528}
2529
2530impl DevicePairRemovePortResponder {
2531    /// Sends a response to the FIDL transaction.
2532    ///
2533    /// Sets the channel to shutdown if an error occurs.
2534    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2535        let _result = self.send_raw(result);
2536        if _result.is_err() {
2537            self.control_handle.shutdown();
2538        }
2539        self.drop_without_shutdown();
2540        _result
2541    }
2542
2543    /// Similar to "send" but does not shutdown the channel if an error occurs.
2544    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2545        let _result = self.send_raw(result);
2546        self.drop_without_shutdown();
2547        _result
2548    }
2549
2550    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2551        self.control_handle
2552            .inner
2553            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2554                result,
2555                self.tx_id,
2556                0x33bb45cc1d3fbe1e,
2557                fidl::encoding::DynamicFlags::empty(),
2558            )
2559    }
2560}
2561
2562#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2563pub struct PortMarker;
2564
2565impl fidl::endpoints::ProtocolMarker for PortMarker {
2566    type Proxy = PortProxy;
2567    type RequestStream = PortRequestStream;
2568    #[cfg(target_os = "fuchsia")]
2569    type SynchronousProxy = PortSynchronousProxy;
2570
2571    const DEBUG_NAME: &'static str = "(anonymous) Port";
2572}
2573
2574pub trait PortProxyInterface: Send + Sync {
2575    type GetStateResponseFut: std::future::Future<Output = Result<InternalState, fidl::Error>>
2576        + Send;
2577    fn r#get_state(&self) -> Self::GetStateResponseFut;
2578    type WatchStateResponseFut: std::future::Future<Output = Result<InternalState, fidl::Error>>
2579        + Send;
2580    fn r#watch_state(&self) -> Self::WatchStateResponseFut;
2581    type SetOnlineResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2582    fn r#set_online(&self, online: bool) -> Self::SetOnlineResponseFut;
2583    fn r#get_port(
2584        &self,
2585        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2586    ) -> Result<(), fidl::Error>;
2587    fn r#remove(&self) -> Result<(), fidl::Error>;
2588}
2589#[derive(Debug)]
2590#[cfg(target_os = "fuchsia")]
2591pub struct PortSynchronousProxy {
2592    client: fidl::client::sync::Client,
2593}
2594
2595#[cfg(target_os = "fuchsia")]
2596impl fidl::endpoints::SynchronousProxy for PortSynchronousProxy {
2597    type Proxy = PortProxy;
2598    type Protocol = PortMarker;
2599
2600    fn from_channel(inner: fidl::Channel) -> Self {
2601        Self::new(inner)
2602    }
2603
2604    fn into_channel(self) -> fidl::Channel {
2605        self.client.into_channel()
2606    }
2607
2608    fn as_channel(&self) -> &fidl::Channel {
2609        self.client.as_channel()
2610    }
2611}
2612
2613#[cfg(target_os = "fuchsia")]
2614impl PortSynchronousProxy {
2615    pub fn new(channel: fidl::Channel) -> Self {
2616        let protocol_name = <PortMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2617        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2618    }
2619
2620    pub fn into_channel(self) -> fidl::Channel {
2621        self.client.into_channel()
2622    }
2623
2624    /// Waits until an event arrives and returns it. It is safe for other
2625    /// threads to make concurrent requests while waiting for an event.
2626    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<PortEvent, fidl::Error> {
2627        PortEvent::decode(self.client.wait_for_event(deadline)?)
2628    }
2629
2630    /// Gets the port internal state.
2631    ///
2632    /// - response `state` a snapshot of the port's internal state.
2633    pub fn r#get_state(
2634        &self,
2635        ___deadline: zx::MonotonicInstant,
2636    ) -> Result<InternalState, fidl::Error> {
2637        let _response =
2638            self.client.send_query::<fidl::encoding::EmptyPayload, PortGetStateResponse>(
2639                (),
2640                0x5022630816212ed,
2641                fidl::encoding::DynamicFlags::empty(),
2642                ___deadline,
2643            )?;
2644        Ok(_response.state)
2645    }
2646
2647    /// Observes changes to internal state.
2648    ///
2649    /// The first call always returns the current internal state, subsequent
2650    /// calls block until the internal state differs from the last one returned
2651    /// from a `WatchState` call.
2652    ///
2653    /// `WatchState` does not provide full history of internal state changes. It
2654    /// is possible that intermediary internal state changes are missed in
2655    /// between `WatchState` calls.
2656    ///
2657    /// - response `state` the latest observed port internal state.
2658    pub fn r#watch_state(
2659        &self,
2660        ___deadline: zx::MonotonicInstant,
2661    ) -> Result<InternalState, fidl::Error> {
2662        let _response =
2663            self.client.send_query::<fidl::encoding::EmptyPayload, PortWatchStateResponse>(
2664                (),
2665                0x74d3c94c96e2b605,
2666                fidl::encoding::DynamicFlags::empty(),
2667                ___deadline,
2668            )?;
2669        Ok(_response.state)
2670    }
2671
2672    /// Sets the port's online status.
2673    ///
2674    /// The online status is visible through
2675    /// [`fuchsia.hardware.network/Port.GetStatus`]. Once `SetOnline` returns,
2676    /// the status reported through `GetStatus` is guaranteed to be the one
2677    /// passed to `SetOnline`.
2678    ///
2679    /// + request `online` desired port online state.
2680    pub fn r#set_online(
2681        &self,
2682        mut online: bool,
2683        ___deadline: zx::MonotonicInstant,
2684    ) -> Result<(), fidl::Error> {
2685        let _response =
2686            self.client.send_query::<PortSetOnlineRequest, fidl::encoding::EmptyPayload>(
2687                (online,),
2688                0x734f83793ce86e6c,
2689                fidl::encoding::DynamicFlags::empty(),
2690                ___deadline,
2691            )?;
2692        Ok(_response)
2693    }
2694
2695    /// Connects to the underlying device port.
2696    ///
2697    /// + request `port` grants access to the device port.
2698    pub fn r#get_port(
2699        &self,
2700        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2701    ) -> Result<(), fidl::Error> {
2702        self.client.send::<PortGetPortRequest>(
2703            (port,),
2704            0x1998638c1d97eed2,
2705            fidl::encoding::DynamicFlags::empty(),
2706        )
2707    }
2708
2709    /// Triggers port removal.
2710    ///
2711    /// The client end will be closed once the server has completely cleaned up
2712    /// all resources related to the port. This is equivalent to simply dropping
2713    /// the client end, but provides callers with a signal of when removal is
2714    /// complete, allowing port identifiers to be reused, for example.
2715    pub fn r#remove(&self) -> Result<(), fidl::Error> {
2716        self.client.send::<fidl::encoding::EmptyPayload>(
2717            (),
2718            0x4f45201ed5719261,
2719            fidl::encoding::DynamicFlags::empty(),
2720        )
2721    }
2722}
2723
2724#[derive(Debug, Clone)]
2725pub struct PortProxy {
2726    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2727}
2728
2729impl fidl::endpoints::Proxy for PortProxy {
2730    type Protocol = PortMarker;
2731
2732    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2733        Self::new(inner)
2734    }
2735
2736    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2737        self.client.into_channel().map_err(|client| Self { client })
2738    }
2739
2740    fn as_channel(&self) -> &::fidl::AsyncChannel {
2741        self.client.as_channel()
2742    }
2743}
2744
2745impl PortProxy {
2746    /// Create a new Proxy for fuchsia.net.tun/Port.
2747    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2748        let protocol_name = <PortMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2749        Self { client: fidl::client::Client::new(channel, protocol_name) }
2750    }
2751
2752    /// Get a Stream of events from the remote end of the protocol.
2753    ///
2754    /// # Panics
2755    ///
2756    /// Panics if the event stream was already taken.
2757    pub fn take_event_stream(&self) -> PortEventStream {
2758        PortEventStream { event_receiver: self.client.take_event_receiver() }
2759    }
2760
2761    /// Gets the port internal state.
2762    ///
2763    /// - response `state` a snapshot of the port's internal state.
2764    pub fn r#get_state(
2765        &self,
2766    ) -> fidl::client::QueryResponseFut<InternalState, fidl::encoding::DefaultFuchsiaResourceDialect>
2767    {
2768        PortProxyInterface::r#get_state(self)
2769    }
2770
2771    /// Observes changes to internal state.
2772    ///
2773    /// The first call always returns the current internal state, subsequent
2774    /// calls block until the internal state differs from the last one returned
2775    /// from a `WatchState` call.
2776    ///
2777    /// `WatchState` does not provide full history of internal state changes. It
2778    /// is possible that intermediary internal state changes are missed in
2779    /// between `WatchState` calls.
2780    ///
2781    /// - response `state` the latest observed port internal state.
2782    pub fn r#watch_state(
2783        &self,
2784    ) -> fidl::client::QueryResponseFut<InternalState, fidl::encoding::DefaultFuchsiaResourceDialect>
2785    {
2786        PortProxyInterface::r#watch_state(self)
2787    }
2788
2789    /// Sets the port's online status.
2790    ///
2791    /// The online status is visible through
2792    /// [`fuchsia.hardware.network/Port.GetStatus`]. Once `SetOnline` returns,
2793    /// the status reported through `GetStatus` is guaranteed to be the one
2794    /// passed to `SetOnline`.
2795    ///
2796    /// + request `online` desired port online state.
2797    pub fn r#set_online(
2798        &self,
2799        mut online: bool,
2800    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2801        PortProxyInterface::r#set_online(self, online)
2802    }
2803
2804    /// Connects to the underlying device port.
2805    ///
2806    /// + request `port` grants access to the device port.
2807    pub fn r#get_port(
2808        &self,
2809        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2810    ) -> Result<(), fidl::Error> {
2811        PortProxyInterface::r#get_port(self, port)
2812    }
2813
2814    /// Triggers port removal.
2815    ///
2816    /// The client end will be closed once the server has completely cleaned up
2817    /// all resources related to the port. This is equivalent to simply dropping
2818    /// the client end, but provides callers with a signal of when removal is
2819    /// complete, allowing port identifiers to be reused, for example.
2820    pub fn r#remove(&self) -> Result<(), fidl::Error> {
2821        PortProxyInterface::r#remove(self)
2822    }
2823}
2824
2825impl PortProxyInterface for PortProxy {
2826    type GetStateResponseFut = fidl::client::QueryResponseFut<
2827        InternalState,
2828        fidl::encoding::DefaultFuchsiaResourceDialect,
2829    >;
2830    fn r#get_state(&self) -> Self::GetStateResponseFut {
2831        fn _decode(
2832            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2833        ) -> Result<InternalState, fidl::Error> {
2834            let _response = fidl::client::decode_transaction_body::<
2835                PortGetStateResponse,
2836                fidl::encoding::DefaultFuchsiaResourceDialect,
2837                0x5022630816212ed,
2838            >(_buf?)?;
2839            Ok(_response.state)
2840        }
2841        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, InternalState>(
2842            (),
2843            0x5022630816212ed,
2844            fidl::encoding::DynamicFlags::empty(),
2845            _decode,
2846        )
2847    }
2848
2849    type WatchStateResponseFut = fidl::client::QueryResponseFut<
2850        InternalState,
2851        fidl::encoding::DefaultFuchsiaResourceDialect,
2852    >;
2853    fn r#watch_state(&self) -> Self::WatchStateResponseFut {
2854        fn _decode(
2855            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2856        ) -> Result<InternalState, fidl::Error> {
2857            let _response = fidl::client::decode_transaction_body::<
2858                PortWatchStateResponse,
2859                fidl::encoding::DefaultFuchsiaResourceDialect,
2860                0x74d3c94c96e2b605,
2861            >(_buf?)?;
2862            Ok(_response.state)
2863        }
2864        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, InternalState>(
2865            (),
2866            0x74d3c94c96e2b605,
2867            fidl::encoding::DynamicFlags::empty(),
2868            _decode,
2869        )
2870    }
2871
2872    type SetOnlineResponseFut =
2873        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2874    fn r#set_online(&self, mut online: bool) -> Self::SetOnlineResponseFut {
2875        fn _decode(
2876            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2877        ) -> Result<(), fidl::Error> {
2878            let _response = fidl::client::decode_transaction_body::<
2879                fidl::encoding::EmptyPayload,
2880                fidl::encoding::DefaultFuchsiaResourceDialect,
2881                0x734f83793ce86e6c,
2882            >(_buf?)?;
2883            Ok(_response)
2884        }
2885        self.client.send_query_and_decode::<PortSetOnlineRequest, ()>(
2886            (online,),
2887            0x734f83793ce86e6c,
2888            fidl::encoding::DynamicFlags::empty(),
2889            _decode,
2890        )
2891    }
2892
2893    fn r#get_port(
2894        &self,
2895        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2896    ) -> Result<(), fidl::Error> {
2897        self.client.send::<PortGetPortRequest>(
2898            (port,),
2899            0x1998638c1d97eed2,
2900            fidl::encoding::DynamicFlags::empty(),
2901        )
2902    }
2903
2904    fn r#remove(&self) -> Result<(), fidl::Error> {
2905        self.client.send::<fidl::encoding::EmptyPayload>(
2906            (),
2907            0x4f45201ed5719261,
2908            fidl::encoding::DynamicFlags::empty(),
2909        )
2910    }
2911}
2912
2913pub struct PortEventStream {
2914    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2915}
2916
2917impl std::marker::Unpin for PortEventStream {}
2918
2919impl futures::stream::FusedStream for PortEventStream {
2920    fn is_terminated(&self) -> bool {
2921        self.event_receiver.is_terminated()
2922    }
2923}
2924
2925impl futures::Stream for PortEventStream {
2926    type Item = Result<PortEvent, fidl::Error>;
2927
2928    fn poll_next(
2929        mut self: std::pin::Pin<&mut Self>,
2930        cx: &mut std::task::Context<'_>,
2931    ) -> std::task::Poll<Option<Self::Item>> {
2932        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2933            &mut self.event_receiver,
2934            cx
2935        )?) {
2936            Some(buf) => std::task::Poll::Ready(Some(PortEvent::decode(buf))),
2937            None => std::task::Poll::Ready(None),
2938        }
2939    }
2940}
2941
2942#[derive(Debug)]
2943pub enum PortEvent {}
2944
2945impl PortEvent {
2946    /// Decodes a message buffer as a [`PortEvent`].
2947    fn decode(
2948        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2949    ) -> Result<PortEvent, fidl::Error> {
2950        let (bytes, _handles) = buf.split_mut();
2951        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2952        debug_assert_eq!(tx_header.tx_id, 0);
2953        match tx_header.ordinal {
2954            _ => Err(fidl::Error::UnknownOrdinal {
2955                ordinal: tx_header.ordinal,
2956                protocol_name: <PortMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2957            }),
2958        }
2959    }
2960}
2961
2962/// A Stream of incoming requests for fuchsia.net.tun/Port.
2963pub struct PortRequestStream {
2964    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2965    is_terminated: bool,
2966}
2967
2968impl std::marker::Unpin for PortRequestStream {}
2969
2970impl futures::stream::FusedStream for PortRequestStream {
2971    fn is_terminated(&self) -> bool {
2972        self.is_terminated
2973    }
2974}
2975
2976impl fidl::endpoints::RequestStream for PortRequestStream {
2977    type Protocol = PortMarker;
2978    type ControlHandle = PortControlHandle;
2979
2980    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2981        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2982    }
2983
2984    fn control_handle(&self) -> Self::ControlHandle {
2985        PortControlHandle { inner: self.inner.clone() }
2986    }
2987
2988    fn into_inner(
2989        self,
2990    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2991    {
2992        (self.inner, self.is_terminated)
2993    }
2994
2995    fn from_inner(
2996        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2997        is_terminated: bool,
2998    ) -> Self {
2999        Self { inner, is_terminated }
3000    }
3001}
3002
3003impl futures::Stream for PortRequestStream {
3004    type Item = Result<PortRequest, fidl::Error>;
3005
3006    fn poll_next(
3007        mut self: std::pin::Pin<&mut Self>,
3008        cx: &mut std::task::Context<'_>,
3009    ) -> std::task::Poll<Option<Self::Item>> {
3010        let this = &mut *self;
3011        if this.inner.check_shutdown(cx) {
3012            this.is_terminated = true;
3013            return std::task::Poll::Ready(None);
3014        }
3015        if this.is_terminated {
3016            panic!("polled PortRequestStream after completion");
3017        }
3018        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3019            |bytes, handles| {
3020                match this.inner.channel().read_etc(cx, bytes, handles) {
3021                    std::task::Poll::Ready(Ok(())) => {}
3022                    std::task::Poll::Pending => return std::task::Poll::Pending,
3023                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3024                        this.is_terminated = true;
3025                        return std::task::Poll::Ready(None);
3026                    }
3027                    std::task::Poll::Ready(Err(e)) => {
3028                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3029                            e.into(),
3030                        ))))
3031                    }
3032                }
3033
3034                // A message has been received from the channel
3035                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3036
3037                std::task::Poll::Ready(Some(match header.ordinal {
3038                    0x5022630816212ed => {
3039                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3040                        let mut req = fidl::new_empty!(
3041                            fidl::encoding::EmptyPayload,
3042                            fidl::encoding::DefaultFuchsiaResourceDialect
3043                        );
3044                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3045                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3046                        Ok(PortRequest::GetState {
3047                            responder: PortGetStateResponder {
3048                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3049                                tx_id: header.tx_id,
3050                            },
3051                        })
3052                    }
3053                    0x74d3c94c96e2b605 => {
3054                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3055                        let mut req = fidl::new_empty!(
3056                            fidl::encoding::EmptyPayload,
3057                            fidl::encoding::DefaultFuchsiaResourceDialect
3058                        );
3059                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3060                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3061                        Ok(PortRequest::WatchState {
3062                            responder: PortWatchStateResponder {
3063                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3064                                tx_id: header.tx_id,
3065                            },
3066                        })
3067                    }
3068                    0x734f83793ce86e6c => {
3069                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3070                        let mut req = fidl::new_empty!(
3071                            PortSetOnlineRequest,
3072                            fidl::encoding::DefaultFuchsiaResourceDialect
3073                        );
3074                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PortSetOnlineRequest>(&header, _body_bytes, handles, &mut req)?;
3075                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3076                        Ok(PortRequest::SetOnline {
3077                            online: req.online,
3078
3079                            responder: PortSetOnlineResponder {
3080                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3081                                tx_id: header.tx_id,
3082                            },
3083                        })
3084                    }
3085                    0x1998638c1d97eed2 => {
3086                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3087                        let mut req = fidl::new_empty!(
3088                            PortGetPortRequest,
3089                            fidl::encoding::DefaultFuchsiaResourceDialect
3090                        );
3091                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PortGetPortRequest>(&header, _body_bytes, handles, &mut req)?;
3092                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3093                        Ok(PortRequest::GetPort { port: req.port, control_handle })
3094                    }
3095                    0x4f45201ed5719261 => {
3096                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3097                        let mut req = fidl::new_empty!(
3098                            fidl::encoding::EmptyPayload,
3099                            fidl::encoding::DefaultFuchsiaResourceDialect
3100                        );
3101                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3102                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3103                        Ok(PortRequest::Remove { control_handle })
3104                    }
3105                    _ => Err(fidl::Error::UnknownOrdinal {
3106                        ordinal: header.ordinal,
3107                        protocol_name: <PortMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3108                    }),
3109                }))
3110            },
3111        )
3112    }
3113}
3114
3115/// A logical port attached to a [`fuchsia.net.tun/Device`].
3116///
3117/// This protocol encodes the underlying object's lifetime in both directions;
3118/// the underlying object is alive iff both ends of the protocol are open. That
3119/// is:
3120///
3121/// - Closing the client end causes the object to be destroyed.
3122/// - Observing a closure of the server end indicates the object no longer
3123/// exists.
3124#[derive(Debug)]
3125pub enum PortRequest {
3126    /// Gets the port internal state.
3127    ///
3128    /// - response `state` a snapshot of the port's internal state.
3129    GetState { responder: PortGetStateResponder },
3130    /// Observes changes to internal state.
3131    ///
3132    /// The first call always returns the current internal state, subsequent
3133    /// calls block until the internal state differs from the last one returned
3134    /// from a `WatchState` call.
3135    ///
3136    /// `WatchState` does not provide full history of internal state changes. It
3137    /// is possible that intermediary internal state changes are missed in
3138    /// between `WatchState` calls.
3139    ///
3140    /// - response `state` the latest observed port internal state.
3141    WatchState { responder: PortWatchStateResponder },
3142    /// Sets the port's online status.
3143    ///
3144    /// The online status is visible through
3145    /// [`fuchsia.hardware.network/Port.GetStatus`]. Once `SetOnline` returns,
3146    /// the status reported through `GetStatus` is guaranteed to be the one
3147    /// passed to `SetOnline`.
3148    ///
3149    /// + request `online` desired port online state.
3150    SetOnline { online: bool, responder: PortSetOnlineResponder },
3151    /// Connects to the underlying device port.
3152    ///
3153    /// + request `port` grants access to the device port.
3154    GetPort {
3155        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
3156        control_handle: PortControlHandle,
3157    },
3158    /// Triggers port removal.
3159    ///
3160    /// The client end will be closed once the server has completely cleaned up
3161    /// all resources related to the port. This is equivalent to simply dropping
3162    /// the client end, but provides callers with a signal of when removal is
3163    /// complete, allowing port identifiers to be reused, for example.
3164    Remove { control_handle: PortControlHandle },
3165}
3166
3167impl PortRequest {
3168    #[allow(irrefutable_let_patterns)]
3169    pub fn into_get_state(self) -> Option<(PortGetStateResponder)> {
3170        if let PortRequest::GetState { responder } = self {
3171            Some((responder))
3172        } else {
3173            None
3174        }
3175    }
3176
3177    #[allow(irrefutable_let_patterns)]
3178    pub fn into_watch_state(self) -> Option<(PortWatchStateResponder)> {
3179        if let PortRequest::WatchState { responder } = self {
3180            Some((responder))
3181        } else {
3182            None
3183        }
3184    }
3185
3186    #[allow(irrefutable_let_patterns)]
3187    pub fn into_set_online(self) -> Option<(bool, PortSetOnlineResponder)> {
3188        if let PortRequest::SetOnline { online, responder } = self {
3189            Some((online, responder))
3190        } else {
3191            None
3192        }
3193    }
3194
3195    #[allow(irrefutable_let_patterns)]
3196    pub fn into_get_port(
3197        self,
3198    ) -> Option<(
3199        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
3200        PortControlHandle,
3201    )> {
3202        if let PortRequest::GetPort { port, control_handle } = self {
3203            Some((port, control_handle))
3204        } else {
3205            None
3206        }
3207    }
3208
3209    #[allow(irrefutable_let_patterns)]
3210    pub fn into_remove(self) -> Option<(PortControlHandle)> {
3211        if let PortRequest::Remove { control_handle } = self {
3212            Some((control_handle))
3213        } else {
3214            None
3215        }
3216    }
3217
3218    /// Name of the method defined in FIDL
3219    pub fn method_name(&self) -> &'static str {
3220        match *self {
3221            PortRequest::GetState { .. } => "get_state",
3222            PortRequest::WatchState { .. } => "watch_state",
3223            PortRequest::SetOnline { .. } => "set_online",
3224            PortRequest::GetPort { .. } => "get_port",
3225            PortRequest::Remove { .. } => "remove",
3226        }
3227    }
3228}
3229
3230#[derive(Debug, Clone)]
3231pub struct PortControlHandle {
3232    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3233}
3234
3235impl fidl::endpoints::ControlHandle for PortControlHandle {
3236    fn shutdown(&self) {
3237        self.inner.shutdown()
3238    }
3239    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3240        self.inner.shutdown_with_epitaph(status)
3241    }
3242
3243    fn is_closed(&self) -> bool {
3244        self.inner.channel().is_closed()
3245    }
3246    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3247        self.inner.channel().on_closed()
3248    }
3249
3250    #[cfg(target_os = "fuchsia")]
3251    fn signal_peer(
3252        &self,
3253        clear_mask: zx::Signals,
3254        set_mask: zx::Signals,
3255    ) -> Result<(), zx_status::Status> {
3256        use fidl::Peered;
3257        self.inner.channel().signal_peer(clear_mask, set_mask)
3258    }
3259}
3260
3261impl PortControlHandle {}
3262
3263#[must_use = "FIDL methods require a response to be sent"]
3264#[derive(Debug)]
3265pub struct PortGetStateResponder {
3266    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3267    tx_id: u32,
3268}
3269
3270/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3271/// if the responder is dropped without sending a response, so that the client
3272/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3273impl std::ops::Drop for PortGetStateResponder {
3274    fn drop(&mut self) {
3275        self.control_handle.shutdown();
3276        // Safety: drops once, never accessed again
3277        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3278    }
3279}
3280
3281impl fidl::endpoints::Responder for PortGetStateResponder {
3282    type ControlHandle = PortControlHandle;
3283
3284    fn control_handle(&self) -> &PortControlHandle {
3285        &self.control_handle
3286    }
3287
3288    fn drop_without_shutdown(mut self) {
3289        // Safety: drops once, never accessed again due to mem::forget
3290        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3291        // Prevent Drop from running (which would shut down the channel)
3292        std::mem::forget(self);
3293    }
3294}
3295
3296impl PortGetStateResponder {
3297    /// Sends a response to the FIDL transaction.
3298    ///
3299    /// Sets the channel to shutdown if an error occurs.
3300    pub fn send(self, mut state: &InternalState) -> Result<(), fidl::Error> {
3301        let _result = self.send_raw(state);
3302        if _result.is_err() {
3303            self.control_handle.shutdown();
3304        }
3305        self.drop_without_shutdown();
3306        _result
3307    }
3308
3309    /// Similar to "send" but does not shutdown the channel if an error occurs.
3310    pub fn send_no_shutdown_on_err(self, mut state: &InternalState) -> Result<(), fidl::Error> {
3311        let _result = self.send_raw(state);
3312        self.drop_without_shutdown();
3313        _result
3314    }
3315
3316    fn send_raw(&self, mut state: &InternalState) -> Result<(), fidl::Error> {
3317        self.control_handle.inner.send::<PortGetStateResponse>(
3318            (state,),
3319            self.tx_id,
3320            0x5022630816212ed,
3321            fidl::encoding::DynamicFlags::empty(),
3322        )
3323    }
3324}
3325
3326#[must_use = "FIDL methods require a response to be sent"]
3327#[derive(Debug)]
3328pub struct PortWatchStateResponder {
3329    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3330    tx_id: u32,
3331}
3332
3333/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3334/// if the responder is dropped without sending a response, so that the client
3335/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3336impl std::ops::Drop for PortWatchStateResponder {
3337    fn drop(&mut self) {
3338        self.control_handle.shutdown();
3339        // Safety: drops once, never accessed again
3340        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3341    }
3342}
3343
3344impl fidl::endpoints::Responder for PortWatchStateResponder {
3345    type ControlHandle = PortControlHandle;
3346
3347    fn control_handle(&self) -> &PortControlHandle {
3348        &self.control_handle
3349    }
3350
3351    fn drop_without_shutdown(mut self) {
3352        // Safety: drops once, never accessed again due to mem::forget
3353        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3354        // Prevent Drop from running (which would shut down the channel)
3355        std::mem::forget(self);
3356    }
3357}
3358
3359impl PortWatchStateResponder {
3360    /// Sends a response to the FIDL transaction.
3361    ///
3362    /// Sets the channel to shutdown if an error occurs.
3363    pub fn send(self, mut state: &InternalState) -> Result<(), fidl::Error> {
3364        let _result = self.send_raw(state);
3365        if _result.is_err() {
3366            self.control_handle.shutdown();
3367        }
3368        self.drop_without_shutdown();
3369        _result
3370    }
3371
3372    /// Similar to "send" but does not shutdown the channel if an error occurs.
3373    pub fn send_no_shutdown_on_err(self, mut state: &InternalState) -> Result<(), fidl::Error> {
3374        let _result = self.send_raw(state);
3375        self.drop_without_shutdown();
3376        _result
3377    }
3378
3379    fn send_raw(&self, mut state: &InternalState) -> Result<(), fidl::Error> {
3380        self.control_handle.inner.send::<PortWatchStateResponse>(
3381            (state,),
3382            self.tx_id,
3383            0x74d3c94c96e2b605,
3384            fidl::encoding::DynamicFlags::empty(),
3385        )
3386    }
3387}
3388
3389#[must_use = "FIDL methods require a response to be sent"]
3390#[derive(Debug)]
3391pub struct PortSetOnlineResponder {
3392    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3393    tx_id: u32,
3394}
3395
3396/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3397/// if the responder is dropped without sending a response, so that the client
3398/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3399impl std::ops::Drop for PortSetOnlineResponder {
3400    fn drop(&mut self) {
3401        self.control_handle.shutdown();
3402        // Safety: drops once, never accessed again
3403        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3404    }
3405}
3406
3407impl fidl::endpoints::Responder for PortSetOnlineResponder {
3408    type ControlHandle = PortControlHandle;
3409
3410    fn control_handle(&self) -> &PortControlHandle {
3411        &self.control_handle
3412    }
3413
3414    fn drop_without_shutdown(mut self) {
3415        // Safety: drops once, never accessed again due to mem::forget
3416        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3417        // Prevent Drop from running (which would shut down the channel)
3418        std::mem::forget(self);
3419    }
3420}
3421
3422impl PortSetOnlineResponder {
3423    /// Sends a response to the FIDL transaction.
3424    ///
3425    /// Sets the channel to shutdown if an error occurs.
3426    pub fn send(self) -> Result<(), fidl::Error> {
3427        let _result = self.send_raw();
3428        if _result.is_err() {
3429            self.control_handle.shutdown();
3430        }
3431        self.drop_without_shutdown();
3432        _result
3433    }
3434
3435    /// Similar to "send" but does not shutdown the channel if an error occurs.
3436    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3437        let _result = self.send_raw();
3438        self.drop_without_shutdown();
3439        _result
3440    }
3441
3442    fn send_raw(&self) -> Result<(), fidl::Error> {
3443        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3444            (),
3445            self.tx_id,
3446            0x734f83793ce86e6c,
3447            fidl::encoding::DynamicFlags::empty(),
3448        )
3449    }
3450}
3451
3452mod internal {
3453    use super::*;
3454
3455    impl fidl::encoding::ResourceTypeMarker for ControlCreateDeviceRequest {
3456        type Borrowed<'a> = &'a mut Self;
3457        fn take_or_borrow<'a>(
3458            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3459        ) -> Self::Borrowed<'a> {
3460            value
3461        }
3462    }
3463
3464    unsafe impl fidl::encoding::TypeMarker for ControlCreateDeviceRequest {
3465        type Owned = Self;
3466
3467        #[inline(always)]
3468        fn inline_align(_context: fidl::encoding::Context) -> usize {
3469            8
3470        }
3471
3472        #[inline(always)]
3473        fn inline_size(_context: fidl::encoding::Context) -> usize {
3474            24
3475        }
3476    }
3477
3478    unsafe impl
3479        fidl::encoding::Encode<
3480            ControlCreateDeviceRequest,
3481            fidl::encoding::DefaultFuchsiaResourceDialect,
3482        > for &mut ControlCreateDeviceRequest
3483    {
3484        #[inline]
3485        unsafe fn encode(
3486            self,
3487            encoder: &mut fidl::encoding::Encoder<
3488                '_,
3489                fidl::encoding::DefaultFuchsiaResourceDialect,
3490            >,
3491            offset: usize,
3492            _depth: fidl::encoding::Depth,
3493        ) -> fidl::Result<()> {
3494            encoder.debug_check_bounds::<ControlCreateDeviceRequest>(offset);
3495            // Delegate to tuple encoding.
3496            fidl::encoding::Encode::<ControlCreateDeviceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3497                (
3498                    <DeviceConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
3499                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.device),
3500                ),
3501                encoder, offset, _depth
3502            )
3503        }
3504    }
3505    unsafe impl<
3506            T0: fidl::encoding::Encode<DeviceConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
3507            T1: fidl::encoding::Encode<
3508                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
3509                fidl::encoding::DefaultFuchsiaResourceDialect,
3510            >,
3511        >
3512        fidl::encoding::Encode<
3513            ControlCreateDeviceRequest,
3514            fidl::encoding::DefaultFuchsiaResourceDialect,
3515        > for (T0, T1)
3516    {
3517        #[inline]
3518        unsafe fn encode(
3519            self,
3520            encoder: &mut fidl::encoding::Encoder<
3521                '_,
3522                fidl::encoding::DefaultFuchsiaResourceDialect,
3523            >,
3524            offset: usize,
3525            depth: fidl::encoding::Depth,
3526        ) -> fidl::Result<()> {
3527            encoder.debug_check_bounds::<ControlCreateDeviceRequest>(offset);
3528            // Zero out padding regions. There's no need to apply masks
3529            // because the unmasked parts will be overwritten by fields.
3530            unsafe {
3531                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3532                (ptr as *mut u64).write_unaligned(0);
3533            }
3534            // Write the fields.
3535            self.0.encode(encoder, offset + 0, depth)?;
3536            self.1.encode(encoder, offset + 16, depth)?;
3537            Ok(())
3538        }
3539    }
3540
3541    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3542        for ControlCreateDeviceRequest
3543    {
3544        #[inline(always)]
3545        fn new_empty() -> Self {
3546            Self {
3547                config: fidl::new_empty!(
3548                    DeviceConfig,
3549                    fidl::encoding::DefaultFuchsiaResourceDialect
3550                ),
3551                device: fidl::new_empty!(
3552                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
3553                    fidl::encoding::DefaultFuchsiaResourceDialect
3554                ),
3555            }
3556        }
3557
3558        #[inline]
3559        unsafe fn decode(
3560            &mut self,
3561            decoder: &mut fidl::encoding::Decoder<
3562                '_,
3563                fidl::encoding::DefaultFuchsiaResourceDialect,
3564            >,
3565            offset: usize,
3566            _depth: fidl::encoding::Depth,
3567        ) -> fidl::Result<()> {
3568            decoder.debug_check_bounds::<Self>(offset);
3569            // Verify that padding bytes are zero.
3570            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3571            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3572            let mask = 0xffffffff00000000u64;
3573            let maskedval = padval & mask;
3574            if maskedval != 0 {
3575                return Err(fidl::Error::NonZeroPadding {
3576                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3577                });
3578            }
3579            fidl::decode!(
3580                DeviceConfig,
3581                fidl::encoding::DefaultFuchsiaResourceDialect,
3582                &mut self.config,
3583                decoder,
3584                offset + 0,
3585                _depth
3586            )?;
3587            fidl::decode!(
3588                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
3589                fidl::encoding::DefaultFuchsiaResourceDialect,
3590                &mut self.device,
3591                decoder,
3592                offset + 16,
3593                _depth
3594            )?;
3595            Ok(())
3596        }
3597    }
3598
3599    impl fidl::encoding::ResourceTypeMarker for ControlCreatePairRequest {
3600        type Borrowed<'a> = &'a mut Self;
3601        fn take_or_borrow<'a>(
3602            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3603        ) -> Self::Borrowed<'a> {
3604            value
3605        }
3606    }
3607
3608    unsafe impl fidl::encoding::TypeMarker for ControlCreatePairRequest {
3609        type Owned = Self;
3610
3611        #[inline(always)]
3612        fn inline_align(_context: fidl::encoding::Context) -> usize {
3613            8
3614        }
3615
3616        #[inline(always)]
3617        fn inline_size(_context: fidl::encoding::Context) -> usize {
3618            24
3619        }
3620    }
3621
3622    unsafe impl
3623        fidl::encoding::Encode<
3624            ControlCreatePairRequest,
3625            fidl::encoding::DefaultFuchsiaResourceDialect,
3626        > for &mut ControlCreatePairRequest
3627    {
3628        #[inline]
3629        unsafe fn encode(
3630            self,
3631            encoder: &mut fidl::encoding::Encoder<
3632                '_,
3633                fidl::encoding::DefaultFuchsiaResourceDialect,
3634            >,
3635            offset: usize,
3636            _depth: fidl::encoding::Depth,
3637        ) -> fidl::Result<()> {
3638            encoder.debug_check_bounds::<ControlCreatePairRequest>(offset);
3639            // Delegate to tuple encoding.
3640            fidl::encoding::Encode::<ControlCreatePairRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3641                (
3642                    <DevicePairConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
3643                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DevicePairMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.device_pair),
3644                ),
3645                encoder, offset, _depth
3646            )
3647        }
3648    }
3649    unsafe impl<
3650            T0: fidl::encoding::Encode<DevicePairConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
3651            T1: fidl::encoding::Encode<
3652                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DevicePairMarker>>,
3653                fidl::encoding::DefaultFuchsiaResourceDialect,
3654            >,
3655        >
3656        fidl::encoding::Encode<
3657            ControlCreatePairRequest,
3658            fidl::encoding::DefaultFuchsiaResourceDialect,
3659        > for (T0, T1)
3660    {
3661        #[inline]
3662        unsafe fn encode(
3663            self,
3664            encoder: &mut fidl::encoding::Encoder<
3665                '_,
3666                fidl::encoding::DefaultFuchsiaResourceDialect,
3667            >,
3668            offset: usize,
3669            depth: fidl::encoding::Depth,
3670        ) -> fidl::Result<()> {
3671            encoder.debug_check_bounds::<ControlCreatePairRequest>(offset);
3672            // Zero out padding regions. There's no need to apply masks
3673            // because the unmasked parts will be overwritten by fields.
3674            unsafe {
3675                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3676                (ptr as *mut u64).write_unaligned(0);
3677            }
3678            // Write the fields.
3679            self.0.encode(encoder, offset + 0, depth)?;
3680            self.1.encode(encoder, offset + 16, depth)?;
3681            Ok(())
3682        }
3683    }
3684
3685    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3686        for ControlCreatePairRequest
3687    {
3688        #[inline(always)]
3689        fn new_empty() -> Self {
3690            Self {
3691                config: fidl::new_empty!(
3692                    DevicePairConfig,
3693                    fidl::encoding::DefaultFuchsiaResourceDialect
3694                ),
3695                device_pair: fidl::new_empty!(
3696                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DevicePairMarker>>,
3697                    fidl::encoding::DefaultFuchsiaResourceDialect
3698                ),
3699            }
3700        }
3701
3702        #[inline]
3703        unsafe fn decode(
3704            &mut self,
3705            decoder: &mut fidl::encoding::Decoder<
3706                '_,
3707                fidl::encoding::DefaultFuchsiaResourceDialect,
3708            >,
3709            offset: usize,
3710            _depth: fidl::encoding::Depth,
3711        ) -> fidl::Result<()> {
3712            decoder.debug_check_bounds::<Self>(offset);
3713            // Verify that padding bytes are zero.
3714            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3715            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3716            let mask = 0xffffffff00000000u64;
3717            let maskedval = padval & mask;
3718            if maskedval != 0 {
3719                return Err(fidl::Error::NonZeroPadding {
3720                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3721                });
3722            }
3723            fidl::decode!(
3724                DevicePairConfig,
3725                fidl::encoding::DefaultFuchsiaResourceDialect,
3726                &mut self.config,
3727                decoder,
3728                offset + 0,
3729                _depth
3730            )?;
3731            fidl::decode!(
3732                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DevicePairMarker>>,
3733                fidl::encoding::DefaultFuchsiaResourceDialect,
3734                &mut self.device_pair,
3735                decoder,
3736                offset + 16,
3737                _depth
3738            )?;
3739            Ok(())
3740        }
3741    }
3742
3743    impl fidl::encoding::ResourceTypeMarker for DeviceAddPortRequest {
3744        type Borrowed<'a> = &'a mut Self;
3745        fn take_or_borrow<'a>(
3746            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3747        ) -> Self::Borrowed<'a> {
3748            value
3749        }
3750    }
3751
3752    unsafe impl fidl::encoding::TypeMarker for DeviceAddPortRequest {
3753        type Owned = Self;
3754
3755        #[inline(always)]
3756        fn inline_align(_context: fidl::encoding::Context) -> usize {
3757            8
3758        }
3759
3760        #[inline(always)]
3761        fn inline_size(_context: fidl::encoding::Context) -> usize {
3762            24
3763        }
3764    }
3765
3766    unsafe impl
3767        fidl::encoding::Encode<DeviceAddPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3768        for &mut DeviceAddPortRequest
3769    {
3770        #[inline]
3771        unsafe fn encode(
3772            self,
3773            encoder: &mut fidl::encoding::Encoder<
3774                '_,
3775                fidl::encoding::DefaultFuchsiaResourceDialect,
3776            >,
3777            offset: usize,
3778            _depth: fidl::encoding::Depth,
3779        ) -> fidl::Result<()> {
3780            encoder.debug_check_bounds::<DeviceAddPortRequest>(offset);
3781            // Delegate to tuple encoding.
3782            fidl::encoding::Encode::<DeviceAddPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3783                (
3784                    <DevicePortConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
3785                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.port),
3786                ),
3787                encoder, offset, _depth
3788            )
3789        }
3790    }
3791    unsafe impl<
3792            T0: fidl::encoding::Encode<DevicePortConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
3793            T1: fidl::encoding::Encode<
3794                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
3795                fidl::encoding::DefaultFuchsiaResourceDialect,
3796            >,
3797        >
3798        fidl::encoding::Encode<DeviceAddPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3799        for (T0, T1)
3800    {
3801        #[inline]
3802        unsafe fn encode(
3803            self,
3804            encoder: &mut fidl::encoding::Encoder<
3805                '_,
3806                fidl::encoding::DefaultFuchsiaResourceDialect,
3807            >,
3808            offset: usize,
3809            depth: fidl::encoding::Depth,
3810        ) -> fidl::Result<()> {
3811            encoder.debug_check_bounds::<DeviceAddPortRequest>(offset);
3812            // Zero out padding regions. There's no need to apply masks
3813            // because the unmasked parts will be overwritten by fields.
3814            unsafe {
3815                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3816                (ptr as *mut u64).write_unaligned(0);
3817            }
3818            // Write the fields.
3819            self.0.encode(encoder, offset + 0, depth)?;
3820            self.1.encode(encoder, offset + 16, depth)?;
3821            Ok(())
3822        }
3823    }
3824
3825    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3826        for DeviceAddPortRequest
3827    {
3828        #[inline(always)]
3829        fn new_empty() -> Self {
3830            Self {
3831                config: fidl::new_empty!(
3832                    DevicePortConfig,
3833                    fidl::encoding::DefaultFuchsiaResourceDialect
3834                ),
3835                port: fidl::new_empty!(
3836                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
3837                    fidl::encoding::DefaultFuchsiaResourceDialect
3838                ),
3839            }
3840        }
3841
3842        #[inline]
3843        unsafe fn decode(
3844            &mut self,
3845            decoder: &mut fidl::encoding::Decoder<
3846                '_,
3847                fidl::encoding::DefaultFuchsiaResourceDialect,
3848            >,
3849            offset: usize,
3850            _depth: fidl::encoding::Depth,
3851        ) -> fidl::Result<()> {
3852            decoder.debug_check_bounds::<Self>(offset);
3853            // Verify that padding bytes are zero.
3854            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3855            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3856            let mask = 0xffffffff00000000u64;
3857            let maskedval = padval & mask;
3858            if maskedval != 0 {
3859                return Err(fidl::Error::NonZeroPadding {
3860                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3861                });
3862            }
3863            fidl::decode!(
3864                DevicePortConfig,
3865                fidl::encoding::DefaultFuchsiaResourceDialect,
3866                &mut self.config,
3867                decoder,
3868                offset + 0,
3869                _depth
3870            )?;
3871            fidl::decode!(
3872                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
3873                fidl::encoding::DefaultFuchsiaResourceDialect,
3874                &mut self.port,
3875                decoder,
3876                offset + 16,
3877                _depth
3878            )?;
3879            Ok(())
3880        }
3881    }
3882
3883    impl fidl::encoding::ResourceTypeMarker for DeviceDelegateRxLeaseRequest {
3884        type Borrowed<'a> = &'a mut Self;
3885        fn take_or_borrow<'a>(
3886            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3887        ) -> Self::Borrowed<'a> {
3888            value
3889        }
3890    }
3891
3892    unsafe impl fidl::encoding::TypeMarker for DeviceDelegateRxLeaseRequest {
3893        type Owned = Self;
3894
3895        #[inline(always)]
3896        fn inline_align(_context: fidl::encoding::Context) -> usize {
3897            8
3898        }
3899
3900        #[inline(always)]
3901        fn inline_size(_context: fidl::encoding::Context) -> usize {
3902            16
3903        }
3904    }
3905
3906    unsafe impl
3907        fidl::encoding::Encode<
3908            DeviceDelegateRxLeaseRequest,
3909            fidl::encoding::DefaultFuchsiaResourceDialect,
3910        > for &mut DeviceDelegateRxLeaseRequest
3911    {
3912        #[inline]
3913        unsafe fn encode(
3914            self,
3915            encoder: &mut fidl::encoding::Encoder<
3916                '_,
3917                fidl::encoding::DefaultFuchsiaResourceDialect,
3918            >,
3919            offset: usize,
3920            _depth: fidl::encoding::Depth,
3921        ) -> fidl::Result<()> {
3922            encoder.debug_check_bounds::<DeviceDelegateRxLeaseRequest>(offset);
3923            // Delegate to tuple encoding.
3924            fidl::encoding::Encode::<DeviceDelegateRxLeaseRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3925                (
3926                    <fidl_fuchsia_hardware_network::DelegatedRxLease as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.lease),
3927                ),
3928                encoder, offset, _depth
3929            )
3930        }
3931    }
3932    unsafe impl<
3933            T0: fidl::encoding::Encode<
3934                fidl_fuchsia_hardware_network::DelegatedRxLease,
3935                fidl::encoding::DefaultFuchsiaResourceDialect,
3936            >,
3937        >
3938        fidl::encoding::Encode<
3939            DeviceDelegateRxLeaseRequest,
3940            fidl::encoding::DefaultFuchsiaResourceDialect,
3941        > for (T0,)
3942    {
3943        #[inline]
3944        unsafe fn encode(
3945            self,
3946            encoder: &mut fidl::encoding::Encoder<
3947                '_,
3948                fidl::encoding::DefaultFuchsiaResourceDialect,
3949            >,
3950            offset: usize,
3951            depth: fidl::encoding::Depth,
3952        ) -> fidl::Result<()> {
3953            encoder.debug_check_bounds::<DeviceDelegateRxLeaseRequest>(offset);
3954            // Zero out padding regions. There's no need to apply masks
3955            // because the unmasked parts will be overwritten by fields.
3956            // Write the fields.
3957            self.0.encode(encoder, offset + 0, depth)?;
3958            Ok(())
3959        }
3960    }
3961
3962    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3963        for DeviceDelegateRxLeaseRequest
3964    {
3965        #[inline(always)]
3966        fn new_empty() -> Self {
3967            Self {
3968                lease: fidl::new_empty!(
3969                    fidl_fuchsia_hardware_network::DelegatedRxLease,
3970                    fidl::encoding::DefaultFuchsiaResourceDialect
3971                ),
3972            }
3973        }
3974
3975        #[inline]
3976        unsafe fn decode(
3977            &mut self,
3978            decoder: &mut fidl::encoding::Decoder<
3979                '_,
3980                fidl::encoding::DefaultFuchsiaResourceDialect,
3981            >,
3982            offset: usize,
3983            _depth: fidl::encoding::Depth,
3984        ) -> fidl::Result<()> {
3985            decoder.debug_check_bounds::<Self>(offset);
3986            // Verify that padding bytes are zero.
3987            fidl::decode!(
3988                fidl_fuchsia_hardware_network::DelegatedRxLease,
3989                fidl::encoding::DefaultFuchsiaResourceDialect,
3990                &mut self.lease,
3991                decoder,
3992                offset + 0,
3993                _depth
3994            )?;
3995            Ok(())
3996        }
3997    }
3998
3999    impl fidl::encoding::ResourceTypeMarker for DeviceGetDeviceRequest {
4000        type Borrowed<'a> = &'a mut Self;
4001        fn take_or_borrow<'a>(
4002            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4003        ) -> Self::Borrowed<'a> {
4004            value
4005        }
4006    }
4007
4008    unsafe impl fidl::encoding::TypeMarker for DeviceGetDeviceRequest {
4009        type Owned = Self;
4010
4011        #[inline(always)]
4012        fn inline_align(_context: fidl::encoding::Context) -> usize {
4013            4
4014        }
4015
4016        #[inline(always)]
4017        fn inline_size(_context: fidl::encoding::Context) -> usize {
4018            4
4019        }
4020    }
4021
4022    unsafe impl
4023        fidl::encoding::Encode<
4024            DeviceGetDeviceRequest,
4025            fidl::encoding::DefaultFuchsiaResourceDialect,
4026        > for &mut DeviceGetDeviceRequest
4027    {
4028        #[inline]
4029        unsafe fn encode(
4030            self,
4031            encoder: &mut fidl::encoding::Encoder<
4032                '_,
4033                fidl::encoding::DefaultFuchsiaResourceDialect,
4034            >,
4035            offset: usize,
4036            _depth: fidl::encoding::Depth,
4037        ) -> fidl::Result<()> {
4038            encoder.debug_check_bounds::<DeviceGetDeviceRequest>(offset);
4039            // Delegate to tuple encoding.
4040            fidl::encoding::Encode::<
4041                DeviceGetDeviceRequest,
4042                fidl::encoding::DefaultFuchsiaResourceDialect,
4043            >::encode(
4044                (<fidl::encoding::Endpoint<
4045                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4046                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4047                    &mut self.device
4048                ),),
4049                encoder,
4050                offset,
4051                _depth,
4052            )
4053        }
4054    }
4055    unsafe impl<
4056            T0: fidl::encoding::Encode<
4057                fidl::encoding::Endpoint<
4058                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4059                >,
4060                fidl::encoding::DefaultFuchsiaResourceDialect,
4061            >,
4062        >
4063        fidl::encoding::Encode<
4064            DeviceGetDeviceRequest,
4065            fidl::encoding::DefaultFuchsiaResourceDialect,
4066        > for (T0,)
4067    {
4068        #[inline]
4069        unsafe fn encode(
4070            self,
4071            encoder: &mut fidl::encoding::Encoder<
4072                '_,
4073                fidl::encoding::DefaultFuchsiaResourceDialect,
4074            >,
4075            offset: usize,
4076            depth: fidl::encoding::Depth,
4077        ) -> fidl::Result<()> {
4078            encoder.debug_check_bounds::<DeviceGetDeviceRequest>(offset);
4079            // Zero out padding regions. There's no need to apply masks
4080            // because the unmasked parts will be overwritten by fields.
4081            // Write the fields.
4082            self.0.encode(encoder, offset + 0, depth)?;
4083            Ok(())
4084        }
4085    }
4086
4087    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4088        for DeviceGetDeviceRequest
4089    {
4090        #[inline(always)]
4091        fn new_empty() -> Self {
4092            Self {
4093                device: fidl::new_empty!(
4094                    fidl::encoding::Endpoint<
4095                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4096                    >,
4097                    fidl::encoding::DefaultFuchsiaResourceDialect
4098                ),
4099            }
4100        }
4101
4102        #[inline]
4103        unsafe fn decode(
4104            &mut self,
4105            decoder: &mut fidl::encoding::Decoder<
4106                '_,
4107                fidl::encoding::DefaultFuchsiaResourceDialect,
4108            >,
4109            offset: usize,
4110            _depth: fidl::encoding::Depth,
4111        ) -> fidl::Result<()> {
4112            decoder.debug_check_bounds::<Self>(offset);
4113            // Verify that padding bytes are zero.
4114            fidl::decode!(
4115                fidl::encoding::Endpoint<
4116                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4117                >,
4118                fidl::encoding::DefaultFuchsiaResourceDialect,
4119                &mut self.device,
4120                decoder,
4121                offset + 0,
4122                _depth
4123            )?;
4124            Ok(())
4125        }
4126    }
4127
4128    impl fidl::encoding::ResourceTypeMarker for DeviceGetSignalsResponse {
4129        type Borrowed<'a> = &'a mut Self;
4130        fn take_or_borrow<'a>(
4131            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4132        ) -> Self::Borrowed<'a> {
4133            value
4134        }
4135    }
4136
4137    unsafe impl fidl::encoding::TypeMarker for DeviceGetSignalsResponse {
4138        type Owned = Self;
4139
4140        #[inline(always)]
4141        fn inline_align(_context: fidl::encoding::Context) -> usize {
4142            4
4143        }
4144
4145        #[inline(always)]
4146        fn inline_size(_context: fidl::encoding::Context) -> usize {
4147            4
4148        }
4149    }
4150
4151    unsafe impl
4152        fidl::encoding::Encode<
4153            DeviceGetSignalsResponse,
4154            fidl::encoding::DefaultFuchsiaResourceDialect,
4155        > for &mut DeviceGetSignalsResponse
4156    {
4157        #[inline]
4158        unsafe fn encode(
4159            self,
4160            encoder: &mut fidl::encoding::Encoder<
4161                '_,
4162                fidl::encoding::DefaultFuchsiaResourceDialect,
4163            >,
4164            offset: usize,
4165            _depth: fidl::encoding::Depth,
4166        ) -> fidl::Result<()> {
4167            encoder.debug_check_bounds::<DeviceGetSignalsResponse>(offset);
4168            // Delegate to tuple encoding.
4169            fidl::encoding::Encode::<
4170                DeviceGetSignalsResponse,
4171                fidl::encoding::DefaultFuchsiaResourceDialect,
4172            >::encode(
4173                (<fidl::encoding::HandleType<
4174                    fidl::EventPair,
4175                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4176                    2147483648,
4177                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4178                    &mut self.signals
4179                ),),
4180                encoder,
4181                offset,
4182                _depth,
4183            )
4184        }
4185    }
4186    unsafe impl<
4187            T0: fidl::encoding::Encode<
4188                fidl::encoding::HandleType<
4189                    fidl::EventPair,
4190                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4191                    2147483648,
4192                >,
4193                fidl::encoding::DefaultFuchsiaResourceDialect,
4194            >,
4195        >
4196        fidl::encoding::Encode<
4197            DeviceGetSignalsResponse,
4198            fidl::encoding::DefaultFuchsiaResourceDialect,
4199        > for (T0,)
4200    {
4201        #[inline]
4202        unsafe fn encode(
4203            self,
4204            encoder: &mut fidl::encoding::Encoder<
4205                '_,
4206                fidl::encoding::DefaultFuchsiaResourceDialect,
4207            >,
4208            offset: usize,
4209            depth: fidl::encoding::Depth,
4210        ) -> fidl::Result<()> {
4211            encoder.debug_check_bounds::<DeviceGetSignalsResponse>(offset);
4212            // Zero out padding regions. There's no need to apply masks
4213            // because the unmasked parts will be overwritten by fields.
4214            // Write the fields.
4215            self.0.encode(encoder, offset + 0, depth)?;
4216            Ok(())
4217        }
4218    }
4219
4220    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4221        for DeviceGetSignalsResponse
4222    {
4223        #[inline(always)]
4224        fn new_empty() -> Self {
4225            Self {
4226                signals: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
4227            }
4228        }
4229
4230        #[inline]
4231        unsafe fn decode(
4232            &mut self,
4233            decoder: &mut fidl::encoding::Decoder<
4234                '_,
4235                fidl::encoding::DefaultFuchsiaResourceDialect,
4236            >,
4237            offset: usize,
4238            _depth: fidl::encoding::Depth,
4239        ) -> fidl::Result<()> {
4240            decoder.debug_check_bounds::<Self>(offset);
4241            // Verify that padding bytes are zero.
4242            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.signals, decoder, offset + 0, _depth)?;
4243            Ok(())
4244        }
4245    }
4246
4247    impl fidl::encoding::ResourceTypeMarker for DevicePairGetLeftPortRequest {
4248        type Borrowed<'a> = &'a mut Self;
4249        fn take_or_borrow<'a>(
4250            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4251        ) -> Self::Borrowed<'a> {
4252            value
4253        }
4254    }
4255
4256    unsafe impl fidl::encoding::TypeMarker for DevicePairGetLeftPortRequest {
4257        type Owned = Self;
4258
4259        #[inline(always)]
4260        fn inline_align(_context: fidl::encoding::Context) -> usize {
4261            4
4262        }
4263
4264        #[inline(always)]
4265        fn inline_size(_context: fidl::encoding::Context) -> usize {
4266            8
4267        }
4268    }
4269
4270    unsafe impl
4271        fidl::encoding::Encode<
4272            DevicePairGetLeftPortRequest,
4273            fidl::encoding::DefaultFuchsiaResourceDialect,
4274        > for &mut DevicePairGetLeftPortRequest
4275    {
4276        #[inline]
4277        unsafe fn encode(
4278            self,
4279            encoder: &mut fidl::encoding::Encoder<
4280                '_,
4281                fidl::encoding::DefaultFuchsiaResourceDialect,
4282            >,
4283            offset: usize,
4284            _depth: fidl::encoding::Depth,
4285        ) -> fidl::Result<()> {
4286            encoder.debug_check_bounds::<DevicePairGetLeftPortRequest>(offset);
4287            // Delegate to tuple encoding.
4288            fidl::encoding::Encode::<
4289                DevicePairGetLeftPortRequest,
4290                fidl::encoding::DefaultFuchsiaResourceDialect,
4291            >::encode(
4292                (
4293                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
4294                    <fidl::encoding::Endpoint<
4295                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4296                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4297                        &mut self.port
4298                    ),
4299                ),
4300                encoder,
4301                offset,
4302                _depth,
4303            )
4304        }
4305    }
4306    unsafe impl<
4307            T0: fidl::encoding::Encode<u8, fidl::encoding::DefaultFuchsiaResourceDialect>,
4308            T1: fidl::encoding::Encode<
4309                fidl::encoding::Endpoint<
4310                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4311                >,
4312                fidl::encoding::DefaultFuchsiaResourceDialect,
4313            >,
4314        >
4315        fidl::encoding::Encode<
4316            DevicePairGetLeftPortRequest,
4317            fidl::encoding::DefaultFuchsiaResourceDialect,
4318        > for (T0, T1)
4319    {
4320        #[inline]
4321        unsafe fn encode(
4322            self,
4323            encoder: &mut fidl::encoding::Encoder<
4324                '_,
4325                fidl::encoding::DefaultFuchsiaResourceDialect,
4326            >,
4327            offset: usize,
4328            depth: fidl::encoding::Depth,
4329        ) -> fidl::Result<()> {
4330            encoder.debug_check_bounds::<DevicePairGetLeftPortRequest>(offset);
4331            // Zero out padding regions. There's no need to apply masks
4332            // because the unmasked parts will be overwritten by fields.
4333            unsafe {
4334                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
4335                (ptr as *mut u32).write_unaligned(0);
4336            }
4337            // Write the fields.
4338            self.0.encode(encoder, offset + 0, depth)?;
4339            self.1.encode(encoder, offset + 4, depth)?;
4340            Ok(())
4341        }
4342    }
4343
4344    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4345        for DevicePairGetLeftPortRequest
4346    {
4347        #[inline(always)]
4348        fn new_empty() -> Self {
4349            Self {
4350                id: fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect),
4351                port: fidl::new_empty!(
4352                    fidl::encoding::Endpoint<
4353                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4354                    >,
4355                    fidl::encoding::DefaultFuchsiaResourceDialect
4356                ),
4357            }
4358        }
4359
4360        #[inline]
4361        unsafe fn decode(
4362            &mut self,
4363            decoder: &mut fidl::encoding::Decoder<
4364                '_,
4365                fidl::encoding::DefaultFuchsiaResourceDialect,
4366            >,
4367            offset: usize,
4368            _depth: fidl::encoding::Depth,
4369        ) -> fidl::Result<()> {
4370            decoder.debug_check_bounds::<Self>(offset);
4371            // Verify that padding bytes are zero.
4372            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
4373            let padval = unsafe { (ptr as *const u32).read_unaligned() };
4374            let mask = 0xffffff00u32;
4375            let maskedval = padval & mask;
4376            if maskedval != 0 {
4377                return Err(fidl::Error::NonZeroPadding {
4378                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
4379                });
4380            }
4381            fidl::decode!(
4382                u8,
4383                fidl::encoding::DefaultFuchsiaResourceDialect,
4384                &mut self.id,
4385                decoder,
4386                offset + 0,
4387                _depth
4388            )?;
4389            fidl::decode!(
4390                fidl::encoding::Endpoint<
4391                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4392                >,
4393                fidl::encoding::DefaultFuchsiaResourceDialect,
4394                &mut self.port,
4395                decoder,
4396                offset + 4,
4397                _depth
4398            )?;
4399            Ok(())
4400        }
4401    }
4402
4403    impl fidl::encoding::ResourceTypeMarker for DevicePairGetLeftRequest {
4404        type Borrowed<'a> = &'a mut Self;
4405        fn take_or_borrow<'a>(
4406            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4407        ) -> Self::Borrowed<'a> {
4408            value
4409        }
4410    }
4411
4412    unsafe impl fidl::encoding::TypeMarker for DevicePairGetLeftRequest {
4413        type Owned = Self;
4414
4415        #[inline(always)]
4416        fn inline_align(_context: fidl::encoding::Context) -> usize {
4417            4
4418        }
4419
4420        #[inline(always)]
4421        fn inline_size(_context: fidl::encoding::Context) -> usize {
4422            4
4423        }
4424    }
4425
4426    unsafe impl
4427        fidl::encoding::Encode<
4428            DevicePairGetLeftRequest,
4429            fidl::encoding::DefaultFuchsiaResourceDialect,
4430        > for &mut DevicePairGetLeftRequest
4431    {
4432        #[inline]
4433        unsafe fn encode(
4434            self,
4435            encoder: &mut fidl::encoding::Encoder<
4436                '_,
4437                fidl::encoding::DefaultFuchsiaResourceDialect,
4438            >,
4439            offset: usize,
4440            _depth: fidl::encoding::Depth,
4441        ) -> fidl::Result<()> {
4442            encoder.debug_check_bounds::<DevicePairGetLeftRequest>(offset);
4443            // Delegate to tuple encoding.
4444            fidl::encoding::Encode::<
4445                DevicePairGetLeftRequest,
4446                fidl::encoding::DefaultFuchsiaResourceDialect,
4447            >::encode(
4448                (<fidl::encoding::Endpoint<
4449                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4450                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4451                    &mut self.device
4452                ),),
4453                encoder,
4454                offset,
4455                _depth,
4456            )
4457        }
4458    }
4459    unsafe impl<
4460            T0: fidl::encoding::Encode<
4461                fidl::encoding::Endpoint<
4462                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4463                >,
4464                fidl::encoding::DefaultFuchsiaResourceDialect,
4465            >,
4466        >
4467        fidl::encoding::Encode<
4468            DevicePairGetLeftRequest,
4469            fidl::encoding::DefaultFuchsiaResourceDialect,
4470        > for (T0,)
4471    {
4472        #[inline]
4473        unsafe fn encode(
4474            self,
4475            encoder: &mut fidl::encoding::Encoder<
4476                '_,
4477                fidl::encoding::DefaultFuchsiaResourceDialect,
4478            >,
4479            offset: usize,
4480            depth: fidl::encoding::Depth,
4481        ) -> fidl::Result<()> {
4482            encoder.debug_check_bounds::<DevicePairGetLeftRequest>(offset);
4483            // Zero out padding regions. There's no need to apply masks
4484            // because the unmasked parts will be overwritten by fields.
4485            // Write the fields.
4486            self.0.encode(encoder, offset + 0, depth)?;
4487            Ok(())
4488        }
4489    }
4490
4491    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4492        for DevicePairGetLeftRequest
4493    {
4494        #[inline(always)]
4495        fn new_empty() -> Self {
4496            Self {
4497                device: fidl::new_empty!(
4498                    fidl::encoding::Endpoint<
4499                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4500                    >,
4501                    fidl::encoding::DefaultFuchsiaResourceDialect
4502                ),
4503            }
4504        }
4505
4506        #[inline]
4507        unsafe fn decode(
4508            &mut self,
4509            decoder: &mut fidl::encoding::Decoder<
4510                '_,
4511                fidl::encoding::DefaultFuchsiaResourceDialect,
4512            >,
4513            offset: usize,
4514            _depth: fidl::encoding::Depth,
4515        ) -> fidl::Result<()> {
4516            decoder.debug_check_bounds::<Self>(offset);
4517            // Verify that padding bytes are zero.
4518            fidl::decode!(
4519                fidl::encoding::Endpoint<
4520                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4521                >,
4522                fidl::encoding::DefaultFuchsiaResourceDialect,
4523                &mut self.device,
4524                decoder,
4525                offset + 0,
4526                _depth
4527            )?;
4528            Ok(())
4529        }
4530    }
4531
4532    impl fidl::encoding::ResourceTypeMarker for DevicePairGetRightPortRequest {
4533        type Borrowed<'a> = &'a mut Self;
4534        fn take_or_borrow<'a>(
4535            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4536        ) -> Self::Borrowed<'a> {
4537            value
4538        }
4539    }
4540
4541    unsafe impl fidl::encoding::TypeMarker for DevicePairGetRightPortRequest {
4542        type Owned = Self;
4543
4544        #[inline(always)]
4545        fn inline_align(_context: fidl::encoding::Context) -> usize {
4546            4
4547        }
4548
4549        #[inline(always)]
4550        fn inline_size(_context: fidl::encoding::Context) -> usize {
4551            8
4552        }
4553    }
4554
4555    unsafe impl
4556        fidl::encoding::Encode<
4557            DevicePairGetRightPortRequest,
4558            fidl::encoding::DefaultFuchsiaResourceDialect,
4559        > for &mut DevicePairGetRightPortRequest
4560    {
4561        #[inline]
4562        unsafe fn encode(
4563            self,
4564            encoder: &mut fidl::encoding::Encoder<
4565                '_,
4566                fidl::encoding::DefaultFuchsiaResourceDialect,
4567            >,
4568            offset: usize,
4569            _depth: fidl::encoding::Depth,
4570        ) -> fidl::Result<()> {
4571            encoder.debug_check_bounds::<DevicePairGetRightPortRequest>(offset);
4572            // Delegate to tuple encoding.
4573            fidl::encoding::Encode::<
4574                DevicePairGetRightPortRequest,
4575                fidl::encoding::DefaultFuchsiaResourceDialect,
4576            >::encode(
4577                (
4578                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
4579                    <fidl::encoding::Endpoint<
4580                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4581                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4582                        &mut self.port
4583                    ),
4584                ),
4585                encoder,
4586                offset,
4587                _depth,
4588            )
4589        }
4590    }
4591    unsafe impl<
4592            T0: fidl::encoding::Encode<u8, fidl::encoding::DefaultFuchsiaResourceDialect>,
4593            T1: fidl::encoding::Encode<
4594                fidl::encoding::Endpoint<
4595                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4596                >,
4597                fidl::encoding::DefaultFuchsiaResourceDialect,
4598            >,
4599        >
4600        fidl::encoding::Encode<
4601            DevicePairGetRightPortRequest,
4602            fidl::encoding::DefaultFuchsiaResourceDialect,
4603        > for (T0, T1)
4604    {
4605        #[inline]
4606        unsafe fn encode(
4607            self,
4608            encoder: &mut fidl::encoding::Encoder<
4609                '_,
4610                fidl::encoding::DefaultFuchsiaResourceDialect,
4611            >,
4612            offset: usize,
4613            depth: fidl::encoding::Depth,
4614        ) -> fidl::Result<()> {
4615            encoder.debug_check_bounds::<DevicePairGetRightPortRequest>(offset);
4616            // Zero out padding regions. There's no need to apply masks
4617            // because the unmasked parts will be overwritten by fields.
4618            unsafe {
4619                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
4620                (ptr as *mut u32).write_unaligned(0);
4621            }
4622            // Write the fields.
4623            self.0.encode(encoder, offset + 0, depth)?;
4624            self.1.encode(encoder, offset + 4, depth)?;
4625            Ok(())
4626        }
4627    }
4628
4629    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4630        for DevicePairGetRightPortRequest
4631    {
4632        #[inline(always)]
4633        fn new_empty() -> Self {
4634            Self {
4635                id: fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect),
4636                port: fidl::new_empty!(
4637                    fidl::encoding::Endpoint<
4638                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4639                    >,
4640                    fidl::encoding::DefaultFuchsiaResourceDialect
4641                ),
4642            }
4643        }
4644
4645        #[inline]
4646        unsafe fn decode(
4647            &mut self,
4648            decoder: &mut fidl::encoding::Decoder<
4649                '_,
4650                fidl::encoding::DefaultFuchsiaResourceDialect,
4651            >,
4652            offset: usize,
4653            _depth: fidl::encoding::Depth,
4654        ) -> fidl::Result<()> {
4655            decoder.debug_check_bounds::<Self>(offset);
4656            // Verify that padding bytes are zero.
4657            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
4658            let padval = unsafe { (ptr as *const u32).read_unaligned() };
4659            let mask = 0xffffff00u32;
4660            let maskedval = padval & mask;
4661            if maskedval != 0 {
4662                return Err(fidl::Error::NonZeroPadding {
4663                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
4664                });
4665            }
4666            fidl::decode!(
4667                u8,
4668                fidl::encoding::DefaultFuchsiaResourceDialect,
4669                &mut self.id,
4670                decoder,
4671                offset + 0,
4672                _depth
4673            )?;
4674            fidl::decode!(
4675                fidl::encoding::Endpoint<
4676                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4677                >,
4678                fidl::encoding::DefaultFuchsiaResourceDialect,
4679                &mut self.port,
4680                decoder,
4681                offset + 4,
4682                _depth
4683            )?;
4684            Ok(())
4685        }
4686    }
4687
4688    impl fidl::encoding::ResourceTypeMarker for DevicePairGetRightRequest {
4689        type Borrowed<'a> = &'a mut Self;
4690        fn take_or_borrow<'a>(
4691            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4692        ) -> Self::Borrowed<'a> {
4693            value
4694        }
4695    }
4696
4697    unsafe impl fidl::encoding::TypeMarker for DevicePairGetRightRequest {
4698        type Owned = Self;
4699
4700        #[inline(always)]
4701        fn inline_align(_context: fidl::encoding::Context) -> usize {
4702            4
4703        }
4704
4705        #[inline(always)]
4706        fn inline_size(_context: fidl::encoding::Context) -> usize {
4707            4
4708        }
4709    }
4710
4711    unsafe impl
4712        fidl::encoding::Encode<
4713            DevicePairGetRightRequest,
4714            fidl::encoding::DefaultFuchsiaResourceDialect,
4715        > for &mut DevicePairGetRightRequest
4716    {
4717        #[inline]
4718        unsafe fn encode(
4719            self,
4720            encoder: &mut fidl::encoding::Encoder<
4721                '_,
4722                fidl::encoding::DefaultFuchsiaResourceDialect,
4723            >,
4724            offset: usize,
4725            _depth: fidl::encoding::Depth,
4726        ) -> fidl::Result<()> {
4727            encoder.debug_check_bounds::<DevicePairGetRightRequest>(offset);
4728            // Delegate to tuple encoding.
4729            fidl::encoding::Encode::<
4730                DevicePairGetRightRequest,
4731                fidl::encoding::DefaultFuchsiaResourceDialect,
4732            >::encode(
4733                (<fidl::encoding::Endpoint<
4734                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4735                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4736                    &mut self.device
4737                ),),
4738                encoder,
4739                offset,
4740                _depth,
4741            )
4742        }
4743    }
4744    unsafe impl<
4745            T0: fidl::encoding::Encode<
4746                fidl::encoding::Endpoint<
4747                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4748                >,
4749                fidl::encoding::DefaultFuchsiaResourceDialect,
4750            >,
4751        >
4752        fidl::encoding::Encode<
4753            DevicePairGetRightRequest,
4754            fidl::encoding::DefaultFuchsiaResourceDialect,
4755        > for (T0,)
4756    {
4757        #[inline]
4758        unsafe fn encode(
4759            self,
4760            encoder: &mut fidl::encoding::Encoder<
4761                '_,
4762                fidl::encoding::DefaultFuchsiaResourceDialect,
4763            >,
4764            offset: usize,
4765            depth: fidl::encoding::Depth,
4766        ) -> fidl::Result<()> {
4767            encoder.debug_check_bounds::<DevicePairGetRightRequest>(offset);
4768            // Zero out padding regions. There's no need to apply masks
4769            // because the unmasked parts will be overwritten by fields.
4770            // Write the fields.
4771            self.0.encode(encoder, offset + 0, depth)?;
4772            Ok(())
4773        }
4774    }
4775
4776    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4777        for DevicePairGetRightRequest
4778    {
4779        #[inline(always)]
4780        fn new_empty() -> Self {
4781            Self {
4782                device: fidl::new_empty!(
4783                    fidl::encoding::Endpoint<
4784                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4785                    >,
4786                    fidl::encoding::DefaultFuchsiaResourceDialect
4787                ),
4788            }
4789        }
4790
4791        #[inline]
4792        unsafe fn decode(
4793            &mut self,
4794            decoder: &mut fidl::encoding::Decoder<
4795                '_,
4796                fidl::encoding::DefaultFuchsiaResourceDialect,
4797            >,
4798            offset: usize,
4799            _depth: fidl::encoding::Depth,
4800        ) -> fidl::Result<()> {
4801            decoder.debug_check_bounds::<Self>(offset);
4802            // Verify that padding bytes are zero.
4803            fidl::decode!(
4804                fidl::encoding::Endpoint<
4805                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4806                >,
4807                fidl::encoding::DefaultFuchsiaResourceDialect,
4808                &mut self.device,
4809                decoder,
4810                offset + 0,
4811                _depth
4812            )?;
4813            Ok(())
4814        }
4815    }
4816
4817    impl fidl::encoding::ResourceTypeMarker for PortGetPortRequest {
4818        type Borrowed<'a> = &'a mut Self;
4819        fn take_or_borrow<'a>(
4820            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4821        ) -> Self::Borrowed<'a> {
4822            value
4823        }
4824    }
4825
4826    unsafe impl fidl::encoding::TypeMarker for PortGetPortRequest {
4827        type Owned = Self;
4828
4829        #[inline(always)]
4830        fn inline_align(_context: fidl::encoding::Context) -> usize {
4831            4
4832        }
4833
4834        #[inline(always)]
4835        fn inline_size(_context: fidl::encoding::Context) -> usize {
4836            4
4837        }
4838    }
4839
4840    unsafe impl
4841        fidl::encoding::Encode<PortGetPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4842        for &mut PortGetPortRequest
4843    {
4844        #[inline]
4845        unsafe fn encode(
4846            self,
4847            encoder: &mut fidl::encoding::Encoder<
4848                '_,
4849                fidl::encoding::DefaultFuchsiaResourceDialect,
4850            >,
4851            offset: usize,
4852            _depth: fidl::encoding::Depth,
4853        ) -> fidl::Result<()> {
4854            encoder.debug_check_bounds::<PortGetPortRequest>(offset);
4855            // Delegate to tuple encoding.
4856            fidl::encoding::Encode::<
4857                PortGetPortRequest,
4858                fidl::encoding::DefaultFuchsiaResourceDialect,
4859            >::encode(
4860                (<fidl::encoding::Endpoint<
4861                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4862                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4863                    &mut self.port
4864                ),),
4865                encoder,
4866                offset,
4867                _depth,
4868            )
4869        }
4870    }
4871    unsafe impl<
4872            T0: fidl::encoding::Encode<
4873                fidl::encoding::Endpoint<
4874                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4875                >,
4876                fidl::encoding::DefaultFuchsiaResourceDialect,
4877            >,
4878        >
4879        fidl::encoding::Encode<PortGetPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4880        for (T0,)
4881    {
4882        #[inline]
4883        unsafe fn encode(
4884            self,
4885            encoder: &mut fidl::encoding::Encoder<
4886                '_,
4887                fidl::encoding::DefaultFuchsiaResourceDialect,
4888            >,
4889            offset: usize,
4890            depth: fidl::encoding::Depth,
4891        ) -> fidl::Result<()> {
4892            encoder.debug_check_bounds::<PortGetPortRequest>(offset);
4893            // Zero out padding regions. There's no need to apply masks
4894            // because the unmasked parts will be overwritten by fields.
4895            // Write the fields.
4896            self.0.encode(encoder, offset + 0, depth)?;
4897            Ok(())
4898        }
4899    }
4900
4901    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4902        for PortGetPortRequest
4903    {
4904        #[inline(always)]
4905        fn new_empty() -> Self {
4906            Self {
4907                port: fidl::new_empty!(
4908                    fidl::encoding::Endpoint<
4909                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4910                    >,
4911                    fidl::encoding::DefaultFuchsiaResourceDialect
4912                ),
4913            }
4914        }
4915
4916        #[inline]
4917        unsafe fn decode(
4918            &mut self,
4919            decoder: &mut fidl::encoding::Decoder<
4920                '_,
4921                fidl::encoding::DefaultFuchsiaResourceDialect,
4922            >,
4923            offset: usize,
4924            _depth: fidl::encoding::Depth,
4925        ) -> fidl::Result<()> {
4926            decoder.debug_check_bounds::<Self>(offset);
4927            // Verify that padding bytes are zero.
4928            fidl::decode!(
4929                fidl::encoding::Endpoint<
4930                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4931                >,
4932                fidl::encoding::DefaultFuchsiaResourceDialect,
4933                &mut self.port,
4934                decoder,
4935                offset + 0,
4936                _depth
4937            )?;
4938            Ok(())
4939        }
4940    }
4941}