Skip to main content

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