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 { Some((responder)) } else { None }
1376    }
1377
1378    #[allow(irrefutable_let_patterns)]
1379    pub fn into_get_signals(self) -> Option<(DeviceGetSignalsResponder)> {
1380        if let DeviceRequest::GetSignals { responder } = self { Some((responder)) } else { None }
1381    }
1382
1383    #[allow(irrefutable_let_patterns)]
1384    pub fn into_add_port(
1385        self,
1386    ) -> Option<(DevicePortConfig, fidl::endpoints::ServerEnd<PortMarker>, DeviceControlHandle)>
1387    {
1388        if let DeviceRequest::AddPort { config, port, control_handle } = self {
1389            Some((config, port, control_handle))
1390        } else {
1391            None
1392        }
1393    }
1394
1395    #[allow(irrefutable_let_patterns)]
1396    pub fn into_get_device(
1397        self,
1398    ) -> Option<(
1399        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1400        DeviceControlHandle,
1401    )> {
1402        if let DeviceRequest::GetDevice { device, control_handle } = self {
1403            Some((device, control_handle))
1404        } else {
1405            None
1406        }
1407    }
1408
1409    #[allow(irrefutable_let_patterns)]
1410    pub fn into_delegate_rx_lease(
1411        self,
1412    ) -> Option<(fidl_fuchsia_hardware_network::DelegatedRxLease, DeviceControlHandle)> {
1413        if let DeviceRequest::DelegateRxLease { lease, control_handle } = self {
1414            Some((lease, control_handle))
1415        } else {
1416            None
1417        }
1418    }
1419
1420    /// Name of the method defined in FIDL
1421    pub fn method_name(&self) -> &'static str {
1422        match *self {
1423            DeviceRequest::WriteFrame { .. } => "write_frame",
1424            DeviceRequest::ReadFrame { .. } => "read_frame",
1425            DeviceRequest::GetSignals { .. } => "get_signals",
1426            DeviceRequest::AddPort { .. } => "add_port",
1427            DeviceRequest::GetDevice { .. } => "get_device",
1428            DeviceRequest::DelegateRxLease { .. } => "delegate_rx_lease",
1429        }
1430    }
1431}
1432
1433#[derive(Debug, Clone)]
1434pub struct DeviceControlHandle {
1435    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1436}
1437
1438impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1439    fn shutdown(&self) {
1440        self.inner.shutdown()
1441    }
1442    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1443        self.inner.shutdown_with_epitaph(status)
1444    }
1445
1446    fn is_closed(&self) -> bool {
1447        self.inner.channel().is_closed()
1448    }
1449    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1450        self.inner.channel().on_closed()
1451    }
1452
1453    #[cfg(target_os = "fuchsia")]
1454    fn signal_peer(
1455        &self,
1456        clear_mask: zx::Signals,
1457        set_mask: zx::Signals,
1458    ) -> Result<(), zx_status::Status> {
1459        use fidl::Peered;
1460        self.inner.channel().signal_peer(clear_mask, set_mask)
1461    }
1462}
1463
1464impl DeviceControlHandle {}
1465
1466#[must_use = "FIDL methods require a response to be sent"]
1467#[derive(Debug)]
1468pub struct DeviceWriteFrameResponder {
1469    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1470    tx_id: u32,
1471}
1472
1473/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1474/// if the responder is dropped without sending a response, so that the client
1475/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1476impl std::ops::Drop for DeviceWriteFrameResponder {
1477    fn drop(&mut self) {
1478        self.control_handle.shutdown();
1479        // Safety: drops once, never accessed again
1480        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1481    }
1482}
1483
1484impl fidl::endpoints::Responder for DeviceWriteFrameResponder {
1485    type ControlHandle = DeviceControlHandle;
1486
1487    fn control_handle(&self) -> &DeviceControlHandle {
1488        &self.control_handle
1489    }
1490
1491    fn drop_without_shutdown(mut self) {
1492        // Safety: drops once, never accessed again due to mem::forget
1493        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1494        // Prevent Drop from running (which would shut down the channel)
1495        std::mem::forget(self);
1496    }
1497}
1498
1499impl DeviceWriteFrameResponder {
1500    /// Sends a response to the FIDL transaction.
1501    ///
1502    /// Sets the channel to shutdown if an error occurs.
1503    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1504        let _result = self.send_raw(result);
1505        if _result.is_err() {
1506            self.control_handle.shutdown();
1507        }
1508        self.drop_without_shutdown();
1509        _result
1510    }
1511
1512    /// Similar to "send" but does not shutdown the channel if an error occurs.
1513    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1514        let _result = self.send_raw(result);
1515        self.drop_without_shutdown();
1516        _result
1517    }
1518
1519    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1520        self.control_handle
1521            .inner
1522            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1523                result,
1524                self.tx_id,
1525                0x2d19e24e149bf6db,
1526                fidl::encoding::DynamicFlags::empty(),
1527            )
1528    }
1529}
1530
1531#[must_use = "FIDL methods require a response to be sent"]
1532#[derive(Debug)]
1533pub struct DeviceReadFrameResponder {
1534    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1535    tx_id: u32,
1536}
1537
1538/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1539/// if the responder is dropped without sending a response, so that the client
1540/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1541impl std::ops::Drop for DeviceReadFrameResponder {
1542    fn drop(&mut self) {
1543        self.control_handle.shutdown();
1544        // Safety: drops once, never accessed again
1545        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1546    }
1547}
1548
1549impl fidl::endpoints::Responder for DeviceReadFrameResponder {
1550    type ControlHandle = DeviceControlHandle;
1551
1552    fn control_handle(&self) -> &DeviceControlHandle {
1553        &self.control_handle
1554    }
1555
1556    fn drop_without_shutdown(mut self) {
1557        // Safety: drops once, never accessed again due to mem::forget
1558        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1559        // Prevent Drop from running (which would shut down the channel)
1560        std::mem::forget(self);
1561    }
1562}
1563
1564impl DeviceReadFrameResponder {
1565    /// Sends a response to the FIDL transaction.
1566    ///
1567    /// Sets the channel to shutdown if an error occurs.
1568    pub fn send(self, mut result: Result<&Frame, i32>) -> Result<(), fidl::Error> {
1569        let _result = self.send_raw(result);
1570        if _result.is_err() {
1571            self.control_handle.shutdown();
1572        }
1573        self.drop_without_shutdown();
1574        _result
1575    }
1576
1577    /// Similar to "send" but does not shutdown the channel if an error occurs.
1578    pub fn send_no_shutdown_on_err(
1579        self,
1580        mut result: Result<&Frame, i32>,
1581    ) -> Result<(), fidl::Error> {
1582        let _result = self.send_raw(result);
1583        self.drop_without_shutdown();
1584        _result
1585    }
1586
1587    fn send_raw(&self, mut result: Result<&Frame, i32>) -> Result<(), fidl::Error> {
1588        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceReadFrameResponse, i32>>(
1589            result.map(|frame| (frame,)),
1590            self.tx_id,
1591            0x6ebc56b8427e1571,
1592            fidl::encoding::DynamicFlags::empty(),
1593        )
1594    }
1595}
1596
1597#[must_use = "FIDL methods require a response to be sent"]
1598#[derive(Debug)]
1599pub struct DeviceGetSignalsResponder {
1600    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1601    tx_id: u32,
1602}
1603
1604/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1605/// if the responder is dropped without sending a response, so that the client
1606/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1607impl std::ops::Drop for DeviceGetSignalsResponder {
1608    fn drop(&mut self) {
1609        self.control_handle.shutdown();
1610        // Safety: drops once, never accessed again
1611        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1612    }
1613}
1614
1615impl fidl::endpoints::Responder for DeviceGetSignalsResponder {
1616    type ControlHandle = DeviceControlHandle;
1617
1618    fn control_handle(&self) -> &DeviceControlHandle {
1619        &self.control_handle
1620    }
1621
1622    fn drop_without_shutdown(mut self) {
1623        // Safety: drops once, never accessed again due to mem::forget
1624        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1625        // Prevent Drop from running (which would shut down the channel)
1626        std::mem::forget(self);
1627    }
1628}
1629
1630impl DeviceGetSignalsResponder {
1631    /// Sends a response to the FIDL transaction.
1632    ///
1633    /// Sets the channel to shutdown if an error occurs.
1634    pub fn send(self, mut signals: fidl::EventPair) -> Result<(), fidl::Error> {
1635        let _result = self.send_raw(signals);
1636        if _result.is_err() {
1637            self.control_handle.shutdown();
1638        }
1639        self.drop_without_shutdown();
1640        _result
1641    }
1642
1643    /// Similar to "send" but does not shutdown the channel if an error occurs.
1644    pub fn send_no_shutdown_on_err(self, mut signals: fidl::EventPair) -> Result<(), fidl::Error> {
1645        let _result = self.send_raw(signals);
1646        self.drop_without_shutdown();
1647        _result
1648    }
1649
1650    fn send_raw(&self, mut signals: fidl::EventPair) -> Result<(), fidl::Error> {
1651        self.control_handle.inner.send::<DeviceGetSignalsResponse>(
1652            (signals,),
1653            self.tx_id,
1654            0x4d1ca50fc53606b9,
1655            fidl::encoding::DynamicFlags::empty(),
1656        )
1657    }
1658}
1659
1660#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1661pub struct DevicePairMarker;
1662
1663impl fidl::endpoints::ProtocolMarker for DevicePairMarker {
1664    type Proxy = DevicePairProxy;
1665    type RequestStream = DevicePairRequestStream;
1666    #[cfg(target_os = "fuchsia")]
1667    type SynchronousProxy = DevicePairSynchronousProxy;
1668
1669    const DEBUG_NAME: &'static str = "(anonymous) DevicePair";
1670}
1671pub type DevicePairAddPortResult = Result<(), i32>;
1672pub type DevicePairRemovePortResult = Result<(), i32>;
1673
1674pub trait DevicePairProxyInterface: Send + Sync {
1675    type AddPortResponseFut: std::future::Future<Output = Result<DevicePairAddPortResult, fidl::Error>>
1676        + Send;
1677    fn r#add_port(&self, config: &DevicePairPortConfig) -> Self::AddPortResponseFut;
1678    type RemovePortResponseFut: std::future::Future<Output = Result<DevicePairRemovePortResult, fidl::Error>>
1679        + Send;
1680    fn r#remove_port(&self, id: u8) -> Self::RemovePortResponseFut;
1681    fn r#get_left(
1682        &self,
1683        device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1684    ) -> Result<(), fidl::Error>;
1685    fn r#get_right(
1686        &self,
1687        device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1688    ) -> Result<(), fidl::Error>;
1689    fn r#get_left_port(
1690        &self,
1691        id: u8,
1692        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1693    ) -> Result<(), fidl::Error>;
1694    fn r#get_right_port(
1695        &self,
1696        id: u8,
1697        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1698    ) -> Result<(), fidl::Error>;
1699}
1700#[derive(Debug)]
1701#[cfg(target_os = "fuchsia")]
1702pub struct DevicePairSynchronousProxy {
1703    client: fidl::client::sync::Client,
1704}
1705
1706#[cfg(target_os = "fuchsia")]
1707impl fidl::endpoints::SynchronousProxy for DevicePairSynchronousProxy {
1708    type Proxy = DevicePairProxy;
1709    type Protocol = DevicePairMarker;
1710
1711    fn from_channel(inner: fidl::Channel) -> Self {
1712        Self::new(inner)
1713    }
1714
1715    fn into_channel(self) -> fidl::Channel {
1716        self.client.into_channel()
1717    }
1718
1719    fn as_channel(&self) -> &fidl::Channel {
1720        self.client.as_channel()
1721    }
1722}
1723
1724#[cfg(target_os = "fuchsia")]
1725impl DevicePairSynchronousProxy {
1726    pub fn new(channel: fidl::Channel) -> Self {
1727        let protocol_name = <DevicePairMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1728        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1729    }
1730
1731    pub fn into_channel(self) -> fidl::Channel {
1732        self.client.into_channel()
1733    }
1734
1735    /// Waits until an event arrives and returns it. It is safe for other
1736    /// threads to make concurrent requests while waiting for an event.
1737    pub fn wait_for_event(
1738        &self,
1739        deadline: zx::MonotonicInstant,
1740    ) -> Result<DevicePairEvent, fidl::Error> {
1741        DevicePairEvent::decode(self.client.wait_for_event(deadline)?)
1742    }
1743
1744    /// Adds a logical port to this device pair.
1745    ///
1746    /// + request `config` port configuration.
1747    /// * error `ZX_ERR_INVALID_ARGS` if `config` is invalid.
1748    /// * error `ZX_ERR_ALREADY_EXISTS` if the provided port identifier is
1749    /// already in use.
1750    pub fn r#add_port(
1751        &self,
1752        mut config: &DevicePairPortConfig,
1753        ___deadline: zx::MonotonicInstant,
1754    ) -> Result<DevicePairAddPortResult, fidl::Error> {
1755        let _response = self.client.send_query::<
1756            DevicePairAddPortRequest,
1757            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1758        >(
1759            (config,),
1760            0x362f4856a075e1f8,
1761            fidl::encoding::DynamicFlags::empty(),
1762            ___deadline,
1763        )?;
1764        Ok(_response.map(|x| x))
1765    }
1766
1767    /// Removes a logical port created by
1768    /// [`fuchsia.net.tun/DevicePair.AddPort`].
1769    ///
1770    /// + request `id` identifier of the port to remove.
1771    /// * error `ZX_ERR_NOT_FOUND` if `id` does not map to an existing port.
1772    pub fn r#remove_port(
1773        &self,
1774        mut id: u8,
1775        ___deadline: zx::MonotonicInstant,
1776    ) -> Result<DevicePairRemovePortResult, fidl::Error> {
1777        let _response = self.client.send_query::<
1778            DevicePairRemovePortRequest,
1779            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1780        >(
1781            (id,),
1782            0x33bb45cc1d3fbe1e,
1783            fidl::encoding::DynamicFlags::empty(),
1784            ___deadline,
1785        )?;
1786        Ok(_response.map(|x| x))
1787    }
1788
1789    /// Connects to the underlying left device endpoint.
1790    ///
1791    /// + request `device` handle serve the left device endpoint on.
1792    pub fn r#get_left(
1793        &self,
1794        mut device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1795    ) -> Result<(), fidl::Error> {
1796        self.client.send::<DevicePairGetLeftRequest>(
1797            (device,),
1798            0x1357a771a6ccb303,
1799            fidl::encoding::DynamicFlags::empty(),
1800        )
1801    }
1802
1803    /// Connects to the underlying right device endpoint.
1804    ///
1805    /// + request `device` handle serve the right device endpoint on.
1806    pub fn r#get_right(
1807        &self,
1808        mut device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1809    ) -> Result<(), fidl::Error> {
1810        self.client.send::<DevicePairGetRightRequest>(
1811            (device,),
1812            0x45ebce063223b60f,
1813            fidl::encoding::DynamicFlags::empty(),
1814        )
1815    }
1816
1817    /// Connects to an underlying left port.
1818    ///
1819    /// + request `id` requested port identifier.
1820    /// + request `port` grants access to the requested port on the left device.
1821    pub fn r#get_left_port(
1822        &self,
1823        mut id: u8,
1824        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1825    ) -> Result<(), fidl::Error> {
1826        self.client.send::<DevicePairGetLeftPortRequest>(
1827            (id, port),
1828            0x6e3038d75096ab77,
1829            fidl::encoding::DynamicFlags::empty(),
1830        )
1831    }
1832
1833    /// Connects to an underlying right port.
1834    ///
1835    /// + request `id` requested port identifier.
1836    /// + request `port` grants access to the requested port on the right device.
1837    pub fn r#get_right_port(
1838        &self,
1839        mut id: u8,
1840        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1841    ) -> Result<(), fidl::Error> {
1842        self.client.send::<DevicePairGetRightPortRequest>(
1843            (id, port),
1844            0x7fc4716601eb987c,
1845            fidl::encoding::DynamicFlags::empty(),
1846        )
1847    }
1848}
1849
1850#[cfg(target_os = "fuchsia")]
1851impl From<DevicePairSynchronousProxy> for zx::Handle {
1852    fn from(value: DevicePairSynchronousProxy) -> Self {
1853        value.into_channel().into()
1854    }
1855}
1856
1857#[cfg(target_os = "fuchsia")]
1858impl From<fidl::Channel> for DevicePairSynchronousProxy {
1859    fn from(value: fidl::Channel) -> Self {
1860        Self::new(value)
1861    }
1862}
1863
1864#[cfg(target_os = "fuchsia")]
1865impl fidl::endpoints::FromClient for DevicePairSynchronousProxy {
1866    type Protocol = DevicePairMarker;
1867
1868    fn from_client(value: fidl::endpoints::ClientEnd<DevicePairMarker>) -> Self {
1869        Self::new(value.into_channel())
1870    }
1871}
1872
1873#[derive(Debug, Clone)]
1874pub struct DevicePairProxy {
1875    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1876}
1877
1878impl fidl::endpoints::Proxy for DevicePairProxy {
1879    type Protocol = DevicePairMarker;
1880
1881    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1882        Self::new(inner)
1883    }
1884
1885    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1886        self.client.into_channel().map_err(|client| Self { client })
1887    }
1888
1889    fn as_channel(&self) -> &::fidl::AsyncChannel {
1890        self.client.as_channel()
1891    }
1892}
1893
1894impl DevicePairProxy {
1895    /// Create a new Proxy for fuchsia.net.tun/DevicePair.
1896    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1897        let protocol_name = <DevicePairMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1898        Self { client: fidl::client::Client::new(channel, protocol_name) }
1899    }
1900
1901    /// Get a Stream of events from the remote end of the protocol.
1902    ///
1903    /// # Panics
1904    ///
1905    /// Panics if the event stream was already taken.
1906    pub fn take_event_stream(&self) -> DevicePairEventStream {
1907        DevicePairEventStream { event_receiver: self.client.take_event_receiver() }
1908    }
1909
1910    /// Adds a logical port to this device pair.
1911    ///
1912    /// + request `config` port configuration.
1913    /// * error `ZX_ERR_INVALID_ARGS` if `config` is invalid.
1914    /// * error `ZX_ERR_ALREADY_EXISTS` if the provided port identifier is
1915    /// already in use.
1916    pub fn r#add_port(
1917        &self,
1918        mut config: &DevicePairPortConfig,
1919    ) -> fidl::client::QueryResponseFut<
1920        DevicePairAddPortResult,
1921        fidl::encoding::DefaultFuchsiaResourceDialect,
1922    > {
1923        DevicePairProxyInterface::r#add_port(self, config)
1924    }
1925
1926    /// Removes a logical port created by
1927    /// [`fuchsia.net.tun/DevicePair.AddPort`].
1928    ///
1929    /// + request `id` identifier of the port to remove.
1930    /// * error `ZX_ERR_NOT_FOUND` if `id` does not map to an existing port.
1931    pub fn r#remove_port(
1932        &self,
1933        mut id: u8,
1934    ) -> fidl::client::QueryResponseFut<
1935        DevicePairRemovePortResult,
1936        fidl::encoding::DefaultFuchsiaResourceDialect,
1937    > {
1938        DevicePairProxyInterface::r#remove_port(self, id)
1939    }
1940
1941    /// Connects to the underlying left device endpoint.
1942    ///
1943    /// + request `device` handle serve the left device endpoint on.
1944    pub fn r#get_left(
1945        &self,
1946        mut device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1947    ) -> Result<(), fidl::Error> {
1948        DevicePairProxyInterface::r#get_left(self, device)
1949    }
1950
1951    /// Connects to the underlying right device endpoint.
1952    ///
1953    /// + request `device` handle serve the right device endpoint on.
1954    pub fn r#get_right(
1955        &self,
1956        mut device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
1957    ) -> Result<(), fidl::Error> {
1958        DevicePairProxyInterface::r#get_right(self, device)
1959    }
1960
1961    /// Connects to an underlying left port.
1962    ///
1963    /// + request `id` requested port identifier.
1964    /// + request `port` grants access to the requested port on the left device.
1965    pub fn r#get_left_port(
1966        &self,
1967        mut id: u8,
1968        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1969    ) -> Result<(), fidl::Error> {
1970        DevicePairProxyInterface::r#get_left_port(self, id, port)
1971    }
1972
1973    /// Connects to an underlying right port.
1974    ///
1975    /// + request `id` requested port identifier.
1976    /// + request `port` grants access to the requested port on the right device.
1977    pub fn r#get_right_port(
1978        &self,
1979        mut id: u8,
1980        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1981    ) -> Result<(), fidl::Error> {
1982        DevicePairProxyInterface::r#get_right_port(self, id, port)
1983    }
1984}
1985
1986impl DevicePairProxyInterface for DevicePairProxy {
1987    type AddPortResponseFut = fidl::client::QueryResponseFut<
1988        DevicePairAddPortResult,
1989        fidl::encoding::DefaultFuchsiaResourceDialect,
1990    >;
1991    fn r#add_port(&self, mut config: &DevicePairPortConfig) -> Self::AddPortResponseFut {
1992        fn _decode(
1993            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1994        ) -> Result<DevicePairAddPortResult, fidl::Error> {
1995            let _response = fidl::client::decode_transaction_body::<
1996                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1997                fidl::encoding::DefaultFuchsiaResourceDialect,
1998                0x362f4856a075e1f8,
1999            >(_buf?)?;
2000            Ok(_response.map(|x| x))
2001        }
2002        self.client.send_query_and_decode::<DevicePairAddPortRequest, DevicePairAddPortResult>(
2003            (config,),
2004            0x362f4856a075e1f8,
2005            fidl::encoding::DynamicFlags::empty(),
2006            _decode,
2007        )
2008    }
2009
2010    type RemovePortResponseFut = fidl::client::QueryResponseFut<
2011        DevicePairRemovePortResult,
2012        fidl::encoding::DefaultFuchsiaResourceDialect,
2013    >;
2014    fn r#remove_port(&self, mut id: u8) -> Self::RemovePortResponseFut {
2015        fn _decode(
2016            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2017        ) -> Result<DevicePairRemovePortResult, fidl::Error> {
2018            let _response = fidl::client::decode_transaction_body::<
2019                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2020                fidl::encoding::DefaultFuchsiaResourceDialect,
2021                0x33bb45cc1d3fbe1e,
2022            >(_buf?)?;
2023            Ok(_response.map(|x| x))
2024        }
2025        self.client
2026            .send_query_and_decode::<DevicePairRemovePortRequest, DevicePairRemovePortResult>(
2027                (id,),
2028                0x33bb45cc1d3fbe1e,
2029                fidl::encoding::DynamicFlags::empty(),
2030                _decode,
2031            )
2032    }
2033
2034    fn r#get_left(
2035        &self,
2036        mut device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
2037    ) -> Result<(), fidl::Error> {
2038        self.client.send::<DevicePairGetLeftRequest>(
2039            (device,),
2040            0x1357a771a6ccb303,
2041            fidl::encoding::DynamicFlags::empty(),
2042        )
2043    }
2044
2045    fn r#get_right(
2046        &self,
2047        mut device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
2048    ) -> Result<(), fidl::Error> {
2049        self.client.send::<DevicePairGetRightRequest>(
2050            (device,),
2051            0x45ebce063223b60f,
2052            fidl::encoding::DynamicFlags::empty(),
2053        )
2054    }
2055
2056    fn r#get_left_port(
2057        &self,
2058        mut id: u8,
2059        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2060    ) -> Result<(), fidl::Error> {
2061        self.client.send::<DevicePairGetLeftPortRequest>(
2062            (id, port),
2063            0x6e3038d75096ab77,
2064            fidl::encoding::DynamicFlags::empty(),
2065        )
2066    }
2067
2068    fn r#get_right_port(
2069        &self,
2070        mut id: u8,
2071        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2072    ) -> Result<(), fidl::Error> {
2073        self.client.send::<DevicePairGetRightPortRequest>(
2074            (id, port),
2075            0x7fc4716601eb987c,
2076            fidl::encoding::DynamicFlags::empty(),
2077        )
2078    }
2079}
2080
2081pub struct DevicePairEventStream {
2082    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2083}
2084
2085impl std::marker::Unpin for DevicePairEventStream {}
2086
2087impl futures::stream::FusedStream for DevicePairEventStream {
2088    fn is_terminated(&self) -> bool {
2089        self.event_receiver.is_terminated()
2090    }
2091}
2092
2093impl futures::Stream for DevicePairEventStream {
2094    type Item = Result<DevicePairEvent, fidl::Error>;
2095
2096    fn poll_next(
2097        mut self: std::pin::Pin<&mut Self>,
2098        cx: &mut std::task::Context<'_>,
2099    ) -> std::task::Poll<Option<Self::Item>> {
2100        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2101            &mut self.event_receiver,
2102            cx
2103        )?) {
2104            Some(buf) => std::task::Poll::Ready(Some(DevicePairEvent::decode(buf))),
2105            None => std::task::Poll::Ready(None),
2106        }
2107    }
2108}
2109
2110#[derive(Debug)]
2111pub enum DevicePairEvent {}
2112
2113impl DevicePairEvent {
2114    /// Decodes a message buffer as a [`DevicePairEvent`].
2115    fn decode(
2116        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2117    ) -> Result<DevicePairEvent, fidl::Error> {
2118        let (bytes, _handles) = buf.split_mut();
2119        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2120        debug_assert_eq!(tx_header.tx_id, 0);
2121        match tx_header.ordinal {
2122            _ => Err(fidl::Error::UnknownOrdinal {
2123                ordinal: tx_header.ordinal,
2124                protocol_name: <DevicePairMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2125            }),
2126        }
2127    }
2128}
2129
2130/// A Stream of incoming requests for fuchsia.net.tun/DevicePair.
2131pub struct DevicePairRequestStream {
2132    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2133    is_terminated: bool,
2134}
2135
2136impl std::marker::Unpin for DevicePairRequestStream {}
2137
2138impl futures::stream::FusedStream for DevicePairRequestStream {
2139    fn is_terminated(&self) -> bool {
2140        self.is_terminated
2141    }
2142}
2143
2144impl fidl::endpoints::RequestStream for DevicePairRequestStream {
2145    type Protocol = DevicePairMarker;
2146    type ControlHandle = DevicePairControlHandle;
2147
2148    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2149        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2150    }
2151
2152    fn control_handle(&self) -> Self::ControlHandle {
2153        DevicePairControlHandle { inner: self.inner.clone() }
2154    }
2155
2156    fn into_inner(
2157        self,
2158    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2159    {
2160        (self.inner, self.is_terminated)
2161    }
2162
2163    fn from_inner(
2164        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2165        is_terminated: bool,
2166    ) -> Self {
2167        Self { inner, is_terminated }
2168    }
2169}
2170
2171impl futures::Stream for DevicePairRequestStream {
2172    type Item = Result<DevicePairRequest, fidl::Error>;
2173
2174    fn poll_next(
2175        mut self: std::pin::Pin<&mut Self>,
2176        cx: &mut std::task::Context<'_>,
2177    ) -> std::task::Poll<Option<Self::Item>> {
2178        let this = &mut *self;
2179        if this.inner.check_shutdown(cx) {
2180            this.is_terminated = true;
2181            return std::task::Poll::Ready(None);
2182        }
2183        if this.is_terminated {
2184            panic!("polled DevicePairRequestStream after completion");
2185        }
2186        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2187            |bytes, handles| {
2188                match this.inner.channel().read_etc(cx, bytes, handles) {
2189                    std::task::Poll::Ready(Ok(())) => {}
2190                    std::task::Poll::Pending => return std::task::Poll::Pending,
2191                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2192                        this.is_terminated = true;
2193                        return std::task::Poll::Ready(None);
2194                    }
2195                    std::task::Poll::Ready(Err(e)) => {
2196                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2197                            e.into(),
2198                        ))));
2199                    }
2200                }
2201
2202                // A message has been received from the channel
2203                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2204
2205                std::task::Poll::Ready(Some(match header.ordinal {
2206                    0x362f4856a075e1f8 => {
2207                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2208                        let mut req = fidl::new_empty!(
2209                            DevicePairAddPortRequest,
2210                            fidl::encoding::DefaultFuchsiaResourceDialect
2211                        );
2212                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevicePairAddPortRequest>(&header, _body_bytes, handles, &mut req)?;
2213                        let control_handle = DevicePairControlHandle { inner: this.inner.clone() };
2214                        Ok(DevicePairRequest::AddPort {
2215                            config: req.config,
2216
2217                            responder: DevicePairAddPortResponder {
2218                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2219                                tx_id: header.tx_id,
2220                            },
2221                        })
2222                    }
2223                    0x33bb45cc1d3fbe1e => {
2224                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2225                        let mut req = fidl::new_empty!(
2226                            DevicePairRemovePortRequest,
2227                            fidl::encoding::DefaultFuchsiaResourceDialect
2228                        );
2229                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevicePairRemovePortRequest>(&header, _body_bytes, handles, &mut req)?;
2230                        let control_handle = DevicePairControlHandle { inner: this.inner.clone() };
2231                        Ok(DevicePairRequest::RemovePort {
2232                            id: req.id,
2233
2234                            responder: DevicePairRemovePortResponder {
2235                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2236                                tx_id: header.tx_id,
2237                            },
2238                        })
2239                    }
2240                    0x1357a771a6ccb303 => {
2241                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2242                        let mut req = fidl::new_empty!(
2243                            DevicePairGetLeftRequest,
2244                            fidl::encoding::DefaultFuchsiaResourceDialect
2245                        );
2246                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevicePairGetLeftRequest>(&header, _body_bytes, handles, &mut req)?;
2247                        let control_handle = DevicePairControlHandle { inner: this.inner.clone() };
2248                        Ok(DevicePairRequest::GetLeft { device: req.device, control_handle })
2249                    }
2250                    0x45ebce063223b60f => {
2251                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2252                        let mut req = fidl::new_empty!(
2253                            DevicePairGetRightRequest,
2254                            fidl::encoding::DefaultFuchsiaResourceDialect
2255                        );
2256                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevicePairGetRightRequest>(&header, _body_bytes, handles, &mut req)?;
2257                        let control_handle = DevicePairControlHandle { inner: this.inner.clone() };
2258                        Ok(DevicePairRequest::GetRight { device: req.device, control_handle })
2259                    }
2260                    0x6e3038d75096ab77 => {
2261                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2262                        let mut req = fidl::new_empty!(
2263                            DevicePairGetLeftPortRequest,
2264                            fidl::encoding::DefaultFuchsiaResourceDialect
2265                        );
2266                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevicePairGetLeftPortRequest>(&header, _body_bytes, handles, &mut req)?;
2267                        let control_handle = DevicePairControlHandle { inner: this.inner.clone() };
2268                        Ok(DevicePairRequest::GetLeftPort {
2269                            id: req.id,
2270                            port: req.port,
2271
2272                            control_handle,
2273                        })
2274                    }
2275                    0x7fc4716601eb987c => {
2276                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2277                        let mut req = fidl::new_empty!(
2278                            DevicePairGetRightPortRequest,
2279                            fidl::encoding::DefaultFuchsiaResourceDialect
2280                        );
2281                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevicePairGetRightPortRequest>(&header, _body_bytes, handles, &mut req)?;
2282                        let control_handle = DevicePairControlHandle { inner: this.inner.clone() };
2283                        Ok(DevicePairRequest::GetRightPort {
2284                            id: req.id,
2285                            port: req.port,
2286
2287                            control_handle,
2288                        })
2289                    }
2290                    _ => Err(fidl::Error::UnknownOrdinal {
2291                        ordinal: header.ordinal,
2292                        protocol_name:
2293                            <DevicePairMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2294                    }),
2295                }))
2296            },
2297        )
2298    }
2299}
2300
2301/// Provides control over a pair of network devices.
2302///
2303/// A `DevicePair` is a simpler version of `Device` that "shorts" two network
2304/// device interfaces, named its "left" and "right" ends. The internal state of
2305/// a `DevicePair` is not accessible, like it is for `Device` and it provides a
2306/// more streamlined (and considerably faster) pair of
2307/// [`fuchsia.hardware.network/Device`]s. The transmit side of each port of the
2308/// left end is connected to the receive side of the port with the same
2309/// identifier on the right end, and vice-versa. A `DevicePair`'s port online
2310/// signal is handled internally (online if any of the ends has an active data
2311/// session). If MAC addresses are provided on creation, the only supported MAC
2312/// filtering mode is `PROMISCUOUS`.
2313///
2314/// This protocol encodes the underlying object's lifetime in both directions;
2315/// the underlying object is alive iff both ends of the protocol are open. That
2316/// is:
2317///
2318/// - Closing the client end causes the object to be destroyed.
2319/// - Observing a closure of the server end indicates the object no longer
2320/// exists.
2321#[derive(Debug)]
2322pub enum DevicePairRequest {
2323    /// Adds a logical port to this device pair.
2324    ///
2325    /// + request `config` port configuration.
2326    /// * error `ZX_ERR_INVALID_ARGS` if `config` is invalid.
2327    /// * error `ZX_ERR_ALREADY_EXISTS` if the provided port identifier is
2328    /// already in use.
2329    AddPort { config: DevicePairPortConfig, responder: DevicePairAddPortResponder },
2330    /// Removes a logical port created by
2331    /// [`fuchsia.net.tun/DevicePair.AddPort`].
2332    ///
2333    /// + request `id` identifier of the port to remove.
2334    /// * error `ZX_ERR_NOT_FOUND` if `id` does not map to an existing port.
2335    RemovePort { id: u8, responder: DevicePairRemovePortResponder },
2336    /// Connects to the underlying left device endpoint.
2337    ///
2338    /// + request `device` handle serve the left device endpoint on.
2339    GetLeft {
2340        device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
2341        control_handle: DevicePairControlHandle,
2342    },
2343    /// Connects to the underlying right device endpoint.
2344    ///
2345    /// + request `device` handle serve the right device endpoint on.
2346    GetRight {
2347        device: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
2348        control_handle: DevicePairControlHandle,
2349    },
2350    /// Connects to an underlying left port.
2351    ///
2352    /// + request `id` requested port identifier.
2353    /// + request `port` grants access to the requested port on the left device.
2354    GetLeftPort {
2355        id: u8,
2356        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2357        control_handle: DevicePairControlHandle,
2358    },
2359    /// Connects to an underlying right port.
2360    ///
2361    /// + request `id` requested port identifier.
2362    /// + request `port` grants access to the requested port on the right device.
2363    GetRightPort {
2364        id: u8,
2365        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2366        control_handle: DevicePairControlHandle,
2367    },
2368}
2369
2370impl DevicePairRequest {
2371    #[allow(irrefutable_let_patterns)]
2372    pub fn into_add_port(self) -> Option<(DevicePairPortConfig, DevicePairAddPortResponder)> {
2373        if let DevicePairRequest::AddPort { config, responder } = self {
2374            Some((config, responder))
2375        } else {
2376            None
2377        }
2378    }
2379
2380    #[allow(irrefutable_let_patterns)]
2381    pub fn into_remove_port(self) -> Option<(u8, DevicePairRemovePortResponder)> {
2382        if let DevicePairRequest::RemovePort { id, responder } = self {
2383            Some((id, responder))
2384        } else {
2385            None
2386        }
2387    }
2388
2389    #[allow(irrefutable_let_patterns)]
2390    pub fn into_get_left(
2391        self,
2392    ) -> Option<(
2393        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
2394        DevicePairControlHandle,
2395    )> {
2396        if let DevicePairRequest::GetLeft { device, control_handle } = self {
2397            Some((device, control_handle))
2398        } else {
2399            None
2400        }
2401    }
2402
2403    #[allow(irrefutable_let_patterns)]
2404    pub fn into_get_right(
2405        self,
2406    ) -> Option<(
2407        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
2408        DevicePairControlHandle,
2409    )> {
2410        if let DevicePairRequest::GetRight { device, control_handle } = self {
2411            Some((device, control_handle))
2412        } else {
2413            None
2414        }
2415    }
2416
2417    #[allow(irrefutable_let_patterns)]
2418    pub fn into_get_left_port(
2419        self,
2420    ) -> Option<(
2421        u8,
2422        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2423        DevicePairControlHandle,
2424    )> {
2425        if let DevicePairRequest::GetLeftPort { id, port, control_handle } = self {
2426            Some((id, port, control_handle))
2427        } else {
2428            None
2429        }
2430    }
2431
2432    #[allow(irrefutable_let_patterns)]
2433    pub fn into_get_right_port(
2434        self,
2435    ) -> Option<(
2436        u8,
2437        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2438        DevicePairControlHandle,
2439    )> {
2440        if let DevicePairRequest::GetRightPort { id, port, control_handle } = self {
2441            Some((id, port, control_handle))
2442        } else {
2443            None
2444        }
2445    }
2446
2447    /// Name of the method defined in FIDL
2448    pub fn method_name(&self) -> &'static str {
2449        match *self {
2450            DevicePairRequest::AddPort { .. } => "add_port",
2451            DevicePairRequest::RemovePort { .. } => "remove_port",
2452            DevicePairRequest::GetLeft { .. } => "get_left",
2453            DevicePairRequest::GetRight { .. } => "get_right",
2454            DevicePairRequest::GetLeftPort { .. } => "get_left_port",
2455            DevicePairRequest::GetRightPort { .. } => "get_right_port",
2456        }
2457    }
2458}
2459
2460#[derive(Debug, Clone)]
2461pub struct DevicePairControlHandle {
2462    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2463}
2464
2465impl fidl::endpoints::ControlHandle for DevicePairControlHandle {
2466    fn shutdown(&self) {
2467        self.inner.shutdown()
2468    }
2469    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2470        self.inner.shutdown_with_epitaph(status)
2471    }
2472
2473    fn is_closed(&self) -> bool {
2474        self.inner.channel().is_closed()
2475    }
2476    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2477        self.inner.channel().on_closed()
2478    }
2479
2480    #[cfg(target_os = "fuchsia")]
2481    fn signal_peer(
2482        &self,
2483        clear_mask: zx::Signals,
2484        set_mask: zx::Signals,
2485    ) -> Result<(), zx_status::Status> {
2486        use fidl::Peered;
2487        self.inner.channel().signal_peer(clear_mask, set_mask)
2488    }
2489}
2490
2491impl DevicePairControlHandle {}
2492
2493#[must_use = "FIDL methods require a response to be sent"]
2494#[derive(Debug)]
2495pub struct DevicePairAddPortResponder {
2496    control_handle: std::mem::ManuallyDrop<DevicePairControlHandle>,
2497    tx_id: u32,
2498}
2499
2500/// Set the the channel to be shutdown (see [`DevicePairControlHandle::shutdown`])
2501/// if the responder is dropped without sending a response, so that the client
2502/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2503impl std::ops::Drop for DevicePairAddPortResponder {
2504    fn drop(&mut self) {
2505        self.control_handle.shutdown();
2506        // Safety: drops once, never accessed again
2507        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2508    }
2509}
2510
2511impl fidl::endpoints::Responder for DevicePairAddPortResponder {
2512    type ControlHandle = DevicePairControlHandle;
2513
2514    fn control_handle(&self) -> &DevicePairControlHandle {
2515        &self.control_handle
2516    }
2517
2518    fn drop_without_shutdown(mut self) {
2519        // Safety: drops once, never accessed again due to mem::forget
2520        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2521        // Prevent Drop from running (which would shut down the channel)
2522        std::mem::forget(self);
2523    }
2524}
2525
2526impl DevicePairAddPortResponder {
2527    /// Sends a response to the FIDL transaction.
2528    ///
2529    /// Sets the channel to shutdown if an error occurs.
2530    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2531        let _result = self.send_raw(result);
2532        if _result.is_err() {
2533            self.control_handle.shutdown();
2534        }
2535        self.drop_without_shutdown();
2536        _result
2537    }
2538
2539    /// Similar to "send" but does not shutdown the channel if an error occurs.
2540    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2541        let _result = self.send_raw(result);
2542        self.drop_without_shutdown();
2543        _result
2544    }
2545
2546    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2547        self.control_handle
2548            .inner
2549            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2550                result,
2551                self.tx_id,
2552                0x362f4856a075e1f8,
2553                fidl::encoding::DynamicFlags::empty(),
2554            )
2555    }
2556}
2557
2558#[must_use = "FIDL methods require a response to be sent"]
2559#[derive(Debug)]
2560pub struct DevicePairRemovePortResponder {
2561    control_handle: std::mem::ManuallyDrop<DevicePairControlHandle>,
2562    tx_id: u32,
2563}
2564
2565/// Set the the channel to be shutdown (see [`DevicePairControlHandle::shutdown`])
2566/// if the responder is dropped without sending a response, so that the client
2567/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2568impl std::ops::Drop for DevicePairRemovePortResponder {
2569    fn drop(&mut self) {
2570        self.control_handle.shutdown();
2571        // Safety: drops once, never accessed again
2572        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2573    }
2574}
2575
2576impl fidl::endpoints::Responder for DevicePairRemovePortResponder {
2577    type ControlHandle = DevicePairControlHandle;
2578
2579    fn control_handle(&self) -> &DevicePairControlHandle {
2580        &self.control_handle
2581    }
2582
2583    fn drop_without_shutdown(mut self) {
2584        // Safety: drops once, never accessed again due to mem::forget
2585        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2586        // Prevent Drop from running (which would shut down the channel)
2587        std::mem::forget(self);
2588    }
2589}
2590
2591impl DevicePairRemovePortResponder {
2592    /// Sends a response to the FIDL transaction.
2593    ///
2594    /// Sets the channel to shutdown if an error occurs.
2595    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2596        let _result = self.send_raw(result);
2597        if _result.is_err() {
2598            self.control_handle.shutdown();
2599        }
2600        self.drop_without_shutdown();
2601        _result
2602    }
2603
2604    /// Similar to "send" but does not shutdown the channel if an error occurs.
2605    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2606        let _result = self.send_raw(result);
2607        self.drop_without_shutdown();
2608        _result
2609    }
2610
2611    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2612        self.control_handle
2613            .inner
2614            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2615                result,
2616                self.tx_id,
2617                0x33bb45cc1d3fbe1e,
2618                fidl::encoding::DynamicFlags::empty(),
2619            )
2620    }
2621}
2622
2623#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2624pub struct PortMarker;
2625
2626impl fidl::endpoints::ProtocolMarker for PortMarker {
2627    type Proxy = PortProxy;
2628    type RequestStream = PortRequestStream;
2629    #[cfg(target_os = "fuchsia")]
2630    type SynchronousProxy = PortSynchronousProxy;
2631
2632    const DEBUG_NAME: &'static str = "(anonymous) Port";
2633}
2634
2635pub trait PortProxyInterface: Send + Sync {
2636    type GetStateResponseFut: std::future::Future<Output = Result<InternalState, fidl::Error>>
2637        + Send;
2638    fn r#get_state(&self) -> Self::GetStateResponseFut;
2639    type WatchStateResponseFut: std::future::Future<Output = Result<InternalState, fidl::Error>>
2640        + Send;
2641    fn r#watch_state(&self) -> Self::WatchStateResponseFut;
2642    type SetOnlineResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2643    fn r#set_online(&self, online: bool) -> Self::SetOnlineResponseFut;
2644    fn r#get_port(
2645        &self,
2646        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2647    ) -> Result<(), fidl::Error>;
2648    fn r#remove(&self) -> Result<(), fidl::Error>;
2649}
2650#[derive(Debug)]
2651#[cfg(target_os = "fuchsia")]
2652pub struct PortSynchronousProxy {
2653    client: fidl::client::sync::Client,
2654}
2655
2656#[cfg(target_os = "fuchsia")]
2657impl fidl::endpoints::SynchronousProxy for PortSynchronousProxy {
2658    type Proxy = PortProxy;
2659    type Protocol = PortMarker;
2660
2661    fn from_channel(inner: fidl::Channel) -> Self {
2662        Self::new(inner)
2663    }
2664
2665    fn into_channel(self) -> fidl::Channel {
2666        self.client.into_channel()
2667    }
2668
2669    fn as_channel(&self) -> &fidl::Channel {
2670        self.client.as_channel()
2671    }
2672}
2673
2674#[cfg(target_os = "fuchsia")]
2675impl PortSynchronousProxy {
2676    pub fn new(channel: fidl::Channel) -> Self {
2677        let protocol_name = <PortMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2678        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2679    }
2680
2681    pub fn into_channel(self) -> fidl::Channel {
2682        self.client.into_channel()
2683    }
2684
2685    /// Waits until an event arrives and returns it. It is safe for other
2686    /// threads to make concurrent requests while waiting for an event.
2687    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<PortEvent, fidl::Error> {
2688        PortEvent::decode(self.client.wait_for_event(deadline)?)
2689    }
2690
2691    /// Gets the port internal state.
2692    ///
2693    /// - response `state` a snapshot of the port's internal state.
2694    pub fn r#get_state(
2695        &self,
2696        ___deadline: zx::MonotonicInstant,
2697    ) -> Result<InternalState, fidl::Error> {
2698        let _response =
2699            self.client.send_query::<fidl::encoding::EmptyPayload, PortGetStateResponse>(
2700                (),
2701                0x5022630816212ed,
2702                fidl::encoding::DynamicFlags::empty(),
2703                ___deadline,
2704            )?;
2705        Ok(_response.state)
2706    }
2707
2708    /// Observes changes to internal state.
2709    ///
2710    /// The first call always returns the current internal state, subsequent
2711    /// calls block until the internal state differs from the last one returned
2712    /// from a `WatchState` call.
2713    ///
2714    /// `WatchState` does not provide full history of internal state changes. It
2715    /// is possible that intermediary internal state changes are missed in
2716    /// between `WatchState` calls.
2717    ///
2718    /// - response `state` the latest observed port internal state.
2719    pub fn r#watch_state(
2720        &self,
2721        ___deadline: zx::MonotonicInstant,
2722    ) -> Result<InternalState, fidl::Error> {
2723        let _response =
2724            self.client.send_query::<fidl::encoding::EmptyPayload, PortWatchStateResponse>(
2725                (),
2726                0x74d3c94c96e2b605,
2727                fidl::encoding::DynamicFlags::empty(),
2728                ___deadline,
2729            )?;
2730        Ok(_response.state)
2731    }
2732
2733    /// Sets the port's online status.
2734    ///
2735    /// The online status is visible through
2736    /// [`fuchsia.hardware.network/Port.GetStatus`]. Once `SetOnline` returns,
2737    /// the status reported through `GetStatus` is guaranteed to be the one
2738    /// passed to `SetOnline`.
2739    ///
2740    /// + request `online` desired port online state.
2741    pub fn r#set_online(
2742        &self,
2743        mut online: bool,
2744        ___deadline: zx::MonotonicInstant,
2745    ) -> Result<(), fidl::Error> {
2746        let _response =
2747            self.client.send_query::<PortSetOnlineRequest, fidl::encoding::EmptyPayload>(
2748                (online,),
2749                0x734f83793ce86e6c,
2750                fidl::encoding::DynamicFlags::empty(),
2751                ___deadline,
2752            )?;
2753        Ok(_response)
2754    }
2755
2756    /// Connects to the underlying device port.
2757    ///
2758    /// + request `port` grants access to the device port.
2759    pub fn r#get_port(
2760        &self,
2761        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2762    ) -> Result<(), fidl::Error> {
2763        self.client.send::<PortGetPortRequest>(
2764            (port,),
2765            0x1998638c1d97eed2,
2766            fidl::encoding::DynamicFlags::empty(),
2767        )
2768    }
2769
2770    /// Triggers port removal.
2771    ///
2772    /// The client end will be closed once the server has completely cleaned up
2773    /// all resources related to the port. This is equivalent to simply dropping
2774    /// the client end, but provides callers with a signal of when removal is
2775    /// complete, allowing port identifiers to be reused, for example.
2776    pub fn r#remove(&self) -> Result<(), fidl::Error> {
2777        self.client.send::<fidl::encoding::EmptyPayload>(
2778            (),
2779            0x4f45201ed5719261,
2780            fidl::encoding::DynamicFlags::empty(),
2781        )
2782    }
2783}
2784
2785#[cfg(target_os = "fuchsia")]
2786impl From<PortSynchronousProxy> for zx::Handle {
2787    fn from(value: PortSynchronousProxy) -> Self {
2788        value.into_channel().into()
2789    }
2790}
2791
2792#[cfg(target_os = "fuchsia")]
2793impl From<fidl::Channel> for PortSynchronousProxy {
2794    fn from(value: fidl::Channel) -> Self {
2795        Self::new(value)
2796    }
2797}
2798
2799#[cfg(target_os = "fuchsia")]
2800impl fidl::endpoints::FromClient for PortSynchronousProxy {
2801    type Protocol = PortMarker;
2802
2803    fn from_client(value: fidl::endpoints::ClientEnd<PortMarker>) -> Self {
2804        Self::new(value.into_channel())
2805    }
2806}
2807
2808#[derive(Debug, Clone)]
2809pub struct PortProxy {
2810    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2811}
2812
2813impl fidl::endpoints::Proxy for PortProxy {
2814    type Protocol = PortMarker;
2815
2816    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2817        Self::new(inner)
2818    }
2819
2820    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2821        self.client.into_channel().map_err(|client| Self { client })
2822    }
2823
2824    fn as_channel(&self) -> &::fidl::AsyncChannel {
2825        self.client.as_channel()
2826    }
2827}
2828
2829impl PortProxy {
2830    /// Create a new Proxy for fuchsia.net.tun/Port.
2831    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2832        let protocol_name = <PortMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2833        Self { client: fidl::client::Client::new(channel, protocol_name) }
2834    }
2835
2836    /// Get a Stream of events from the remote end of the protocol.
2837    ///
2838    /// # Panics
2839    ///
2840    /// Panics if the event stream was already taken.
2841    pub fn take_event_stream(&self) -> PortEventStream {
2842        PortEventStream { event_receiver: self.client.take_event_receiver() }
2843    }
2844
2845    /// Gets the port internal state.
2846    ///
2847    /// - response `state` a snapshot of the port's internal state.
2848    pub fn r#get_state(
2849        &self,
2850    ) -> fidl::client::QueryResponseFut<InternalState, fidl::encoding::DefaultFuchsiaResourceDialect>
2851    {
2852        PortProxyInterface::r#get_state(self)
2853    }
2854
2855    /// Observes changes to internal state.
2856    ///
2857    /// The first call always returns the current internal state, subsequent
2858    /// calls block until the internal state differs from the last one returned
2859    /// from a `WatchState` call.
2860    ///
2861    /// `WatchState` does not provide full history of internal state changes. It
2862    /// is possible that intermediary internal state changes are missed in
2863    /// between `WatchState` calls.
2864    ///
2865    /// - response `state` the latest observed port internal state.
2866    pub fn r#watch_state(
2867        &self,
2868    ) -> fidl::client::QueryResponseFut<InternalState, fidl::encoding::DefaultFuchsiaResourceDialect>
2869    {
2870        PortProxyInterface::r#watch_state(self)
2871    }
2872
2873    /// Sets the port's online status.
2874    ///
2875    /// The online status is visible through
2876    /// [`fuchsia.hardware.network/Port.GetStatus`]. Once `SetOnline` returns,
2877    /// the status reported through `GetStatus` is guaranteed to be the one
2878    /// passed to `SetOnline`.
2879    ///
2880    /// + request `online` desired port online state.
2881    pub fn r#set_online(
2882        &self,
2883        mut online: bool,
2884    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2885        PortProxyInterface::r#set_online(self, online)
2886    }
2887
2888    /// Connects to the underlying device port.
2889    ///
2890    /// + request `port` grants access to the device port.
2891    pub fn r#get_port(
2892        &self,
2893        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2894    ) -> Result<(), fidl::Error> {
2895        PortProxyInterface::r#get_port(self, port)
2896    }
2897
2898    /// Triggers port removal.
2899    ///
2900    /// The client end will be closed once the server has completely cleaned up
2901    /// all resources related to the port. This is equivalent to simply dropping
2902    /// the client end, but provides callers with a signal of when removal is
2903    /// complete, allowing port identifiers to be reused, for example.
2904    pub fn r#remove(&self) -> Result<(), fidl::Error> {
2905        PortProxyInterface::r#remove(self)
2906    }
2907}
2908
2909impl PortProxyInterface for PortProxy {
2910    type GetStateResponseFut = fidl::client::QueryResponseFut<
2911        InternalState,
2912        fidl::encoding::DefaultFuchsiaResourceDialect,
2913    >;
2914    fn r#get_state(&self) -> Self::GetStateResponseFut {
2915        fn _decode(
2916            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2917        ) -> Result<InternalState, fidl::Error> {
2918            let _response = fidl::client::decode_transaction_body::<
2919                PortGetStateResponse,
2920                fidl::encoding::DefaultFuchsiaResourceDialect,
2921                0x5022630816212ed,
2922            >(_buf?)?;
2923            Ok(_response.state)
2924        }
2925        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, InternalState>(
2926            (),
2927            0x5022630816212ed,
2928            fidl::encoding::DynamicFlags::empty(),
2929            _decode,
2930        )
2931    }
2932
2933    type WatchStateResponseFut = fidl::client::QueryResponseFut<
2934        InternalState,
2935        fidl::encoding::DefaultFuchsiaResourceDialect,
2936    >;
2937    fn r#watch_state(&self) -> Self::WatchStateResponseFut {
2938        fn _decode(
2939            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2940        ) -> Result<InternalState, fidl::Error> {
2941            let _response = fidl::client::decode_transaction_body::<
2942                PortWatchStateResponse,
2943                fidl::encoding::DefaultFuchsiaResourceDialect,
2944                0x74d3c94c96e2b605,
2945            >(_buf?)?;
2946            Ok(_response.state)
2947        }
2948        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, InternalState>(
2949            (),
2950            0x74d3c94c96e2b605,
2951            fidl::encoding::DynamicFlags::empty(),
2952            _decode,
2953        )
2954    }
2955
2956    type SetOnlineResponseFut =
2957        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2958    fn r#set_online(&self, mut online: bool) -> Self::SetOnlineResponseFut {
2959        fn _decode(
2960            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2961        ) -> Result<(), fidl::Error> {
2962            let _response = fidl::client::decode_transaction_body::<
2963                fidl::encoding::EmptyPayload,
2964                fidl::encoding::DefaultFuchsiaResourceDialect,
2965                0x734f83793ce86e6c,
2966            >(_buf?)?;
2967            Ok(_response)
2968        }
2969        self.client.send_query_and_decode::<PortSetOnlineRequest, ()>(
2970            (online,),
2971            0x734f83793ce86e6c,
2972            fidl::encoding::DynamicFlags::empty(),
2973            _decode,
2974        )
2975    }
2976
2977    fn r#get_port(
2978        &self,
2979        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
2980    ) -> Result<(), fidl::Error> {
2981        self.client.send::<PortGetPortRequest>(
2982            (port,),
2983            0x1998638c1d97eed2,
2984            fidl::encoding::DynamicFlags::empty(),
2985        )
2986    }
2987
2988    fn r#remove(&self) -> Result<(), fidl::Error> {
2989        self.client.send::<fidl::encoding::EmptyPayload>(
2990            (),
2991            0x4f45201ed5719261,
2992            fidl::encoding::DynamicFlags::empty(),
2993        )
2994    }
2995}
2996
2997pub struct PortEventStream {
2998    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2999}
3000
3001impl std::marker::Unpin for PortEventStream {}
3002
3003impl futures::stream::FusedStream for PortEventStream {
3004    fn is_terminated(&self) -> bool {
3005        self.event_receiver.is_terminated()
3006    }
3007}
3008
3009impl futures::Stream for PortEventStream {
3010    type Item = Result<PortEvent, fidl::Error>;
3011
3012    fn poll_next(
3013        mut self: std::pin::Pin<&mut Self>,
3014        cx: &mut std::task::Context<'_>,
3015    ) -> std::task::Poll<Option<Self::Item>> {
3016        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3017            &mut self.event_receiver,
3018            cx
3019        )?) {
3020            Some(buf) => std::task::Poll::Ready(Some(PortEvent::decode(buf))),
3021            None => std::task::Poll::Ready(None),
3022        }
3023    }
3024}
3025
3026#[derive(Debug)]
3027pub enum PortEvent {}
3028
3029impl PortEvent {
3030    /// Decodes a message buffer as a [`PortEvent`].
3031    fn decode(
3032        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3033    ) -> Result<PortEvent, fidl::Error> {
3034        let (bytes, _handles) = buf.split_mut();
3035        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3036        debug_assert_eq!(tx_header.tx_id, 0);
3037        match tx_header.ordinal {
3038            _ => Err(fidl::Error::UnknownOrdinal {
3039                ordinal: tx_header.ordinal,
3040                protocol_name: <PortMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3041            }),
3042        }
3043    }
3044}
3045
3046/// A Stream of incoming requests for fuchsia.net.tun/Port.
3047pub struct PortRequestStream {
3048    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3049    is_terminated: bool,
3050}
3051
3052impl std::marker::Unpin for PortRequestStream {}
3053
3054impl futures::stream::FusedStream for PortRequestStream {
3055    fn is_terminated(&self) -> bool {
3056        self.is_terminated
3057    }
3058}
3059
3060impl fidl::endpoints::RequestStream for PortRequestStream {
3061    type Protocol = PortMarker;
3062    type ControlHandle = PortControlHandle;
3063
3064    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3065        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3066    }
3067
3068    fn control_handle(&self) -> Self::ControlHandle {
3069        PortControlHandle { inner: self.inner.clone() }
3070    }
3071
3072    fn into_inner(
3073        self,
3074    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3075    {
3076        (self.inner, self.is_terminated)
3077    }
3078
3079    fn from_inner(
3080        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3081        is_terminated: bool,
3082    ) -> Self {
3083        Self { inner, is_terminated }
3084    }
3085}
3086
3087impl futures::Stream for PortRequestStream {
3088    type Item = Result<PortRequest, fidl::Error>;
3089
3090    fn poll_next(
3091        mut self: std::pin::Pin<&mut Self>,
3092        cx: &mut std::task::Context<'_>,
3093    ) -> std::task::Poll<Option<Self::Item>> {
3094        let this = &mut *self;
3095        if this.inner.check_shutdown(cx) {
3096            this.is_terminated = true;
3097            return std::task::Poll::Ready(None);
3098        }
3099        if this.is_terminated {
3100            panic!("polled PortRequestStream after completion");
3101        }
3102        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3103            |bytes, handles| {
3104                match this.inner.channel().read_etc(cx, bytes, handles) {
3105                    std::task::Poll::Ready(Ok(())) => {}
3106                    std::task::Poll::Pending => return std::task::Poll::Pending,
3107                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3108                        this.is_terminated = true;
3109                        return std::task::Poll::Ready(None);
3110                    }
3111                    std::task::Poll::Ready(Err(e)) => {
3112                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3113                            e.into(),
3114                        ))));
3115                    }
3116                }
3117
3118                // A message has been received from the channel
3119                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3120
3121                std::task::Poll::Ready(Some(match header.ordinal {
3122                    0x5022630816212ed => {
3123                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3124                        let mut req = fidl::new_empty!(
3125                            fidl::encoding::EmptyPayload,
3126                            fidl::encoding::DefaultFuchsiaResourceDialect
3127                        );
3128                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3129                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3130                        Ok(PortRequest::GetState {
3131                            responder: PortGetStateResponder {
3132                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3133                                tx_id: header.tx_id,
3134                            },
3135                        })
3136                    }
3137                    0x74d3c94c96e2b605 => {
3138                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3139                        let mut req = fidl::new_empty!(
3140                            fidl::encoding::EmptyPayload,
3141                            fidl::encoding::DefaultFuchsiaResourceDialect
3142                        );
3143                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3144                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3145                        Ok(PortRequest::WatchState {
3146                            responder: PortWatchStateResponder {
3147                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3148                                tx_id: header.tx_id,
3149                            },
3150                        })
3151                    }
3152                    0x734f83793ce86e6c => {
3153                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3154                        let mut req = fidl::new_empty!(
3155                            PortSetOnlineRequest,
3156                            fidl::encoding::DefaultFuchsiaResourceDialect
3157                        );
3158                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PortSetOnlineRequest>(&header, _body_bytes, handles, &mut req)?;
3159                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3160                        Ok(PortRequest::SetOnline {
3161                            online: req.online,
3162
3163                            responder: PortSetOnlineResponder {
3164                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3165                                tx_id: header.tx_id,
3166                            },
3167                        })
3168                    }
3169                    0x1998638c1d97eed2 => {
3170                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3171                        let mut req = fidl::new_empty!(
3172                            PortGetPortRequest,
3173                            fidl::encoding::DefaultFuchsiaResourceDialect
3174                        );
3175                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PortGetPortRequest>(&header, _body_bytes, handles, &mut req)?;
3176                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3177                        Ok(PortRequest::GetPort { port: req.port, control_handle })
3178                    }
3179                    0x4f45201ed5719261 => {
3180                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3181                        let mut req = fidl::new_empty!(
3182                            fidl::encoding::EmptyPayload,
3183                            fidl::encoding::DefaultFuchsiaResourceDialect
3184                        );
3185                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3186                        let control_handle = PortControlHandle { inner: this.inner.clone() };
3187                        Ok(PortRequest::Remove { control_handle })
3188                    }
3189                    _ => Err(fidl::Error::UnknownOrdinal {
3190                        ordinal: header.ordinal,
3191                        protocol_name: <PortMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3192                    }),
3193                }))
3194            },
3195        )
3196    }
3197}
3198
3199/// A logical port attached to a [`fuchsia.net.tun/Device`].
3200///
3201/// This protocol encodes the underlying object's lifetime in both directions;
3202/// the underlying object is alive iff both ends of the protocol are open. That
3203/// is:
3204///
3205/// - Closing the client end causes the object to be destroyed.
3206/// - Observing a closure of the server end indicates the object no longer
3207/// exists.
3208#[derive(Debug)]
3209pub enum PortRequest {
3210    /// Gets the port internal state.
3211    ///
3212    /// - response `state` a snapshot of the port's internal state.
3213    GetState { responder: PortGetStateResponder },
3214    /// Observes changes to internal state.
3215    ///
3216    /// The first call always returns the current internal state, subsequent
3217    /// calls block until the internal state differs from the last one returned
3218    /// from a `WatchState` call.
3219    ///
3220    /// `WatchState` does not provide full history of internal state changes. It
3221    /// is possible that intermediary internal state changes are missed in
3222    /// between `WatchState` calls.
3223    ///
3224    /// - response `state` the latest observed port internal state.
3225    WatchState { responder: PortWatchStateResponder },
3226    /// Sets the port's online status.
3227    ///
3228    /// The online status is visible through
3229    /// [`fuchsia.hardware.network/Port.GetStatus`]. Once `SetOnline` returns,
3230    /// the status reported through `GetStatus` is guaranteed to be the one
3231    /// passed to `SetOnline`.
3232    ///
3233    /// + request `online` desired port online state.
3234    SetOnline { online: bool, responder: PortSetOnlineResponder },
3235    /// Connects to the underlying device port.
3236    ///
3237    /// + request `port` grants access to the device port.
3238    GetPort {
3239        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
3240        control_handle: PortControlHandle,
3241    },
3242    /// Triggers port removal.
3243    ///
3244    /// The client end will be closed once the server has completely cleaned up
3245    /// all resources related to the port. This is equivalent to simply dropping
3246    /// the client end, but provides callers with a signal of when removal is
3247    /// complete, allowing port identifiers to be reused, for example.
3248    Remove { control_handle: PortControlHandle },
3249}
3250
3251impl PortRequest {
3252    #[allow(irrefutable_let_patterns)]
3253    pub fn into_get_state(self) -> Option<(PortGetStateResponder)> {
3254        if let PortRequest::GetState { responder } = self { Some((responder)) } else { None }
3255    }
3256
3257    #[allow(irrefutable_let_patterns)]
3258    pub fn into_watch_state(self) -> Option<(PortWatchStateResponder)> {
3259        if let PortRequest::WatchState { responder } = self { Some((responder)) } else { None }
3260    }
3261
3262    #[allow(irrefutable_let_patterns)]
3263    pub fn into_set_online(self) -> Option<(bool, PortSetOnlineResponder)> {
3264        if let PortRequest::SetOnline { online, responder } = self {
3265            Some((online, responder))
3266        } else {
3267            None
3268        }
3269    }
3270
3271    #[allow(irrefutable_let_patterns)]
3272    pub fn into_get_port(
3273        self,
3274    ) -> Option<(
3275        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
3276        PortControlHandle,
3277    )> {
3278        if let PortRequest::GetPort { port, control_handle } = self {
3279            Some((port, control_handle))
3280        } else {
3281            None
3282        }
3283    }
3284
3285    #[allow(irrefutable_let_patterns)]
3286    pub fn into_remove(self) -> Option<(PortControlHandle)> {
3287        if let PortRequest::Remove { control_handle } = self {
3288            Some((control_handle))
3289        } else {
3290            None
3291        }
3292    }
3293
3294    /// Name of the method defined in FIDL
3295    pub fn method_name(&self) -> &'static str {
3296        match *self {
3297            PortRequest::GetState { .. } => "get_state",
3298            PortRequest::WatchState { .. } => "watch_state",
3299            PortRequest::SetOnline { .. } => "set_online",
3300            PortRequest::GetPort { .. } => "get_port",
3301            PortRequest::Remove { .. } => "remove",
3302        }
3303    }
3304}
3305
3306#[derive(Debug, Clone)]
3307pub struct PortControlHandle {
3308    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3309}
3310
3311impl fidl::endpoints::ControlHandle for PortControlHandle {
3312    fn shutdown(&self) {
3313        self.inner.shutdown()
3314    }
3315    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3316        self.inner.shutdown_with_epitaph(status)
3317    }
3318
3319    fn is_closed(&self) -> bool {
3320        self.inner.channel().is_closed()
3321    }
3322    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3323        self.inner.channel().on_closed()
3324    }
3325
3326    #[cfg(target_os = "fuchsia")]
3327    fn signal_peer(
3328        &self,
3329        clear_mask: zx::Signals,
3330        set_mask: zx::Signals,
3331    ) -> Result<(), zx_status::Status> {
3332        use fidl::Peered;
3333        self.inner.channel().signal_peer(clear_mask, set_mask)
3334    }
3335}
3336
3337impl PortControlHandle {}
3338
3339#[must_use = "FIDL methods require a response to be sent"]
3340#[derive(Debug)]
3341pub struct PortGetStateResponder {
3342    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3343    tx_id: u32,
3344}
3345
3346/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3347/// if the responder is dropped without sending a response, so that the client
3348/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3349impl std::ops::Drop for PortGetStateResponder {
3350    fn drop(&mut self) {
3351        self.control_handle.shutdown();
3352        // Safety: drops once, never accessed again
3353        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3354    }
3355}
3356
3357impl fidl::endpoints::Responder for PortGetStateResponder {
3358    type ControlHandle = PortControlHandle;
3359
3360    fn control_handle(&self) -> &PortControlHandle {
3361        &self.control_handle
3362    }
3363
3364    fn drop_without_shutdown(mut self) {
3365        // Safety: drops once, never accessed again due to mem::forget
3366        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3367        // Prevent Drop from running (which would shut down the channel)
3368        std::mem::forget(self);
3369    }
3370}
3371
3372impl PortGetStateResponder {
3373    /// Sends a response to the FIDL transaction.
3374    ///
3375    /// Sets the channel to shutdown if an error occurs.
3376    pub fn send(self, mut state: &InternalState) -> Result<(), fidl::Error> {
3377        let _result = self.send_raw(state);
3378        if _result.is_err() {
3379            self.control_handle.shutdown();
3380        }
3381        self.drop_without_shutdown();
3382        _result
3383    }
3384
3385    /// Similar to "send" but does not shutdown the channel if an error occurs.
3386    pub fn send_no_shutdown_on_err(self, mut state: &InternalState) -> Result<(), fidl::Error> {
3387        let _result = self.send_raw(state);
3388        self.drop_without_shutdown();
3389        _result
3390    }
3391
3392    fn send_raw(&self, mut state: &InternalState) -> Result<(), fidl::Error> {
3393        self.control_handle.inner.send::<PortGetStateResponse>(
3394            (state,),
3395            self.tx_id,
3396            0x5022630816212ed,
3397            fidl::encoding::DynamicFlags::empty(),
3398        )
3399    }
3400}
3401
3402#[must_use = "FIDL methods require a response to be sent"]
3403#[derive(Debug)]
3404pub struct PortWatchStateResponder {
3405    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3406    tx_id: u32,
3407}
3408
3409/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3410/// if the responder is dropped without sending a response, so that the client
3411/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3412impl std::ops::Drop for PortWatchStateResponder {
3413    fn drop(&mut self) {
3414        self.control_handle.shutdown();
3415        // Safety: drops once, never accessed again
3416        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3417    }
3418}
3419
3420impl fidl::endpoints::Responder for PortWatchStateResponder {
3421    type ControlHandle = PortControlHandle;
3422
3423    fn control_handle(&self) -> &PortControlHandle {
3424        &self.control_handle
3425    }
3426
3427    fn drop_without_shutdown(mut self) {
3428        // Safety: drops once, never accessed again due to mem::forget
3429        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3430        // Prevent Drop from running (which would shut down the channel)
3431        std::mem::forget(self);
3432    }
3433}
3434
3435impl PortWatchStateResponder {
3436    /// Sends a response to the FIDL transaction.
3437    ///
3438    /// Sets the channel to shutdown if an error occurs.
3439    pub fn send(self, mut state: &InternalState) -> Result<(), fidl::Error> {
3440        let _result = self.send_raw(state);
3441        if _result.is_err() {
3442            self.control_handle.shutdown();
3443        }
3444        self.drop_without_shutdown();
3445        _result
3446    }
3447
3448    /// Similar to "send" but does not shutdown the channel if an error occurs.
3449    pub fn send_no_shutdown_on_err(self, mut state: &InternalState) -> Result<(), fidl::Error> {
3450        let _result = self.send_raw(state);
3451        self.drop_without_shutdown();
3452        _result
3453    }
3454
3455    fn send_raw(&self, mut state: &InternalState) -> Result<(), fidl::Error> {
3456        self.control_handle.inner.send::<PortWatchStateResponse>(
3457            (state,),
3458            self.tx_id,
3459            0x74d3c94c96e2b605,
3460            fidl::encoding::DynamicFlags::empty(),
3461        )
3462    }
3463}
3464
3465#[must_use = "FIDL methods require a response to be sent"]
3466#[derive(Debug)]
3467pub struct PortSetOnlineResponder {
3468    control_handle: std::mem::ManuallyDrop<PortControlHandle>,
3469    tx_id: u32,
3470}
3471
3472/// Set the the channel to be shutdown (see [`PortControlHandle::shutdown`])
3473/// if the responder is dropped without sending a response, so that the client
3474/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3475impl std::ops::Drop for PortSetOnlineResponder {
3476    fn drop(&mut self) {
3477        self.control_handle.shutdown();
3478        // Safety: drops once, never accessed again
3479        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3480    }
3481}
3482
3483impl fidl::endpoints::Responder for PortSetOnlineResponder {
3484    type ControlHandle = PortControlHandle;
3485
3486    fn control_handle(&self) -> &PortControlHandle {
3487        &self.control_handle
3488    }
3489
3490    fn drop_without_shutdown(mut self) {
3491        // Safety: drops once, never accessed again due to mem::forget
3492        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3493        // Prevent Drop from running (which would shut down the channel)
3494        std::mem::forget(self);
3495    }
3496}
3497
3498impl PortSetOnlineResponder {
3499    /// Sends a response to the FIDL transaction.
3500    ///
3501    /// Sets the channel to shutdown if an error occurs.
3502    pub fn send(self) -> Result<(), fidl::Error> {
3503        let _result = self.send_raw();
3504        if _result.is_err() {
3505            self.control_handle.shutdown();
3506        }
3507        self.drop_without_shutdown();
3508        _result
3509    }
3510
3511    /// Similar to "send" but does not shutdown the channel if an error occurs.
3512    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3513        let _result = self.send_raw();
3514        self.drop_without_shutdown();
3515        _result
3516    }
3517
3518    fn send_raw(&self) -> Result<(), fidl::Error> {
3519        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3520            (),
3521            self.tx_id,
3522            0x734f83793ce86e6c,
3523            fidl::encoding::DynamicFlags::empty(),
3524        )
3525    }
3526}
3527
3528mod internal {
3529    use super::*;
3530
3531    impl fidl::encoding::ResourceTypeMarker for ControlCreateDeviceRequest {
3532        type Borrowed<'a> = &'a mut Self;
3533        fn take_or_borrow<'a>(
3534            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3535        ) -> Self::Borrowed<'a> {
3536            value
3537        }
3538    }
3539
3540    unsafe impl fidl::encoding::TypeMarker for ControlCreateDeviceRequest {
3541        type Owned = Self;
3542
3543        #[inline(always)]
3544        fn inline_align(_context: fidl::encoding::Context) -> usize {
3545            8
3546        }
3547
3548        #[inline(always)]
3549        fn inline_size(_context: fidl::encoding::Context) -> usize {
3550            24
3551        }
3552    }
3553
3554    unsafe impl
3555        fidl::encoding::Encode<
3556            ControlCreateDeviceRequest,
3557            fidl::encoding::DefaultFuchsiaResourceDialect,
3558        > for &mut ControlCreateDeviceRequest
3559    {
3560        #[inline]
3561        unsafe fn encode(
3562            self,
3563            encoder: &mut fidl::encoding::Encoder<
3564                '_,
3565                fidl::encoding::DefaultFuchsiaResourceDialect,
3566            >,
3567            offset: usize,
3568            _depth: fidl::encoding::Depth,
3569        ) -> fidl::Result<()> {
3570            encoder.debug_check_bounds::<ControlCreateDeviceRequest>(offset);
3571            // Delegate to tuple encoding.
3572            fidl::encoding::Encode::<ControlCreateDeviceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3573                (
3574                    <DeviceConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
3575                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.device),
3576                ),
3577                encoder, offset, _depth
3578            )
3579        }
3580    }
3581    unsafe impl<
3582        T0: fidl::encoding::Encode<DeviceConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
3583        T1: fidl::encoding::Encode<
3584                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
3585                fidl::encoding::DefaultFuchsiaResourceDialect,
3586            >,
3587    >
3588        fidl::encoding::Encode<
3589            ControlCreateDeviceRequest,
3590            fidl::encoding::DefaultFuchsiaResourceDialect,
3591        > for (T0, T1)
3592    {
3593        #[inline]
3594        unsafe fn encode(
3595            self,
3596            encoder: &mut fidl::encoding::Encoder<
3597                '_,
3598                fidl::encoding::DefaultFuchsiaResourceDialect,
3599            >,
3600            offset: usize,
3601            depth: fidl::encoding::Depth,
3602        ) -> fidl::Result<()> {
3603            encoder.debug_check_bounds::<ControlCreateDeviceRequest>(offset);
3604            // Zero out padding regions. There's no need to apply masks
3605            // because the unmasked parts will be overwritten by fields.
3606            unsafe {
3607                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3608                (ptr as *mut u64).write_unaligned(0);
3609            }
3610            // Write the fields.
3611            self.0.encode(encoder, offset + 0, depth)?;
3612            self.1.encode(encoder, offset + 16, depth)?;
3613            Ok(())
3614        }
3615    }
3616
3617    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3618        for ControlCreateDeviceRequest
3619    {
3620        #[inline(always)]
3621        fn new_empty() -> Self {
3622            Self {
3623                config: fidl::new_empty!(
3624                    DeviceConfig,
3625                    fidl::encoding::DefaultFuchsiaResourceDialect
3626                ),
3627                device: fidl::new_empty!(
3628                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
3629                    fidl::encoding::DefaultFuchsiaResourceDialect
3630                ),
3631            }
3632        }
3633
3634        #[inline]
3635        unsafe fn decode(
3636            &mut self,
3637            decoder: &mut fidl::encoding::Decoder<
3638                '_,
3639                fidl::encoding::DefaultFuchsiaResourceDialect,
3640            >,
3641            offset: usize,
3642            _depth: fidl::encoding::Depth,
3643        ) -> fidl::Result<()> {
3644            decoder.debug_check_bounds::<Self>(offset);
3645            // Verify that padding bytes are zero.
3646            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3647            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3648            let mask = 0xffffffff00000000u64;
3649            let maskedval = padval & mask;
3650            if maskedval != 0 {
3651                return Err(fidl::Error::NonZeroPadding {
3652                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3653                });
3654            }
3655            fidl::decode!(
3656                DeviceConfig,
3657                fidl::encoding::DefaultFuchsiaResourceDialect,
3658                &mut self.config,
3659                decoder,
3660                offset + 0,
3661                _depth
3662            )?;
3663            fidl::decode!(
3664                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
3665                fidl::encoding::DefaultFuchsiaResourceDialect,
3666                &mut self.device,
3667                decoder,
3668                offset + 16,
3669                _depth
3670            )?;
3671            Ok(())
3672        }
3673    }
3674
3675    impl fidl::encoding::ResourceTypeMarker for ControlCreatePairRequest {
3676        type Borrowed<'a> = &'a mut Self;
3677        fn take_or_borrow<'a>(
3678            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3679        ) -> Self::Borrowed<'a> {
3680            value
3681        }
3682    }
3683
3684    unsafe impl fidl::encoding::TypeMarker for ControlCreatePairRequest {
3685        type Owned = Self;
3686
3687        #[inline(always)]
3688        fn inline_align(_context: fidl::encoding::Context) -> usize {
3689            8
3690        }
3691
3692        #[inline(always)]
3693        fn inline_size(_context: fidl::encoding::Context) -> usize {
3694            24
3695        }
3696    }
3697
3698    unsafe impl
3699        fidl::encoding::Encode<
3700            ControlCreatePairRequest,
3701            fidl::encoding::DefaultFuchsiaResourceDialect,
3702        > for &mut ControlCreatePairRequest
3703    {
3704        #[inline]
3705        unsafe fn encode(
3706            self,
3707            encoder: &mut fidl::encoding::Encoder<
3708                '_,
3709                fidl::encoding::DefaultFuchsiaResourceDialect,
3710            >,
3711            offset: usize,
3712            _depth: fidl::encoding::Depth,
3713        ) -> fidl::Result<()> {
3714            encoder.debug_check_bounds::<ControlCreatePairRequest>(offset);
3715            // Delegate to tuple encoding.
3716            fidl::encoding::Encode::<ControlCreatePairRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3717                (
3718                    <DevicePairConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
3719                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DevicePairMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.device_pair),
3720                ),
3721                encoder, offset, _depth
3722            )
3723        }
3724    }
3725    unsafe impl<
3726        T0: fidl::encoding::Encode<DevicePairConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
3727        T1: fidl::encoding::Encode<
3728                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DevicePairMarker>>,
3729                fidl::encoding::DefaultFuchsiaResourceDialect,
3730            >,
3731    >
3732        fidl::encoding::Encode<
3733            ControlCreatePairRequest,
3734            fidl::encoding::DefaultFuchsiaResourceDialect,
3735        > for (T0, T1)
3736    {
3737        #[inline]
3738        unsafe fn encode(
3739            self,
3740            encoder: &mut fidl::encoding::Encoder<
3741                '_,
3742                fidl::encoding::DefaultFuchsiaResourceDialect,
3743            >,
3744            offset: usize,
3745            depth: fidl::encoding::Depth,
3746        ) -> fidl::Result<()> {
3747            encoder.debug_check_bounds::<ControlCreatePairRequest>(offset);
3748            // Zero out padding regions. There's no need to apply masks
3749            // because the unmasked parts will be overwritten by fields.
3750            unsafe {
3751                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3752                (ptr as *mut u64).write_unaligned(0);
3753            }
3754            // Write the fields.
3755            self.0.encode(encoder, offset + 0, depth)?;
3756            self.1.encode(encoder, offset + 16, depth)?;
3757            Ok(())
3758        }
3759    }
3760
3761    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3762        for ControlCreatePairRequest
3763    {
3764        #[inline(always)]
3765        fn new_empty() -> Self {
3766            Self {
3767                config: fidl::new_empty!(
3768                    DevicePairConfig,
3769                    fidl::encoding::DefaultFuchsiaResourceDialect
3770                ),
3771                device_pair: fidl::new_empty!(
3772                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DevicePairMarker>>,
3773                    fidl::encoding::DefaultFuchsiaResourceDialect
3774                ),
3775            }
3776        }
3777
3778        #[inline]
3779        unsafe fn decode(
3780            &mut self,
3781            decoder: &mut fidl::encoding::Decoder<
3782                '_,
3783                fidl::encoding::DefaultFuchsiaResourceDialect,
3784            >,
3785            offset: usize,
3786            _depth: fidl::encoding::Depth,
3787        ) -> fidl::Result<()> {
3788            decoder.debug_check_bounds::<Self>(offset);
3789            // Verify that padding bytes are zero.
3790            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3791            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3792            let mask = 0xffffffff00000000u64;
3793            let maskedval = padval & mask;
3794            if maskedval != 0 {
3795                return Err(fidl::Error::NonZeroPadding {
3796                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3797                });
3798            }
3799            fidl::decode!(
3800                DevicePairConfig,
3801                fidl::encoding::DefaultFuchsiaResourceDialect,
3802                &mut self.config,
3803                decoder,
3804                offset + 0,
3805                _depth
3806            )?;
3807            fidl::decode!(
3808                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DevicePairMarker>>,
3809                fidl::encoding::DefaultFuchsiaResourceDialect,
3810                &mut self.device_pair,
3811                decoder,
3812                offset + 16,
3813                _depth
3814            )?;
3815            Ok(())
3816        }
3817    }
3818
3819    impl fidl::encoding::ResourceTypeMarker for DeviceAddPortRequest {
3820        type Borrowed<'a> = &'a mut Self;
3821        fn take_or_borrow<'a>(
3822            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3823        ) -> Self::Borrowed<'a> {
3824            value
3825        }
3826    }
3827
3828    unsafe impl fidl::encoding::TypeMarker for DeviceAddPortRequest {
3829        type Owned = Self;
3830
3831        #[inline(always)]
3832        fn inline_align(_context: fidl::encoding::Context) -> usize {
3833            8
3834        }
3835
3836        #[inline(always)]
3837        fn inline_size(_context: fidl::encoding::Context) -> usize {
3838            24
3839        }
3840    }
3841
3842    unsafe impl
3843        fidl::encoding::Encode<DeviceAddPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3844        for &mut DeviceAddPortRequest
3845    {
3846        #[inline]
3847        unsafe fn encode(
3848            self,
3849            encoder: &mut fidl::encoding::Encoder<
3850                '_,
3851                fidl::encoding::DefaultFuchsiaResourceDialect,
3852            >,
3853            offset: usize,
3854            _depth: fidl::encoding::Depth,
3855        ) -> fidl::Result<()> {
3856            encoder.debug_check_bounds::<DeviceAddPortRequest>(offset);
3857            // Delegate to tuple encoding.
3858            fidl::encoding::Encode::<DeviceAddPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3859                (
3860                    <DevicePortConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
3861                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.port),
3862                ),
3863                encoder, offset, _depth
3864            )
3865        }
3866    }
3867    unsafe impl<
3868        T0: fidl::encoding::Encode<DevicePortConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
3869        T1: fidl::encoding::Encode<
3870                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
3871                fidl::encoding::DefaultFuchsiaResourceDialect,
3872            >,
3873    >
3874        fidl::encoding::Encode<DeviceAddPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3875        for (T0, T1)
3876    {
3877        #[inline]
3878        unsafe fn encode(
3879            self,
3880            encoder: &mut fidl::encoding::Encoder<
3881                '_,
3882                fidl::encoding::DefaultFuchsiaResourceDialect,
3883            >,
3884            offset: usize,
3885            depth: fidl::encoding::Depth,
3886        ) -> fidl::Result<()> {
3887            encoder.debug_check_bounds::<DeviceAddPortRequest>(offset);
3888            // Zero out padding regions. There's no need to apply masks
3889            // because the unmasked parts will be overwritten by fields.
3890            unsafe {
3891                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3892                (ptr as *mut u64).write_unaligned(0);
3893            }
3894            // Write the fields.
3895            self.0.encode(encoder, offset + 0, depth)?;
3896            self.1.encode(encoder, offset + 16, depth)?;
3897            Ok(())
3898        }
3899    }
3900
3901    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3902        for DeviceAddPortRequest
3903    {
3904        #[inline(always)]
3905        fn new_empty() -> Self {
3906            Self {
3907                config: fidl::new_empty!(
3908                    DevicePortConfig,
3909                    fidl::encoding::DefaultFuchsiaResourceDialect
3910                ),
3911                port: fidl::new_empty!(
3912                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
3913                    fidl::encoding::DefaultFuchsiaResourceDialect
3914                ),
3915            }
3916        }
3917
3918        #[inline]
3919        unsafe fn decode(
3920            &mut self,
3921            decoder: &mut fidl::encoding::Decoder<
3922                '_,
3923                fidl::encoding::DefaultFuchsiaResourceDialect,
3924            >,
3925            offset: usize,
3926            _depth: fidl::encoding::Depth,
3927        ) -> fidl::Result<()> {
3928            decoder.debug_check_bounds::<Self>(offset);
3929            // Verify that padding bytes are zero.
3930            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3931            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3932            let mask = 0xffffffff00000000u64;
3933            let maskedval = padval & mask;
3934            if maskedval != 0 {
3935                return Err(fidl::Error::NonZeroPadding {
3936                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3937                });
3938            }
3939            fidl::decode!(
3940                DevicePortConfig,
3941                fidl::encoding::DefaultFuchsiaResourceDialect,
3942                &mut self.config,
3943                decoder,
3944                offset + 0,
3945                _depth
3946            )?;
3947            fidl::decode!(
3948                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PortMarker>>,
3949                fidl::encoding::DefaultFuchsiaResourceDialect,
3950                &mut self.port,
3951                decoder,
3952                offset + 16,
3953                _depth
3954            )?;
3955            Ok(())
3956        }
3957    }
3958
3959    impl fidl::encoding::ResourceTypeMarker for DeviceDelegateRxLeaseRequest {
3960        type Borrowed<'a> = &'a mut Self;
3961        fn take_or_borrow<'a>(
3962            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3963        ) -> Self::Borrowed<'a> {
3964            value
3965        }
3966    }
3967
3968    unsafe impl fidl::encoding::TypeMarker for DeviceDelegateRxLeaseRequest {
3969        type Owned = Self;
3970
3971        #[inline(always)]
3972        fn inline_align(_context: fidl::encoding::Context) -> usize {
3973            8
3974        }
3975
3976        #[inline(always)]
3977        fn inline_size(_context: fidl::encoding::Context) -> usize {
3978            16
3979        }
3980    }
3981
3982    unsafe impl
3983        fidl::encoding::Encode<
3984            DeviceDelegateRxLeaseRequest,
3985            fidl::encoding::DefaultFuchsiaResourceDialect,
3986        > for &mut DeviceDelegateRxLeaseRequest
3987    {
3988        #[inline]
3989        unsafe fn encode(
3990            self,
3991            encoder: &mut fidl::encoding::Encoder<
3992                '_,
3993                fidl::encoding::DefaultFuchsiaResourceDialect,
3994            >,
3995            offset: usize,
3996            _depth: fidl::encoding::Depth,
3997        ) -> fidl::Result<()> {
3998            encoder.debug_check_bounds::<DeviceDelegateRxLeaseRequest>(offset);
3999            // Delegate to tuple encoding.
4000            fidl::encoding::Encode::<DeviceDelegateRxLeaseRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4001                (
4002                    <fidl_fuchsia_hardware_network::DelegatedRxLease as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.lease),
4003                ),
4004                encoder, offset, _depth
4005            )
4006        }
4007    }
4008    unsafe impl<
4009        T0: fidl::encoding::Encode<
4010                fidl_fuchsia_hardware_network::DelegatedRxLease,
4011                fidl::encoding::DefaultFuchsiaResourceDialect,
4012            >,
4013    >
4014        fidl::encoding::Encode<
4015            DeviceDelegateRxLeaseRequest,
4016            fidl::encoding::DefaultFuchsiaResourceDialect,
4017        > for (T0,)
4018    {
4019        #[inline]
4020        unsafe fn encode(
4021            self,
4022            encoder: &mut fidl::encoding::Encoder<
4023                '_,
4024                fidl::encoding::DefaultFuchsiaResourceDialect,
4025            >,
4026            offset: usize,
4027            depth: fidl::encoding::Depth,
4028        ) -> fidl::Result<()> {
4029            encoder.debug_check_bounds::<DeviceDelegateRxLeaseRequest>(offset);
4030            // Zero out padding regions. There's no need to apply masks
4031            // because the unmasked parts will be overwritten by fields.
4032            // Write the fields.
4033            self.0.encode(encoder, offset + 0, depth)?;
4034            Ok(())
4035        }
4036    }
4037
4038    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4039        for DeviceDelegateRxLeaseRequest
4040    {
4041        #[inline(always)]
4042        fn new_empty() -> Self {
4043            Self {
4044                lease: fidl::new_empty!(
4045                    fidl_fuchsia_hardware_network::DelegatedRxLease,
4046                    fidl::encoding::DefaultFuchsiaResourceDialect
4047                ),
4048            }
4049        }
4050
4051        #[inline]
4052        unsafe fn decode(
4053            &mut self,
4054            decoder: &mut fidl::encoding::Decoder<
4055                '_,
4056                fidl::encoding::DefaultFuchsiaResourceDialect,
4057            >,
4058            offset: usize,
4059            _depth: fidl::encoding::Depth,
4060        ) -> fidl::Result<()> {
4061            decoder.debug_check_bounds::<Self>(offset);
4062            // Verify that padding bytes are zero.
4063            fidl::decode!(
4064                fidl_fuchsia_hardware_network::DelegatedRxLease,
4065                fidl::encoding::DefaultFuchsiaResourceDialect,
4066                &mut self.lease,
4067                decoder,
4068                offset + 0,
4069                _depth
4070            )?;
4071            Ok(())
4072        }
4073    }
4074
4075    impl fidl::encoding::ResourceTypeMarker for DeviceGetDeviceRequest {
4076        type Borrowed<'a> = &'a mut Self;
4077        fn take_or_borrow<'a>(
4078            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4079        ) -> Self::Borrowed<'a> {
4080            value
4081        }
4082    }
4083
4084    unsafe impl fidl::encoding::TypeMarker for DeviceGetDeviceRequest {
4085        type Owned = Self;
4086
4087        #[inline(always)]
4088        fn inline_align(_context: fidl::encoding::Context) -> usize {
4089            4
4090        }
4091
4092        #[inline(always)]
4093        fn inline_size(_context: fidl::encoding::Context) -> usize {
4094            4
4095        }
4096    }
4097
4098    unsafe impl
4099        fidl::encoding::Encode<
4100            DeviceGetDeviceRequest,
4101            fidl::encoding::DefaultFuchsiaResourceDialect,
4102        > for &mut DeviceGetDeviceRequest
4103    {
4104        #[inline]
4105        unsafe fn encode(
4106            self,
4107            encoder: &mut fidl::encoding::Encoder<
4108                '_,
4109                fidl::encoding::DefaultFuchsiaResourceDialect,
4110            >,
4111            offset: usize,
4112            _depth: fidl::encoding::Depth,
4113        ) -> fidl::Result<()> {
4114            encoder.debug_check_bounds::<DeviceGetDeviceRequest>(offset);
4115            // Delegate to tuple encoding.
4116            fidl::encoding::Encode::<
4117                DeviceGetDeviceRequest,
4118                fidl::encoding::DefaultFuchsiaResourceDialect,
4119            >::encode(
4120                (<fidl::encoding::Endpoint<
4121                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4122                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4123                    &mut self.device
4124                ),),
4125                encoder,
4126                offset,
4127                _depth,
4128            )
4129        }
4130    }
4131    unsafe impl<
4132        T0: fidl::encoding::Encode<
4133                fidl::encoding::Endpoint<
4134                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4135                >,
4136                fidl::encoding::DefaultFuchsiaResourceDialect,
4137            >,
4138    >
4139        fidl::encoding::Encode<
4140            DeviceGetDeviceRequest,
4141            fidl::encoding::DefaultFuchsiaResourceDialect,
4142        > for (T0,)
4143    {
4144        #[inline]
4145        unsafe fn encode(
4146            self,
4147            encoder: &mut fidl::encoding::Encoder<
4148                '_,
4149                fidl::encoding::DefaultFuchsiaResourceDialect,
4150            >,
4151            offset: usize,
4152            depth: fidl::encoding::Depth,
4153        ) -> fidl::Result<()> {
4154            encoder.debug_check_bounds::<DeviceGetDeviceRequest>(offset);
4155            // Zero out padding regions. There's no need to apply masks
4156            // because the unmasked parts will be overwritten by fields.
4157            // Write the fields.
4158            self.0.encode(encoder, offset + 0, depth)?;
4159            Ok(())
4160        }
4161    }
4162
4163    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4164        for DeviceGetDeviceRequest
4165    {
4166        #[inline(always)]
4167        fn new_empty() -> Self {
4168            Self {
4169                device: fidl::new_empty!(
4170                    fidl::encoding::Endpoint<
4171                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4172                    >,
4173                    fidl::encoding::DefaultFuchsiaResourceDialect
4174                ),
4175            }
4176        }
4177
4178        #[inline]
4179        unsafe fn decode(
4180            &mut self,
4181            decoder: &mut fidl::encoding::Decoder<
4182                '_,
4183                fidl::encoding::DefaultFuchsiaResourceDialect,
4184            >,
4185            offset: usize,
4186            _depth: fidl::encoding::Depth,
4187        ) -> fidl::Result<()> {
4188            decoder.debug_check_bounds::<Self>(offset);
4189            // Verify that padding bytes are zero.
4190            fidl::decode!(
4191                fidl::encoding::Endpoint<
4192                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4193                >,
4194                fidl::encoding::DefaultFuchsiaResourceDialect,
4195                &mut self.device,
4196                decoder,
4197                offset + 0,
4198                _depth
4199            )?;
4200            Ok(())
4201        }
4202    }
4203
4204    impl fidl::encoding::ResourceTypeMarker for DeviceGetSignalsResponse {
4205        type Borrowed<'a> = &'a mut Self;
4206        fn take_or_borrow<'a>(
4207            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4208        ) -> Self::Borrowed<'a> {
4209            value
4210        }
4211    }
4212
4213    unsafe impl fidl::encoding::TypeMarker for DeviceGetSignalsResponse {
4214        type Owned = Self;
4215
4216        #[inline(always)]
4217        fn inline_align(_context: fidl::encoding::Context) -> usize {
4218            4
4219        }
4220
4221        #[inline(always)]
4222        fn inline_size(_context: fidl::encoding::Context) -> usize {
4223            4
4224        }
4225    }
4226
4227    unsafe impl
4228        fidl::encoding::Encode<
4229            DeviceGetSignalsResponse,
4230            fidl::encoding::DefaultFuchsiaResourceDialect,
4231        > for &mut DeviceGetSignalsResponse
4232    {
4233        #[inline]
4234        unsafe fn encode(
4235            self,
4236            encoder: &mut fidl::encoding::Encoder<
4237                '_,
4238                fidl::encoding::DefaultFuchsiaResourceDialect,
4239            >,
4240            offset: usize,
4241            _depth: fidl::encoding::Depth,
4242        ) -> fidl::Result<()> {
4243            encoder.debug_check_bounds::<DeviceGetSignalsResponse>(offset);
4244            // Delegate to tuple encoding.
4245            fidl::encoding::Encode::<
4246                DeviceGetSignalsResponse,
4247                fidl::encoding::DefaultFuchsiaResourceDialect,
4248            >::encode(
4249                (<fidl::encoding::HandleType<
4250                    fidl::EventPair,
4251                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4252                    2147483648,
4253                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4254                    &mut self.signals
4255                ),),
4256                encoder,
4257                offset,
4258                _depth,
4259            )
4260        }
4261    }
4262    unsafe impl<
4263        T0: fidl::encoding::Encode<
4264                fidl::encoding::HandleType<
4265                    fidl::EventPair,
4266                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4267                    2147483648,
4268                >,
4269                fidl::encoding::DefaultFuchsiaResourceDialect,
4270            >,
4271    >
4272        fidl::encoding::Encode<
4273            DeviceGetSignalsResponse,
4274            fidl::encoding::DefaultFuchsiaResourceDialect,
4275        > for (T0,)
4276    {
4277        #[inline]
4278        unsafe fn encode(
4279            self,
4280            encoder: &mut fidl::encoding::Encoder<
4281                '_,
4282                fidl::encoding::DefaultFuchsiaResourceDialect,
4283            >,
4284            offset: usize,
4285            depth: fidl::encoding::Depth,
4286        ) -> fidl::Result<()> {
4287            encoder.debug_check_bounds::<DeviceGetSignalsResponse>(offset);
4288            // Zero out padding regions. There's no need to apply masks
4289            // because the unmasked parts will be overwritten by fields.
4290            // Write the fields.
4291            self.0.encode(encoder, offset + 0, depth)?;
4292            Ok(())
4293        }
4294    }
4295
4296    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4297        for DeviceGetSignalsResponse
4298    {
4299        #[inline(always)]
4300        fn new_empty() -> Self {
4301            Self {
4302                signals: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
4303            }
4304        }
4305
4306        #[inline]
4307        unsafe fn decode(
4308            &mut self,
4309            decoder: &mut fidl::encoding::Decoder<
4310                '_,
4311                fidl::encoding::DefaultFuchsiaResourceDialect,
4312            >,
4313            offset: usize,
4314            _depth: fidl::encoding::Depth,
4315        ) -> fidl::Result<()> {
4316            decoder.debug_check_bounds::<Self>(offset);
4317            // Verify that padding bytes are zero.
4318            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.signals, decoder, offset + 0, _depth)?;
4319            Ok(())
4320        }
4321    }
4322
4323    impl fidl::encoding::ResourceTypeMarker for DevicePairGetLeftPortRequest {
4324        type Borrowed<'a> = &'a mut Self;
4325        fn take_or_borrow<'a>(
4326            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4327        ) -> Self::Borrowed<'a> {
4328            value
4329        }
4330    }
4331
4332    unsafe impl fidl::encoding::TypeMarker for DevicePairGetLeftPortRequest {
4333        type Owned = Self;
4334
4335        #[inline(always)]
4336        fn inline_align(_context: fidl::encoding::Context) -> usize {
4337            4
4338        }
4339
4340        #[inline(always)]
4341        fn inline_size(_context: fidl::encoding::Context) -> usize {
4342            8
4343        }
4344    }
4345
4346    unsafe impl
4347        fidl::encoding::Encode<
4348            DevicePairGetLeftPortRequest,
4349            fidl::encoding::DefaultFuchsiaResourceDialect,
4350        > for &mut DevicePairGetLeftPortRequest
4351    {
4352        #[inline]
4353        unsafe fn encode(
4354            self,
4355            encoder: &mut fidl::encoding::Encoder<
4356                '_,
4357                fidl::encoding::DefaultFuchsiaResourceDialect,
4358            >,
4359            offset: usize,
4360            _depth: fidl::encoding::Depth,
4361        ) -> fidl::Result<()> {
4362            encoder.debug_check_bounds::<DevicePairGetLeftPortRequest>(offset);
4363            // Delegate to tuple encoding.
4364            fidl::encoding::Encode::<
4365                DevicePairGetLeftPortRequest,
4366                fidl::encoding::DefaultFuchsiaResourceDialect,
4367            >::encode(
4368                (
4369                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
4370                    <fidl::encoding::Endpoint<
4371                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4372                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4373                        &mut self.port
4374                    ),
4375                ),
4376                encoder,
4377                offset,
4378                _depth,
4379            )
4380        }
4381    }
4382    unsafe impl<
4383        T0: fidl::encoding::Encode<u8, fidl::encoding::DefaultFuchsiaResourceDialect>,
4384        T1: fidl::encoding::Encode<
4385                fidl::encoding::Endpoint<
4386                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4387                >,
4388                fidl::encoding::DefaultFuchsiaResourceDialect,
4389            >,
4390    >
4391        fidl::encoding::Encode<
4392            DevicePairGetLeftPortRequest,
4393            fidl::encoding::DefaultFuchsiaResourceDialect,
4394        > for (T0, T1)
4395    {
4396        #[inline]
4397        unsafe fn encode(
4398            self,
4399            encoder: &mut fidl::encoding::Encoder<
4400                '_,
4401                fidl::encoding::DefaultFuchsiaResourceDialect,
4402            >,
4403            offset: usize,
4404            depth: fidl::encoding::Depth,
4405        ) -> fidl::Result<()> {
4406            encoder.debug_check_bounds::<DevicePairGetLeftPortRequest>(offset);
4407            // Zero out padding regions. There's no need to apply masks
4408            // because the unmasked parts will be overwritten by fields.
4409            unsafe {
4410                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
4411                (ptr as *mut u32).write_unaligned(0);
4412            }
4413            // Write the fields.
4414            self.0.encode(encoder, offset + 0, depth)?;
4415            self.1.encode(encoder, offset + 4, depth)?;
4416            Ok(())
4417        }
4418    }
4419
4420    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4421        for DevicePairGetLeftPortRequest
4422    {
4423        #[inline(always)]
4424        fn new_empty() -> Self {
4425            Self {
4426                id: fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect),
4427                port: fidl::new_empty!(
4428                    fidl::encoding::Endpoint<
4429                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4430                    >,
4431                    fidl::encoding::DefaultFuchsiaResourceDialect
4432                ),
4433            }
4434        }
4435
4436        #[inline]
4437        unsafe fn decode(
4438            &mut self,
4439            decoder: &mut fidl::encoding::Decoder<
4440                '_,
4441                fidl::encoding::DefaultFuchsiaResourceDialect,
4442            >,
4443            offset: usize,
4444            _depth: fidl::encoding::Depth,
4445        ) -> fidl::Result<()> {
4446            decoder.debug_check_bounds::<Self>(offset);
4447            // Verify that padding bytes are zero.
4448            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
4449            let padval = unsafe { (ptr as *const u32).read_unaligned() };
4450            let mask = 0xffffff00u32;
4451            let maskedval = padval & mask;
4452            if maskedval != 0 {
4453                return Err(fidl::Error::NonZeroPadding {
4454                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
4455                });
4456            }
4457            fidl::decode!(
4458                u8,
4459                fidl::encoding::DefaultFuchsiaResourceDialect,
4460                &mut self.id,
4461                decoder,
4462                offset + 0,
4463                _depth
4464            )?;
4465            fidl::decode!(
4466                fidl::encoding::Endpoint<
4467                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4468                >,
4469                fidl::encoding::DefaultFuchsiaResourceDialect,
4470                &mut self.port,
4471                decoder,
4472                offset + 4,
4473                _depth
4474            )?;
4475            Ok(())
4476        }
4477    }
4478
4479    impl fidl::encoding::ResourceTypeMarker for DevicePairGetLeftRequest {
4480        type Borrowed<'a> = &'a mut Self;
4481        fn take_or_borrow<'a>(
4482            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4483        ) -> Self::Borrowed<'a> {
4484            value
4485        }
4486    }
4487
4488    unsafe impl fidl::encoding::TypeMarker for DevicePairGetLeftRequest {
4489        type Owned = Self;
4490
4491        #[inline(always)]
4492        fn inline_align(_context: fidl::encoding::Context) -> usize {
4493            4
4494        }
4495
4496        #[inline(always)]
4497        fn inline_size(_context: fidl::encoding::Context) -> usize {
4498            4
4499        }
4500    }
4501
4502    unsafe impl
4503        fidl::encoding::Encode<
4504            DevicePairGetLeftRequest,
4505            fidl::encoding::DefaultFuchsiaResourceDialect,
4506        > for &mut DevicePairGetLeftRequest
4507    {
4508        #[inline]
4509        unsafe fn encode(
4510            self,
4511            encoder: &mut fidl::encoding::Encoder<
4512                '_,
4513                fidl::encoding::DefaultFuchsiaResourceDialect,
4514            >,
4515            offset: usize,
4516            _depth: fidl::encoding::Depth,
4517        ) -> fidl::Result<()> {
4518            encoder.debug_check_bounds::<DevicePairGetLeftRequest>(offset);
4519            // Delegate to tuple encoding.
4520            fidl::encoding::Encode::<
4521                DevicePairGetLeftRequest,
4522                fidl::encoding::DefaultFuchsiaResourceDialect,
4523            >::encode(
4524                (<fidl::encoding::Endpoint<
4525                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4526                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4527                    &mut self.device
4528                ),),
4529                encoder,
4530                offset,
4531                _depth,
4532            )
4533        }
4534    }
4535    unsafe impl<
4536        T0: fidl::encoding::Encode<
4537                fidl::encoding::Endpoint<
4538                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4539                >,
4540                fidl::encoding::DefaultFuchsiaResourceDialect,
4541            >,
4542    >
4543        fidl::encoding::Encode<
4544            DevicePairGetLeftRequest,
4545            fidl::encoding::DefaultFuchsiaResourceDialect,
4546        > for (T0,)
4547    {
4548        #[inline]
4549        unsafe fn encode(
4550            self,
4551            encoder: &mut fidl::encoding::Encoder<
4552                '_,
4553                fidl::encoding::DefaultFuchsiaResourceDialect,
4554            >,
4555            offset: usize,
4556            depth: fidl::encoding::Depth,
4557        ) -> fidl::Result<()> {
4558            encoder.debug_check_bounds::<DevicePairGetLeftRequest>(offset);
4559            // Zero out padding regions. There's no need to apply masks
4560            // because the unmasked parts will be overwritten by fields.
4561            // Write the fields.
4562            self.0.encode(encoder, offset + 0, depth)?;
4563            Ok(())
4564        }
4565    }
4566
4567    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4568        for DevicePairGetLeftRequest
4569    {
4570        #[inline(always)]
4571        fn new_empty() -> Self {
4572            Self {
4573                device: fidl::new_empty!(
4574                    fidl::encoding::Endpoint<
4575                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4576                    >,
4577                    fidl::encoding::DefaultFuchsiaResourceDialect
4578                ),
4579            }
4580        }
4581
4582        #[inline]
4583        unsafe fn decode(
4584            &mut self,
4585            decoder: &mut fidl::encoding::Decoder<
4586                '_,
4587                fidl::encoding::DefaultFuchsiaResourceDialect,
4588            >,
4589            offset: usize,
4590            _depth: fidl::encoding::Depth,
4591        ) -> fidl::Result<()> {
4592            decoder.debug_check_bounds::<Self>(offset);
4593            // Verify that padding bytes are zero.
4594            fidl::decode!(
4595                fidl::encoding::Endpoint<
4596                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4597                >,
4598                fidl::encoding::DefaultFuchsiaResourceDialect,
4599                &mut self.device,
4600                decoder,
4601                offset + 0,
4602                _depth
4603            )?;
4604            Ok(())
4605        }
4606    }
4607
4608    impl fidl::encoding::ResourceTypeMarker for DevicePairGetRightPortRequest {
4609        type Borrowed<'a> = &'a mut Self;
4610        fn take_or_borrow<'a>(
4611            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4612        ) -> Self::Borrowed<'a> {
4613            value
4614        }
4615    }
4616
4617    unsafe impl fidl::encoding::TypeMarker for DevicePairGetRightPortRequest {
4618        type Owned = Self;
4619
4620        #[inline(always)]
4621        fn inline_align(_context: fidl::encoding::Context) -> usize {
4622            4
4623        }
4624
4625        #[inline(always)]
4626        fn inline_size(_context: fidl::encoding::Context) -> usize {
4627            8
4628        }
4629    }
4630
4631    unsafe impl
4632        fidl::encoding::Encode<
4633            DevicePairGetRightPortRequest,
4634            fidl::encoding::DefaultFuchsiaResourceDialect,
4635        > for &mut DevicePairGetRightPortRequest
4636    {
4637        #[inline]
4638        unsafe fn encode(
4639            self,
4640            encoder: &mut fidl::encoding::Encoder<
4641                '_,
4642                fidl::encoding::DefaultFuchsiaResourceDialect,
4643            >,
4644            offset: usize,
4645            _depth: fidl::encoding::Depth,
4646        ) -> fidl::Result<()> {
4647            encoder.debug_check_bounds::<DevicePairGetRightPortRequest>(offset);
4648            // Delegate to tuple encoding.
4649            fidl::encoding::Encode::<
4650                DevicePairGetRightPortRequest,
4651                fidl::encoding::DefaultFuchsiaResourceDialect,
4652            >::encode(
4653                (
4654                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
4655                    <fidl::encoding::Endpoint<
4656                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4657                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4658                        &mut self.port
4659                    ),
4660                ),
4661                encoder,
4662                offset,
4663                _depth,
4664            )
4665        }
4666    }
4667    unsafe impl<
4668        T0: fidl::encoding::Encode<u8, fidl::encoding::DefaultFuchsiaResourceDialect>,
4669        T1: fidl::encoding::Encode<
4670                fidl::encoding::Endpoint<
4671                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4672                >,
4673                fidl::encoding::DefaultFuchsiaResourceDialect,
4674            >,
4675    >
4676        fidl::encoding::Encode<
4677            DevicePairGetRightPortRequest,
4678            fidl::encoding::DefaultFuchsiaResourceDialect,
4679        > for (T0, T1)
4680    {
4681        #[inline]
4682        unsafe fn encode(
4683            self,
4684            encoder: &mut fidl::encoding::Encoder<
4685                '_,
4686                fidl::encoding::DefaultFuchsiaResourceDialect,
4687            >,
4688            offset: usize,
4689            depth: fidl::encoding::Depth,
4690        ) -> fidl::Result<()> {
4691            encoder.debug_check_bounds::<DevicePairGetRightPortRequest>(offset);
4692            // Zero out padding regions. There's no need to apply masks
4693            // because the unmasked parts will be overwritten by fields.
4694            unsafe {
4695                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
4696                (ptr as *mut u32).write_unaligned(0);
4697            }
4698            // Write the fields.
4699            self.0.encode(encoder, offset + 0, depth)?;
4700            self.1.encode(encoder, offset + 4, depth)?;
4701            Ok(())
4702        }
4703    }
4704
4705    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4706        for DevicePairGetRightPortRequest
4707    {
4708        #[inline(always)]
4709        fn new_empty() -> Self {
4710            Self {
4711                id: fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect),
4712                port: fidl::new_empty!(
4713                    fidl::encoding::Endpoint<
4714                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4715                    >,
4716                    fidl::encoding::DefaultFuchsiaResourceDialect
4717                ),
4718            }
4719        }
4720
4721        #[inline]
4722        unsafe fn decode(
4723            &mut self,
4724            decoder: &mut fidl::encoding::Decoder<
4725                '_,
4726                fidl::encoding::DefaultFuchsiaResourceDialect,
4727            >,
4728            offset: usize,
4729            _depth: fidl::encoding::Depth,
4730        ) -> fidl::Result<()> {
4731            decoder.debug_check_bounds::<Self>(offset);
4732            // Verify that padding bytes are zero.
4733            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
4734            let padval = unsafe { (ptr as *const u32).read_unaligned() };
4735            let mask = 0xffffff00u32;
4736            let maskedval = padval & mask;
4737            if maskedval != 0 {
4738                return Err(fidl::Error::NonZeroPadding {
4739                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
4740                });
4741            }
4742            fidl::decode!(
4743                u8,
4744                fidl::encoding::DefaultFuchsiaResourceDialect,
4745                &mut self.id,
4746                decoder,
4747                offset + 0,
4748                _depth
4749            )?;
4750            fidl::decode!(
4751                fidl::encoding::Endpoint<
4752                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4753                >,
4754                fidl::encoding::DefaultFuchsiaResourceDialect,
4755                &mut self.port,
4756                decoder,
4757                offset + 4,
4758                _depth
4759            )?;
4760            Ok(())
4761        }
4762    }
4763
4764    impl fidl::encoding::ResourceTypeMarker for DevicePairGetRightRequest {
4765        type Borrowed<'a> = &'a mut Self;
4766        fn take_or_borrow<'a>(
4767            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4768        ) -> Self::Borrowed<'a> {
4769            value
4770        }
4771    }
4772
4773    unsafe impl fidl::encoding::TypeMarker for DevicePairGetRightRequest {
4774        type Owned = Self;
4775
4776        #[inline(always)]
4777        fn inline_align(_context: fidl::encoding::Context) -> usize {
4778            4
4779        }
4780
4781        #[inline(always)]
4782        fn inline_size(_context: fidl::encoding::Context) -> usize {
4783            4
4784        }
4785    }
4786
4787    unsafe impl
4788        fidl::encoding::Encode<
4789            DevicePairGetRightRequest,
4790            fidl::encoding::DefaultFuchsiaResourceDialect,
4791        > for &mut DevicePairGetRightRequest
4792    {
4793        #[inline]
4794        unsafe fn encode(
4795            self,
4796            encoder: &mut fidl::encoding::Encoder<
4797                '_,
4798                fidl::encoding::DefaultFuchsiaResourceDialect,
4799            >,
4800            offset: usize,
4801            _depth: fidl::encoding::Depth,
4802        ) -> fidl::Result<()> {
4803            encoder.debug_check_bounds::<DevicePairGetRightRequest>(offset);
4804            // Delegate to tuple encoding.
4805            fidl::encoding::Encode::<
4806                DevicePairGetRightRequest,
4807                fidl::encoding::DefaultFuchsiaResourceDialect,
4808            >::encode(
4809                (<fidl::encoding::Endpoint<
4810                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4811                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4812                    &mut self.device
4813                ),),
4814                encoder,
4815                offset,
4816                _depth,
4817            )
4818        }
4819    }
4820    unsafe impl<
4821        T0: fidl::encoding::Encode<
4822                fidl::encoding::Endpoint<
4823                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4824                >,
4825                fidl::encoding::DefaultFuchsiaResourceDialect,
4826            >,
4827    >
4828        fidl::encoding::Encode<
4829            DevicePairGetRightRequest,
4830            fidl::encoding::DefaultFuchsiaResourceDialect,
4831        > for (T0,)
4832    {
4833        #[inline]
4834        unsafe fn encode(
4835            self,
4836            encoder: &mut fidl::encoding::Encoder<
4837                '_,
4838                fidl::encoding::DefaultFuchsiaResourceDialect,
4839            >,
4840            offset: usize,
4841            depth: fidl::encoding::Depth,
4842        ) -> fidl::Result<()> {
4843            encoder.debug_check_bounds::<DevicePairGetRightRequest>(offset);
4844            // Zero out padding regions. There's no need to apply masks
4845            // because the unmasked parts will be overwritten by fields.
4846            // Write the fields.
4847            self.0.encode(encoder, offset + 0, depth)?;
4848            Ok(())
4849        }
4850    }
4851
4852    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4853        for DevicePairGetRightRequest
4854    {
4855        #[inline(always)]
4856        fn new_empty() -> Self {
4857            Self {
4858                device: fidl::new_empty!(
4859                    fidl::encoding::Endpoint<
4860                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4861                    >,
4862                    fidl::encoding::DefaultFuchsiaResourceDialect
4863                ),
4864            }
4865        }
4866
4867        #[inline]
4868        unsafe fn decode(
4869            &mut self,
4870            decoder: &mut fidl::encoding::Decoder<
4871                '_,
4872                fidl::encoding::DefaultFuchsiaResourceDialect,
4873            >,
4874            offset: usize,
4875            _depth: fidl::encoding::Depth,
4876        ) -> fidl::Result<()> {
4877            decoder.debug_check_bounds::<Self>(offset);
4878            // Verify that padding bytes are zero.
4879            fidl::decode!(
4880                fidl::encoding::Endpoint<
4881                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceMarker>,
4882                >,
4883                fidl::encoding::DefaultFuchsiaResourceDialect,
4884                &mut self.device,
4885                decoder,
4886                offset + 0,
4887                _depth
4888            )?;
4889            Ok(())
4890        }
4891    }
4892
4893    impl fidl::encoding::ResourceTypeMarker for PortGetPortRequest {
4894        type Borrowed<'a> = &'a mut Self;
4895        fn take_or_borrow<'a>(
4896            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4897        ) -> Self::Borrowed<'a> {
4898            value
4899        }
4900    }
4901
4902    unsafe impl fidl::encoding::TypeMarker for PortGetPortRequest {
4903        type Owned = Self;
4904
4905        #[inline(always)]
4906        fn inline_align(_context: fidl::encoding::Context) -> usize {
4907            4
4908        }
4909
4910        #[inline(always)]
4911        fn inline_size(_context: fidl::encoding::Context) -> usize {
4912            4
4913        }
4914    }
4915
4916    unsafe impl
4917        fidl::encoding::Encode<PortGetPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4918        for &mut PortGetPortRequest
4919    {
4920        #[inline]
4921        unsafe fn encode(
4922            self,
4923            encoder: &mut fidl::encoding::Encoder<
4924                '_,
4925                fidl::encoding::DefaultFuchsiaResourceDialect,
4926            >,
4927            offset: usize,
4928            _depth: fidl::encoding::Depth,
4929        ) -> fidl::Result<()> {
4930            encoder.debug_check_bounds::<PortGetPortRequest>(offset);
4931            // Delegate to tuple encoding.
4932            fidl::encoding::Encode::<
4933                PortGetPortRequest,
4934                fidl::encoding::DefaultFuchsiaResourceDialect,
4935            >::encode(
4936                (<fidl::encoding::Endpoint<
4937                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4938                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4939                    &mut self.port
4940                ),),
4941                encoder,
4942                offset,
4943                _depth,
4944            )
4945        }
4946    }
4947    unsafe impl<
4948        T0: fidl::encoding::Encode<
4949                fidl::encoding::Endpoint<
4950                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4951                >,
4952                fidl::encoding::DefaultFuchsiaResourceDialect,
4953            >,
4954    > fidl::encoding::Encode<PortGetPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4955        for (T0,)
4956    {
4957        #[inline]
4958        unsafe fn encode(
4959            self,
4960            encoder: &mut fidl::encoding::Encoder<
4961                '_,
4962                fidl::encoding::DefaultFuchsiaResourceDialect,
4963            >,
4964            offset: usize,
4965            depth: fidl::encoding::Depth,
4966        ) -> fidl::Result<()> {
4967            encoder.debug_check_bounds::<PortGetPortRequest>(offset);
4968            // Zero out padding regions. There's no need to apply masks
4969            // because the unmasked parts will be overwritten by fields.
4970            // Write the fields.
4971            self.0.encode(encoder, offset + 0, depth)?;
4972            Ok(())
4973        }
4974    }
4975
4976    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4977        for PortGetPortRequest
4978    {
4979        #[inline(always)]
4980        fn new_empty() -> Self {
4981            Self {
4982                port: fidl::new_empty!(
4983                    fidl::encoding::Endpoint<
4984                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
4985                    >,
4986                    fidl::encoding::DefaultFuchsiaResourceDialect
4987                ),
4988            }
4989        }
4990
4991        #[inline]
4992        unsafe fn decode(
4993            &mut self,
4994            decoder: &mut fidl::encoding::Decoder<
4995                '_,
4996                fidl::encoding::DefaultFuchsiaResourceDialect,
4997            >,
4998            offset: usize,
4999            _depth: fidl::encoding::Depth,
5000        ) -> fidl::Result<()> {
5001            decoder.debug_check_bounds::<Self>(offset);
5002            // Verify that padding bytes are zero.
5003            fidl::decode!(
5004                fidl::encoding::Endpoint<
5005                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
5006                >,
5007                fidl::encoding::DefaultFuchsiaResourceDialect,
5008                &mut self.port,
5009                decoder,
5010                offset + 0,
5011                _depth
5012            )?;
5013            Ok(())
5014        }
5015    }
5016}