fidl_fuchsia_net_tun/
fidl_fuchsia_net_tun.rs

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