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