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