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