Skip to main content

fidl_fuchsia_net_virtualization/
fidl_fuchsia_net_virtualization.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_virtualization__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ControlCreateNetworkRequest {
16    pub config: Config,
17    pub network: fidl::endpoints::ServerEnd<NetworkMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for ControlCreateNetworkRequest
22{
23}
24
25#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct NetworkAddPortRequest {
27    pub port: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
28    pub interface: fidl::endpoints::ServerEnd<InterfaceMarker>,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NetworkAddPortRequest {}
32
33#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
34pub struct ControlMarker;
35
36impl fidl::endpoints::ProtocolMarker for ControlMarker {
37    type Proxy = ControlProxy;
38    type RequestStream = ControlRequestStream;
39    #[cfg(target_os = "fuchsia")]
40    type SynchronousProxy = ControlSynchronousProxy;
41
42    const DEBUG_NAME: &'static str = "fuchsia.net.virtualization.Control";
43}
44impl fidl::endpoints::DiscoverableProtocolMarker for ControlMarker {}
45
46pub trait ControlProxyInterface: Send + Sync {
47    fn r#create_network(
48        &self,
49        config: &Config,
50        network: fidl::endpoints::ServerEnd<NetworkMarker>,
51    ) -> Result<(), fidl::Error>;
52}
53#[derive(Debug)]
54#[cfg(target_os = "fuchsia")]
55pub struct ControlSynchronousProxy {
56    client: fidl::client::sync::Client,
57}
58
59#[cfg(target_os = "fuchsia")]
60impl fidl::endpoints::SynchronousProxy for ControlSynchronousProxy {
61    type Proxy = ControlProxy;
62    type Protocol = ControlMarker;
63
64    fn from_channel(inner: fidl::Channel) -> Self {
65        Self::new(inner)
66    }
67
68    fn into_channel(self) -> fidl::Channel {
69        self.client.into_channel()
70    }
71
72    fn as_channel(&self) -> &fidl::Channel {
73        self.client.as_channel()
74    }
75}
76
77#[cfg(target_os = "fuchsia")]
78impl ControlSynchronousProxy {
79    pub fn new(channel: fidl::Channel) -> Self {
80        Self { client: fidl::client::sync::Client::new(channel) }
81    }
82
83    pub fn into_channel(self) -> fidl::Channel {
84        self.client.into_channel()
85    }
86
87    /// Waits until an event arrives and returns it. It is safe for other
88    /// threads to make concurrent requests while waiting for an event.
89    pub fn wait_for_event(
90        &self,
91        deadline: zx::MonotonicInstant,
92    ) -> Result<ControlEvent, fidl::Error> {
93        ControlEvent::decode(self.client.wait_for_event::<ControlMarker>(deadline)?)
94    }
95
96    /// Create a new network with configurable upstream connectivity.
97    ///
98    /// The network itself is always guaranteed to be created, but upstream
99    /// connectivity may not be established initially and may be lost at
100    /// any time.
101    ///
102    /// + request `config` network configuration.
103    /// + request `network` provides control over the created network. The
104    ///     protocol will be terminated after emitting a terminal event if the
105    ///     network cannot be added.
106    pub fn r#create_network(
107        &self,
108        mut config: &Config,
109        mut network: fidl::endpoints::ServerEnd<NetworkMarker>,
110    ) -> Result<(), fidl::Error> {
111        self.client.send::<ControlCreateNetworkRequest>(
112            (config, network),
113            0x4e5909b506960eaf,
114            fidl::encoding::DynamicFlags::empty(),
115        )
116    }
117}
118
119#[cfg(target_os = "fuchsia")]
120impl From<ControlSynchronousProxy> for zx::NullableHandle {
121    fn from(value: ControlSynchronousProxy) -> Self {
122        value.into_channel().into()
123    }
124}
125
126#[cfg(target_os = "fuchsia")]
127impl From<fidl::Channel> for ControlSynchronousProxy {
128    fn from(value: fidl::Channel) -> Self {
129        Self::new(value)
130    }
131}
132
133#[cfg(target_os = "fuchsia")]
134impl fidl::endpoints::FromClient for ControlSynchronousProxy {
135    type Protocol = ControlMarker;
136
137    fn from_client(value: fidl::endpoints::ClientEnd<ControlMarker>) -> Self {
138        Self::new(value.into_channel())
139    }
140}
141
142#[derive(Debug, Clone)]
143pub struct ControlProxy {
144    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
145}
146
147impl fidl::endpoints::Proxy for ControlProxy {
148    type Protocol = ControlMarker;
149
150    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
151        Self::new(inner)
152    }
153
154    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
155        self.client.into_channel().map_err(|client| Self { client })
156    }
157
158    fn as_channel(&self) -> &::fidl::AsyncChannel {
159        self.client.as_channel()
160    }
161}
162
163impl ControlProxy {
164    /// Create a new Proxy for fuchsia.net.virtualization/Control.
165    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
166        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
167        Self { client: fidl::client::Client::new(channel, protocol_name) }
168    }
169
170    /// Get a Stream of events from the remote end of the protocol.
171    ///
172    /// # Panics
173    ///
174    /// Panics if the event stream was already taken.
175    pub fn take_event_stream(&self) -> ControlEventStream {
176        ControlEventStream { event_receiver: self.client.take_event_receiver() }
177    }
178
179    /// Create a new network with configurable upstream connectivity.
180    ///
181    /// The network itself is always guaranteed to be created, but upstream
182    /// connectivity may not be established initially and may be lost at
183    /// any time.
184    ///
185    /// + request `config` network configuration.
186    /// + request `network` provides control over the created network. The
187    ///     protocol will be terminated after emitting a terminal event if the
188    ///     network cannot be added.
189    pub fn r#create_network(
190        &self,
191        mut config: &Config,
192        mut network: fidl::endpoints::ServerEnd<NetworkMarker>,
193    ) -> Result<(), fidl::Error> {
194        ControlProxyInterface::r#create_network(self, config, network)
195    }
196}
197
198impl ControlProxyInterface for ControlProxy {
199    fn r#create_network(
200        &self,
201        mut config: &Config,
202        mut network: fidl::endpoints::ServerEnd<NetworkMarker>,
203    ) -> Result<(), fidl::Error> {
204        self.client.send::<ControlCreateNetworkRequest>(
205            (config, network),
206            0x4e5909b506960eaf,
207            fidl::encoding::DynamicFlags::empty(),
208        )
209    }
210}
211
212pub struct ControlEventStream {
213    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
214}
215
216impl std::marker::Unpin for ControlEventStream {}
217
218impl futures::stream::FusedStream for ControlEventStream {
219    fn is_terminated(&self) -> bool {
220        self.event_receiver.is_terminated()
221    }
222}
223
224impl futures::Stream for ControlEventStream {
225    type Item = Result<ControlEvent, fidl::Error>;
226
227    fn poll_next(
228        mut self: std::pin::Pin<&mut Self>,
229        cx: &mut std::task::Context<'_>,
230    ) -> std::task::Poll<Option<Self::Item>> {
231        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
232            &mut self.event_receiver,
233            cx
234        )?) {
235            Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
236            None => std::task::Poll::Ready(None),
237        }
238    }
239}
240
241#[derive(Debug)]
242pub enum ControlEvent {}
243
244impl ControlEvent {
245    /// Decodes a message buffer as a [`ControlEvent`].
246    fn decode(
247        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
248    ) -> Result<ControlEvent, fidl::Error> {
249        let (bytes, _handles) = buf.split_mut();
250        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
251        debug_assert_eq!(tx_header.tx_id, 0);
252        match tx_header.ordinal {
253            _ => Err(fidl::Error::UnknownOrdinal {
254                ordinal: tx_header.ordinal,
255                protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
256            }),
257        }
258    }
259}
260
261/// A Stream of incoming requests for fuchsia.net.virtualization/Control.
262pub struct ControlRequestStream {
263    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
264    is_terminated: bool,
265}
266
267impl std::marker::Unpin for ControlRequestStream {}
268
269impl futures::stream::FusedStream for ControlRequestStream {
270    fn is_terminated(&self) -> bool {
271        self.is_terminated
272    }
273}
274
275impl fidl::endpoints::RequestStream for ControlRequestStream {
276    type Protocol = ControlMarker;
277    type ControlHandle = ControlControlHandle;
278
279    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
280        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
281    }
282
283    fn control_handle(&self) -> Self::ControlHandle {
284        ControlControlHandle { inner: self.inner.clone() }
285    }
286
287    fn into_inner(
288        self,
289    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
290    {
291        (self.inner, self.is_terminated)
292    }
293
294    fn from_inner(
295        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
296        is_terminated: bool,
297    ) -> Self {
298        Self { inner, is_terminated }
299    }
300}
301
302impl futures::Stream for ControlRequestStream {
303    type Item = Result<ControlRequest, fidl::Error>;
304
305    fn poll_next(
306        mut self: std::pin::Pin<&mut Self>,
307        cx: &mut std::task::Context<'_>,
308    ) -> std::task::Poll<Option<Self::Item>> {
309        let this = &mut *self;
310        if this.inner.check_shutdown(cx) {
311            this.is_terminated = true;
312            return std::task::Poll::Ready(None);
313        }
314        if this.is_terminated {
315            panic!("polled ControlRequestStream after completion");
316        }
317        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
318            |bytes, handles| {
319                match this.inner.channel().read_etc(cx, bytes, handles) {
320                    std::task::Poll::Ready(Ok(())) => {}
321                    std::task::Poll::Pending => return std::task::Poll::Pending,
322                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
323                        this.is_terminated = true;
324                        return std::task::Poll::Ready(None);
325                    }
326                    std::task::Poll::Ready(Err(e)) => {
327                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
328                            e.into(),
329                        ))));
330                    }
331                }
332
333                // A message has been received from the channel
334                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
335
336                std::task::Poll::Ready(Some(match header.ordinal {
337                    0x4e5909b506960eaf => {
338                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
339                        let mut req = fidl::new_empty!(
340                            ControlCreateNetworkRequest,
341                            fidl::encoding::DefaultFuchsiaResourceDialect
342                        );
343                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlCreateNetworkRequest>(&header, _body_bytes, handles, &mut req)?;
344                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
345                        Ok(ControlRequest::CreateNetwork {
346                            config: req.config,
347                            network: req.network,
348
349                            control_handle,
350                        })
351                    }
352                    _ => Err(fidl::Error::UnknownOrdinal {
353                        ordinal: header.ordinal,
354                        protocol_name:
355                            <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
356                    }),
357                }))
358            },
359        )
360    }
361}
362
363/// Provides control over virtualization network configuration.
364#[derive(Debug)]
365pub enum ControlRequest {
366    /// Create a new network with configurable upstream connectivity.
367    ///
368    /// The network itself is always guaranteed to be created, but upstream
369    /// connectivity may not be established initially and may be lost at
370    /// any time.
371    ///
372    /// + request `config` network configuration.
373    /// + request `network` provides control over the created network. The
374    ///     protocol will be terminated after emitting a terminal event if the
375    ///     network cannot be added.
376    CreateNetwork {
377        config: Config,
378        network: fidl::endpoints::ServerEnd<NetworkMarker>,
379        control_handle: ControlControlHandle,
380    },
381}
382
383impl ControlRequest {
384    #[allow(irrefutable_let_patterns)]
385    pub fn into_create_network(
386        self,
387    ) -> Option<(Config, fidl::endpoints::ServerEnd<NetworkMarker>, ControlControlHandle)> {
388        if let ControlRequest::CreateNetwork { config, network, control_handle } = self {
389            Some((config, network, control_handle))
390        } else {
391            None
392        }
393    }
394
395    /// Name of the method defined in FIDL
396    pub fn method_name(&self) -> &'static str {
397        match *self {
398            ControlRequest::CreateNetwork { .. } => "create_network",
399        }
400    }
401}
402
403#[derive(Debug, Clone)]
404pub struct ControlControlHandle {
405    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
406}
407
408impl fidl::endpoints::ControlHandle for ControlControlHandle {
409    fn shutdown(&self) {
410        self.inner.shutdown()
411    }
412
413    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
414        self.inner.shutdown_with_epitaph(status)
415    }
416
417    fn is_closed(&self) -> bool {
418        self.inner.channel().is_closed()
419    }
420    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
421        self.inner.channel().on_closed()
422    }
423
424    #[cfg(target_os = "fuchsia")]
425    fn signal_peer(
426        &self,
427        clear_mask: zx::Signals,
428        set_mask: zx::Signals,
429    ) -> Result<(), zx_status::Status> {
430        use fidl::Peered;
431        self.inner.channel().signal_peer(clear_mask, set_mask)
432    }
433}
434
435impl ControlControlHandle {}
436
437#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
438pub struct InterfaceMarker;
439
440impl fidl::endpoints::ProtocolMarker for InterfaceMarker {
441    type Proxy = InterfaceProxy;
442    type RequestStream = InterfaceRequestStream;
443    #[cfg(target_os = "fuchsia")]
444    type SynchronousProxy = InterfaceSynchronousProxy;
445
446    const DEBUG_NAME: &'static str = "(anonymous) Interface";
447}
448
449pub trait InterfaceProxyInterface: Send + Sync {}
450#[derive(Debug)]
451#[cfg(target_os = "fuchsia")]
452pub struct InterfaceSynchronousProxy {
453    client: fidl::client::sync::Client,
454}
455
456#[cfg(target_os = "fuchsia")]
457impl fidl::endpoints::SynchronousProxy for InterfaceSynchronousProxy {
458    type Proxy = InterfaceProxy;
459    type Protocol = InterfaceMarker;
460
461    fn from_channel(inner: fidl::Channel) -> Self {
462        Self::new(inner)
463    }
464
465    fn into_channel(self) -> fidl::Channel {
466        self.client.into_channel()
467    }
468
469    fn as_channel(&self) -> &fidl::Channel {
470        self.client.as_channel()
471    }
472}
473
474#[cfg(target_os = "fuchsia")]
475impl InterfaceSynchronousProxy {
476    pub fn new(channel: fidl::Channel) -> Self {
477        Self { client: fidl::client::sync::Client::new(channel) }
478    }
479
480    pub fn into_channel(self) -> fidl::Channel {
481        self.client.into_channel()
482    }
483
484    /// Waits until an event arrives and returns it. It is safe for other
485    /// threads to make concurrent requests while waiting for an event.
486    pub fn wait_for_event(
487        &self,
488        deadline: zx::MonotonicInstant,
489    ) -> Result<InterfaceEvent, fidl::Error> {
490        InterfaceEvent::decode(self.client.wait_for_event::<InterfaceMarker>(deadline)?)
491    }
492}
493
494#[cfg(target_os = "fuchsia")]
495impl From<InterfaceSynchronousProxy> for zx::NullableHandle {
496    fn from(value: InterfaceSynchronousProxy) -> Self {
497        value.into_channel().into()
498    }
499}
500
501#[cfg(target_os = "fuchsia")]
502impl From<fidl::Channel> for InterfaceSynchronousProxy {
503    fn from(value: fidl::Channel) -> Self {
504        Self::new(value)
505    }
506}
507
508#[cfg(target_os = "fuchsia")]
509impl fidl::endpoints::FromClient for InterfaceSynchronousProxy {
510    type Protocol = InterfaceMarker;
511
512    fn from_client(value: fidl::endpoints::ClientEnd<InterfaceMarker>) -> Self {
513        Self::new(value.into_channel())
514    }
515}
516
517#[derive(Debug, Clone)]
518pub struct InterfaceProxy {
519    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
520}
521
522impl fidl::endpoints::Proxy for InterfaceProxy {
523    type Protocol = InterfaceMarker;
524
525    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
526        Self::new(inner)
527    }
528
529    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
530        self.client.into_channel().map_err(|client| Self { client })
531    }
532
533    fn as_channel(&self) -> &::fidl::AsyncChannel {
534        self.client.as_channel()
535    }
536}
537
538impl InterfaceProxy {
539    /// Create a new Proxy for fuchsia.net.virtualization/Interface.
540    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
541        let protocol_name = <InterfaceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
542        Self { client: fidl::client::Client::new(channel, protocol_name) }
543    }
544
545    /// Get a Stream of events from the remote end of the protocol.
546    ///
547    /// # Panics
548    ///
549    /// Panics if the event stream was already taken.
550    pub fn take_event_stream(&self) -> InterfaceEventStream {
551        InterfaceEventStream { event_receiver: self.client.take_event_receiver() }
552    }
553}
554
555impl InterfaceProxyInterface for InterfaceProxy {}
556
557pub struct InterfaceEventStream {
558    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
559}
560
561impl std::marker::Unpin for InterfaceEventStream {}
562
563impl futures::stream::FusedStream for InterfaceEventStream {
564    fn is_terminated(&self) -> bool {
565        self.event_receiver.is_terminated()
566    }
567}
568
569impl futures::Stream for InterfaceEventStream {
570    type Item = Result<InterfaceEvent, fidl::Error>;
571
572    fn poll_next(
573        mut self: std::pin::Pin<&mut Self>,
574        cx: &mut std::task::Context<'_>,
575    ) -> std::task::Poll<Option<Self::Item>> {
576        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
577            &mut self.event_receiver,
578            cx
579        )?) {
580            Some(buf) => std::task::Poll::Ready(Some(InterfaceEvent::decode(buf))),
581            None => std::task::Poll::Ready(None),
582        }
583    }
584}
585
586#[derive(Debug)]
587pub enum InterfaceEvent {
588    OnRemoved { reason: InterfaceRemovalReason },
589}
590
591impl InterfaceEvent {
592    #[allow(irrefutable_let_patterns)]
593    pub fn into_on_removed(self) -> Option<InterfaceRemovalReason> {
594        if let InterfaceEvent::OnRemoved { reason } = self { Some((reason)) } else { None }
595    }
596
597    /// Decodes a message buffer as a [`InterfaceEvent`].
598    fn decode(
599        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
600    ) -> Result<InterfaceEvent, fidl::Error> {
601        let (bytes, _handles) = buf.split_mut();
602        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
603        debug_assert_eq!(tx_header.tx_id, 0);
604        match tx_header.ordinal {
605            0x4785571ae39a2617 => {
606                let mut out = fidl::new_empty!(
607                    InterfaceOnRemovedRequest,
608                    fidl::encoding::DefaultFuchsiaResourceDialect
609                );
610                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InterfaceOnRemovedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
611                Ok((InterfaceEvent::OnRemoved { reason: out.reason }))
612            }
613            _ => Err(fidl::Error::UnknownOrdinal {
614                ordinal: tx_header.ordinal,
615                protocol_name: <InterfaceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
616            }),
617        }
618    }
619}
620
621/// A Stream of incoming requests for fuchsia.net.virtualization/Interface.
622pub struct InterfaceRequestStream {
623    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
624    is_terminated: bool,
625}
626
627impl std::marker::Unpin for InterfaceRequestStream {}
628
629impl futures::stream::FusedStream for InterfaceRequestStream {
630    fn is_terminated(&self) -> bool {
631        self.is_terminated
632    }
633}
634
635impl fidl::endpoints::RequestStream for InterfaceRequestStream {
636    type Protocol = InterfaceMarker;
637    type ControlHandle = InterfaceControlHandle;
638
639    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
640        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
641    }
642
643    fn control_handle(&self) -> Self::ControlHandle {
644        InterfaceControlHandle { inner: self.inner.clone() }
645    }
646
647    fn into_inner(
648        self,
649    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
650    {
651        (self.inner, self.is_terminated)
652    }
653
654    fn from_inner(
655        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
656        is_terminated: bool,
657    ) -> Self {
658        Self { inner, is_terminated }
659    }
660}
661
662impl futures::Stream for InterfaceRequestStream {
663    type Item = Result<InterfaceRequest, fidl::Error>;
664
665    fn poll_next(
666        mut self: std::pin::Pin<&mut Self>,
667        cx: &mut std::task::Context<'_>,
668    ) -> std::task::Poll<Option<Self::Item>> {
669        let this = &mut *self;
670        if this.inner.check_shutdown(cx) {
671            this.is_terminated = true;
672            return std::task::Poll::Ready(None);
673        }
674        if this.is_terminated {
675            panic!("polled InterfaceRequestStream after completion");
676        }
677        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
678            |bytes, handles| {
679                match this.inner.channel().read_etc(cx, bytes, handles) {
680                    std::task::Poll::Ready(Ok(())) => {}
681                    std::task::Poll::Pending => return std::task::Poll::Pending,
682                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
683                        this.is_terminated = true;
684                        return std::task::Poll::Ready(None);
685                    }
686                    std::task::Poll::Ready(Err(e)) => {
687                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
688                            e.into(),
689                        ))));
690                    }
691                }
692
693                // A message has been received from the channel
694                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
695
696                std::task::Poll::Ready(Some(match header.ordinal {
697                    _ => Err(fidl::Error::UnknownOrdinal {
698                        ordinal: header.ordinal,
699                        protocol_name:
700                            <InterfaceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
701                    }),
702                }))
703            },
704        )
705    }
706}
707
708/// Provides control over an interface.
709///
710/// This protocol encodes the lifetime of the underlying interface in both
711/// directions, that is:
712/// - if the client end is closed, the server will detach the interface
713///     from the network it belongs to and detach the network device;
714/// - if the server end is closed, the interface has been detached from
715///     the network it was attached to and destroyed.
716#[derive(Debug)]
717pub enum InterfaceRequest {}
718
719impl InterfaceRequest {
720    /// Name of the method defined in FIDL
721    pub fn method_name(&self) -> &'static str {
722        match *self {}
723    }
724}
725
726#[derive(Debug, Clone)]
727pub struct InterfaceControlHandle {
728    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
729}
730
731impl fidl::endpoints::ControlHandle for InterfaceControlHandle {
732    fn shutdown(&self) {
733        self.inner.shutdown()
734    }
735
736    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
737        self.inner.shutdown_with_epitaph(status)
738    }
739
740    fn is_closed(&self) -> bool {
741        self.inner.channel().is_closed()
742    }
743    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
744        self.inner.channel().on_closed()
745    }
746
747    #[cfg(target_os = "fuchsia")]
748    fn signal_peer(
749        &self,
750        clear_mask: zx::Signals,
751        set_mask: zx::Signals,
752    ) -> Result<(), zx_status::Status> {
753        use fidl::Peered;
754        self.inner.channel().signal_peer(clear_mask, set_mask)
755    }
756}
757
758impl InterfaceControlHandle {
759    pub fn send_on_removed(&self, mut reason: InterfaceRemovalReason) -> Result<(), fidl::Error> {
760        self.inner.send::<InterfaceOnRemovedRequest>(
761            (reason,),
762            0,
763            0x4785571ae39a2617,
764            fidl::encoding::DynamicFlags::empty(),
765        )
766    }
767}
768
769#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
770pub struct NetworkMarker;
771
772impl fidl::endpoints::ProtocolMarker for NetworkMarker {
773    type Proxy = NetworkProxy;
774    type RequestStream = NetworkRequestStream;
775    #[cfg(target_os = "fuchsia")]
776    type SynchronousProxy = NetworkSynchronousProxy;
777
778    const DEBUG_NAME: &'static str = "(anonymous) Network";
779}
780
781pub trait NetworkProxyInterface: Send + Sync {
782    fn r#add_port(
783        &self,
784        port: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
785        interface: fidl::endpoints::ServerEnd<InterfaceMarker>,
786    ) -> Result<(), fidl::Error>;
787}
788#[derive(Debug)]
789#[cfg(target_os = "fuchsia")]
790pub struct NetworkSynchronousProxy {
791    client: fidl::client::sync::Client,
792}
793
794#[cfg(target_os = "fuchsia")]
795impl fidl::endpoints::SynchronousProxy for NetworkSynchronousProxy {
796    type Proxy = NetworkProxy;
797    type Protocol = NetworkMarker;
798
799    fn from_channel(inner: fidl::Channel) -> Self {
800        Self::new(inner)
801    }
802
803    fn into_channel(self) -> fidl::Channel {
804        self.client.into_channel()
805    }
806
807    fn as_channel(&self) -> &fidl::Channel {
808        self.client.as_channel()
809    }
810}
811
812#[cfg(target_os = "fuchsia")]
813impl NetworkSynchronousProxy {
814    pub fn new(channel: fidl::Channel) -> Self {
815        Self { client: fidl::client::sync::Client::new(channel) }
816    }
817
818    pub fn into_channel(self) -> fidl::Channel {
819        self.client.into_channel()
820    }
821
822    /// Waits until an event arrives and returns it. It is safe for other
823    /// threads to make concurrent requests while waiting for an event.
824    pub fn wait_for_event(
825        &self,
826        deadline: zx::MonotonicInstant,
827    ) -> Result<NetworkEvent, fidl::Error> {
828        NetworkEvent::decode(self.client.wait_for_event::<NetworkMarker>(deadline)?)
829    }
830
831    /// Adds a port to the network.
832    ///
833    /// + request `port` port to be added.
834    /// + request `interface` provides control over the interface.
835    pub fn r#add_port(
836        &self,
837        mut port: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
838        mut interface: fidl::endpoints::ServerEnd<InterfaceMarker>,
839    ) -> Result<(), fidl::Error> {
840        self.client.send::<NetworkAddPortRequest>(
841            (port, interface),
842            0x7ad6a60c931a3f4e,
843            fidl::encoding::DynamicFlags::empty(),
844        )
845    }
846}
847
848#[cfg(target_os = "fuchsia")]
849impl From<NetworkSynchronousProxy> for zx::NullableHandle {
850    fn from(value: NetworkSynchronousProxy) -> Self {
851        value.into_channel().into()
852    }
853}
854
855#[cfg(target_os = "fuchsia")]
856impl From<fidl::Channel> for NetworkSynchronousProxy {
857    fn from(value: fidl::Channel) -> Self {
858        Self::new(value)
859    }
860}
861
862#[cfg(target_os = "fuchsia")]
863impl fidl::endpoints::FromClient for NetworkSynchronousProxy {
864    type Protocol = NetworkMarker;
865
866    fn from_client(value: fidl::endpoints::ClientEnd<NetworkMarker>) -> Self {
867        Self::new(value.into_channel())
868    }
869}
870
871#[derive(Debug, Clone)]
872pub struct NetworkProxy {
873    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
874}
875
876impl fidl::endpoints::Proxy for NetworkProxy {
877    type Protocol = NetworkMarker;
878
879    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
880        Self::new(inner)
881    }
882
883    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
884        self.client.into_channel().map_err(|client| Self { client })
885    }
886
887    fn as_channel(&self) -> &::fidl::AsyncChannel {
888        self.client.as_channel()
889    }
890}
891
892impl NetworkProxy {
893    /// Create a new Proxy for fuchsia.net.virtualization/Network.
894    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
895        let protocol_name = <NetworkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
896        Self { client: fidl::client::Client::new(channel, protocol_name) }
897    }
898
899    /// Get a Stream of events from the remote end of the protocol.
900    ///
901    /// # Panics
902    ///
903    /// Panics if the event stream was already taken.
904    pub fn take_event_stream(&self) -> NetworkEventStream {
905        NetworkEventStream { event_receiver: self.client.take_event_receiver() }
906    }
907
908    /// Adds a port to the network.
909    ///
910    /// + request `port` port to be added.
911    /// + request `interface` provides control over the interface.
912    pub fn r#add_port(
913        &self,
914        mut port: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
915        mut interface: fidl::endpoints::ServerEnd<InterfaceMarker>,
916    ) -> Result<(), fidl::Error> {
917        NetworkProxyInterface::r#add_port(self, port, interface)
918    }
919}
920
921impl NetworkProxyInterface for NetworkProxy {
922    fn r#add_port(
923        &self,
924        mut port: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
925        mut interface: fidl::endpoints::ServerEnd<InterfaceMarker>,
926    ) -> Result<(), fidl::Error> {
927        self.client.send::<NetworkAddPortRequest>(
928            (port, interface),
929            0x7ad6a60c931a3f4e,
930            fidl::encoding::DynamicFlags::empty(),
931        )
932    }
933}
934
935pub struct NetworkEventStream {
936    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
937}
938
939impl std::marker::Unpin for NetworkEventStream {}
940
941impl futures::stream::FusedStream for NetworkEventStream {
942    fn is_terminated(&self) -> bool {
943        self.event_receiver.is_terminated()
944    }
945}
946
947impl futures::Stream for NetworkEventStream {
948    type Item = Result<NetworkEvent, fidl::Error>;
949
950    fn poll_next(
951        mut self: std::pin::Pin<&mut Self>,
952        cx: &mut std::task::Context<'_>,
953    ) -> std::task::Poll<Option<Self::Item>> {
954        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
955            &mut self.event_receiver,
956            cx
957        )?) {
958            Some(buf) => std::task::Poll::Ready(Some(NetworkEvent::decode(buf))),
959            None => std::task::Poll::Ready(None),
960        }
961    }
962}
963
964#[derive(Debug)]
965pub enum NetworkEvent {
966    OnRemoved { reason: NetworkRemovalReason },
967}
968
969impl NetworkEvent {
970    #[allow(irrefutable_let_patterns)]
971    pub fn into_on_removed(self) -> Option<NetworkRemovalReason> {
972        if let NetworkEvent::OnRemoved { reason } = self { Some((reason)) } else { None }
973    }
974
975    /// Decodes a message buffer as a [`NetworkEvent`].
976    fn decode(
977        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
978    ) -> Result<NetworkEvent, fidl::Error> {
979        let (bytes, _handles) = buf.split_mut();
980        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
981        debug_assert_eq!(tx_header.tx_id, 0);
982        match tx_header.ordinal {
983            0xfe80656d1e5ec4a => {
984                let mut out = fidl::new_empty!(
985                    NetworkOnRemovedRequest,
986                    fidl::encoding::DefaultFuchsiaResourceDialect
987                );
988                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkOnRemovedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
989                Ok((NetworkEvent::OnRemoved { reason: out.reason }))
990            }
991            _ => Err(fidl::Error::UnknownOrdinal {
992                ordinal: tx_header.ordinal,
993                protocol_name: <NetworkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
994            }),
995        }
996    }
997}
998
999/// A Stream of incoming requests for fuchsia.net.virtualization/Network.
1000pub struct NetworkRequestStream {
1001    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1002    is_terminated: bool,
1003}
1004
1005impl std::marker::Unpin for NetworkRequestStream {}
1006
1007impl futures::stream::FusedStream for NetworkRequestStream {
1008    fn is_terminated(&self) -> bool {
1009        self.is_terminated
1010    }
1011}
1012
1013impl fidl::endpoints::RequestStream for NetworkRequestStream {
1014    type Protocol = NetworkMarker;
1015    type ControlHandle = NetworkControlHandle;
1016
1017    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1018        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1019    }
1020
1021    fn control_handle(&self) -> Self::ControlHandle {
1022        NetworkControlHandle { inner: self.inner.clone() }
1023    }
1024
1025    fn into_inner(
1026        self,
1027    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1028    {
1029        (self.inner, self.is_terminated)
1030    }
1031
1032    fn from_inner(
1033        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1034        is_terminated: bool,
1035    ) -> Self {
1036        Self { inner, is_terminated }
1037    }
1038}
1039
1040impl futures::Stream for NetworkRequestStream {
1041    type Item = Result<NetworkRequest, fidl::Error>;
1042
1043    fn poll_next(
1044        mut self: std::pin::Pin<&mut Self>,
1045        cx: &mut std::task::Context<'_>,
1046    ) -> std::task::Poll<Option<Self::Item>> {
1047        let this = &mut *self;
1048        if this.inner.check_shutdown(cx) {
1049            this.is_terminated = true;
1050            return std::task::Poll::Ready(None);
1051        }
1052        if this.is_terminated {
1053            panic!("polled NetworkRequestStream after completion");
1054        }
1055        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1056            |bytes, handles| {
1057                match this.inner.channel().read_etc(cx, bytes, handles) {
1058                    std::task::Poll::Ready(Ok(())) => {}
1059                    std::task::Poll::Pending => return std::task::Poll::Pending,
1060                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1061                        this.is_terminated = true;
1062                        return std::task::Poll::Ready(None);
1063                    }
1064                    std::task::Poll::Ready(Err(e)) => {
1065                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1066                            e.into(),
1067                        ))));
1068                    }
1069                }
1070
1071                // A message has been received from the channel
1072                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1073
1074                std::task::Poll::Ready(Some(match header.ordinal {
1075                    0x7ad6a60c931a3f4e => {
1076                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1077                        let mut req = fidl::new_empty!(
1078                            NetworkAddPortRequest,
1079                            fidl::encoding::DefaultFuchsiaResourceDialect
1080                        );
1081                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkAddPortRequest>(&header, _body_bytes, handles, &mut req)?;
1082                        let control_handle = NetworkControlHandle { inner: this.inner.clone() };
1083                        Ok(NetworkRequest::AddPort {
1084                            port: req.port,
1085                            interface: req.interface,
1086
1087                            control_handle,
1088                        })
1089                    }
1090                    _ => Err(fidl::Error::UnknownOrdinal {
1091                        ordinal: header.ordinal,
1092                        protocol_name:
1093                            <NetworkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1094                    }),
1095                }))
1096            },
1097        )
1098    }
1099}
1100
1101/// Provides control over a network.
1102///
1103/// This protocol encodes the lifetime of the underlying network in both
1104/// directions, that is:
1105/// - if the client end is closed: all interfaces added to the network
1106///     (not including any used to provide upstream connectivity) will be
1107///     removed and destroyed, and the network will be removed;
1108/// - if the server end is closed, all interfaces on the network and the
1109///     network itself have been destroyed.
1110#[derive(Debug)]
1111pub enum NetworkRequest {
1112    /// Adds a port to the network.
1113    ///
1114    /// + request `port` port to be added.
1115    /// + request `interface` provides control over the interface.
1116    AddPort {
1117        port: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
1118        interface: fidl::endpoints::ServerEnd<InterfaceMarker>,
1119        control_handle: NetworkControlHandle,
1120    },
1121}
1122
1123impl NetworkRequest {
1124    #[allow(irrefutable_let_patterns)]
1125    pub fn into_add_port(
1126        self,
1127    ) -> Option<(
1128        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
1129        fidl::endpoints::ServerEnd<InterfaceMarker>,
1130        NetworkControlHandle,
1131    )> {
1132        if let NetworkRequest::AddPort { port, interface, control_handle } = self {
1133            Some((port, interface, control_handle))
1134        } else {
1135            None
1136        }
1137    }
1138
1139    /// Name of the method defined in FIDL
1140    pub fn method_name(&self) -> &'static str {
1141        match *self {
1142            NetworkRequest::AddPort { .. } => "add_port",
1143        }
1144    }
1145}
1146
1147#[derive(Debug, Clone)]
1148pub struct NetworkControlHandle {
1149    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1150}
1151
1152impl fidl::endpoints::ControlHandle for NetworkControlHandle {
1153    fn shutdown(&self) {
1154        self.inner.shutdown()
1155    }
1156
1157    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1158        self.inner.shutdown_with_epitaph(status)
1159    }
1160
1161    fn is_closed(&self) -> bool {
1162        self.inner.channel().is_closed()
1163    }
1164    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1165        self.inner.channel().on_closed()
1166    }
1167
1168    #[cfg(target_os = "fuchsia")]
1169    fn signal_peer(
1170        &self,
1171        clear_mask: zx::Signals,
1172        set_mask: zx::Signals,
1173    ) -> Result<(), zx_status::Status> {
1174        use fidl::Peered;
1175        self.inner.channel().signal_peer(clear_mask, set_mask)
1176    }
1177}
1178
1179impl NetworkControlHandle {
1180    pub fn send_on_removed(&self, mut reason: NetworkRemovalReason) -> Result<(), fidl::Error> {
1181        self.inner.send::<NetworkOnRemovedRequest>(
1182            (reason,),
1183            0,
1184            0xfe80656d1e5ec4a,
1185            fidl::encoding::DynamicFlags::empty(),
1186        )
1187    }
1188}
1189
1190mod internal {
1191    use super::*;
1192
1193    impl fidl::encoding::ResourceTypeMarker for ControlCreateNetworkRequest {
1194        type Borrowed<'a> = &'a mut Self;
1195        fn take_or_borrow<'a>(
1196            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1197        ) -> Self::Borrowed<'a> {
1198            value
1199        }
1200    }
1201
1202    unsafe impl fidl::encoding::TypeMarker for ControlCreateNetworkRequest {
1203        type Owned = Self;
1204
1205        #[inline(always)]
1206        fn inline_align(_context: fidl::encoding::Context) -> usize {
1207            8
1208        }
1209
1210        #[inline(always)]
1211        fn inline_size(_context: fidl::encoding::Context) -> usize {
1212            24
1213        }
1214    }
1215
1216    unsafe impl
1217        fidl::encoding::Encode<
1218            ControlCreateNetworkRequest,
1219            fidl::encoding::DefaultFuchsiaResourceDialect,
1220        > for &mut ControlCreateNetworkRequest
1221    {
1222        #[inline]
1223        unsafe fn encode(
1224            self,
1225            encoder: &mut fidl::encoding::Encoder<
1226                '_,
1227                fidl::encoding::DefaultFuchsiaResourceDialect,
1228            >,
1229            offset: usize,
1230            _depth: fidl::encoding::Depth,
1231        ) -> fidl::Result<()> {
1232            encoder.debug_check_bounds::<ControlCreateNetworkRequest>(offset);
1233            // Delegate to tuple encoding.
1234            fidl::encoding::Encode::<ControlCreateNetworkRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1235                (
1236                    <Config as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
1237                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NetworkMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.network),
1238                ),
1239                encoder, offset, _depth
1240            )
1241        }
1242    }
1243    unsafe impl<
1244        T0: fidl::encoding::Encode<Config, fidl::encoding::DefaultFuchsiaResourceDialect>,
1245        T1: fidl::encoding::Encode<
1246                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NetworkMarker>>,
1247                fidl::encoding::DefaultFuchsiaResourceDialect,
1248            >,
1249    >
1250        fidl::encoding::Encode<
1251            ControlCreateNetworkRequest,
1252            fidl::encoding::DefaultFuchsiaResourceDialect,
1253        > for (T0, T1)
1254    {
1255        #[inline]
1256        unsafe fn encode(
1257            self,
1258            encoder: &mut fidl::encoding::Encoder<
1259                '_,
1260                fidl::encoding::DefaultFuchsiaResourceDialect,
1261            >,
1262            offset: usize,
1263            depth: fidl::encoding::Depth,
1264        ) -> fidl::Result<()> {
1265            encoder.debug_check_bounds::<ControlCreateNetworkRequest>(offset);
1266            // Zero out padding regions. There's no need to apply masks
1267            // because the unmasked parts will be overwritten by fields.
1268            unsafe {
1269                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1270                (ptr as *mut u64).write_unaligned(0);
1271            }
1272            // Write the fields.
1273            self.0.encode(encoder, offset + 0, depth)?;
1274            self.1.encode(encoder, offset + 16, depth)?;
1275            Ok(())
1276        }
1277    }
1278
1279    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1280        for ControlCreateNetworkRequest
1281    {
1282        #[inline(always)]
1283        fn new_empty() -> Self {
1284            Self {
1285                config: fidl::new_empty!(Config, fidl::encoding::DefaultFuchsiaResourceDialect),
1286                network: fidl::new_empty!(
1287                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NetworkMarker>>,
1288                    fidl::encoding::DefaultFuchsiaResourceDialect
1289                ),
1290            }
1291        }
1292
1293        #[inline]
1294        unsafe fn decode(
1295            &mut self,
1296            decoder: &mut fidl::encoding::Decoder<
1297                '_,
1298                fidl::encoding::DefaultFuchsiaResourceDialect,
1299            >,
1300            offset: usize,
1301            _depth: fidl::encoding::Depth,
1302        ) -> fidl::Result<()> {
1303            decoder.debug_check_bounds::<Self>(offset);
1304            // Verify that padding bytes are zero.
1305            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1306            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1307            let mask = 0xffffffff00000000u64;
1308            let maskedval = padval & mask;
1309            if maskedval != 0 {
1310                return Err(fidl::Error::NonZeroPadding {
1311                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1312                });
1313            }
1314            fidl::decode!(
1315                Config,
1316                fidl::encoding::DefaultFuchsiaResourceDialect,
1317                &mut self.config,
1318                decoder,
1319                offset + 0,
1320                _depth
1321            )?;
1322            fidl::decode!(
1323                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NetworkMarker>>,
1324                fidl::encoding::DefaultFuchsiaResourceDialect,
1325                &mut self.network,
1326                decoder,
1327                offset + 16,
1328                _depth
1329            )?;
1330            Ok(())
1331        }
1332    }
1333
1334    impl fidl::encoding::ResourceTypeMarker for NetworkAddPortRequest {
1335        type Borrowed<'a> = &'a mut Self;
1336        fn take_or_borrow<'a>(
1337            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1338        ) -> Self::Borrowed<'a> {
1339            value
1340        }
1341    }
1342
1343    unsafe impl fidl::encoding::TypeMarker for NetworkAddPortRequest {
1344        type Owned = Self;
1345
1346        #[inline(always)]
1347        fn inline_align(_context: fidl::encoding::Context) -> usize {
1348            4
1349        }
1350
1351        #[inline(always)]
1352        fn inline_size(_context: fidl::encoding::Context) -> usize {
1353            8
1354        }
1355    }
1356
1357    unsafe impl
1358        fidl::encoding::Encode<NetworkAddPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1359        for &mut NetworkAddPortRequest
1360    {
1361        #[inline]
1362        unsafe fn encode(
1363            self,
1364            encoder: &mut fidl::encoding::Encoder<
1365                '_,
1366                fidl::encoding::DefaultFuchsiaResourceDialect,
1367            >,
1368            offset: usize,
1369            _depth: fidl::encoding::Depth,
1370        ) -> fidl::Result<()> {
1371            encoder.debug_check_bounds::<NetworkAddPortRequest>(offset);
1372            // Delegate to tuple encoding.
1373            fidl::encoding::Encode::<NetworkAddPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1374                (
1375                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.port),
1376                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InterfaceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.interface),
1377                ),
1378                encoder, offset, _depth
1379            )
1380        }
1381    }
1382    unsafe impl<
1383        T0: fidl::encoding::Encode<
1384                fidl::encoding::Endpoint<
1385                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
1386                >,
1387                fidl::encoding::DefaultFuchsiaResourceDialect,
1388            >,
1389        T1: fidl::encoding::Encode<
1390                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InterfaceMarker>>,
1391                fidl::encoding::DefaultFuchsiaResourceDialect,
1392            >,
1393    >
1394        fidl::encoding::Encode<NetworkAddPortRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1395        for (T0, T1)
1396    {
1397        #[inline]
1398        unsafe fn encode(
1399            self,
1400            encoder: &mut fidl::encoding::Encoder<
1401                '_,
1402                fidl::encoding::DefaultFuchsiaResourceDialect,
1403            >,
1404            offset: usize,
1405            depth: fidl::encoding::Depth,
1406        ) -> fidl::Result<()> {
1407            encoder.debug_check_bounds::<NetworkAddPortRequest>(offset);
1408            // Zero out padding regions. There's no need to apply masks
1409            // because the unmasked parts will be overwritten by fields.
1410            // Write the fields.
1411            self.0.encode(encoder, offset + 0, depth)?;
1412            self.1.encode(encoder, offset + 4, depth)?;
1413            Ok(())
1414        }
1415    }
1416
1417    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1418        for NetworkAddPortRequest
1419    {
1420        #[inline(always)]
1421        fn new_empty() -> Self {
1422            Self {
1423                port: fidl::new_empty!(
1424                    fidl::encoding::Endpoint<
1425                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
1426                    >,
1427                    fidl::encoding::DefaultFuchsiaResourceDialect
1428                ),
1429                interface: fidl::new_empty!(
1430                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InterfaceMarker>>,
1431                    fidl::encoding::DefaultFuchsiaResourceDialect
1432                ),
1433            }
1434        }
1435
1436        #[inline]
1437        unsafe fn decode(
1438            &mut self,
1439            decoder: &mut fidl::encoding::Decoder<
1440                '_,
1441                fidl::encoding::DefaultFuchsiaResourceDialect,
1442            >,
1443            offset: usize,
1444            _depth: fidl::encoding::Depth,
1445        ) -> fidl::Result<()> {
1446            decoder.debug_check_bounds::<Self>(offset);
1447            // Verify that padding bytes are zero.
1448            fidl::decode!(
1449                fidl::encoding::Endpoint<
1450                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
1451                >,
1452                fidl::encoding::DefaultFuchsiaResourceDialect,
1453                &mut self.port,
1454                decoder,
1455                offset + 0,
1456                _depth
1457            )?;
1458            fidl::decode!(
1459                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<InterfaceMarker>>,
1460                fidl::encoding::DefaultFuchsiaResourceDialect,
1461                &mut self.interface,
1462                decoder,
1463                offset + 4,
1464                _depth
1465            )?;
1466            Ok(())
1467        }
1468    }
1469}