fidl_fuchsia_netemul_network/
fidl_fuchsia_netemul_network.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_netemul_network_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DeviceProxyServeControllerRequest {
16    pub req: fidl::endpoints::ServerEnd<fidl_fuchsia_device::ControllerMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for DeviceProxyServeControllerRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct DeviceProxyServeDeviceRequest {
26    pub req: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceInstanceMarker>,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
30    for DeviceProxyServeDeviceRequest
31{
32}
33
34#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct EndpointGetPortRequest {
36    pub port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
37}
38
39impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for EndpointGetPortRequest {}
40
41#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
42pub struct EndpointGetProxyRequest {
43    pub proxy: fidl::endpoints::ServerEnd<DeviceProxy_Marker>,
44}
45
46impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for EndpointGetProxyRequest {}
47
48#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
49pub struct EndpointManagerCreateEndpointResponse {
50    pub status: i32,
51    pub endpoint: Option<fidl::endpoints::ClientEnd<EndpointMarker>>,
52}
53
54impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
55    for EndpointManagerCreateEndpointResponse
56{
57}
58
59#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
60pub struct EndpointManagerGetEndpointResponse {
61    pub endpoint: Option<fidl::endpoints::ClientEnd<EndpointMarker>>,
62}
63
64impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
65    for EndpointManagerGetEndpointResponse
66{
67}
68
69#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
70pub struct NetworkContextCloneRequest {
71    pub network_context: fidl::endpoints::ServerEnd<NetworkContextMarker>,
72}
73
74impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
75    for NetworkContextCloneRequest
76{
77}
78
79#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
80pub struct NetworkContextGetEndpointManagerRequest {
81    pub endp_manager: fidl::endpoints::ServerEnd<EndpointManagerMarker>,
82}
83
84impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
85    for NetworkContextGetEndpointManagerRequest
86{
87}
88
89#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
90pub struct NetworkContextGetNetworkManagerRequest {
91    pub net_manager: fidl::endpoints::ServerEnd<NetworkManagerMarker>,
92}
93
94impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
95    for NetworkContextGetNetworkManagerRequest
96{
97}
98
99#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
100pub struct NetworkContextSetupResponse {
101    pub status: i32,
102    pub setup_handle: Option<fidl::endpoints::ClientEnd<SetupHandleMarker>>,
103}
104
105impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
106    for NetworkContextSetupResponse
107{
108}
109
110#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
111pub struct NetworkCreateFakeEndpointRequest {
112    pub ep: fidl::endpoints::ServerEnd<FakeEndpointMarker>,
113}
114
115impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
116    for NetworkCreateFakeEndpointRequest
117{
118}
119
120#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
121pub struct NetworkManagerCreateNetworkResponse {
122    pub status: i32,
123    pub net: Option<fidl::endpoints::ClientEnd<NetworkMarker>>,
124}
125
126impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
127    for NetworkManagerCreateNetworkResponse
128{
129}
130
131#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
132pub struct NetworkManagerGetNetworkResponse {
133    pub net: Option<fidl::endpoints::ClientEnd<NetworkMarker>>,
134}
135
136impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
137    for NetworkManagerGetNetworkResponse
138{
139}
140
141#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
142pub struct DeviceProxy_Marker;
143
144impl fidl::endpoints::ProtocolMarker for DeviceProxy_Marker {
145    type Proxy = DeviceProxy_Proxy;
146    type RequestStream = DeviceProxy_RequestStream;
147    #[cfg(target_os = "fuchsia")]
148    type SynchronousProxy = DeviceProxy_SynchronousProxy;
149
150    const DEBUG_NAME: &'static str = "(anonymous) DeviceProxy_";
151}
152
153pub trait DeviceProxy_ProxyInterface: Send + Sync {
154    fn r#serve_controller(
155        &self,
156        req: fidl::endpoints::ServerEnd<fidl_fuchsia_device::ControllerMarker>,
157    ) -> Result<(), fidl::Error>;
158    fn r#serve_device(
159        &self,
160        req: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceInstanceMarker>,
161    ) -> Result<(), fidl::Error>;
162}
163#[derive(Debug)]
164#[cfg(target_os = "fuchsia")]
165pub struct DeviceProxy_SynchronousProxy {
166    client: fidl::client::sync::Client,
167}
168
169#[cfg(target_os = "fuchsia")]
170impl fidl::endpoints::SynchronousProxy for DeviceProxy_SynchronousProxy {
171    type Proxy = DeviceProxy_Proxy;
172    type Protocol = DeviceProxy_Marker;
173
174    fn from_channel(inner: fidl::Channel) -> Self {
175        Self::new(inner)
176    }
177
178    fn into_channel(self) -> fidl::Channel {
179        self.client.into_channel()
180    }
181
182    fn as_channel(&self) -> &fidl::Channel {
183        self.client.as_channel()
184    }
185}
186
187#[cfg(target_os = "fuchsia")]
188impl DeviceProxy_SynchronousProxy {
189    pub fn new(channel: fidl::Channel) -> Self {
190        let protocol_name = <DeviceProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
191        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
192    }
193
194    pub fn into_channel(self) -> fidl::Channel {
195        self.client.into_channel()
196    }
197
198    /// Waits until an event arrives and returns it. It is safe for other
199    /// threads to make concurrent requests while waiting for an event.
200    pub fn wait_for_event(
201        &self,
202        deadline: zx::MonotonicInstant,
203    ) -> Result<DeviceProxy_Event, fidl::Error> {
204        DeviceProxy_Event::decode(self.client.wait_for_event(deadline)?)
205    }
206
207    /// Serve the Controller protocol for this device.
208    pub fn r#serve_controller(
209        &self,
210        mut req: fidl::endpoints::ServerEnd<fidl_fuchsia_device::ControllerMarker>,
211    ) -> Result<(), fidl::Error> {
212        self.client.send::<DeviceProxyServeControllerRequest>(
213            (req,),
214            0x326c17ad2d3879ee,
215            fidl::encoding::DynamicFlags::empty(),
216        )
217    }
218
219    /// Serve the device's FIDL protocol.
220    pub fn r#serve_device(
221        &self,
222        mut req: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceInstanceMarker>,
223    ) -> Result<(), fidl::Error> {
224        self.client.send::<DeviceProxyServeDeviceRequest>(
225            (req,),
226            0x645dae2573613288,
227            fidl::encoding::DynamicFlags::empty(),
228        )
229    }
230}
231
232#[cfg(target_os = "fuchsia")]
233impl From<DeviceProxy_SynchronousProxy> for zx::Handle {
234    fn from(value: DeviceProxy_SynchronousProxy) -> Self {
235        value.into_channel().into()
236    }
237}
238
239#[cfg(target_os = "fuchsia")]
240impl From<fidl::Channel> for DeviceProxy_SynchronousProxy {
241    fn from(value: fidl::Channel) -> Self {
242        Self::new(value)
243    }
244}
245
246#[derive(Debug, Clone)]
247pub struct DeviceProxy_Proxy {
248    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
249}
250
251impl fidl::endpoints::Proxy for DeviceProxy_Proxy {
252    type Protocol = DeviceProxy_Marker;
253
254    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
255        Self::new(inner)
256    }
257
258    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
259        self.client.into_channel().map_err(|client| Self { client })
260    }
261
262    fn as_channel(&self) -> &::fidl::AsyncChannel {
263        self.client.as_channel()
264    }
265}
266
267impl DeviceProxy_Proxy {
268    /// Create a new Proxy for fuchsia.netemul.network/DeviceProxy.
269    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
270        let protocol_name = <DeviceProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
271        Self { client: fidl::client::Client::new(channel, protocol_name) }
272    }
273
274    /// Get a Stream of events from the remote end of the protocol.
275    ///
276    /// # Panics
277    ///
278    /// Panics if the event stream was already taken.
279    pub fn take_event_stream(&self) -> DeviceProxy_EventStream {
280        DeviceProxy_EventStream { event_receiver: self.client.take_event_receiver() }
281    }
282
283    /// Serve the Controller protocol for this device.
284    pub fn r#serve_controller(
285        &self,
286        mut req: fidl::endpoints::ServerEnd<fidl_fuchsia_device::ControllerMarker>,
287    ) -> Result<(), fidl::Error> {
288        DeviceProxy_ProxyInterface::r#serve_controller(self, req)
289    }
290
291    /// Serve the device's FIDL protocol.
292    pub fn r#serve_device(
293        &self,
294        mut req: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceInstanceMarker>,
295    ) -> Result<(), fidl::Error> {
296        DeviceProxy_ProxyInterface::r#serve_device(self, req)
297    }
298}
299
300impl DeviceProxy_ProxyInterface for DeviceProxy_Proxy {
301    fn r#serve_controller(
302        &self,
303        mut req: fidl::endpoints::ServerEnd<fidl_fuchsia_device::ControllerMarker>,
304    ) -> Result<(), fidl::Error> {
305        self.client.send::<DeviceProxyServeControllerRequest>(
306            (req,),
307            0x326c17ad2d3879ee,
308            fidl::encoding::DynamicFlags::empty(),
309        )
310    }
311
312    fn r#serve_device(
313        &self,
314        mut req: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceInstanceMarker>,
315    ) -> Result<(), fidl::Error> {
316        self.client.send::<DeviceProxyServeDeviceRequest>(
317            (req,),
318            0x645dae2573613288,
319            fidl::encoding::DynamicFlags::empty(),
320        )
321    }
322}
323
324pub struct DeviceProxy_EventStream {
325    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
326}
327
328impl std::marker::Unpin for DeviceProxy_EventStream {}
329
330impl futures::stream::FusedStream for DeviceProxy_EventStream {
331    fn is_terminated(&self) -> bool {
332        self.event_receiver.is_terminated()
333    }
334}
335
336impl futures::Stream for DeviceProxy_EventStream {
337    type Item = Result<DeviceProxy_Event, fidl::Error>;
338
339    fn poll_next(
340        mut self: std::pin::Pin<&mut Self>,
341        cx: &mut std::task::Context<'_>,
342    ) -> std::task::Poll<Option<Self::Item>> {
343        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
344            &mut self.event_receiver,
345            cx
346        )?) {
347            Some(buf) => std::task::Poll::Ready(Some(DeviceProxy_Event::decode(buf))),
348            None => std::task::Poll::Ready(None),
349        }
350    }
351}
352
353#[derive(Debug)]
354pub enum DeviceProxy_Event {}
355
356impl DeviceProxy_Event {
357    /// Decodes a message buffer as a [`DeviceProxy_Event`].
358    fn decode(
359        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
360    ) -> Result<DeviceProxy_Event, fidl::Error> {
361        let (bytes, _handles) = buf.split_mut();
362        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
363        debug_assert_eq!(tx_header.tx_id, 0);
364        match tx_header.ordinal {
365            _ => Err(fidl::Error::UnknownOrdinal {
366                ordinal: tx_header.ordinal,
367                protocol_name: <DeviceProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
368            }),
369        }
370    }
371}
372
373/// A Stream of incoming requests for fuchsia.netemul.network/DeviceProxy.
374pub struct DeviceProxy_RequestStream {
375    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
376    is_terminated: bool,
377}
378
379impl std::marker::Unpin for DeviceProxy_RequestStream {}
380
381impl futures::stream::FusedStream for DeviceProxy_RequestStream {
382    fn is_terminated(&self) -> bool {
383        self.is_terminated
384    }
385}
386
387impl fidl::endpoints::RequestStream for DeviceProxy_RequestStream {
388    type Protocol = DeviceProxy_Marker;
389    type ControlHandle = DeviceProxy_ControlHandle;
390
391    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
392        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
393    }
394
395    fn control_handle(&self) -> Self::ControlHandle {
396        DeviceProxy_ControlHandle { inner: self.inner.clone() }
397    }
398
399    fn into_inner(
400        self,
401    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
402    {
403        (self.inner, self.is_terminated)
404    }
405
406    fn from_inner(
407        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
408        is_terminated: bool,
409    ) -> Self {
410        Self { inner, is_terminated }
411    }
412}
413
414impl futures::Stream for DeviceProxy_RequestStream {
415    type Item = Result<DeviceProxy_Request, fidl::Error>;
416
417    fn poll_next(
418        mut self: std::pin::Pin<&mut Self>,
419        cx: &mut std::task::Context<'_>,
420    ) -> std::task::Poll<Option<Self::Item>> {
421        let this = &mut *self;
422        if this.inner.check_shutdown(cx) {
423            this.is_terminated = true;
424            return std::task::Poll::Ready(None);
425        }
426        if this.is_terminated {
427            panic!("polled DeviceProxy_RequestStream after completion");
428        }
429        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
430            |bytes, handles| {
431                match this.inner.channel().read_etc(cx, bytes, handles) {
432                    std::task::Poll::Ready(Ok(())) => {}
433                    std::task::Poll::Pending => return std::task::Poll::Pending,
434                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
435                        this.is_terminated = true;
436                        return std::task::Poll::Ready(None);
437                    }
438                    std::task::Poll::Ready(Err(e)) => {
439                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
440                            e.into(),
441                        ))))
442                    }
443                }
444
445                // A message has been received from the channel
446                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
447
448                std::task::Poll::Ready(Some(match header.ordinal {
449                    0x326c17ad2d3879ee => {
450                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
451                        let mut req = fidl::new_empty!(
452                            DeviceProxyServeControllerRequest,
453                            fidl::encoding::DefaultFuchsiaResourceDialect
454                        );
455                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceProxyServeControllerRequest>(&header, _body_bytes, handles, &mut req)?;
456                        let control_handle =
457                            DeviceProxy_ControlHandle { inner: this.inner.clone() };
458                        Ok(DeviceProxy_Request::ServeController { req: req.req, control_handle })
459                    }
460                    0x645dae2573613288 => {
461                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
462                        let mut req = fidl::new_empty!(
463                            DeviceProxyServeDeviceRequest,
464                            fidl::encoding::DefaultFuchsiaResourceDialect
465                        );
466                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceProxyServeDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
467                        let control_handle =
468                            DeviceProxy_ControlHandle { inner: this.inner.clone() };
469                        Ok(DeviceProxy_Request::ServeDevice { req: req.req, control_handle })
470                    }
471                    _ => Err(fidl::Error::UnknownOrdinal {
472                        ordinal: header.ordinal,
473                        protocol_name:
474                            <DeviceProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
475                    }),
476                }))
477            },
478        )
479    }
480}
481
482/// Simple interface to serve devices over fidl.
483#[derive(Debug)]
484pub enum DeviceProxy_Request {
485    /// Serve the Controller protocol for this device.
486    ServeController {
487        req: fidl::endpoints::ServerEnd<fidl_fuchsia_device::ControllerMarker>,
488        control_handle: DeviceProxy_ControlHandle,
489    },
490    /// Serve the device's FIDL protocol.
491    ServeDevice {
492        req: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceInstanceMarker>,
493        control_handle: DeviceProxy_ControlHandle,
494    },
495}
496
497impl DeviceProxy_Request {
498    #[allow(irrefutable_let_patterns)]
499    pub fn into_serve_controller(
500        self,
501    ) -> Option<(
502        fidl::endpoints::ServerEnd<fidl_fuchsia_device::ControllerMarker>,
503        DeviceProxy_ControlHandle,
504    )> {
505        if let DeviceProxy_Request::ServeController { req, control_handle } = self {
506            Some((req, control_handle))
507        } else {
508            None
509        }
510    }
511
512    #[allow(irrefutable_let_patterns)]
513    pub fn into_serve_device(
514        self,
515    ) -> Option<(
516        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceInstanceMarker>,
517        DeviceProxy_ControlHandle,
518    )> {
519        if let DeviceProxy_Request::ServeDevice { req, control_handle } = self {
520            Some((req, control_handle))
521        } else {
522            None
523        }
524    }
525
526    /// Name of the method defined in FIDL
527    pub fn method_name(&self) -> &'static str {
528        match *self {
529            DeviceProxy_Request::ServeController { .. } => "serve_controller",
530            DeviceProxy_Request::ServeDevice { .. } => "serve_device",
531        }
532    }
533}
534
535#[derive(Debug, Clone)]
536pub struct DeviceProxy_ControlHandle {
537    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
538}
539
540impl fidl::endpoints::ControlHandle for DeviceProxy_ControlHandle {
541    fn shutdown(&self) {
542        self.inner.shutdown()
543    }
544    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
545        self.inner.shutdown_with_epitaph(status)
546    }
547
548    fn is_closed(&self) -> bool {
549        self.inner.channel().is_closed()
550    }
551    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
552        self.inner.channel().on_closed()
553    }
554
555    #[cfg(target_os = "fuchsia")]
556    fn signal_peer(
557        &self,
558        clear_mask: zx::Signals,
559        set_mask: zx::Signals,
560    ) -> Result<(), zx_status::Status> {
561        use fidl::Peered;
562        self.inner.channel().signal_peer(clear_mask, set_mask)
563    }
564}
565
566impl DeviceProxy_ControlHandle {}
567
568#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
569pub struct EndpointMarker;
570
571impl fidl::endpoints::ProtocolMarker for EndpointMarker {
572    type Proxy = EndpointProxy;
573    type RequestStream = EndpointRequestStream;
574    #[cfg(target_os = "fuchsia")]
575    type SynchronousProxy = EndpointSynchronousProxy;
576
577    const DEBUG_NAME: &'static str = "(anonymous) Endpoint";
578}
579
580pub trait EndpointProxyInterface: Send + Sync {
581    type GetConfigResponseFut: std::future::Future<Output = Result<EndpointConfig, fidl::Error>>
582        + Send;
583    fn r#get_config(&self) -> Self::GetConfigResponseFut;
584    type GetNameResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
585    fn r#get_name(&self) -> Self::GetNameResponseFut;
586    type SetLinkUpResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
587    fn r#set_link_up(&self, up: bool) -> Self::SetLinkUpResponseFut;
588    fn r#get_port(
589        &self,
590        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
591    ) -> Result<(), fidl::Error>;
592    fn r#get_proxy_(
593        &self,
594        proxy: fidl::endpoints::ServerEnd<DeviceProxy_Marker>,
595    ) -> Result<(), fidl::Error>;
596}
597#[derive(Debug)]
598#[cfg(target_os = "fuchsia")]
599pub struct EndpointSynchronousProxy {
600    client: fidl::client::sync::Client,
601}
602
603#[cfg(target_os = "fuchsia")]
604impl fidl::endpoints::SynchronousProxy for EndpointSynchronousProxy {
605    type Proxy = EndpointProxy;
606    type Protocol = EndpointMarker;
607
608    fn from_channel(inner: fidl::Channel) -> Self {
609        Self::new(inner)
610    }
611
612    fn into_channel(self) -> fidl::Channel {
613        self.client.into_channel()
614    }
615
616    fn as_channel(&self) -> &fidl::Channel {
617        self.client.as_channel()
618    }
619}
620
621#[cfg(target_os = "fuchsia")]
622impl EndpointSynchronousProxy {
623    pub fn new(channel: fidl::Channel) -> Self {
624        let protocol_name = <EndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
625        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
626    }
627
628    pub fn into_channel(self) -> fidl::Channel {
629        self.client.into_channel()
630    }
631
632    /// Waits until an event arrives and returns it. It is safe for other
633    /// threads to make concurrent requests while waiting for an event.
634    pub fn wait_for_event(
635        &self,
636        deadline: zx::MonotonicInstant,
637    ) -> Result<EndpointEvent, fidl::Error> {
638        EndpointEvent::decode(self.client.wait_for_event(deadline)?)
639    }
640
641    pub fn r#get_config(
642        &self,
643        ___deadline: zx::MonotonicInstant,
644    ) -> Result<EndpointConfig, fidl::Error> {
645        let _response =
646            self.client.send_query::<fidl::encoding::EmptyPayload, EndpointGetConfigResponse>(
647                (),
648                0x3589f54aa3748539,
649                fidl::encoding::DynamicFlags::empty(),
650                ___deadline,
651            )?;
652        Ok(_response.config)
653    }
654
655    /// Gets endpoint name.
656    pub fn r#get_name(&self, ___deadline: zx::MonotonicInstant) -> Result<String, fidl::Error> {
657        let _response =
658            self.client.send_query::<fidl::encoding::EmptyPayload, EndpointGetNameResponse>(
659                (),
660                0x7d69650823557aab,
661                fidl::encoding::DynamicFlags::empty(),
662                ___deadline,
663            )?;
664        Ok(_response.name)
665    }
666
667    /// Sends link up or down signal
668    pub fn r#set_link_up(
669        &self,
670        mut up: bool,
671        ___deadline: zx::MonotonicInstant,
672    ) -> Result<(), fidl::Error> {
673        let _response =
674            self.client.send_query::<EndpointSetLinkUpRequest, fidl::encoding::EmptyPayload>(
675                (up,),
676                0x4dde77de68d02e11,
677                fidl::encoding::DynamicFlags::empty(),
678                ___deadline,
679            )?;
680        Ok(_response)
681    }
682
683    /// Connects to the underlying device port.
684    pub fn r#get_port(
685        &self,
686        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
687    ) -> Result<(), fidl::Error> {
688        self.client.send::<EndpointGetPortRequest>(
689            (port,),
690            0x68151e034eccc958,
691            fidl::encoding::DynamicFlags::empty(),
692        )
693    }
694
695    /// Gets a proxy to open requests with zircon ethernet device.
696    pub fn r#get_proxy_(
697        &self,
698        mut proxy: fidl::endpoints::ServerEnd<DeviceProxy_Marker>,
699    ) -> Result<(), fidl::Error> {
700        self.client.send::<EndpointGetProxyRequest>(
701            (proxy,),
702            0x476e5a57c4288ee9,
703            fidl::encoding::DynamicFlags::empty(),
704        )
705    }
706}
707
708#[cfg(target_os = "fuchsia")]
709impl From<EndpointSynchronousProxy> for zx::Handle {
710    fn from(value: EndpointSynchronousProxy) -> Self {
711        value.into_channel().into()
712    }
713}
714
715#[cfg(target_os = "fuchsia")]
716impl From<fidl::Channel> for EndpointSynchronousProxy {
717    fn from(value: fidl::Channel) -> Self {
718        Self::new(value)
719    }
720}
721
722#[derive(Debug, Clone)]
723pub struct EndpointProxy {
724    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
725}
726
727impl fidl::endpoints::Proxy for EndpointProxy {
728    type Protocol = EndpointMarker;
729
730    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
731        Self::new(inner)
732    }
733
734    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
735        self.client.into_channel().map_err(|client| Self { client })
736    }
737
738    fn as_channel(&self) -> &::fidl::AsyncChannel {
739        self.client.as_channel()
740    }
741}
742
743impl EndpointProxy {
744    /// Create a new Proxy for fuchsia.netemul.network/Endpoint.
745    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
746        let protocol_name = <EndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
747        Self { client: fidl::client::Client::new(channel, protocol_name) }
748    }
749
750    /// Get a Stream of events from the remote end of the protocol.
751    ///
752    /// # Panics
753    ///
754    /// Panics if the event stream was already taken.
755    pub fn take_event_stream(&self) -> EndpointEventStream {
756        EndpointEventStream { event_receiver: self.client.take_event_receiver() }
757    }
758
759    pub fn r#get_config(
760        &self,
761    ) -> fidl::client::QueryResponseFut<EndpointConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
762    {
763        EndpointProxyInterface::r#get_config(self)
764    }
765
766    /// Gets endpoint name.
767    pub fn r#get_name(
768        &self,
769    ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
770        EndpointProxyInterface::r#get_name(self)
771    }
772
773    /// Sends link up or down signal
774    pub fn r#set_link_up(
775        &self,
776        mut up: bool,
777    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
778        EndpointProxyInterface::r#set_link_up(self, up)
779    }
780
781    /// Connects to the underlying device port.
782    pub fn r#get_port(
783        &self,
784        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
785    ) -> Result<(), fidl::Error> {
786        EndpointProxyInterface::r#get_port(self, port)
787    }
788
789    /// Gets a proxy to open requests with zircon ethernet device.
790    pub fn r#get_proxy_(
791        &self,
792        mut proxy: fidl::endpoints::ServerEnd<DeviceProxy_Marker>,
793    ) -> Result<(), fidl::Error> {
794        EndpointProxyInterface::r#get_proxy_(self, proxy)
795    }
796}
797
798impl EndpointProxyInterface for EndpointProxy {
799    type GetConfigResponseFut = fidl::client::QueryResponseFut<
800        EndpointConfig,
801        fidl::encoding::DefaultFuchsiaResourceDialect,
802    >;
803    fn r#get_config(&self) -> Self::GetConfigResponseFut {
804        fn _decode(
805            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
806        ) -> Result<EndpointConfig, fidl::Error> {
807            let _response = fidl::client::decode_transaction_body::<
808                EndpointGetConfigResponse,
809                fidl::encoding::DefaultFuchsiaResourceDialect,
810                0x3589f54aa3748539,
811            >(_buf?)?;
812            Ok(_response.config)
813        }
814        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, EndpointConfig>(
815            (),
816            0x3589f54aa3748539,
817            fidl::encoding::DynamicFlags::empty(),
818            _decode,
819        )
820    }
821
822    type GetNameResponseFut =
823        fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
824    fn r#get_name(&self) -> Self::GetNameResponseFut {
825        fn _decode(
826            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
827        ) -> Result<String, fidl::Error> {
828            let _response = fidl::client::decode_transaction_body::<
829                EndpointGetNameResponse,
830                fidl::encoding::DefaultFuchsiaResourceDialect,
831                0x7d69650823557aab,
832            >(_buf?)?;
833            Ok(_response.name)
834        }
835        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
836            (),
837            0x7d69650823557aab,
838            fidl::encoding::DynamicFlags::empty(),
839            _decode,
840        )
841    }
842
843    type SetLinkUpResponseFut =
844        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
845    fn r#set_link_up(&self, mut up: bool) -> Self::SetLinkUpResponseFut {
846        fn _decode(
847            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
848        ) -> Result<(), fidl::Error> {
849            let _response = fidl::client::decode_transaction_body::<
850                fidl::encoding::EmptyPayload,
851                fidl::encoding::DefaultFuchsiaResourceDialect,
852                0x4dde77de68d02e11,
853            >(_buf?)?;
854            Ok(_response)
855        }
856        self.client.send_query_and_decode::<EndpointSetLinkUpRequest, ()>(
857            (up,),
858            0x4dde77de68d02e11,
859            fidl::encoding::DynamicFlags::empty(),
860            _decode,
861        )
862    }
863
864    fn r#get_port(
865        &self,
866        mut port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
867    ) -> Result<(), fidl::Error> {
868        self.client.send::<EndpointGetPortRequest>(
869            (port,),
870            0x68151e034eccc958,
871            fidl::encoding::DynamicFlags::empty(),
872        )
873    }
874
875    fn r#get_proxy_(
876        &self,
877        mut proxy: fidl::endpoints::ServerEnd<DeviceProxy_Marker>,
878    ) -> Result<(), fidl::Error> {
879        self.client.send::<EndpointGetProxyRequest>(
880            (proxy,),
881            0x476e5a57c4288ee9,
882            fidl::encoding::DynamicFlags::empty(),
883        )
884    }
885}
886
887pub struct EndpointEventStream {
888    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
889}
890
891impl std::marker::Unpin for EndpointEventStream {}
892
893impl futures::stream::FusedStream for EndpointEventStream {
894    fn is_terminated(&self) -> bool {
895        self.event_receiver.is_terminated()
896    }
897}
898
899impl futures::Stream for EndpointEventStream {
900    type Item = Result<EndpointEvent, fidl::Error>;
901
902    fn poll_next(
903        mut self: std::pin::Pin<&mut Self>,
904        cx: &mut std::task::Context<'_>,
905    ) -> std::task::Poll<Option<Self::Item>> {
906        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
907            &mut self.event_receiver,
908            cx
909        )?) {
910            Some(buf) => std::task::Poll::Ready(Some(EndpointEvent::decode(buf))),
911            None => std::task::Poll::Ready(None),
912        }
913    }
914}
915
916#[derive(Debug)]
917pub enum EndpointEvent {}
918
919impl EndpointEvent {
920    /// Decodes a message buffer as a [`EndpointEvent`].
921    fn decode(
922        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
923    ) -> Result<EndpointEvent, fidl::Error> {
924        let (bytes, _handles) = buf.split_mut();
925        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
926        debug_assert_eq!(tx_header.tx_id, 0);
927        match tx_header.ordinal {
928            _ => Err(fidl::Error::UnknownOrdinal {
929                ordinal: tx_header.ordinal,
930                protocol_name: <EndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
931            }),
932        }
933    }
934}
935
936/// A Stream of incoming requests for fuchsia.netemul.network/Endpoint.
937pub struct EndpointRequestStream {
938    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
939    is_terminated: bool,
940}
941
942impl std::marker::Unpin for EndpointRequestStream {}
943
944impl futures::stream::FusedStream for EndpointRequestStream {
945    fn is_terminated(&self) -> bool {
946        self.is_terminated
947    }
948}
949
950impl fidl::endpoints::RequestStream for EndpointRequestStream {
951    type Protocol = EndpointMarker;
952    type ControlHandle = EndpointControlHandle;
953
954    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
955        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
956    }
957
958    fn control_handle(&self) -> Self::ControlHandle {
959        EndpointControlHandle { inner: self.inner.clone() }
960    }
961
962    fn into_inner(
963        self,
964    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
965    {
966        (self.inner, self.is_terminated)
967    }
968
969    fn from_inner(
970        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
971        is_terminated: bool,
972    ) -> Self {
973        Self { inner, is_terminated }
974    }
975}
976
977impl futures::Stream for EndpointRequestStream {
978    type Item = Result<EndpointRequest, fidl::Error>;
979
980    fn poll_next(
981        mut self: std::pin::Pin<&mut Self>,
982        cx: &mut std::task::Context<'_>,
983    ) -> std::task::Poll<Option<Self::Item>> {
984        let this = &mut *self;
985        if this.inner.check_shutdown(cx) {
986            this.is_terminated = true;
987            return std::task::Poll::Ready(None);
988        }
989        if this.is_terminated {
990            panic!("polled EndpointRequestStream after completion");
991        }
992        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
993            |bytes, handles| {
994                match this.inner.channel().read_etc(cx, bytes, handles) {
995                    std::task::Poll::Ready(Ok(())) => {}
996                    std::task::Poll::Pending => return std::task::Poll::Pending,
997                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
998                        this.is_terminated = true;
999                        return std::task::Poll::Ready(None);
1000                    }
1001                    std::task::Poll::Ready(Err(e)) => {
1002                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1003                            e.into(),
1004                        ))))
1005                    }
1006                }
1007
1008                // A message has been received from the channel
1009                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1010
1011                std::task::Poll::Ready(Some(match header.ordinal {
1012                    0x3589f54aa3748539 => {
1013                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1014                        let mut req = fidl::new_empty!(
1015                            fidl::encoding::EmptyPayload,
1016                            fidl::encoding::DefaultFuchsiaResourceDialect
1017                        );
1018                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1019                        let control_handle = EndpointControlHandle { inner: this.inner.clone() };
1020                        Ok(EndpointRequest::GetConfig {
1021                            responder: EndpointGetConfigResponder {
1022                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1023                                tx_id: header.tx_id,
1024                            },
1025                        })
1026                    }
1027                    0x7d69650823557aab => {
1028                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1029                        let mut req = fidl::new_empty!(
1030                            fidl::encoding::EmptyPayload,
1031                            fidl::encoding::DefaultFuchsiaResourceDialect
1032                        );
1033                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1034                        let control_handle = EndpointControlHandle { inner: this.inner.clone() };
1035                        Ok(EndpointRequest::GetName {
1036                            responder: EndpointGetNameResponder {
1037                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1038                                tx_id: header.tx_id,
1039                            },
1040                        })
1041                    }
1042                    0x4dde77de68d02e11 => {
1043                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1044                        let mut req = fidl::new_empty!(
1045                            EndpointSetLinkUpRequest,
1046                            fidl::encoding::DefaultFuchsiaResourceDialect
1047                        );
1048                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EndpointSetLinkUpRequest>(&header, _body_bytes, handles, &mut req)?;
1049                        let control_handle = EndpointControlHandle { inner: this.inner.clone() };
1050                        Ok(EndpointRequest::SetLinkUp {
1051                            up: req.up,
1052
1053                            responder: EndpointSetLinkUpResponder {
1054                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1055                                tx_id: header.tx_id,
1056                            },
1057                        })
1058                    }
1059                    0x68151e034eccc958 => {
1060                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1061                        let mut req = fidl::new_empty!(
1062                            EndpointGetPortRequest,
1063                            fidl::encoding::DefaultFuchsiaResourceDialect
1064                        );
1065                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EndpointGetPortRequest>(&header, _body_bytes, handles, &mut req)?;
1066                        let control_handle = EndpointControlHandle { inner: this.inner.clone() };
1067                        Ok(EndpointRequest::GetPort { port: req.port, control_handle })
1068                    }
1069                    0x476e5a57c4288ee9 => {
1070                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1071                        let mut req = fidl::new_empty!(
1072                            EndpointGetProxyRequest,
1073                            fidl::encoding::DefaultFuchsiaResourceDialect
1074                        );
1075                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EndpointGetProxyRequest>(&header, _body_bytes, handles, &mut req)?;
1076                        let control_handle = EndpointControlHandle { inner: this.inner.clone() };
1077                        Ok(EndpointRequest::GetProxy_ { proxy: req.proxy, control_handle })
1078                    }
1079                    _ => Err(fidl::Error::UnknownOrdinal {
1080                        ordinal: header.ordinal,
1081                        protocol_name:
1082                            <EndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1083                    }),
1084                }))
1085            },
1086        )
1087    }
1088}
1089
1090/// Virtual ethernet endpoint.
1091#[derive(Debug)]
1092pub enum EndpointRequest {
1093    GetConfig {
1094        responder: EndpointGetConfigResponder,
1095    },
1096    /// Gets endpoint name.
1097    GetName {
1098        responder: EndpointGetNameResponder,
1099    },
1100    /// Sends link up or down signal
1101    SetLinkUp {
1102        up: bool,
1103        responder: EndpointSetLinkUpResponder,
1104    },
1105    /// Connects to the underlying device port.
1106    GetPort {
1107        port: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1108        control_handle: EndpointControlHandle,
1109    },
1110    /// Gets a proxy to open requests with zircon ethernet device.
1111    GetProxy_ {
1112        proxy: fidl::endpoints::ServerEnd<DeviceProxy_Marker>,
1113        control_handle: EndpointControlHandle,
1114    },
1115}
1116
1117impl EndpointRequest {
1118    #[allow(irrefutable_let_patterns)]
1119    pub fn into_get_config(self) -> Option<(EndpointGetConfigResponder)> {
1120        if let EndpointRequest::GetConfig { responder } = self {
1121            Some((responder))
1122        } else {
1123            None
1124        }
1125    }
1126
1127    #[allow(irrefutable_let_patterns)]
1128    pub fn into_get_name(self) -> Option<(EndpointGetNameResponder)> {
1129        if let EndpointRequest::GetName { responder } = self {
1130            Some((responder))
1131        } else {
1132            None
1133        }
1134    }
1135
1136    #[allow(irrefutable_let_patterns)]
1137    pub fn into_set_link_up(self) -> Option<(bool, EndpointSetLinkUpResponder)> {
1138        if let EndpointRequest::SetLinkUp { up, responder } = self {
1139            Some((up, responder))
1140        } else {
1141            None
1142        }
1143    }
1144
1145    #[allow(irrefutable_let_patterns)]
1146    pub fn into_get_port(
1147        self,
1148    ) -> Option<(
1149        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
1150        EndpointControlHandle,
1151    )> {
1152        if let EndpointRequest::GetPort { port, control_handle } = self {
1153            Some((port, control_handle))
1154        } else {
1155            None
1156        }
1157    }
1158
1159    #[allow(irrefutable_let_patterns)]
1160    pub fn into_get_proxy_(
1161        self,
1162    ) -> Option<(fidl::endpoints::ServerEnd<DeviceProxy_Marker>, EndpointControlHandle)> {
1163        if let EndpointRequest::GetProxy_ { proxy, control_handle } = self {
1164            Some((proxy, control_handle))
1165        } else {
1166            None
1167        }
1168    }
1169
1170    /// Name of the method defined in FIDL
1171    pub fn method_name(&self) -> &'static str {
1172        match *self {
1173            EndpointRequest::GetConfig { .. } => "get_config",
1174            EndpointRequest::GetName { .. } => "get_name",
1175            EndpointRequest::SetLinkUp { .. } => "set_link_up",
1176            EndpointRequest::GetPort { .. } => "get_port",
1177            EndpointRequest::GetProxy_ { .. } => "get_proxy_",
1178        }
1179    }
1180}
1181
1182#[derive(Debug, Clone)]
1183pub struct EndpointControlHandle {
1184    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1185}
1186
1187impl fidl::endpoints::ControlHandle for EndpointControlHandle {
1188    fn shutdown(&self) {
1189        self.inner.shutdown()
1190    }
1191    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1192        self.inner.shutdown_with_epitaph(status)
1193    }
1194
1195    fn is_closed(&self) -> bool {
1196        self.inner.channel().is_closed()
1197    }
1198    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1199        self.inner.channel().on_closed()
1200    }
1201
1202    #[cfg(target_os = "fuchsia")]
1203    fn signal_peer(
1204        &self,
1205        clear_mask: zx::Signals,
1206        set_mask: zx::Signals,
1207    ) -> Result<(), zx_status::Status> {
1208        use fidl::Peered;
1209        self.inner.channel().signal_peer(clear_mask, set_mask)
1210    }
1211}
1212
1213impl EndpointControlHandle {}
1214
1215#[must_use = "FIDL methods require a response to be sent"]
1216#[derive(Debug)]
1217pub struct EndpointGetConfigResponder {
1218    control_handle: std::mem::ManuallyDrop<EndpointControlHandle>,
1219    tx_id: u32,
1220}
1221
1222/// Set the the channel to be shutdown (see [`EndpointControlHandle::shutdown`])
1223/// if the responder is dropped without sending a response, so that the client
1224/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1225impl std::ops::Drop for EndpointGetConfigResponder {
1226    fn drop(&mut self) {
1227        self.control_handle.shutdown();
1228        // Safety: drops once, never accessed again
1229        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1230    }
1231}
1232
1233impl fidl::endpoints::Responder for EndpointGetConfigResponder {
1234    type ControlHandle = EndpointControlHandle;
1235
1236    fn control_handle(&self) -> &EndpointControlHandle {
1237        &self.control_handle
1238    }
1239
1240    fn drop_without_shutdown(mut self) {
1241        // Safety: drops once, never accessed again due to mem::forget
1242        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1243        // Prevent Drop from running (which would shut down the channel)
1244        std::mem::forget(self);
1245    }
1246}
1247
1248impl EndpointGetConfigResponder {
1249    /// Sends a response to the FIDL transaction.
1250    ///
1251    /// Sets the channel to shutdown if an error occurs.
1252    pub fn send(self, mut config: &EndpointConfig) -> Result<(), fidl::Error> {
1253        let _result = self.send_raw(config);
1254        if _result.is_err() {
1255            self.control_handle.shutdown();
1256        }
1257        self.drop_without_shutdown();
1258        _result
1259    }
1260
1261    /// Similar to "send" but does not shutdown the channel if an error occurs.
1262    pub fn send_no_shutdown_on_err(self, mut config: &EndpointConfig) -> Result<(), fidl::Error> {
1263        let _result = self.send_raw(config);
1264        self.drop_without_shutdown();
1265        _result
1266    }
1267
1268    fn send_raw(&self, mut config: &EndpointConfig) -> Result<(), fidl::Error> {
1269        self.control_handle.inner.send::<EndpointGetConfigResponse>(
1270            (config,),
1271            self.tx_id,
1272            0x3589f54aa3748539,
1273            fidl::encoding::DynamicFlags::empty(),
1274        )
1275    }
1276}
1277
1278#[must_use = "FIDL methods require a response to be sent"]
1279#[derive(Debug)]
1280pub struct EndpointGetNameResponder {
1281    control_handle: std::mem::ManuallyDrop<EndpointControlHandle>,
1282    tx_id: u32,
1283}
1284
1285/// Set the the channel to be shutdown (see [`EndpointControlHandle::shutdown`])
1286/// if the responder is dropped without sending a response, so that the client
1287/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1288impl std::ops::Drop for EndpointGetNameResponder {
1289    fn drop(&mut self) {
1290        self.control_handle.shutdown();
1291        // Safety: drops once, never accessed again
1292        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1293    }
1294}
1295
1296impl fidl::endpoints::Responder for EndpointGetNameResponder {
1297    type ControlHandle = EndpointControlHandle;
1298
1299    fn control_handle(&self) -> &EndpointControlHandle {
1300        &self.control_handle
1301    }
1302
1303    fn drop_without_shutdown(mut self) {
1304        // Safety: drops once, never accessed again due to mem::forget
1305        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1306        // Prevent Drop from running (which would shut down the channel)
1307        std::mem::forget(self);
1308    }
1309}
1310
1311impl EndpointGetNameResponder {
1312    /// Sends a response to the FIDL transaction.
1313    ///
1314    /// Sets the channel to shutdown if an error occurs.
1315    pub fn send(self, mut name: &str) -> Result<(), fidl::Error> {
1316        let _result = self.send_raw(name);
1317        if _result.is_err() {
1318            self.control_handle.shutdown();
1319        }
1320        self.drop_without_shutdown();
1321        _result
1322    }
1323
1324    /// Similar to "send" but does not shutdown the channel if an error occurs.
1325    pub fn send_no_shutdown_on_err(self, mut name: &str) -> Result<(), fidl::Error> {
1326        let _result = self.send_raw(name);
1327        self.drop_without_shutdown();
1328        _result
1329    }
1330
1331    fn send_raw(&self, mut name: &str) -> Result<(), fidl::Error> {
1332        self.control_handle.inner.send::<EndpointGetNameResponse>(
1333            (name,),
1334            self.tx_id,
1335            0x7d69650823557aab,
1336            fidl::encoding::DynamicFlags::empty(),
1337        )
1338    }
1339}
1340
1341#[must_use = "FIDL methods require a response to be sent"]
1342#[derive(Debug)]
1343pub struct EndpointSetLinkUpResponder {
1344    control_handle: std::mem::ManuallyDrop<EndpointControlHandle>,
1345    tx_id: u32,
1346}
1347
1348/// Set the the channel to be shutdown (see [`EndpointControlHandle::shutdown`])
1349/// if the responder is dropped without sending a response, so that the client
1350/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1351impl std::ops::Drop for EndpointSetLinkUpResponder {
1352    fn drop(&mut self) {
1353        self.control_handle.shutdown();
1354        // Safety: drops once, never accessed again
1355        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1356    }
1357}
1358
1359impl fidl::endpoints::Responder for EndpointSetLinkUpResponder {
1360    type ControlHandle = EndpointControlHandle;
1361
1362    fn control_handle(&self) -> &EndpointControlHandle {
1363        &self.control_handle
1364    }
1365
1366    fn drop_without_shutdown(mut self) {
1367        // Safety: drops once, never accessed again due to mem::forget
1368        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1369        // Prevent Drop from running (which would shut down the channel)
1370        std::mem::forget(self);
1371    }
1372}
1373
1374impl EndpointSetLinkUpResponder {
1375    /// Sends a response to the FIDL transaction.
1376    ///
1377    /// Sets the channel to shutdown if an error occurs.
1378    pub fn send(self) -> Result<(), fidl::Error> {
1379        let _result = self.send_raw();
1380        if _result.is_err() {
1381            self.control_handle.shutdown();
1382        }
1383        self.drop_without_shutdown();
1384        _result
1385    }
1386
1387    /// Similar to "send" but does not shutdown the channel if an error occurs.
1388    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1389        let _result = self.send_raw();
1390        self.drop_without_shutdown();
1391        _result
1392    }
1393
1394    fn send_raw(&self) -> Result<(), fidl::Error> {
1395        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1396            (),
1397            self.tx_id,
1398            0x4dde77de68d02e11,
1399            fidl::encoding::DynamicFlags::empty(),
1400        )
1401    }
1402}
1403
1404#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1405pub struct EndpointManagerMarker;
1406
1407impl fidl::endpoints::ProtocolMarker for EndpointManagerMarker {
1408    type Proxy = EndpointManagerProxy;
1409    type RequestStream = EndpointManagerRequestStream;
1410    #[cfg(target_os = "fuchsia")]
1411    type SynchronousProxy = EndpointManagerSynchronousProxy;
1412
1413    const DEBUG_NAME: &'static str = "(anonymous) EndpointManager";
1414}
1415
1416pub trait EndpointManagerProxyInterface: Send + Sync {
1417    type ListEndpointsResponseFut: std::future::Future<Output = Result<Vec<String>, fidl::Error>>
1418        + Send;
1419    fn r#list_endpoints(&self) -> Self::ListEndpointsResponseFut;
1420    type CreateEndpointResponseFut: std::future::Future<
1421            Output = Result<(i32, Option<fidl::endpoints::ClientEnd<EndpointMarker>>), fidl::Error>,
1422        > + Send;
1423    fn r#create_endpoint(
1424        &self,
1425        name: &str,
1426        config: &EndpointConfig,
1427    ) -> Self::CreateEndpointResponseFut;
1428    type GetEndpointResponseFut: std::future::Future<
1429            Output = Result<Option<fidl::endpoints::ClientEnd<EndpointMarker>>, fidl::Error>,
1430        > + Send;
1431    fn r#get_endpoint(&self, name: &str) -> Self::GetEndpointResponseFut;
1432}
1433#[derive(Debug)]
1434#[cfg(target_os = "fuchsia")]
1435pub struct EndpointManagerSynchronousProxy {
1436    client: fidl::client::sync::Client,
1437}
1438
1439#[cfg(target_os = "fuchsia")]
1440impl fidl::endpoints::SynchronousProxy for EndpointManagerSynchronousProxy {
1441    type Proxy = EndpointManagerProxy;
1442    type Protocol = EndpointManagerMarker;
1443
1444    fn from_channel(inner: fidl::Channel) -> Self {
1445        Self::new(inner)
1446    }
1447
1448    fn into_channel(self) -> fidl::Channel {
1449        self.client.into_channel()
1450    }
1451
1452    fn as_channel(&self) -> &fidl::Channel {
1453        self.client.as_channel()
1454    }
1455}
1456
1457#[cfg(target_os = "fuchsia")]
1458impl EndpointManagerSynchronousProxy {
1459    pub fn new(channel: fidl::Channel) -> Self {
1460        let protocol_name = <EndpointManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1461        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1462    }
1463
1464    pub fn into_channel(self) -> fidl::Channel {
1465        self.client.into_channel()
1466    }
1467
1468    /// Waits until an event arrives and returns it. It is safe for other
1469    /// threads to make concurrent requests while waiting for an event.
1470    pub fn wait_for_event(
1471        &self,
1472        deadline: zx::MonotonicInstant,
1473    ) -> Result<EndpointManagerEvent, fidl::Error> {
1474        EndpointManagerEvent::decode(self.client.wait_for_event(deadline)?)
1475    }
1476
1477    /// Lists endpoints by name.
1478    pub fn r#list_endpoints(
1479        &self,
1480        ___deadline: zx::MonotonicInstant,
1481    ) -> Result<Vec<String>, fidl::Error> {
1482        let _response = self
1483            .client
1484            .send_query::<fidl::encoding::EmptyPayload, EndpointManagerListEndpointsResponse>(
1485                (),
1486                0x78c83d9454e3d228,
1487                fidl::encoding::DynamicFlags::empty(),
1488                ___deadline,
1489            )?;
1490        Ok(_response.endp)
1491    }
1492
1493    /// Creates endpoint with given name and config.
1494    pub fn r#create_endpoint(
1495        &self,
1496        mut name: &str,
1497        mut config: &EndpointConfig,
1498        ___deadline: zx::MonotonicInstant,
1499    ) -> Result<(i32, Option<fidl::endpoints::ClientEnd<EndpointMarker>>), fidl::Error> {
1500        let _response = self.client.send_query::<
1501            EndpointManagerCreateEndpointRequest,
1502            EndpointManagerCreateEndpointResponse,
1503        >(
1504            (name, config,),
1505            0x7defe4cd5e4e7d7c,
1506            fidl::encoding::DynamicFlags::empty(),
1507            ___deadline,
1508        )?;
1509        Ok((_response.status, _response.endpoint))
1510    }
1511
1512    /// Gets a handle to an endpoint.
1513    pub fn r#get_endpoint(
1514        &self,
1515        mut name: &str,
1516        ___deadline: zx::MonotonicInstant,
1517    ) -> Result<Option<fidl::endpoints::ClientEnd<EndpointMarker>>, fidl::Error> {
1518        let _response = self
1519            .client
1520            .send_query::<EndpointManagerGetEndpointRequest, EndpointManagerGetEndpointResponse>(
1521                (name,),
1522                0x437e956b7b860751,
1523                fidl::encoding::DynamicFlags::empty(),
1524                ___deadline,
1525            )?;
1526        Ok(_response.endpoint)
1527    }
1528}
1529
1530#[cfg(target_os = "fuchsia")]
1531impl From<EndpointManagerSynchronousProxy> for zx::Handle {
1532    fn from(value: EndpointManagerSynchronousProxy) -> Self {
1533        value.into_channel().into()
1534    }
1535}
1536
1537#[cfg(target_os = "fuchsia")]
1538impl From<fidl::Channel> for EndpointManagerSynchronousProxy {
1539    fn from(value: fidl::Channel) -> Self {
1540        Self::new(value)
1541    }
1542}
1543
1544#[derive(Debug, Clone)]
1545pub struct EndpointManagerProxy {
1546    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1547}
1548
1549impl fidl::endpoints::Proxy for EndpointManagerProxy {
1550    type Protocol = EndpointManagerMarker;
1551
1552    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1553        Self::new(inner)
1554    }
1555
1556    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1557        self.client.into_channel().map_err(|client| Self { client })
1558    }
1559
1560    fn as_channel(&self) -> &::fidl::AsyncChannel {
1561        self.client.as_channel()
1562    }
1563}
1564
1565impl EndpointManagerProxy {
1566    /// Create a new Proxy for fuchsia.netemul.network/EndpointManager.
1567    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1568        let protocol_name = <EndpointManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1569        Self { client: fidl::client::Client::new(channel, protocol_name) }
1570    }
1571
1572    /// Get a Stream of events from the remote end of the protocol.
1573    ///
1574    /// # Panics
1575    ///
1576    /// Panics if the event stream was already taken.
1577    pub fn take_event_stream(&self) -> EndpointManagerEventStream {
1578        EndpointManagerEventStream { event_receiver: self.client.take_event_receiver() }
1579    }
1580
1581    /// Lists endpoints by name.
1582    pub fn r#list_endpoints(
1583        &self,
1584    ) -> fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>
1585    {
1586        EndpointManagerProxyInterface::r#list_endpoints(self)
1587    }
1588
1589    /// Creates endpoint with given name and config.
1590    pub fn r#create_endpoint(
1591        &self,
1592        mut name: &str,
1593        mut config: &EndpointConfig,
1594    ) -> fidl::client::QueryResponseFut<
1595        (i32, Option<fidl::endpoints::ClientEnd<EndpointMarker>>),
1596        fidl::encoding::DefaultFuchsiaResourceDialect,
1597    > {
1598        EndpointManagerProxyInterface::r#create_endpoint(self, name, config)
1599    }
1600
1601    /// Gets a handle to an endpoint.
1602    pub fn r#get_endpoint(
1603        &self,
1604        mut name: &str,
1605    ) -> fidl::client::QueryResponseFut<
1606        Option<fidl::endpoints::ClientEnd<EndpointMarker>>,
1607        fidl::encoding::DefaultFuchsiaResourceDialect,
1608    > {
1609        EndpointManagerProxyInterface::r#get_endpoint(self, name)
1610    }
1611}
1612
1613impl EndpointManagerProxyInterface for EndpointManagerProxy {
1614    type ListEndpointsResponseFut =
1615        fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>;
1616    fn r#list_endpoints(&self) -> Self::ListEndpointsResponseFut {
1617        fn _decode(
1618            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1619        ) -> Result<Vec<String>, fidl::Error> {
1620            let _response = fidl::client::decode_transaction_body::<
1621                EndpointManagerListEndpointsResponse,
1622                fidl::encoding::DefaultFuchsiaResourceDialect,
1623                0x78c83d9454e3d228,
1624            >(_buf?)?;
1625            Ok(_response.endp)
1626        }
1627        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<String>>(
1628            (),
1629            0x78c83d9454e3d228,
1630            fidl::encoding::DynamicFlags::empty(),
1631            _decode,
1632        )
1633    }
1634
1635    type CreateEndpointResponseFut = fidl::client::QueryResponseFut<
1636        (i32, Option<fidl::endpoints::ClientEnd<EndpointMarker>>),
1637        fidl::encoding::DefaultFuchsiaResourceDialect,
1638    >;
1639    fn r#create_endpoint(
1640        &self,
1641        mut name: &str,
1642        mut config: &EndpointConfig,
1643    ) -> Self::CreateEndpointResponseFut {
1644        fn _decode(
1645            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1646        ) -> Result<(i32, Option<fidl::endpoints::ClientEnd<EndpointMarker>>), fidl::Error>
1647        {
1648            let _response = fidl::client::decode_transaction_body::<
1649                EndpointManagerCreateEndpointResponse,
1650                fidl::encoding::DefaultFuchsiaResourceDialect,
1651                0x7defe4cd5e4e7d7c,
1652            >(_buf?)?;
1653            Ok((_response.status, _response.endpoint))
1654        }
1655        self.client.send_query_and_decode::<
1656            EndpointManagerCreateEndpointRequest,
1657            (i32, Option<fidl::endpoints::ClientEnd<EndpointMarker>>),
1658        >(
1659            (name, config,),
1660            0x7defe4cd5e4e7d7c,
1661            fidl::encoding::DynamicFlags::empty(),
1662            _decode,
1663        )
1664    }
1665
1666    type GetEndpointResponseFut = fidl::client::QueryResponseFut<
1667        Option<fidl::endpoints::ClientEnd<EndpointMarker>>,
1668        fidl::encoding::DefaultFuchsiaResourceDialect,
1669    >;
1670    fn r#get_endpoint(&self, mut name: &str) -> Self::GetEndpointResponseFut {
1671        fn _decode(
1672            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1673        ) -> Result<Option<fidl::endpoints::ClientEnd<EndpointMarker>>, fidl::Error> {
1674            let _response = fidl::client::decode_transaction_body::<
1675                EndpointManagerGetEndpointResponse,
1676                fidl::encoding::DefaultFuchsiaResourceDialect,
1677                0x437e956b7b860751,
1678            >(_buf?)?;
1679            Ok(_response.endpoint)
1680        }
1681        self.client.send_query_and_decode::<
1682            EndpointManagerGetEndpointRequest,
1683            Option<fidl::endpoints::ClientEnd<EndpointMarker>>,
1684        >(
1685            (name,),
1686            0x437e956b7b860751,
1687            fidl::encoding::DynamicFlags::empty(),
1688            _decode,
1689        )
1690    }
1691}
1692
1693pub struct EndpointManagerEventStream {
1694    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1695}
1696
1697impl std::marker::Unpin for EndpointManagerEventStream {}
1698
1699impl futures::stream::FusedStream for EndpointManagerEventStream {
1700    fn is_terminated(&self) -> bool {
1701        self.event_receiver.is_terminated()
1702    }
1703}
1704
1705impl futures::Stream for EndpointManagerEventStream {
1706    type Item = Result<EndpointManagerEvent, fidl::Error>;
1707
1708    fn poll_next(
1709        mut self: std::pin::Pin<&mut Self>,
1710        cx: &mut std::task::Context<'_>,
1711    ) -> std::task::Poll<Option<Self::Item>> {
1712        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1713            &mut self.event_receiver,
1714            cx
1715        )?) {
1716            Some(buf) => std::task::Poll::Ready(Some(EndpointManagerEvent::decode(buf))),
1717            None => std::task::Poll::Ready(None),
1718        }
1719    }
1720}
1721
1722#[derive(Debug)]
1723pub enum EndpointManagerEvent {}
1724
1725impl EndpointManagerEvent {
1726    /// Decodes a message buffer as a [`EndpointManagerEvent`].
1727    fn decode(
1728        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1729    ) -> Result<EndpointManagerEvent, fidl::Error> {
1730        let (bytes, _handles) = buf.split_mut();
1731        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1732        debug_assert_eq!(tx_header.tx_id, 0);
1733        match tx_header.ordinal {
1734            _ => Err(fidl::Error::UnknownOrdinal {
1735                ordinal: tx_header.ordinal,
1736                protocol_name:
1737                    <EndpointManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1738            }),
1739        }
1740    }
1741}
1742
1743/// A Stream of incoming requests for fuchsia.netemul.network/EndpointManager.
1744pub struct EndpointManagerRequestStream {
1745    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1746    is_terminated: bool,
1747}
1748
1749impl std::marker::Unpin for EndpointManagerRequestStream {}
1750
1751impl futures::stream::FusedStream for EndpointManagerRequestStream {
1752    fn is_terminated(&self) -> bool {
1753        self.is_terminated
1754    }
1755}
1756
1757impl fidl::endpoints::RequestStream for EndpointManagerRequestStream {
1758    type Protocol = EndpointManagerMarker;
1759    type ControlHandle = EndpointManagerControlHandle;
1760
1761    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1762        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1763    }
1764
1765    fn control_handle(&self) -> Self::ControlHandle {
1766        EndpointManagerControlHandle { inner: self.inner.clone() }
1767    }
1768
1769    fn into_inner(
1770        self,
1771    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1772    {
1773        (self.inner, self.is_terminated)
1774    }
1775
1776    fn from_inner(
1777        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1778        is_terminated: bool,
1779    ) -> Self {
1780        Self { inner, is_terminated }
1781    }
1782}
1783
1784impl futures::Stream for EndpointManagerRequestStream {
1785    type Item = Result<EndpointManagerRequest, fidl::Error>;
1786
1787    fn poll_next(
1788        mut self: std::pin::Pin<&mut Self>,
1789        cx: &mut std::task::Context<'_>,
1790    ) -> std::task::Poll<Option<Self::Item>> {
1791        let this = &mut *self;
1792        if this.inner.check_shutdown(cx) {
1793            this.is_terminated = true;
1794            return std::task::Poll::Ready(None);
1795        }
1796        if this.is_terminated {
1797            panic!("polled EndpointManagerRequestStream after completion");
1798        }
1799        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1800            |bytes, handles| {
1801                match this.inner.channel().read_etc(cx, bytes, handles) {
1802                    std::task::Poll::Ready(Ok(())) => {}
1803                    std::task::Poll::Pending => return std::task::Poll::Pending,
1804                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1805                        this.is_terminated = true;
1806                        return std::task::Poll::Ready(None);
1807                    }
1808                    std::task::Poll::Ready(Err(e)) => {
1809                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1810                            e.into(),
1811                        ))))
1812                    }
1813                }
1814
1815                // A message has been received from the channel
1816                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1817
1818                std::task::Poll::Ready(Some(match header.ordinal {
1819                    0x78c83d9454e3d228 => {
1820                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1821                        let mut req = fidl::new_empty!(
1822                            fidl::encoding::EmptyPayload,
1823                            fidl::encoding::DefaultFuchsiaResourceDialect
1824                        );
1825                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1826                        let control_handle =
1827                            EndpointManagerControlHandle { inner: this.inner.clone() };
1828                        Ok(EndpointManagerRequest::ListEndpoints {
1829                            responder: EndpointManagerListEndpointsResponder {
1830                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1831                                tx_id: header.tx_id,
1832                            },
1833                        })
1834                    }
1835                    0x7defe4cd5e4e7d7c => {
1836                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1837                        let mut req = fidl::new_empty!(
1838                            EndpointManagerCreateEndpointRequest,
1839                            fidl::encoding::DefaultFuchsiaResourceDialect
1840                        );
1841                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EndpointManagerCreateEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
1842                        let control_handle =
1843                            EndpointManagerControlHandle { inner: this.inner.clone() };
1844                        Ok(EndpointManagerRequest::CreateEndpoint {
1845                            name: req.name,
1846                            config: req.config,
1847
1848                            responder: EndpointManagerCreateEndpointResponder {
1849                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1850                                tx_id: header.tx_id,
1851                            },
1852                        })
1853                    }
1854                    0x437e956b7b860751 => {
1855                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1856                        let mut req = fidl::new_empty!(
1857                            EndpointManagerGetEndpointRequest,
1858                            fidl::encoding::DefaultFuchsiaResourceDialect
1859                        );
1860                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EndpointManagerGetEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
1861                        let control_handle =
1862                            EndpointManagerControlHandle { inner: this.inner.clone() };
1863                        Ok(EndpointManagerRequest::GetEndpoint {
1864                            name: req.name,
1865
1866                            responder: EndpointManagerGetEndpointResponder {
1867                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1868                                tx_id: header.tx_id,
1869                            },
1870                        })
1871                    }
1872                    _ => Err(fidl::Error::UnknownOrdinal {
1873                        ordinal: header.ordinal,
1874                        protocol_name:
1875                            <EndpointManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1876                    }),
1877                }))
1878            },
1879        )
1880    }
1881}
1882
1883/// Manages virtual endpoints.
1884#[derive(Debug)]
1885pub enum EndpointManagerRequest {
1886    /// Lists endpoints by name.
1887    ListEndpoints { responder: EndpointManagerListEndpointsResponder },
1888    /// Creates endpoint with given name and config.
1889    CreateEndpoint {
1890        name: String,
1891        config: EndpointConfig,
1892        responder: EndpointManagerCreateEndpointResponder,
1893    },
1894    /// Gets a handle to an endpoint.
1895    GetEndpoint { name: String, responder: EndpointManagerGetEndpointResponder },
1896}
1897
1898impl EndpointManagerRequest {
1899    #[allow(irrefutable_let_patterns)]
1900    pub fn into_list_endpoints(self) -> Option<(EndpointManagerListEndpointsResponder)> {
1901        if let EndpointManagerRequest::ListEndpoints { responder } = self {
1902            Some((responder))
1903        } else {
1904            None
1905        }
1906    }
1907
1908    #[allow(irrefutable_let_patterns)]
1909    pub fn into_create_endpoint(
1910        self,
1911    ) -> Option<(String, EndpointConfig, EndpointManagerCreateEndpointResponder)> {
1912        if let EndpointManagerRequest::CreateEndpoint { name, config, responder } = self {
1913            Some((name, config, responder))
1914        } else {
1915            None
1916        }
1917    }
1918
1919    #[allow(irrefutable_let_patterns)]
1920    pub fn into_get_endpoint(self) -> Option<(String, EndpointManagerGetEndpointResponder)> {
1921        if let EndpointManagerRequest::GetEndpoint { name, responder } = self {
1922            Some((name, responder))
1923        } else {
1924            None
1925        }
1926    }
1927
1928    /// Name of the method defined in FIDL
1929    pub fn method_name(&self) -> &'static str {
1930        match *self {
1931            EndpointManagerRequest::ListEndpoints { .. } => "list_endpoints",
1932            EndpointManagerRequest::CreateEndpoint { .. } => "create_endpoint",
1933            EndpointManagerRequest::GetEndpoint { .. } => "get_endpoint",
1934        }
1935    }
1936}
1937
1938#[derive(Debug, Clone)]
1939pub struct EndpointManagerControlHandle {
1940    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1941}
1942
1943impl fidl::endpoints::ControlHandle for EndpointManagerControlHandle {
1944    fn shutdown(&self) {
1945        self.inner.shutdown()
1946    }
1947    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1948        self.inner.shutdown_with_epitaph(status)
1949    }
1950
1951    fn is_closed(&self) -> bool {
1952        self.inner.channel().is_closed()
1953    }
1954    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1955        self.inner.channel().on_closed()
1956    }
1957
1958    #[cfg(target_os = "fuchsia")]
1959    fn signal_peer(
1960        &self,
1961        clear_mask: zx::Signals,
1962        set_mask: zx::Signals,
1963    ) -> Result<(), zx_status::Status> {
1964        use fidl::Peered;
1965        self.inner.channel().signal_peer(clear_mask, set_mask)
1966    }
1967}
1968
1969impl EndpointManagerControlHandle {}
1970
1971#[must_use = "FIDL methods require a response to be sent"]
1972#[derive(Debug)]
1973pub struct EndpointManagerListEndpointsResponder {
1974    control_handle: std::mem::ManuallyDrop<EndpointManagerControlHandle>,
1975    tx_id: u32,
1976}
1977
1978/// Set the the channel to be shutdown (see [`EndpointManagerControlHandle::shutdown`])
1979/// if the responder is dropped without sending a response, so that the client
1980/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1981impl std::ops::Drop for EndpointManagerListEndpointsResponder {
1982    fn drop(&mut self) {
1983        self.control_handle.shutdown();
1984        // Safety: drops once, never accessed again
1985        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1986    }
1987}
1988
1989impl fidl::endpoints::Responder for EndpointManagerListEndpointsResponder {
1990    type ControlHandle = EndpointManagerControlHandle;
1991
1992    fn control_handle(&self) -> &EndpointManagerControlHandle {
1993        &self.control_handle
1994    }
1995
1996    fn drop_without_shutdown(mut self) {
1997        // Safety: drops once, never accessed again due to mem::forget
1998        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1999        // Prevent Drop from running (which would shut down the channel)
2000        std::mem::forget(self);
2001    }
2002}
2003
2004impl EndpointManagerListEndpointsResponder {
2005    /// Sends a response to the FIDL transaction.
2006    ///
2007    /// Sets the channel to shutdown if an error occurs.
2008    pub fn send(self, mut endp: &[String]) -> Result<(), fidl::Error> {
2009        let _result = self.send_raw(endp);
2010        if _result.is_err() {
2011            self.control_handle.shutdown();
2012        }
2013        self.drop_without_shutdown();
2014        _result
2015    }
2016
2017    /// Similar to "send" but does not shutdown the channel if an error occurs.
2018    pub fn send_no_shutdown_on_err(self, mut endp: &[String]) -> Result<(), fidl::Error> {
2019        let _result = self.send_raw(endp);
2020        self.drop_without_shutdown();
2021        _result
2022    }
2023
2024    fn send_raw(&self, mut endp: &[String]) -> Result<(), fidl::Error> {
2025        self.control_handle.inner.send::<EndpointManagerListEndpointsResponse>(
2026            (endp,),
2027            self.tx_id,
2028            0x78c83d9454e3d228,
2029            fidl::encoding::DynamicFlags::empty(),
2030        )
2031    }
2032}
2033
2034#[must_use = "FIDL methods require a response to be sent"]
2035#[derive(Debug)]
2036pub struct EndpointManagerCreateEndpointResponder {
2037    control_handle: std::mem::ManuallyDrop<EndpointManagerControlHandle>,
2038    tx_id: u32,
2039}
2040
2041/// Set the the channel to be shutdown (see [`EndpointManagerControlHandle::shutdown`])
2042/// if the responder is dropped without sending a response, so that the client
2043/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2044impl std::ops::Drop for EndpointManagerCreateEndpointResponder {
2045    fn drop(&mut self) {
2046        self.control_handle.shutdown();
2047        // Safety: drops once, never accessed again
2048        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2049    }
2050}
2051
2052impl fidl::endpoints::Responder for EndpointManagerCreateEndpointResponder {
2053    type ControlHandle = EndpointManagerControlHandle;
2054
2055    fn control_handle(&self) -> &EndpointManagerControlHandle {
2056        &self.control_handle
2057    }
2058
2059    fn drop_without_shutdown(mut self) {
2060        // Safety: drops once, never accessed again due to mem::forget
2061        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2062        // Prevent Drop from running (which would shut down the channel)
2063        std::mem::forget(self);
2064    }
2065}
2066
2067impl EndpointManagerCreateEndpointResponder {
2068    /// Sends a response to the FIDL transaction.
2069    ///
2070    /// Sets the channel to shutdown if an error occurs.
2071    pub fn send(
2072        self,
2073        mut status: i32,
2074        mut endpoint: Option<fidl::endpoints::ClientEnd<EndpointMarker>>,
2075    ) -> Result<(), fidl::Error> {
2076        let _result = self.send_raw(status, endpoint);
2077        if _result.is_err() {
2078            self.control_handle.shutdown();
2079        }
2080        self.drop_without_shutdown();
2081        _result
2082    }
2083
2084    /// Similar to "send" but does not shutdown the channel if an error occurs.
2085    pub fn send_no_shutdown_on_err(
2086        self,
2087        mut status: i32,
2088        mut endpoint: Option<fidl::endpoints::ClientEnd<EndpointMarker>>,
2089    ) -> Result<(), fidl::Error> {
2090        let _result = self.send_raw(status, endpoint);
2091        self.drop_without_shutdown();
2092        _result
2093    }
2094
2095    fn send_raw(
2096        &self,
2097        mut status: i32,
2098        mut endpoint: Option<fidl::endpoints::ClientEnd<EndpointMarker>>,
2099    ) -> Result<(), fidl::Error> {
2100        self.control_handle.inner.send::<EndpointManagerCreateEndpointResponse>(
2101            (status, endpoint),
2102            self.tx_id,
2103            0x7defe4cd5e4e7d7c,
2104            fidl::encoding::DynamicFlags::empty(),
2105        )
2106    }
2107}
2108
2109#[must_use = "FIDL methods require a response to be sent"]
2110#[derive(Debug)]
2111pub struct EndpointManagerGetEndpointResponder {
2112    control_handle: std::mem::ManuallyDrop<EndpointManagerControlHandle>,
2113    tx_id: u32,
2114}
2115
2116/// Set the the channel to be shutdown (see [`EndpointManagerControlHandle::shutdown`])
2117/// if the responder is dropped without sending a response, so that the client
2118/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2119impl std::ops::Drop for EndpointManagerGetEndpointResponder {
2120    fn drop(&mut self) {
2121        self.control_handle.shutdown();
2122        // Safety: drops once, never accessed again
2123        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2124    }
2125}
2126
2127impl fidl::endpoints::Responder for EndpointManagerGetEndpointResponder {
2128    type ControlHandle = EndpointManagerControlHandle;
2129
2130    fn control_handle(&self) -> &EndpointManagerControlHandle {
2131        &self.control_handle
2132    }
2133
2134    fn drop_without_shutdown(mut self) {
2135        // Safety: drops once, never accessed again due to mem::forget
2136        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2137        // Prevent Drop from running (which would shut down the channel)
2138        std::mem::forget(self);
2139    }
2140}
2141
2142impl EndpointManagerGetEndpointResponder {
2143    /// Sends a response to the FIDL transaction.
2144    ///
2145    /// Sets the channel to shutdown if an error occurs.
2146    pub fn send(
2147        self,
2148        mut endpoint: Option<fidl::endpoints::ClientEnd<EndpointMarker>>,
2149    ) -> Result<(), fidl::Error> {
2150        let _result = self.send_raw(endpoint);
2151        if _result.is_err() {
2152            self.control_handle.shutdown();
2153        }
2154        self.drop_without_shutdown();
2155        _result
2156    }
2157
2158    /// Similar to "send" but does not shutdown the channel if an error occurs.
2159    pub fn send_no_shutdown_on_err(
2160        self,
2161        mut endpoint: Option<fidl::endpoints::ClientEnd<EndpointMarker>>,
2162    ) -> Result<(), fidl::Error> {
2163        let _result = self.send_raw(endpoint);
2164        self.drop_without_shutdown();
2165        _result
2166    }
2167
2168    fn send_raw(
2169        &self,
2170        mut endpoint: Option<fidl::endpoints::ClientEnd<EndpointMarker>>,
2171    ) -> Result<(), fidl::Error> {
2172        self.control_handle.inner.send::<EndpointManagerGetEndpointResponse>(
2173            (endpoint,),
2174            self.tx_id,
2175            0x437e956b7b860751,
2176            fidl::encoding::DynamicFlags::empty(),
2177        )
2178    }
2179}
2180
2181#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2182pub struct FakeEndpointMarker;
2183
2184impl fidl::endpoints::ProtocolMarker for FakeEndpointMarker {
2185    type Proxy = FakeEndpointProxy;
2186    type RequestStream = FakeEndpointRequestStream;
2187    #[cfg(target_os = "fuchsia")]
2188    type SynchronousProxy = FakeEndpointSynchronousProxy;
2189
2190    const DEBUG_NAME: &'static str = "(anonymous) FakeEndpoint";
2191}
2192
2193pub trait FakeEndpointProxyInterface: Send + Sync {
2194    type WriteResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2195    fn r#write(&self, data: &[u8]) -> Self::WriteResponseFut;
2196    type ReadResponseFut: std::future::Future<Output = Result<(Vec<u8>, u64), fidl::Error>> + Send;
2197    fn r#read(&self) -> Self::ReadResponseFut;
2198}
2199#[derive(Debug)]
2200#[cfg(target_os = "fuchsia")]
2201pub struct FakeEndpointSynchronousProxy {
2202    client: fidl::client::sync::Client,
2203}
2204
2205#[cfg(target_os = "fuchsia")]
2206impl fidl::endpoints::SynchronousProxy for FakeEndpointSynchronousProxy {
2207    type Proxy = FakeEndpointProxy;
2208    type Protocol = FakeEndpointMarker;
2209
2210    fn from_channel(inner: fidl::Channel) -> Self {
2211        Self::new(inner)
2212    }
2213
2214    fn into_channel(self) -> fidl::Channel {
2215        self.client.into_channel()
2216    }
2217
2218    fn as_channel(&self) -> &fidl::Channel {
2219        self.client.as_channel()
2220    }
2221}
2222
2223#[cfg(target_os = "fuchsia")]
2224impl FakeEndpointSynchronousProxy {
2225    pub fn new(channel: fidl::Channel) -> Self {
2226        let protocol_name = <FakeEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2227        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2228    }
2229
2230    pub fn into_channel(self) -> fidl::Channel {
2231        self.client.into_channel()
2232    }
2233
2234    /// Waits until an event arrives and returns it. It is safe for other
2235    /// threads to make concurrent requests while waiting for an event.
2236    pub fn wait_for_event(
2237        &self,
2238        deadline: zx::MonotonicInstant,
2239    ) -> Result<FakeEndpointEvent, fidl::Error> {
2240        FakeEndpointEvent::decode(self.client.wait_for_event(deadline)?)
2241    }
2242
2243    /// Writes a frame to the network.
2244    pub fn r#write(
2245        &self,
2246        mut data: &[u8],
2247        ___deadline: zx::MonotonicInstant,
2248    ) -> Result<(), fidl::Error> {
2249        let _response =
2250            self.client.send_query::<FakeEndpointWriteRequest, fidl::encoding::EmptyPayload>(
2251                (data,),
2252                0x2c54af94338c523b,
2253                fidl::encoding::DynamicFlags::empty(),
2254                ___deadline,
2255            )?;
2256        Ok(_response)
2257    }
2258
2259    /// Reads a single frame from the network.
2260    ///
2261    /// Blocks until new data is available to be read. FakeEndpoint will keep a limited amount of
2262    /// frames to be read, dropping the oldest ones if the data is not fetched fast enough. The
2263    /// number of dropped frames since the last call to `Read` is returned in `dropped_frames`.
2264    ///
2265    /// Issuing a second `Read` request when the first one is still pending will cause the channel
2266    /// to be closed with `ZX_ERR_BAD_STATE`.
2267    pub fn r#read(&self, ___deadline: zx::MonotonicInstant) -> Result<(Vec<u8>, u64), fidl::Error> {
2268        let _response =
2269            self.client.send_query::<fidl::encoding::EmptyPayload, FakeEndpointReadResponse>(
2270                (),
2271                0x58e2d032a8f36234,
2272                fidl::encoding::DynamicFlags::empty(),
2273                ___deadline,
2274            )?;
2275        Ok((_response.data, _response.dropped_frames))
2276    }
2277}
2278
2279#[cfg(target_os = "fuchsia")]
2280impl From<FakeEndpointSynchronousProxy> for zx::Handle {
2281    fn from(value: FakeEndpointSynchronousProxy) -> Self {
2282        value.into_channel().into()
2283    }
2284}
2285
2286#[cfg(target_os = "fuchsia")]
2287impl From<fidl::Channel> for FakeEndpointSynchronousProxy {
2288    fn from(value: fidl::Channel) -> Self {
2289        Self::new(value)
2290    }
2291}
2292
2293#[derive(Debug, Clone)]
2294pub struct FakeEndpointProxy {
2295    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2296}
2297
2298impl fidl::endpoints::Proxy for FakeEndpointProxy {
2299    type Protocol = FakeEndpointMarker;
2300
2301    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2302        Self::new(inner)
2303    }
2304
2305    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2306        self.client.into_channel().map_err(|client| Self { client })
2307    }
2308
2309    fn as_channel(&self) -> &::fidl::AsyncChannel {
2310        self.client.as_channel()
2311    }
2312}
2313
2314impl FakeEndpointProxy {
2315    /// Create a new Proxy for fuchsia.netemul.network/FakeEndpoint.
2316    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2317        let protocol_name = <FakeEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2318        Self { client: fidl::client::Client::new(channel, protocol_name) }
2319    }
2320
2321    /// Get a Stream of events from the remote end of the protocol.
2322    ///
2323    /// # Panics
2324    ///
2325    /// Panics if the event stream was already taken.
2326    pub fn take_event_stream(&self) -> FakeEndpointEventStream {
2327        FakeEndpointEventStream { event_receiver: self.client.take_event_receiver() }
2328    }
2329
2330    /// Writes a frame to the network.
2331    pub fn r#write(
2332        &self,
2333        mut data: &[u8],
2334    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2335        FakeEndpointProxyInterface::r#write(self, data)
2336    }
2337
2338    /// Reads a single frame from the network.
2339    ///
2340    /// Blocks until new data is available to be read. FakeEndpoint will keep a limited amount of
2341    /// frames to be read, dropping the oldest ones if the data is not fetched fast enough. The
2342    /// number of dropped frames since the last call to `Read` is returned in `dropped_frames`.
2343    ///
2344    /// Issuing a second `Read` request when the first one is still pending will cause the channel
2345    /// to be closed with `ZX_ERR_BAD_STATE`.
2346    pub fn r#read(
2347        &self,
2348    ) -> fidl::client::QueryResponseFut<(Vec<u8>, u64), fidl::encoding::DefaultFuchsiaResourceDialect>
2349    {
2350        FakeEndpointProxyInterface::r#read(self)
2351    }
2352}
2353
2354impl FakeEndpointProxyInterface for FakeEndpointProxy {
2355    type WriteResponseFut =
2356        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2357    fn r#write(&self, mut data: &[u8]) -> Self::WriteResponseFut {
2358        fn _decode(
2359            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2360        ) -> Result<(), fidl::Error> {
2361            let _response = fidl::client::decode_transaction_body::<
2362                fidl::encoding::EmptyPayload,
2363                fidl::encoding::DefaultFuchsiaResourceDialect,
2364                0x2c54af94338c523b,
2365            >(_buf?)?;
2366            Ok(_response)
2367        }
2368        self.client.send_query_and_decode::<FakeEndpointWriteRequest, ()>(
2369            (data,),
2370            0x2c54af94338c523b,
2371            fidl::encoding::DynamicFlags::empty(),
2372            _decode,
2373        )
2374    }
2375
2376    type ReadResponseFut = fidl::client::QueryResponseFut<
2377        (Vec<u8>, u64),
2378        fidl::encoding::DefaultFuchsiaResourceDialect,
2379    >;
2380    fn r#read(&self) -> Self::ReadResponseFut {
2381        fn _decode(
2382            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2383        ) -> Result<(Vec<u8>, u64), fidl::Error> {
2384            let _response = fidl::client::decode_transaction_body::<
2385                FakeEndpointReadResponse,
2386                fidl::encoding::DefaultFuchsiaResourceDialect,
2387                0x58e2d032a8f36234,
2388            >(_buf?)?;
2389            Ok((_response.data, _response.dropped_frames))
2390        }
2391        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (Vec<u8>, u64)>(
2392            (),
2393            0x58e2d032a8f36234,
2394            fidl::encoding::DynamicFlags::empty(),
2395            _decode,
2396        )
2397    }
2398}
2399
2400pub struct FakeEndpointEventStream {
2401    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2402}
2403
2404impl std::marker::Unpin for FakeEndpointEventStream {}
2405
2406impl futures::stream::FusedStream for FakeEndpointEventStream {
2407    fn is_terminated(&self) -> bool {
2408        self.event_receiver.is_terminated()
2409    }
2410}
2411
2412impl futures::Stream for FakeEndpointEventStream {
2413    type Item = Result<FakeEndpointEvent, fidl::Error>;
2414
2415    fn poll_next(
2416        mut self: std::pin::Pin<&mut Self>,
2417        cx: &mut std::task::Context<'_>,
2418    ) -> std::task::Poll<Option<Self::Item>> {
2419        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2420            &mut self.event_receiver,
2421            cx
2422        )?) {
2423            Some(buf) => std::task::Poll::Ready(Some(FakeEndpointEvent::decode(buf))),
2424            None => std::task::Poll::Ready(None),
2425        }
2426    }
2427}
2428
2429#[derive(Debug)]
2430pub enum FakeEndpointEvent {}
2431
2432impl FakeEndpointEvent {
2433    /// Decodes a message buffer as a [`FakeEndpointEvent`].
2434    fn decode(
2435        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2436    ) -> Result<FakeEndpointEvent, fidl::Error> {
2437        let (bytes, _handles) = buf.split_mut();
2438        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2439        debug_assert_eq!(tx_header.tx_id, 0);
2440        match tx_header.ordinal {
2441            _ => Err(fidl::Error::UnknownOrdinal {
2442                ordinal: tx_header.ordinal,
2443                protocol_name: <FakeEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2444            }),
2445        }
2446    }
2447}
2448
2449/// A Stream of incoming requests for fuchsia.netemul.network/FakeEndpoint.
2450pub struct FakeEndpointRequestStream {
2451    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2452    is_terminated: bool,
2453}
2454
2455impl std::marker::Unpin for FakeEndpointRequestStream {}
2456
2457impl futures::stream::FusedStream for FakeEndpointRequestStream {
2458    fn is_terminated(&self) -> bool {
2459        self.is_terminated
2460    }
2461}
2462
2463impl fidl::endpoints::RequestStream for FakeEndpointRequestStream {
2464    type Protocol = FakeEndpointMarker;
2465    type ControlHandle = FakeEndpointControlHandle;
2466
2467    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2468        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2469    }
2470
2471    fn control_handle(&self) -> Self::ControlHandle {
2472        FakeEndpointControlHandle { inner: self.inner.clone() }
2473    }
2474
2475    fn into_inner(
2476        self,
2477    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2478    {
2479        (self.inner, self.is_terminated)
2480    }
2481
2482    fn from_inner(
2483        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2484        is_terminated: bool,
2485    ) -> Self {
2486        Self { inner, is_terminated }
2487    }
2488}
2489
2490impl futures::Stream for FakeEndpointRequestStream {
2491    type Item = Result<FakeEndpointRequest, fidl::Error>;
2492
2493    fn poll_next(
2494        mut self: std::pin::Pin<&mut Self>,
2495        cx: &mut std::task::Context<'_>,
2496    ) -> std::task::Poll<Option<Self::Item>> {
2497        let this = &mut *self;
2498        if this.inner.check_shutdown(cx) {
2499            this.is_terminated = true;
2500            return std::task::Poll::Ready(None);
2501        }
2502        if this.is_terminated {
2503            panic!("polled FakeEndpointRequestStream after completion");
2504        }
2505        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2506            |bytes, handles| {
2507                match this.inner.channel().read_etc(cx, bytes, handles) {
2508                    std::task::Poll::Ready(Ok(())) => {}
2509                    std::task::Poll::Pending => return std::task::Poll::Pending,
2510                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2511                        this.is_terminated = true;
2512                        return std::task::Poll::Ready(None);
2513                    }
2514                    std::task::Poll::Ready(Err(e)) => {
2515                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2516                            e.into(),
2517                        ))))
2518                    }
2519                }
2520
2521                // A message has been received from the channel
2522                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2523
2524                std::task::Poll::Ready(Some(match header.ordinal {
2525                    0x2c54af94338c523b => {
2526                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2527                        let mut req = fidl::new_empty!(
2528                            FakeEndpointWriteRequest,
2529                            fidl::encoding::DefaultFuchsiaResourceDialect
2530                        );
2531                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeEndpointWriteRequest>(&header, _body_bytes, handles, &mut req)?;
2532                        let control_handle =
2533                            FakeEndpointControlHandle { inner: this.inner.clone() };
2534                        Ok(FakeEndpointRequest::Write {
2535                            data: req.data,
2536
2537                            responder: FakeEndpointWriteResponder {
2538                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2539                                tx_id: header.tx_id,
2540                            },
2541                        })
2542                    }
2543                    0x58e2d032a8f36234 => {
2544                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2545                        let mut req = fidl::new_empty!(
2546                            fidl::encoding::EmptyPayload,
2547                            fidl::encoding::DefaultFuchsiaResourceDialect
2548                        );
2549                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2550                        let control_handle =
2551                            FakeEndpointControlHandle { inner: this.inner.clone() };
2552                        Ok(FakeEndpointRequest::Read {
2553                            responder: FakeEndpointReadResponder {
2554                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2555                                tx_id: header.tx_id,
2556                            },
2557                        })
2558                    }
2559                    _ => Err(fidl::Error::UnknownOrdinal {
2560                        ordinal: header.ordinal,
2561                        protocol_name:
2562                            <FakeEndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2563                    }),
2564                }))
2565            },
2566        )
2567    }
2568}
2569
2570/// Fake endpoint can be added to a network to snoop or inject packets.
2571#[derive(Debug)]
2572pub enum FakeEndpointRequest {
2573    /// Writes a frame to the network.
2574    Write { data: Vec<u8>, responder: FakeEndpointWriteResponder },
2575    /// Reads a single frame from the network.
2576    ///
2577    /// Blocks until new data is available to be read. FakeEndpoint will keep a limited amount of
2578    /// frames to be read, dropping the oldest ones if the data is not fetched fast enough. The
2579    /// number of dropped frames since the last call to `Read` is returned in `dropped_frames`.
2580    ///
2581    /// Issuing a second `Read` request when the first one is still pending will cause the channel
2582    /// to be closed with `ZX_ERR_BAD_STATE`.
2583    Read { responder: FakeEndpointReadResponder },
2584}
2585
2586impl FakeEndpointRequest {
2587    #[allow(irrefutable_let_patterns)]
2588    pub fn into_write(self) -> Option<(Vec<u8>, FakeEndpointWriteResponder)> {
2589        if let FakeEndpointRequest::Write { data, responder } = self {
2590            Some((data, responder))
2591        } else {
2592            None
2593        }
2594    }
2595
2596    #[allow(irrefutable_let_patterns)]
2597    pub fn into_read(self) -> Option<(FakeEndpointReadResponder)> {
2598        if let FakeEndpointRequest::Read { responder } = self {
2599            Some((responder))
2600        } else {
2601            None
2602        }
2603    }
2604
2605    /// Name of the method defined in FIDL
2606    pub fn method_name(&self) -> &'static str {
2607        match *self {
2608            FakeEndpointRequest::Write { .. } => "write",
2609            FakeEndpointRequest::Read { .. } => "read",
2610        }
2611    }
2612}
2613
2614#[derive(Debug, Clone)]
2615pub struct FakeEndpointControlHandle {
2616    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2617}
2618
2619impl fidl::endpoints::ControlHandle for FakeEndpointControlHandle {
2620    fn shutdown(&self) {
2621        self.inner.shutdown()
2622    }
2623    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2624        self.inner.shutdown_with_epitaph(status)
2625    }
2626
2627    fn is_closed(&self) -> bool {
2628        self.inner.channel().is_closed()
2629    }
2630    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2631        self.inner.channel().on_closed()
2632    }
2633
2634    #[cfg(target_os = "fuchsia")]
2635    fn signal_peer(
2636        &self,
2637        clear_mask: zx::Signals,
2638        set_mask: zx::Signals,
2639    ) -> Result<(), zx_status::Status> {
2640        use fidl::Peered;
2641        self.inner.channel().signal_peer(clear_mask, set_mask)
2642    }
2643}
2644
2645impl FakeEndpointControlHandle {}
2646
2647#[must_use = "FIDL methods require a response to be sent"]
2648#[derive(Debug)]
2649pub struct FakeEndpointWriteResponder {
2650    control_handle: std::mem::ManuallyDrop<FakeEndpointControlHandle>,
2651    tx_id: u32,
2652}
2653
2654/// Set the the channel to be shutdown (see [`FakeEndpointControlHandle::shutdown`])
2655/// if the responder is dropped without sending a response, so that the client
2656/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2657impl std::ops::Drop for FakeEndpointWriteResponder {
2658    fn drop(&mut self) {
2659        self.control_handle.shutdown();
2660        // Safety: drops once, never accessed again
2661        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2662    }
2663}
2664
2665impl fidl::endpoints::Responder for FakeEndpointWriteResponder {
2666    type ControlHandle = FakeEndpointControlHandle;
2667
2668    fn control_handle(&self) -> &FakeEndpointControlHandle {
2669        &self.control_handle
2670    }
2671
2672    fn drop_without_shutdown(mut self) {
2673        // Safety: drops once, never accessed again due to mem::forget
2674        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2675        // Prevent Drop from running (which would shut down the channel)
2676        std::mem::forget(self);
2677    }
2678}
2679
2680impl FakeEndpointWriteResponder {
2681    /// Sends a response to the FIDL transaction.
2682    ///
2683    /// Sets the channel to shutdown if an error occurs.
2684    pub fn send(self) -> Result<(), fidl::Error> {
2685        let _result = self.send_raw();
2686        if _result.is_err() {
2687            self.control_handle.shutdown();
2688        }
2689        self.drop_without_shutdown();
2690        _result
2691    }
2692
2693    /// Similar to "send" but does not shutdown the channel if an error occurs.
2694    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2695        let _result = self.send_raw();
2696        self.drop_without_shutdown();
2697        _result
2698    }
2699
2700    fn send_raw(&self) -> Result<(), fidl::Error> {
2701        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2702            (),
2703            self.tx_id,
2704            0x2c54af94338c523b,
2705            fidl::encoding::DynamicFlags::empty(),
2706        )
2707    }
2708}
2709
2710#[must_use = "FIDL methods require a response to be sent"]
2711#[derive(Debug)]
2712pub struct FakeEndpointReadResponder {
2713    control_handle: std::mem::ManuallyDrop<FakeEndpointControlHandle>,
2714    tx_id: u32,
2715}
2716
2717/// Set the the channel to be shutdown (see [`FakeEndpointControlHandle::shutdown`])
2718/// if the responder is dropped without sending a response, so that the client
2719/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2720impl std::ops::Drop for FakeEndpointReadResponder {
2721    fn drop(&mut self) {
2722        self.control_handle.shutdown();
2723        // Safety: drops once, never accessed again
2724        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2725    }
2726}
2727
2728impl fidl::endpoints::Responder for FakeEndpointReadResponder {
2729    type ControlHandle = FakeEndpointControlHandle;
2730
2731    fn control_handle(&self) -> &FakeEndpointControlHandle {
2732        &self.control_handle
2733    }
2734
2735    fn drop_without_shutdown(mut self) {
2736        // Safety: drops once, never accessed again due to mem::forget
2737        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2738        // Prevent Drop from running (which would shut down the channel)
2739        std::mem::forget(self);
2740    }
2741}
2742
2743impl FakeEndpointReadResponder {
2744    /// Sends a response to the FIDL transaction.
2745    ///
2746    /// Sets the channel to shutdown if an error occurs.
2747    pub fn send(self, mut data: &[u8], mut dropped_frames: u64) -> Result<(), fidl::Error> {
2748        let _result = self.send_raw(data, dropped_frames);
2749        if _result.is_err() {
2750            self.control_handle.shutdown();
2751        }
2752        self.drop_without_shutdown();
2753        _result
2754    }
2755
2756    /// Similar to "send" but does not shutdown the channel if an error occurs.
2757    pub fn send_no_shutdown_on_err(
2758        self,
2759        mut data: &[u8],
2760        mut dropped_frames: u64,
2761    ) -> Result<(), fidl::Error> {
2762        let _result = self.send_raw(data, dropped_frames);
2763        self.drop_without_shutdown();
2764        _result
2765    }
2766
2767    fn send_raw(&self, mut data: &[u8], mut dropped_frames: u64) -> Result<(), fidl::Error> {
2768        self.control_handle.inner.send::<FakeEndpointReadResponse>(
2769            (data, dropped_frames),
2770            self.tx_id,
2771            0x58e2d032a8f36234,
2772            fidl::encoding::DynamicFlags::empty(),
2773        )
2774    }
2775}
2776
2777#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2778pub struct NetworkMarker;
2779
2780impl fidl::endpoints::ProtocolMarker for NetworkMarker {
2781    type Proxy = NetworkProxy;
2782    type RequestStream = NetworkRequestStream;
2783    #[cfg(target_os = "fuchsia")]
2784    type SynchronousProxy = NetworkSynchronousProxy;
2785
2786    const DEBUG_NAME: &'static str = "(anonymous) Network";
2787}
2788
2789pub trait NetworkProxyInterface: Send + Sync {
2790    fn r#add_port(
2791        &self,
2792        port: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
2793        interface: fidl::endpoints::ServerEnd<fidl_fuchsia_net_virtualization::InterfaceMarker>,
2794    ) -> Result<(), fidl::Error>;
2795    type GetConfigResponseFut: std::future::Future<Output = Result<NetworkConfig, fidl::Error>>
2796        + Send;
2797    fn r#get_config(&self) -> Self::GetConfigResponseFut;
2798    type GetNameResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
2799    fn r#get_name(&self) -> Self::GetNameResponseFut;
2800    type SetConfigResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
2801    fn r#set_config(&self, config: &NetworkConfig) -> Self::SetConfigResponseFut;
2802    type AttachEndpointResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
2803    fn r#attach_endpoint(&self, name: &str) -> Self::AttachEndpointResponseFut;
2804    type RemoveEndpointResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
2805    fn r#remove_endpoint(&self, name: &str) -> Self::RemoveEndpointResponseFut;
2806    fn r#create_fake_endpoint(
2807        &self,
2808        ep: fidl::endpoints::ServerEnd<FakeEndpointMarker>,
2809    ) -> Result<(), fidl::Error>;
2810    type StartCaptureResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
2811    fn r#start_capture(&self, name: &str) -> Self::StartCaptureResponseFut;
2812    type StopCaptureResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2813    fn r#stop_capture(&self) -> Self::StopCaptureResponseFut;
2814}
2815#[derive(Debug)]
2816#[cfg(target_os = "fuchsia")]
2817pub struct NetworkSynchronousProxy {
2818    client: fidl::client::sync::Client,
2819}
2820
2821#[cfg(target_os = "fuchsia")]
2822impl fidl::endpoints::SynchronousProxy for NetworkSynchronousProxy {
2823    type Proxy = NetworkProxy;
2824    type Protocol = NetworkMarker;
2825
2826    fn from_channel(inner: fidl::Channel) -> Self {
2827        Self::new(inner)
2828    }
2829
2830    fn into_channel(self) -> fidl::Channel {
2831        self.client.into_channel()
2832    }
2833
2834    fn as_channel(&self) -> &fidl::Channel {
2835        self.client.as_channel()
2836    }
2837}
2838
2839#[cfg(target_os = "fuchsia")]
2840impl NetworkSynchronousProxy {
2841    pub fn new(channel: fidl::Channel) -> Self {
2842        let protocol_name = <NetworkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2843        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2844    }
2845
2846    pub fn into_channel(self) -> fidl::Channel {
2847        self.client.into_channel()
2848    }
2849
2850    /// Waits until an event arrives and returns it. It is safe for other
2851    /// threads to make concurrent requests while waiting for an event.
2852    pub fn wait_for_event(
2853        &self,
2854        deadline: zx::MonotonicInstant,
2855    ) -> Result<NetworkEvent, fidl::Error> {
2856        NetworkEvent::decode(self.client.wait_for_event(deadline)?)
2857    }
2858
2859    /// Adds a port to the network.
2860    ///
2861    /// + request `port` port to be added.
2862    /// + request `interface` provides control over the interface.
2863    pub fn r#add_port(
2864        &self,
2865        mut port: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
2866        mut interface: fidl::endpoints::ServerEnd<fidl_fuchsia_net_virtualization::InterfaceMarker>,
2867    ) -> Result<(), fidl::Error> {
2868        self.client.send::<fidl_fuchsia_net_virtualization::NetworkAddPortRequest>(
2869            (port, interface),
2870            0x7ad6a60c931a3f4e,
2871            fidl::encoding::DynamicFlags::empty(),
2872        )
2873    }
2874
2875    /// Gets network configuration.
2876    pub fn r#get_config(
2877        &self,
2878        ___deadline: zx::MonotonicInstant,
2879    ) -> Result<NetworkConfig, fidl::Error> {
2880        let _response =
2881            self.client.send_query::<fidl::encoding::EmptyPayload, NetworkGetConfigResponse>(
2882                (),
2883                0x8dc04557e2ab069,
2884                fidl::encoding::DynamicFlags::empty(),
2885                ___deadline,
2886            )?;
2887        Ok(_response.config)
2888    }
2889
2890    /// Gets network name.
2891    pub fn r#get_name(&self, ___deadline: zx::MonotonicInstant) -> Result<String, fidl::Error> {
2892        let _response =
2893            self.client.send_query::<fidl::encoding::EmptyPayload, NetworkGetNameResponse>(
2894                (),
2895                0x57b7701d1ffeedb1,
2896                fidl::encoding::DynamicFlags::empty(),
2897                ___deadline,
2898            )?;
2899        Ok(_response.name)
2900    }
2901
2902    /// Updates network configuration.
2903    pub fn r#set_config(
2904        &self,
2905        mut config: &NetworkConfig,
2906        ___deadline: zx::MonotonicInstant,
2907    ) -> Result<i32, fidl::Error> {
2908        let _response =
2909            self.client.send_query::<NetworkSetConfigRequest, NetworkSetConfigResponse>(
2910                (config,),
2911                0x18a490ee9d4bfa16,
2912                fidl::encoding::DynamicFlags::empty(),
2913                ___deadline,
2914            )?;
2915        Ok(_response.status)
2916    }
2917
2918    /// Attaches endpoint with given name to network.
2919    pub fn r#attach_endpoint(
2920        &self,
2921        mut name: &str,
2922        ___deadline: zx::MonotonicInstant,
2923    ) -> Result<i32, fidl::Error> {
2924        let _response =
2925            self.client.send_query::<NetworkAttachEndpointRequest, NetworkAttachEndpointResponse>(
2926                (name,),
2927                0x6e8ff8e9ea1b9a98,
2928                fidl::encoding::DynamicFlags::empty(),
2929                ___deadline,
2930            )?;
2931        Ok(_response.status)
2932    }
2933
2934    /// Removes endpoint with given name from network.
2935    pub fn r#remove_endpoint(
2936        &self,
2937        mut name: &str,
2938        ___deadline: zx::MonotonicInstant,
2939    ) -> Result<i32, fidl::Error> {
2940        let _response =
2941            self.client.send_query::<NetworkRemoveEndpointRequest, NetworkRemoveEndpointResponse>(
2942                (name,),
2943                0x298eaac56bfcdd25,
2944                fidl::encoding::DynamicFlags::empty(),
2945                ___deadline,
2946            )?;
2947        Ok(_response.status)
2948    }
2949
2950    /// Injects a fake endpoint.
2951    pub fn r#create_fake_endpoint(
2952        &self,
2953        mut ep: fidl::endpoints::ServerEnd<FakeEndpointMarker>,
2954    ) -> Result<(), fidl::Error> {
2955        self.client.send::<NetworkCreateFakeEndpointRequest>(
2956            (ep,),
2957            0x3eb8f71b45e1e1f3,
2958            fidl::encoding::DynamicFlags::empty(),
2959        )
2960    }
2961
2962    /// Starts capturing packet in this network.
2963    ///
2964    /// The packet capture will be stored at `/custom_artifacts/{name}.pcapng`.
2965    ///
2966    /// Returns [`ZX_ERR_ALREADY_EXISTS`] if the capturing is already started
2967    /// in this network.
2968    pub fn r#start_capture(
2969        &self,
2970        mut name: &str,
2971        ___deadline: zx::MonotonicInstant,
2972    ) -> Result<i32, fidl::Error> {
2973        let _response =
2974            self.client.send_query::<NetworkStartCaptureRequest, NetworkStartCaptureResponse>(
2975                (name,),
2976                0x3ca44940622932c,
2977                fidl::encoding::DynamicFlags::empty(),
2978                ___deadline,
2979            )?;
2980        Ok(_response.status)
2981    }
2982
2983    /// Stops capturing packets. This function is guaranteed to succeed.
2984    ///
2985    /// The packet capture will be stored in the file at the path chosen when
2986    /// capturing started. The packet capture will stop automatically once the
2987    /// network is destroyed regardless of whether this method is called.
2988    pub fn r#stop_capture(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
2989        let _response =
2990            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
2991                (),
2992                0x1d7827adad109468,
2993                fidl::encoding::DynamicFlags::empty(),
2994                ___deadline,
2995            )?;
2996        Ok(_response)
2997    }
2998}
2999
3000#[cfg(target_os = "fuchsia")]
3001impl From<NetworkSynchronousProxy> for zx::Handle {
3002    fn from(value: NetworkSynchronousProxy) -> Self {
3003        value.into_channel().into()
3004    }
3005}
3006
3007#[cfg(target_os = "fuchsia")]
3008impl From<fidl::Channel> for NetworkSynchronousProxy {
3009    fn from(value: fidl::Channel) -> Self {
3010        Self::new(value)
3011    }
3012}
3013
3014#[derive(Debug, Clone)]
3015pub struct NetworkProxy {
3016    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3017}
3018
3019impl fidl::endpoints::Proxy for NetworkProxy {
3020    type Protocol = NetworkMarker;
3021
3022    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3023        Self::new(inner)
3024    }
3025
3026    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3027        self.client.into_channel().map_err(|client| Self { client })
3028    }
3029
3030    fn as_channel(&self) -> &::fidl::AsyncChannel {
3031        self.client.as_channel()
3032    }
3033}
3034
3035impl NetworkProxy {
3036    /// Create a new Proxy for fuchsia.netemul.network/Network.
3037    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3038        let protocol_name = <NetworkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3039        Self { client: fidl::client::Client::new(channel, protocol_name) }
3040    }
3041
3042    /// Get a Stream of events from the remote end of the protocol.
3043    ///
3044    /// # Panics
3045    ///
3046    /// Panics if the event stream was already taken.
3047    pub fn take_event_stream(&self) -> NetworkEventStream {
3048        NetworkEventStream { event_receiver: self.client.take_event_receiver() }
3049    }
3050
3051    /// Adds a port to the network.
3052    ///
3053    /// + request `port` port to be added.
3054    /// + request `interface` provides control over the interface.
3055    pub fn r#add_port(
3056        &self,
3057        mut port: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
3058        mut interface: fidl::endpoints::ServerEnd<fidl_fuchsia_net_virtualization::InterfaceMarker>,
3059    ) -> Result<(), fidl::Error> {
3060        NetworkProxyInterface::r#add_port(self, port, interface)
3061    }
3062
3063    /// Gets network configuration.
3064    pub fn r#get_config(
3065        &self,
3066    ) -> fidl::client::QueryResponseFut<NetworkConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
3067    {
3068        NetworkProxyInterface::r#get_config(self)
3069    }
3070
3071    /// Gets network name.
3072    pub fn r#get_name(
3073        &self,
3074    ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
3075        NetworkProxyInterface::r#get_name(self)
3076    }
3077
3078    /// Updates network configuration.
3079    pub fn r#set_config(
3080        &self,
3081        mut config: &NetworkConfig,
3082    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
3083        NetworkProxyInterface::r#set_config(self, config)
3084    }
3085
3086    /// Attaches endpoint with given name to network.
3087    pub fn r#attach_endpoint(
3088        &self,
3089        mut name: &str,
3090    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
3091        NetworkProxyInterface::r#attach_endpoint(self, name)
3092    }
3093
3094    /// Removes endpoint with given name from network.
3095    pub fn r#remove_endpoint(
3096        &self,
3097        mut name: &str,
3098    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
3099        NetworkProxyInterface::r#remove_endpoint(self, name)
3100    }
3101
3102    /// Injects a fake endpoint.
3103    pub fn r#create_fake_endpoint(
3104        &self,
3105        mut ep: fidl::endpoints::ServerEnd<FakeEndpointMarker>,
3106    ) -> Result<(), fidl::Error> {
3107        NetworkProxyInterface::r#create_fake_endpoint(self, ep)
3108    }
3109
3110    /// Starts capturing packet in this network.
3111    ///
3112    /// The packet capture will be stored at `/custom_artifacts/{name}.pcapng`.
3113    ///
3114    /// Returns [`ZX_ERR_ALREADY_EXISTS`] if the capturing is already started
3115    /// in this network.
3116    pub fn r#start_capture(
3117        &self,
3118        mut name: &str,
3119    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
3120        NetworkProxyInterface::r#start_capture(self, name)
3121    }
3122
3123    /// Stops capturing packets. This function is guaranteed to succeed.
3124    ///
3125    /// The packet capture will be stored in the file at the path chosen when
3126    /// capturing started. The packet capture will stop automatically once the
3127    /// network is destroyed regardless of whether this method is called.
3128    pub fn r#stop_capture(
3129        &self,
3130    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3131        NetworkProxyInterface::r#stop_capture(self)
3132    }
3133}
3134
3135impl NetworkProxyInterface for NetworkProxy {
3136    fn r#add_port(
3137        &self,
3138        mut port: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
3139        mut interface: fidl::endpoints::ServerEnd<fidl_fuchsia_net_virtualization::InterfaceMarker>,
3140    ) -> Result<(), fidl::Error> {
3141        self.client.send::<fidl_fuchsia_net_virtualization::NetworkAddPortRequest>(
3142            (port, interface),
3143            0x7ad6a60c931a3f4e,
3144            fidl::encoding::DynamicFlags::empty(),
3145        )
3146    }
3147
3148    type GetConfigResponseFut = fidl::client::QueryResponseFut<
3149        NetworkConfig,
3150        fidl::encoding::DefaultFuchsiaResourceDialect,
3151    >;
3152    fn r#get_config(&self) -> Self::GetConfigResponseFut {
3153        fn _decode(
3154            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3155        ) -> Result<NetworkConfig, fidl::Error> {
3156            let _response = fidl::client::decode_transaction_body::<
3157                NetworkGetConfigResponse,
3158                fidl::encoding::DefaultFuchsiaResourceDialect,
3159                0x8dc04557e2ab069,
3160            >(_buf?)?;
3161            Ok(_response.config)
3162        }
3163        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NetworkConfig>(
3164            (),
3165            0x8dc04557e2ab069,
3166            fidl::encoding::DynamicFlags::empty(),
3167            _decode,
3168        )
3169    }
3170
3171    type GetNameResponseFut =
3172        fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
3173    fn r#get_name(&self) -> Self::GetNameResponseFut {
3174        fn _decode(
3175            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3176        ) -> Result<String, fidl::Error> {
3177            let _response = fidl::client::decode_transaction_body::<
3178                NetworkGetNameResponse,
3179                fidl::encoding::DefaultFuchsiaResourceDialect,
3180                0x57b7701d1ffeedb1,
3181            >(_buf?)?;
3182            Ok(_response.name)
3183        }
3184        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
3185            (),
3186            0x57b7701d1ffeedb1,
3187            fidl::encoding::DynamicFlags::empty(),
3188            _decode,
3189        )
3190    }
3191
3192    type SetConfigResponseFut =
3193        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
3194    fn r#set_config(&self, mut config: &NetworkConfig) -> Self::SetConfigResponseFut {
3195        fn _decode(
3196            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3197        ) -> Result<i32, fidl::Error> {
3198            let _response = fidl::client::decode_transaction_body::<
3199                NetworkSetConfigResponse,
3200                fidl::encoding::DefaultFuchsiaResourceDialect,
3201                0x18a490ee9d4bfa16,
3202            >(_buf?)?;
3203            Ok(_response.status)
3204        }
3205        self.client.send_query_and_decode::<NetworkSetConfigRequest, i32>(
3206            (config,),
3207            0x18a490ee9d4bfa16,
3208            fidl::encoding::DynamicFlags::empty(),
3209            _decode,
3210        )
3211    }
3212
3213    type AttachEndpointResponseFut =
3214        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
3215    fn r#attach_endpoint(&self, mut name: &str) -> Self::AttachEndpointResponseFut {
3216        fn _decode(
3217            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3218        ) -> Result<i32, fidl::Error> {
3219            let _response = fidl::client::decode_transaction_body::<
3220                NetworkAttachEndpointResponse,
3221                fidl::encoding::DefaultFuchsiaResourceDialect,
3222                0x6e8ff8e9ea1b9a98,
3223            >(_buf?)?;
3224            Ok(_response.status)
3225        }
3226        self.client.send_query_and_decode::<NetworkAttachEndpointRequest, i32>(
3227            (name,),
3228            0x6e8ff8e9ea1b9a98,
3229            fidl::encoding::DynamicFlags::empty(),
3230            _decode,
3231        )
3232    }
3233
3234    type RemoveEndpointResponseFut =
3235        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
3236    fn r#remove_endpoint(&self, mut name: &str) -> Self::RemoveEndpointResponseFut {
3237        fn _decode(
3238            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3239        ) -> Result<i32, fidl::Error> {
3240            let _response = fidl::client::decode_transaction_body::<
3241                NetworkRemoveEndpointResponse,
3242                fidl::encoding::DefaultFuchsiaResourceDialect,
3243                0x298eaac56bfcdd25,
3244            >(_buf?)?;
3245            Ok(_response.status)
3246        }
3247        self.client.send_query_and_decode::<NetworkRemoveEndpointRequest, i32>(
3248            (name,),
3249            0x298eaac56bfcdd25,
3250            fidl::encoding::DynamicFlags::empty(),
3251            _decode,
3252        )
3253    }
3254
3255    fn r#create_fake_endpoint(
3256        &self,
3257        mut ep: fidl::endpoints::ServerEnd<FakeEndpointMarker>,
3258    ) -> Result<(), fidl::Error> {
3259        self.client.send::<NetworkCreateFakeEndpointRequest>(
3260            (ep,),
3261            0x3eb8f71b45e1e1f3,
3262            fidl::encoding::DynamicFlags::empty(),
3263        )
3264    }
3265
3266    type StartCaptureResponseFut =
3267        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
3268    fn r#start_capture(&self, mut name: &str) -> Self::StartCaptureResponseFut {
3269        fn _decode(
3270            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3271        ) -> Result<i32, fidl::Error> {
3272            let _response = fidl::client::decode_transaction_body::<
3273                NetworkStartCaptureResponse,
3274                fidl::encoding::DefaultFuchsiaResourceDialect,
3275                0x3ca44940622932c,
3276            >(_buf?)?;
3277            Ok(_response.status)
3278        }
3279        self.client.send_query_and_decode::<NetworkStartCaptureRequest, i32>(
3280            (name,),
3281            0x3ca44940622932c,
3282            fidl::encoding::DynamicFlags::empty(),
3283            _decode,
3284        )
3285    }
3286
3287    type StopCaptureResponseFut =
3288        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3289    fn r#stop_capture(&self) -> Self::StopCaptureResponseFut {
3290        fn _decode(
3291            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3292        ) -> Result<(), fidl::Error> {
3293            let _response = fidl::client::decode_transaction_body::<
3294                fidl::encoding::EmptyPayload,
3295                fidl::encoding::DefaultFuchsiaResourceDialect,
3296                0x1d7827adad109468,
3297            >(_buf?)?;
3298            Ok(_response)
3299        }
3300        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
3301            (),
3302            0x1d7827adad109468,
3303            fidl::encoding::DynamicFlags::empty(),
3304            _decode,
3305        )
3306    }
3307}
3308
3309pub struct NetworkEventStream {
3310    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3311}
3312
3313impl std::marker::Unpin for NetworkEventStream {}
3314
3315impl futures::stream::FusedStream for NetworkEventStream {
3316    fn is_terminated(&self) -> bool {
3317        self.event_receiver.is_terminated()
3318    }
3319}
3320
3321impl futures::Stream for NetworkEventStream {
3322    type Item = Result<NetworkEvent, fidl::Error>;
3323
3324    fn poll_next(
3325        mut self: std::pin::Pin<&mut Self>,
3326        cx: &mut std::task::Context<'_>,
3327    ) -> std::task::Poll<Option<Self::Item>> {
3328        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3329            &mut self.event_receiver,
3330            cx
3331        )?) {
3332            Some(buf) => std::task::Poll::Ready(Some(NetworkEvent::decode(buf))),
3333            None => std::task::Poll::Ready(None),
3334        }
3335    }
3336}
3337
3338#[derive(Debug)]
3339pub enum NetworkEvent {
3340    OnRemoved { reason: fidl_fuchsia_net_virtualization::NetworkRemovalReason },
3341}
3342
3343impl NetworkEvent {
3344    #[allow(irrefutable_let_patterns)]
3345    pub fn into_on_removed(self) -> Option<fidl_fuchsia_net_virtualization::NetworkRemovalReason> {
3346        if let NetworkEvent::OnRemoved { reason } = self {
3347            Some((reason))
3348        } else {
3349            None
3350        }
3351    }
3352
3353    /// Decodes a message buffer as a [`NetworkEvent`].
3354    fn decode(
3355        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3356    ) -> Result<NetworkEvent, fidl::Error> {
3357        let (bytes, _handles) = buf.split_mut();
3358        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3359        debug_assert_eq!(tx_header.tx_id, 0);
3360        match tx_header.ordinal {
3361            0xfe80656d1e5ec4a => {
3362                let mut out = fidl::new_empty!(
3363                    fidl_fuchsia_net_virtualization::NetworkOnRemovedRequest,
3364                    fidl::encoding::DefaultFuchsiaResourceDialect
3365                );
3366                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_net_virtualization::NetworkOnRemovedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
3367                Ok((NetworkEvent::OnRemoved { reason: out.reason }))
3368            }
3369            _ => Err(fidl::Error::UnknownOrdinal {
3370                ordinal: tx_header.ordinal,
3371                protocol_name: <NetworkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3372            }),
3373        }
3374    }
3375}
3376
3377/// A Stream of incoming requests for fuchsia.netemul.network/Network.
3378pub struct NetworkRequestStream {
3379    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3380    is_terminated: bool,
3381}
3382
3383impl std::marker::Unpin for NetworkRequestStream {}
3384
3385impl futures::stream::FusedStream for NetworkRequestStream {
3386    fn is_terminated(&self) -> bool {
3387        self.is_terminated
3388    }
3389}
3390
3391impl fidl::endpoints::RequestStream for NetworkRequestStream {
3392    type Protocol = NetworkMarker;
3393    type ControlHandle = NetworkControlHandle;
3394
3395    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3396        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3397    }
3398
3399    fn control_handle(&self) -> Self::ControlHandle {
3400        NetworkControlHandle { inner: self.inner.clone() }
3401    }
3402
3403    fn into_inner(
3404        self,
3405    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3406    {
3407        (self.inner, self.is_terminated)
3408    }
3409
3410    fn from_inner(
3411        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3412        is_terminated: bool,
3413    ) -> Self {
3414        Self { inner, is_terminated }
3415    }
3416}
3417
3418impl futures::Stream for NetworkRequestStream {
3419    type Item = Result<NetworkRequest, fidl::Error>;
3420
3421    fn poll_next(
3422        mut self: std::pin::Pin<&mut Self>,
3423        cx: &mut std::task::Context<'_>,
3424    ) -> std::task::Poll<Option<Self::Item>> {
3425        let this = &mut *self;
3426        if this.inner.check_shutdown(cx) {
3427            this.is_terminated = true;
3428            return std::task::Poll::Ready(None);
3429        }
3430        if this.is_terminated {
3431            panic!("polled NetworkRequestStream after completion");
3432        }
3433        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3434            |bytes, handles| {
3435                match this.inner.channel().read_etc(cx, bytes, handles) {
3436                    std::task::Poll::Ready(Ok(())) => {}
3437                    std::task::Poll::Pending => return std::task::Poll::Pending,
3438                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3439                        this.is_terminated = true;
3440                        return std::task::Poll::Ready(None);
3441                    }
3442                    std::task::Poll::Ready(Err(e)) => {
3443                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3444                            e.into(),
3445                        ))))
3446                    }
3447                }
3448
3449                // A message has been received from the channel
3450                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3451
3452                std::task::Poll::Ready(Some(match header.ordinal {
3453                    0x7ad6a60c931a3f4e => {
3454                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3455                        let mut req = fidl::new_empty!(
3456                            fidl_fuchsia_net_virtualization::NetworkAddPortRequest,
3457                            fidl::encoding::DefaultFuchsiaResourceDialect
3458                        );
3459                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_net_virtualization::NetworkAddPortRequest>(&header, _body_bytes, handles, &mut req)?;
3460                        let control_handle = NetworkControlHandle { inner: this.inner.clone() };
3461                        Ok(NetworkRequest::AddPort {
3462                            port: req.port,
3463                            interface: req.interface,
3464
3465                            control_handle,
3466                        })
3467                    }
3468                    0x8dc04557e2ab069 => {
3469                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3470                        let mut req = fidl::new_empty!(
3471                            fidl::encoding::EmptyPayload,
3472                            fidl::encoding::DefaultFuchsiaResourceDialect
3473                        );
3474                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3475                        let control_handle = NetworkControlHandle { inner: this.inner.clone() };
3476                        Ok(NetworkRequest::GetConfig {
3477                            responder: NetworkGetConfigResponder {
3478                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3479                                tx_id: header.tx_id,
3480                            },
3481                        })
3482                    }
3483                    0x57b7701d1ffeedb1 => {
3484                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3485                        let mut req = fidl::new_empty!(
3486                            fidl::encoding::EmptyPayload,
3487                            fidl::encoding::DefaultFuchsiaResourceDialect
3488                        );
3489                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3490                        let control_handle = NetworkControlHandle { inner: this.inner.clone() };
3491                        Ok(NetworkRequest::GetName {
3492                            responder: NetworkGetNameResponder {
3493                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3494                                tx_id: header.tx_id,
3495                            },
3496                        })
3497                    }
3498                    0x18a490ee9d4bfa16 => {
3499                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3500                        let mut req = fidl::new_empty!(
3501                            NetworkSetConfigRequest,
3502                            fidl::encoding::DefaultFuchsiaResourceDialect
3503                        );
3504                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkSetConfigRequest>(&header, _body_bytes, handles, &mut req)?;
3505                        let control_handle = NetworkControlHandle { inner: this.inner.clone() };
3506                        Ok(NetworkRequest::SetConfig {
3507                            config: req.config,
3508
3509                            responder: NetworkSetConfigResponder {
3510                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3511                                tx_id: header.tx_id,
3512                            },
3513                        })
3514                    }
3515                    0x6e8ff8e9ea1b9a98 => {
3516                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3517                        let mut req = fidl::new_empty!(
3518                            NetworkAttachEndpointRequest,
3519                            fidl::encoding::DefaultFuchsiaResourceDialect
3520                        );
3521                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkAttachEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
3522                        let control_handle = NetworkControlHandle { inner: this.inner.clone() };
3523                        Ok(NetworkRequest::AttachEndpoint {
3524                            name: req.name,
3525
3526                            responder: NetworkAttachEndpointResponder {
3527                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3528                                tx_id: header.tx_id,
3529                            },
3530                        })
3531                    }
3532                    0x298eaac56bfcdd25 => {
3533                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3534                        let mut req = fidl::new_empty!(
3535                            NetworkRemoveEndpointRequest,
3536                            fidl::encoding::DefaultFuchsiaResourceDialect
3537                        );
3538                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkRemoveEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
3539                        let control_handle = NetworkControlHandle { inner: this.inner.clone() };
3540                        Ok(NetworkRequest::RemoveEndpoint {
3541                            name: req.name,
3542
3543                            responder: NetworkRemoveEndpointResponder {
3544                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3545                                tx_id: header.tx_id,
3546                            },
3547                        })
3548                    }
3549                    0x3eb8f71b45e1e1f3 => {
3550                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3551                        let mut req = fidl::new_empty!(
3552                            NetworkCreateFakeEndpointRequest,
3553                            fidl::encoding::DefaultFuchsiaResourceDialect
3554                        );
3555                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkCreateFakeEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
3556                        let control_handle = NetworkControlHandle { inner: this.inner.clone() };
3557                        Ok(NetworkRequest::CreateFakeEndpoint { ep: req.ep, control_handle })
3558                    }
3559                    0x3ca44940622932c => {
3560                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3561                        let mut req = fidl::new_empty!(
3562                            NetworkStartCaptureRequest,
3563                            fidl::encoding::DefaultFuchsiaResourceDialect
3564                        );
3565                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkStartCaptureRequest>(&header, _body_bytes, handles, &mut req)?;
3566                        let control_handle = NetworkControlHandle { inner: this.inner.clone() };
3567                        Ok(NetworkRequest::StartCapture {
3568                            name: req.name,
3569
3570                            responder: NetworkStartCaptureResponder {
3571                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3572                                tx_id: header.tx_id,
3573                            },
3574                        })
3575                    }
3576                    0x1d7827adad109468 => {
3577                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3578                        let mut req = fidl::new_empty!(
3579                            fidl::encoding::EmptyPayload,
3580                            fidl::encoding::DefaultFuchsiaResourceDialect
3581                        );
3582                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3583                        let control_handle = NetworkControlHandle { inner: this.inner.clone() };
3584                        Ok(NetworkRequest::StopCapture {
3585                            responder: NetworkStopCaptureResponder {
3586                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3587                                tx_id: header.tx_id,
3588                            },
3589                        })
3590                    }
3591                    _ => Err(fidl::Error::UnknownOrdinal {
3592                        ordinal: header.ordinal,
3593                        protocol_name:
3594                            <NetworkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3595                    }),
3596                }))
3597            },
3598        )
3599    }
3600}
3601
3602/// Virtual network.
3603#[derive(Debug)]
3604pub enum NetworkRequest {
3605    /// Adds a port to the network.
3606    ///
3607    /// + request `port` port to be added.
3608    /// + request `interface` provides control over the interface.
3609    AddPort {
3610        port: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
3611        interface: fidl::endpoints::ServerEnd<fidl_fuchsia_net_virtualization::InterfaceMarker>,
3612        control_handle: NetworkControlHandle,
3613    },
3614    /// Gets network configuration.
3615    GetConfig { responder: NetworkGetConfigResponder },
3616    /// Gets network name.
3617    GetName { responder: NetworkGetNameResponder },
3618    /// Updates network configuration.
3619    SetConfig { config: NetworkConfig, responder: NetworkSetConfigResponder },
3620    /// Attaches endpoint with given name to network.
3621    AttachEndpoint { name: String, responder: NetworkAttachEndpointResponder },
3622    /// Removes endpoint with given name from network.
3623    RemoveEndpoint { name: String, responder: NetworkRemoveEndpointResponder },
3624    /// Injects a fake endpoint.
3625    CreateFakeEndpoint {
3626        ep: fidl::endpoints::ServerEnd<FakeEndpointMarker>,
3627        control_handle: NetworkControlHandle,
3628    },
3629    /// Starts capturing packet in this network.
3630    ///
3631    /// The packet capture will be stored at `/custom_artifacts/{name}.pcapng`.
3632    ///
3633    /// Returns [`ZX_ERR_ALREADY_EXISTS`] if the capturing is already started
3634    /// in this network.
3635    StartCapture { name: String, responder: NetworkStartCaptureResponder },
3636    /// Stops capturing packets. This function is guaranteed to succeed.
3637    ///
3638    /// The packet capture will be stored in the file at the path chosen when
3639    /// capturing started. The packet capture will stop automatically once the
3640    /// network is destroyed regardless of whether this method is called.
3641    StopCapture { responder: NetworkStopCaptureResponder },
3642}
3643
3644impl NetworkRequest {
3645    #[allow(irrefutable_let_patterns)]
3646    pub fn into_add_port(
3647        self,
3648    ) -> Option<(
3649        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_network::PortMarker>,
3650        fidl::endpoints::ServerEnd<fidl_fuchsia_net_virtualization::InterfaceMarker>,
3651        NetworkControlHandle,
3652    )> {
3653        if let NetworkRequest::AddPort { port, interface, control_handle } = self {
3654            Some((port, interface, control_handle))
3655        } else {
3656            None
3657        }
3658    }
3659
3660    #[allow(irrefutable_let_patterns)]
3661    pub fn into_get_config(self) -> Option<(NetworkGetConfigResponder)> {
3662        if let NetworkRequest::GetConfig { responder } = self {
3663            Some((responder))
3664        } else {
3665            None
3666        }
3667    }
3668
3669    #[allow(irrefutable_let_patterns)]
3670    pub fn into_get_name(self) -> Option<(NetworkGetNameResponder)> {
3671        if let NetworkRequest::GetName { responder } = self {
3672            Some((responder))
3673        } else {
3674            None
3675        }
3676    }
3677
3678    #[allow(irrefutable_let_patterns)]
3679    pub fn into_set_config(self) -> Option<(NetworkConfig, NetworkSetConfigResponder)> {
3680        if let NetworkRequest::SetConfig { config, responder } = self {
3681            Some((config, responder))
3682        } else {
3683            None
3684        }
3685    }
3686
3687    #[allow(irrefutable_let_patterns)]
3688    pub fn into_attach_endpoint(self) -> Option<(String, NetworkAttachEndpointResponder)> {
3689        if let NetworkRequest::AttachEndpoint { name, responder } = self {
3690            Some((name, responder))
3691        } else {
3692            None
3693        }
3694    }
3695
3696    #[allow(irrefutable_let_patterns)]
3697    pub fn into_remove_endpoint(self) -> Option<(String, NetworkRemoveEndpointResponder)> {
3698        if let NetworkRequest::RemoveEndpoint { name, responder } = self {
3699            Some((name, responder))
3700        } else {
3701            None
3702        }
3703    }
3704
3705    #[allow(irrefutable_let_patterns)]
3706    pub fn into_create_fake_endpoint(
3707        self,
3708    ) -> Option<(fidl::endpoints::ServerEnd<FakeEndpointMarker>, NetworkControlHandle)> {
3709        if let NetworkRequest::CreateFakeEndpoint { ep, control_handle } = self {
3710            Some((ep, control_handle))
3711        } else {
3712            None
3713        }
3714    }
3715
3716    #[allow(irrefutable_let_patterns)]
3717    pub fn into_start_capture(self) -> Option<(String, NetworkStartCaptureResponder)> {
3718        if let NetworkRequest::StartCapture { name, responder } = self {
3719            Some((name, responder))
3720        } else {
3721            None
3722        }
3723    }
3724
3725    #[allow(irrefutable_let_patterns)]
3726    pub fn into_stop_capture(self) -> Option<(NetworkStopCaptureResponder)> {
3727        if let NetworkRequest::StopCapture { responder } = self {
3728            Some((responder))
3729        } else {
3730            None
3731        }
3732    }
3733
3734    /// Name of the method defined in FIDL
3735    pub fn method_name(&self) -> &'static str {
3736        match *self {
3737            NetworkRequest::AddPort { .. } => "add_port",
3738            NetworkRequest::GetConfig { .. } => "get_config",
3739            NetworkRequest::GetName { .. } => "get_name",
3740            NetworkRequest::SetConfig { .. } => "set_config",
3741            NetworkRequest::AttachEndpoint { .. } => "attach_endpoint",
3742            NetworkRequest::RemoveEndpoint { .. } => "remove_endpoint",
3743            NetworkRequest::CreateFakeEndpoint { .. } => "create_fake_endpoint",
3744            NetworkRequest::StartCapture { .. } => "start_capture",
3745            NetworkRequest::StopCapture { .. } => "stop_capture",
3746        }
3747    }
3748}
3749
3750#[derive(Debug, Clone)]
3751pub struct NetworkControlHandle {
3752    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3753}
3754
3755impl fidl::endpoints::ControlHandle for NetworkControlHandle {
3756    fn shutdown(&self) {
3757        self.inner.shutdown()
3758    }
3759    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3760        self.inner.shutdown_with_epitaph(status)
3761    }
3762
3763    fn is_closed(&self) -> bool {
3764        self.inner.channel().is_closed()
3765    }
3766    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3767        self.inner.channel().on_closed()
3768    }
3769
3770    #[cfg(target_os = "fuchsia")]
3771    fn signal_peer(
3772        &self,
3773        clear_mask: zx::Signals,
3774        set_mask: zx::Signals,
3775    ) -> Result<(), zx_status::Status> {
3776        use fidl::Peered;
3777        self.inner.channel().signal_peer(clear_mask, set_mask)
3778    }
3779}
3780
3781impl NetworkControlHandle {
3782    pub fn send_on_removed(
3783        &self,
3784        mut reason: fidl_fuchsia_net_virtualization::NetworkRemovalReason,
3785    ) -> Result<(), fidl::Error> {
3786        self.inner.send::<fidl_fuchsia_net_virtualization::NetworkOnRemovedRequest>(
3787            (reason,),
3788            0,
3789            0xfe80656d1e5ec4a,
3790            fidl::encoding::DynamicFlags::empty(),
3791        )
3792    }
3793}
3794
3795#[must_use = "FIDL methods require a response to be sent"]
3796#[derive(Debug)]
3797pub struct NetworkGetConfigResponder {
3798    control_handle: std::mem::ManuallyDrop<NetworkControlHandle>,
3799    tx_id: u32,
3800}
3801
3802/// Set the the channel to be shutdown (see [`NetworkControlHandle::shutdown`])
3803/// if the responder is dropped without sending a response, so that the client
3804/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3805impl std::ops::Drop for NetworkGetConfigResponder {
3806    fn drop(&mut self) {
3807        self.control_handle.shutdown();
3808        // Safety: drops once, never accessed again
3809        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3810    }
3811}
3812
3813impl fidl::endpoints::Responder for NetworkGetConfigResponder {
3814    type ControlHandle = NetworkControlHandle;
3815
3816    fn control_handle(&self) -> &NetworkControlHandle {
3817        &self.control_handle
3818    }
3819
3820    fn drop_without_shutdown(mut self) {
3821        // Safety: drops once, never accessed again due to mem::forget
3822        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3823        // Prevent Drop from running (which would shut down the channel)
3824        std::mem::forget(self);
3825    }
3826}
3827
3828impl NetworkGetConfigResponder {
3829    /// Sends a response to the FIDL transaction.
3830    ///
3831    /// Sets the channel to shutdown if an error occurs.
3832    pub fn send(self, mut config: &NetworkConfig) -> Result<(), fidl::Error> {
3833        let _result = self.send_raw(config);
3834        if _result.is_err() {
3835            self.control_handle.shutdown();
3836        }
3837        self.drop_without_shutdown();
3838        _result
3839    }
3840
3841    /// Similar to "send" but does not shutdown the channel if an error occurs.
3842    pub fn send_no_shutdown_on_err(self, mut config: &NetworkConfig) -> Result<(), fidl::Error> {
3843        let _result = self.send_raw(config);
3844        self.drop_without_shutdown();
3845        _result
3846    }
3847
3848    fn send_raw(&self, mut config: &NetworkConfig) -> Result<(), fidl::Error> {
3849        self.control_handle.inner.send::<NetworkGetConfigResponse>(
3850            (config,),
3851            self.tx_id,
3852            0x8dc04557e2ab069,
3853            fidl::encoding::DynamicFlags::empty(),
3854        )
3855    }
3856}
3857
3858#[must_use = "FIDL methods require a response to be sent"]
3859#[derive(Debug)]
3860pub struct NetworkGetNameResponder {
3861    control_handle: std::mem::ManuallyDrop<NetworkControlHandle>,
3862    tx_id: u32,
3863}
3864
3865/// Set the the channel to be shutdown (see [`NetworkControlHandle::shutdown`])
3866/// if the responder is dropped without sending a response, so that the client
3867/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3868impl std::ops::Drop for NetworkGetNameResponder {
3869    fn drop(&mut self) {
3870        self.control_handle.shutdown();
3871        // Safety: drops once, never accessed again
3872        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3873    }
3874}
3875
3876impl fidl::endpoints::Responder for NetworkGetNameResponder {
3877    type ControlHandle = NetworkControlHandle;
3878
3879    fn control_handle(&self) -> &NetworkControlHandle {
3880        &self.control_handle
3881    }
3882
3883    fn drop_without_shutdown(mut self) {
3884        // Safety: drops once, never accessed again due to mem::forget
3885        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3886        // Prevent Drop from running (which would shut down the channel)
3887        std::mem::forget(self);
3888    }
3889}
3890
3891impl NetworkGetNameResponder {
3892    /// Sends a response to the FIDL transaction.
3893    ///
3894    /// Sets the channel to shutdown if an error occurs.
3895    pub fn send(self, mut name: &str) -> Result<(), fidl::Error> {
3896        let _result = self.send_raw(name);
3897        if _result.is_err() {
3898            self.control_handle.shutdown();
3899        }
3900        self.drop_without_shutdown();
3901        _result
3902    }
3903
3904    /// Similar to "send" but does not shutdown the channel if an error occurs.
3905    pub fn send_no_shutdown_on_err(self, mut name: &str) -> Result<(), fidl::Error> {
3906        let _result = self.send_raw(name);
3907        self.drop_without_shutdown();
3908        _result
3909    }
3910
3911    fn send_raw(&self, mut name: &str) -> Result<(), fidl::Error> {
3912        self.control_handle.inner.send::<NetworkGetNameResponse>(
3913            (name,),
3914            self.tx_id,
3915            0x57b7701d1ffeedb1,
3916            fidl::encoding::DynamicFlags::empty(),
3917        )
3918    }
3919}
3920
3921#[must_use = "FIDL methods require a response to be sent"]
3922#[derive(Debug)]
3923pub struct NetworkSetConfigResponder {
3924    control_handle: std::mem::ManuallyDrop<NetworkControlHandle>,
3925    tx_id: u32,
3926}
3927
3928/// Set the the channel to be shutdown (see [`NetworkControlHandle::shutdown`])
3929/// if the responder is dropped without sending a response, so that the client
3930/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3931impl std::ops::Drop for NetworkSetConfigResponder {
3932    fn drop(&mut self) {
3933        self.control_handle.shutdown();
3934        // Safety: drops once, never accessed again
3935        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3936    }
3937}
3938
3939impl fidl::endpoints::Responder for NetworkSetConfigResponder {
3940    type ControlHandle = NetworkControlHandle;
3941
3942    fn control_handle(&self) -> &NetworkControlHandle {
3943        &self.control_handle
3944    }
3945
3946    fn drop_without_shutdown(mut self) {
3947        // Safety: drops once, never accessed again due to mem::forget
3948        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3949        // Prevent Drop from running (which would shut down the channel)
3950        std::mem::forget(self);
3951    }
3952}
3953
3954impl NetworkSetConfigResponder {
3955    /// Sends a response to the FIDL transaction.
3956    ///
3957    /// Sets the channel to shutdown if an error occurs.
3958    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
3959        let _result = self.send_raw(status);
3960        if _result.is_err() {
3961            self.control_handle.shutdown();
3962        }
3963        self.drop_without_shutdown();
3964        _result
3965    }
3966
3967    /// Similar to "send" but does not shutdown the channel if an error occurs.
3968    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
3969        let _result = self.send_raw(status);
3970        self.drop_without_shutdown();
3971        _result
3972    }
3973
3974    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
3975        self.control_handle.inner.send::<NetworkSetConfigResponse>(
3976            (status,),
3977            self.tx_id,
3978            0x18a490ee9d4bfa16,
3979            fidl::encoding::DynamicFlags::empty(),
3980        )
3981    }
3982}
3983
3984#[must_use = "FIDL methods require a response to be sent"]
3985#[derive(Debug)]
3986pub struct NetworkAttachEndpointResponder {
3987    control_handle: std::mem::ManuallyDrop<NetworkControlHandle>,
3988    tx_id: u32,
3989}
3990
3991/// Set the the channel to be shutdown (see [`NetworkControlHandle::shutdown`])
3992/// if the responder is dropped without sending a response, so that the client
3993/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3994impl std::ops::Drop for NetworkAttachEndpointResponder {
3995    fn drop(&mut self) {
3996        self.control_handle.shutdown();
3997        // Safety: drops once, never accessed again
3998        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3999    }
4000}
4001
4002impl fidl::endpoints::Responder for NetworkAttachEndpointResponder {
4003    type ControlHandle = NetworkControlHandle;
4004
4005    fn control_handle(&self) -> &NetworkControlHandle {
4006        &self.control_handle
4007    }
4008
4009    fn drop_without_shutdown(mut self) {
4010        // Safety: drops once, never accessed again due to mem::forget
4011        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4012        // Prevent Drop from running (which would shut down the channel)
4013        std::mem::forget(self);
4014    }
4015}
4016
4017impl NetworkAttachEndpointResponder {
4018    /// Sends a response to the FIDL transaction.
4019    ///
4020    /// Sets the channel to shutdown if an error occurs.
4021    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
4022        let _result = self.send_raw(status);
4023        if _result.is_err() {
4024            self.control_handle.shutdown();
4025        }
4026        self.drop_without_shutdown();
4027        _result
4028    }
4029
4030    /// Similar to "send" but does not shutdown the channel if an error occurs.
4031    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
4032        let _result = self.send_raw(status);
4033        self.drop_without_shutdown();
4034        _result
4035    }
4036
4037    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
4038        self.control_handle.inner.send::<NetworkAttachEndpointResponse>(
4039            (status,),
4040            self.tx_id,
4041            0x6e8ff8e9ea1b9a98,
4042            fidl::encoding::DynamicFlags::empty(),
4043        )
4044    }
4045}
4046
4047#[must_use = "FIDL methods require a response to be sent"]
4048#[derive(Debug)]
4049pub struct NetworkRemoveEndpointResponder {
4050    control_handle: std::mem::ManuallyDrop<NetworkControlHandle>,
4051    tx_id: u32,
4052}
4053
4054/// Set the the channel to be shutdown (see [`NetworkControlHandle::shutdown`])
4055/// if the responder is dropped without sending a response, so that the client
4056/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4057impl std::ops::Drop for NetworkRemoveEndpointResponder {
4058    fn drop(&mut self) {
4059        self.control_handle.shutdown();
4060        // Safety: drops once, never accessed again
4061        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4062    }
4063}
4064
4065impl fidl::endpoints::Responder for NetworkRemoveEndpointResponder {
4066    type ControlHandle = NetworkControlHandle;
4067
4068    fn control_handle(&self) -> &NetworkControlHandle {
4069        &self.control_handle
4070    }
4071
4072    fn drop_without_shutdown(mut self) {
4073        // Safety: drops once, never accessed again due to mem::forget
4074        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4075        // Prevent Drop from running (which would shut down the channel)
4076        std::mem::forget(self);
4077    }
4078}
4079
4080impl NetworkRemoveEndpointResponder {
4081    /// Sends a response to the FIDL transaction.
4082    ///
4083    /// Sets the channel to shutdown if an error occurs.
4084    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
4085        let _result = self.send_raw(status);
4086        if _result.is_err() {
4087            self.control_handle.shutdown();
4088        }
4089        self.drop_without_shutdown();
4090        _result
4091    }
4092
4093    /// Similar to "send" but does not shutdown the channel if an error occurs.
4094    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
4095        let _result = self.send_raw(status);
4096        self.drop_without_shutdown();
4097        _result
4098    }
4099
4100    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
4101        self.control_handle.inner.send::<NetworkRemoveEndpointResponse>(
4102            (status,),
4103            self.tx_id,
4104            0x298eaac56bfcdd25,
4105            fidl::encoding::DynamicFlags::empty(),
4106        )
4107    }
4108}
4109
4110#[must_use = "FIDL methods require a response to be sent"]
4111#[derive(Debug)]
4112pub struct NetworkStartCaptureResponder {
4113    control_handle: std::mem::ManuallyDrop<NetworkControlHandle>,
4114    tx_id: u32,
4115}
4116
4117/// Set the the channel to be shutdown (see [`NetworkControlHandle::shutdown`])
4118/// if the responder is dropped without sending a response, so that the client
4119/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4120impl std::ops::Drop for NetworkStartCaptureResponder {
4121    fn drop(&mut self) {
4122        self.control_handle.shutdown();
4123        // Safety: drops once, never accessed again
4124        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4125    }
4126}
4127
4128impl fidl::endpoints::Responder for NetworkStartCaptureResponder {
4129    type ControlHandle = NetworkControlHandle;
4130
4131    fn control_handle(&self) -> &NetworkControlHandle {
4132        &self.control_handle
4133    }
4134
4135    fn drop_without_shutdown(mut self) {
4136        // Safety: drops once, never accessed again due to mem::forget
4137        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4138        // Prevent Drop from running (which would shut down the channel)
4139        std::mem::forget(self);
4140    }
4141}
4142
4143impl NetworkStartCaptureResponder {
4144    /// Sends a response to the FIDL transaction.
4145    ///
4146    /// Sets the channel to shutdown if an error occurs.
4147    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
4148        let _result = self.send_raw(status);
4149        if _result.is_err() {
4150            self.control_handle.shutdown();
4151        }
4152        self.drop_without_shutdown();
4153        _result
4154    }
4155
4156    /// Similar to "send" but does not shutdown the channel if an error occurs.
4157    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
4158        let _result = self.send_raw(status);
4159        self.drop_without_shutdown();
4160        _result
4161    }
4162
4163    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
4164        self.control_handle.inner.send::<NetworkStartCaptureResponse>(
4165            (status,),
4166            self.tx_id,
4167            0x3ca44940622932c,
4168            fidl::encoding::DynamicFlags::empty(),
4169        )
4170    }
4171}
4172
4173#[must_use = "FIDL methods require a response to be sent"]
4174#[derive(Debug)]
4175pub struct NetworkStopCaptureResponder {
4176    control_handle: std::mem::ManuallyDrop<NetworkControlHandle>,
4177    tx_id: u32,
4178}
4179
4180/// Set the the channel to be shutdown (see [`NetworkControlHandle::shutdown`])
4181/// if the responder is dropped without sending a response, so that the client
4182/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4183impl std::ops::Drop for NetworkStopCaptureResponder {
4184    fn drop(&mut self) {
4185        self.control_handle.shutdown();
4186        // Safety: drops once, never accessed again
4187        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4188    }
4189}
4190
4191impl fidl::endpoints::Responder for NetworkStopCaptureResponder {
4192    type ControlHandle = NetworkControlHandle;
4193
4194    fn control_handle(&self) -> &NetworkControlHandle {
4195        &self.control_handle
4196    }
4197
4198    fn drop_without_shutdown(mut self) {
4199        // Safety: drops once, never accessed again due to mem::forget
4200        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4201        // Prevent Drop from running (which would shut down the channel)
4202        std::mem::forget(self);
4203    }
4204}
4205
4206impl NetworkStopCaptureResponder {
4207    /// Sends a response to the FIDL transaction.
4208    ///
4209    /// Sets the channel to shutdown if an error occurs.
4210    pub fn send(self) -> Result<(), fidl::Error> {
4211        let _result = self.send_raw();
4212        if _result.is_err() {
4213            self.control_handle.shutdown();
4214        }
4215        self.drop_without_shutdown();
4216        _result
4217    }
4218
4219    /// Similar to "send" but does not shutdown the channel if an error occurs.
4220    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4221        let _result = self.send_raw();
4222        self.drop_without_shutdown();
4223        _result
4224    }
4225
4226    fn send_raw(&self) -> Result<(), fidl::Error> {
4227        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4228            (),
4229            self.tx_id,
4230            0x1d7827adad109468,
4231            fidl::encoding::DynamicFlags::empty(),
4232        )
4233    }
4234}
4235
4236#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4237pub struct NetworkContextMarker;
4238
4239impl fidl::endpoints::ProtocolMarker for NetworkContextMarker {
4240    type Proxy = NetworkContextProxy;
4241    type RequestStream = NetworkContextRequestStream;
4242    #[cfg(target_os = "fuchsia")]
4243    type SynchronousProxy = NetworkContextSynchronousProxy;
4244
4245    const DEBUG_NAME: &'static str = "fuchsia.netemul.network.NetworkContext";
4246}
4247impl fidl::endpoints::DiscoverableProtocolMarker for NetworkContextMarker {}
4248
4249pub trait NetworkContextProxyInterface: Send + Sync {
4250    fn r#clone(
4251        &self,
4252        network_context: fidl::endpoints::ServerEnd<NetworkContextMarker>,
4253    ) -> Result<(), fidl::Error>;
4254    fn r#get_network_manager(
4255        &self,
4256        net_manager: fidl::endpoints::ServerEnd<NetworkManagerMarker>,
4257    ) -> Result<(), fidl::Error>;
4258    fn r#get_endpoint_manager(
4259        &self,
4260        endp_manager: fidl::endpoints::ServerEnd<EndpointManagerMarker>,
4261    ) -> Result<(), fidl::Error>;
4262    type SetupResponseFut: std::future::Future<
4263            Output = Result<
4264                (i32, Option<fidl::endpoints::ClientEnd<SetupHandleMarker>>),
4265                fidl::Error,
4266            >,
4267        > + Send;
4268    fn r#setup(&self, networks: &[NetworkSetup]) -> Self::SetupResponseFut;
4269}
4270#[derive(Debug)]
4271#[cfg(target_os = "fuchsia")]
4272pub struct NetworkContextSynchronousProxy {
4273    client: fidl::client::sync::Client,
4274}
4275
4276#[cfg(target_os = "fuchsia")]
4277impl fidl::endpoints::SynchronousProxy for NetworkContextSynchronousProxy {
4278    type Proxy = NetworkContextProxy;
4279    type Protocol = NetworkContextMarker;
4280
4281    fn from_channel(inner: fidl::Channel) -> Self {
4282        Self::new(inner)
4283    }
4284
4285    fn into_channel(self) -> fidl::Channel {
4286        self.client.into_channel()
4287    }
4288
4289    fn as_channel(&self) -> &fidl::Channel {
4290        self.client.as_channel()
4291    }
4292}
4293
4294#[cfg(target_os = "fuchsia")]
4295impl NetworkContextSynchronousProxy {
4296    pub fn new(channel: fidl::Channel) -> Self {
4297        let protocol_name = <NetworkContextMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4298        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4299    }
4300
4301    pub fn into_channel(self) -> fidl::Channel {
4302        self.client.into_channel()
4303    }
4304
4305    /// Waits until an event arrives and returns it. It is safe for other
4306    /// threads to make concurrent requests while waiting for an event.
4307    pub fn wait_for_event(
4308        &self,
4309        deadline: zx::MonotonicInstant,
4310    ) -> Result<NetworkContextEvent, fidl::Error> {
4311        NetworkContextEvent::decode(self.client.wait_for_event(deadline)?)
4312    }
4313
4314    pub fn r#clone(
4315        &self,
4316        mut network_context: fidl::endpoints::ServerEnd<NetworkContextMarker>,
4317    ) -> Result<(), fidl::Error> {
4318        self.client.send::<NetworkContextCloneRequest>(
4319            (network_context,),
4320            0x1f7eb1b78a2ad2b0,
4321            fidl::encoding::DynamicFlags::empty(),
4322        )
4323    }
4324
4325    pub fn r#get_network_manager(
4326        &self,
4327        mut net_manager: fidl::endpoints::ServerEnd<NetworkManagerMarker>,
4328    ) -> Result<(), fidl::Error> {
4329        self.client.send::<NetworkContextGetNetworkManagerRequest>(
4330            (net_manager,),
4331            0x379899a30766afd4,
4332            fidl::encoding::DynamicFlags::empty(),
4333        )
4334    }
4335
4336    pub fn r#get_endpoint_manager(
4337        &self,
4338        mut endp_manager: fidl::endpoints::ServerEnd<EndpointManagerMarker>,
4339    ) -> Result<(), fidl::Error> {
4340        self.client.send::<NetworkContextGetEndpointManagerRequest>(
4341            (endp_manager,),
4342            0x5e64360363b9bd81,
4343            fidl::encoding::DynamicFlags::empty(),
4344        )
4345    }
4346
4347    /// Creates a collection of networks described by `networks`.
4348    /// `status` is `ZX_OK` for success
4349    /// `setup_handle` is a resource that references and maintains the lifecycle of
4350    ///                the created networks and endpoints.
4351    pub fn r#setup(
4352        &self,
4353        mut networks: &[NetworkSetup],
4354        ___deadline: zx::MonotonicInstant,
4355    ) -> Result<(i32, Option<fidl::endpoints::ClientEnd<SetupHandleMarker>>), fidl::Error> {
4356        let _response =
4357            self.client.send_query::<NetworkContextSetupRequest, NetworkContextSetupResponse>(
4358                (networks,),
4359                0x1680e0b13823fc8c,
4360                fidl::encoding::DynamicFlags::empty(),
4361                ___deadline,
4362            )?;
4363        Ok((_response.status, _response.setup_handle))
4364    }
4365}
4366
4367#[cfg(target_os = "fuchsia")]
4368impl From<NetworkContextSynchronousProxy> for zx::Handle {
4369    fn from(value: NetworkContextSynchronousProxy) -> Self {
4370        value.into_channel().into()
4371    }
4372}
4373
4374#[cfg(target_os = "fuchsia")]
4375impl From<fidl::Channel> for NetworkContextSynchronousProxy {
4376    fn from(value: fidl::Channel) -> Self {
4377        Self::new(value)
4378    }
4379}
4380
4381#[derive(Debug, Clone)]
4382pub struct NetworkContextProxy {
4383    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4384}
4385
4386impl fidl::endpoints::Proxy for NetworkContextProxy {
4387    type Protocol = NetworkContextMarker;
4388
4389    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4390        Self::new(inner)
4391    }
4392
4393    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4394        self.client.into_channel().map_err(|client| Self { client })
4395    }
4396
4397    fn as_channel(&self) -> &::fidl::AsyncChannel {
4398        self.client.as_channel()
4399    }
4400}
4401
4402impl NetworkContextProxy {
4403    /// Create a new Proxy for fuchsia.netemul.network/NetworkContext.
4404    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4405        let protocol_name = <NetworkContextMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4406        Self { client: fidl::client::Client::new(channel, protocol_name) }
4407    }
4408
4409    /// Get a Stream of events from the remote end of the protocol.
4410    ///
4411    /// # Panics
4412    ///
4413    /// Panics if the event stream was already taken.
4414    pub fn take_event_stream(&self) -> NetworkContextEventStream {
4415        NetworkContextEventStream { event_receiver: self.client.take_event_receiver() }
4416    }
4417
4418    pub fn r#clone(
4419        &self,
4420        mut network_context: fidl::endpoints::ServerEnd<NetworkContextMarker>,
4421    ) -> Result<(), fidl::Error> {
4422        NetworkContextProxyInterface::r#clone(self, network_context)
4423    }
4424
4425    pub fn r#get_network_manager(
4426        &self,
4427        mut net_manager: fidl::endpoints::ServerEnd<NetworkManagerMarker>,
4428    ) -> Result<(), fidl::Error> {
4429        NetworkContextProxyInterface::r#get_network_manager(self, net_manager)
4430    }
4431
4432    pub fn r#get_endpoint_manager(
4433        &self,
4434        mut endp_manager: fidl::endpoints::ServerEnd<EndpointManagerMarker>,
4435    ) -> Result<(), fidl::Error> {
4436        NetworkContextProxyInterface::r#get_endpoint_manager(self, endp_manager)
4437    }
4438
4439    /// Creates a collection of networks described by `networks`.
4440    /// `status` is `ZX_OK` for success
4441    /// `setup_handle` is a resource that references and maintains the lifecycle of
4442    ///                the created networks and endpoints.
4443    pub fn r#setup(
4444        &self,
4445        mut networks: &[NetworkSetup],
4446    ) -> fidl::client::QueryResponseFut<
4447        (i32, Option<fidl::endpoints::ClientEnd<SetupHandleMarker>>),
4448        fidl::encoding::DefaultFuchsiaResourceDialect,
4449    > {
4450        NetworkContextProxyInterface::r#setup(self, networks)
4451    }
4452}
4453
4454impl NetworkContextProxyInterface for NetworkContextProxy {
4455    fn r#clone(
4456        &self,
4457        mut network_context: fidl::endpoints::ServerEnd<NetworkContextMarker>,
4458    ) -> Result<(), fidl::Error> {
4459        self.client.send::<NetworkContextCloneRequest>(
4460            (network_context,),
4461            0x1f7eb1b78a2ad2b0,
4462            fidl::encoding::DynamicFlags::empty(),
4463        )
4464    }
4465
4466    fn r#get_network_manager(
4467        &self,
4468        mut net_manager: fidl::endpoints::ServerEnd<NetworkManagerMarker>,
4469    ) -> Result<(), fidl::Error> {
4470        self.client.send::<NetworkContextGetNetworkManagerRequest>(
4471            (net_manager,),
4472            0x379899a30766afd4,
4473            fidl::encoding::DynamicFlags::empty(),
4474        )
4475    }
4476
4477    fn r#get_endpoint_manager(
4478        &self,
4479        mut endp_manager: fidl::endpoints::ServerEnd<EndpointManagerMarker>,
4480    ) -> Result<(), fidl::Error> {
4481        self.client.send::<NetworkContextGetEndpointManagerRequest>(
4482            (endp_manager,),
4483            0x5e64360363b9bd81,
4484            fidl::encoding::DynamicFlags::empty(),
4485        )
4486    }
4487
4488    type SetupResponseFut = fidl::client::QueryResponseFut<
4489        (i32, Option<fidl::endpoints::ClientEnd<SetupHandleMarker>>),
4490        fidl::encoding::DefaultFuchsiaResourceDialect,
4491    >;
4492    fn r#setup(&self, mut networks: &[NetworkSetup]) -> Self::SetupResponseFut {
4493        fn _decode(
4494            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4495        ) -> Result<(i32, Option<fidl::endpoints::ClientEnd<SetupHandleMarker>>), fidl::Error>
4496        {
4497            let _response = fidl::client::decode_transaction_body::<
4498                NetworkContextSetupResponse,
4499                fidl::encoding::DefaultFuchsiaResourceDialect,
4500                0x1680e0b13823fc8c,
4501            >(_buf?)?;
4502            Ok((_response.status, _response.setup_handle))
4503        }
4504        self.client.send_query_and_decode::<
4505            NetworkContextSetupRequest,
4506            (i32, Option<fidl::endpoints::ClientEnd<SetupHandleMarker>>),
4507        >(
4508            (networks,),
4509            0x1680e0b13823fc8c,
4510            fidl::encoding::DynamicFlags::empty(),
4511            _decode,
4512        )
4513    }
4514}
4515
4516pub struct NetworkContextEventStream {
4517    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4518}
4519
4520impl std::marker::Unpin for NetworkContextEventStream {}
4521
4522impl futures::stream::FusedStream for NetworkContextEventStream {
4523    fn is_terminated(&self) -> bool {
4524        self.event_receiver.is_terminated()
4525    }
4526}
4527
4528impl futures::Stream for NetworkContextEventStream {
4529    type Item = Result<NetworkContextEvent, fidl::Error>;
4530
4531    fn poll_next(
4532        mut self: std::pin::Pin<&mut Self>,
4533        cx: &mut std::task::Context<'_>,
4534    ) -> std::task::Poll<Option<Self::Item>> {
4535        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4536            &mut self.event_receiver,
4537            cx
4538        )?) {
4539            Some(buf) => std::task::Poll::Ready(Some(NetworkContextEvent::decode(buf))),
4540            None => std::task::Poll::Ready(None),
4541        }
4542    }
4543}
4544
4545#[derive(Debug)]
4546pub enum NetworkContextEvent {}
4547
4548impl NetworkContextEvent {
4549    /// Decodes a message buffer as a [`NetworkContextEvent`].
4550    fn decode(
4551        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4552    ) -> Result<NetworkContextEvent, fidl::Error> {
4553        let (bytes, _handles) = buf.split_mut();
4554        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4555        debug_assert_eq!(tx_header.tx_id, 0);
4556        match tx_header.ordinal {
4557            _ => Err(fidl::Error::UnknownOrdinal {
4558                ordinal: tx_header.ordinal,
4559                protocol_name:
4560                    <NetworkContextMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4561            }),
4562        }
4563    }
4564}
4565
4566/// A Stream of incoming requests for fuchsia.netemul.network/NetworkContext.
4567pub struct NetworkContextRequestStream {
4568    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4569    is_terminated: bool,
4570}
4571
4572impl std::marker::Unpin for NetworkContextRequestStream {}
4573
4574impl futures::stream::FusedStream for NetworkContextRequestStream {
4575    fn is_terminated(&self) -> bool {
4576        self.is_terminated
4577    }
4578}
4579
4580impl fidl::endpoints::RequestStream for NetworkContextRequestStream {
4581    type Protocol = NetworkContextMarker;
4582    type ControlHandle = NetworkContextControlHandle;
4583
4584    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4585        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4586    }
4587
4588    fn control_handle(&self) -> Self::ControlHandle {
4589        NetworkContextControlHandle { inner: self.inner.clone() }
4590    }
4591
4592    fn into_inner(
4593        self,
4594    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4595    {
4596        (self.inner, self.is_terminated)
4597    }
4598
4599    fn from_inner(
4600        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4601        is_terminated: bool,
4602    ) -> Self {
4603        Self { inner, is_terminated }
4604    }
4605}
4606
4607impl futures::Stream for NetworkContextRequestStream {
4608    type Item = Result<NetworkContextRequest, fidl::Error>;
4609
4610    fn poll_next(
4611        mut self: std::pin::Pin<&mut Self>,
4612        cx: &mut std::task::Context<'_>,
4613    ) -> std::task::Poll<Option<Self::Item>> {
4614        let this = &mut *self;
4615        if this.inner.check_shutdown(cx) {
4616            this.is_terminated = true;
4617            return std::task::Poll::Ready(None);
4618        }
4619        if this.is_terminated {
4620            panic!("polled NetworkContextRequestStream after completion");
4621        }
4622        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4623            |bytes, handles| {
4624                match this.inner.channel().read_etc(cx, bytes, handles) {
4625                    std::task::Poll::Ready(Ok(())) => {}
4626                    std::task::Poll::Pending => return std::task::Poll::Pending,
4627                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4628                        this.is_terminated = true;
4629                        return std::task::Poll::Ready(None);
4630                    }
4631                    std::task::Poll::Ready(Err(e)) => {
4632                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4633                            e.into(),
4634                        ))))
4635                    }
4636                }
4637
4638                // A message has been received from the channel
4639                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4640
4641                std::task::Poll::Ready(Some(match header.ordinal {
4642                    0x1f7eb1b78a2ad2b0 => {
4643                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4644                        let mut req = fidl::new_empty!(
4645                            NetworkContextCloneRequest,
4646                            fidl::encoding::DefaultFuchsiaResourceDialect
4647                        );
4648                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkContextCloneRequest>(&header, _body_bytes, handles, &mut req)?;
4649                        let control_handle =
4650                            NetworkContextControlHandle { inner: this.inner.clone() };
4651                        Ok(NetworkContextRequest::Clone {
4652                            network_context: req.network_context,
4653
4654                            control_handle,
4655                        })
4656                    }
4657                    0x379899a30766afd4 => {
4658                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4659                        let mut req = fidl::new_empty!(
4660                            NetworkContextGetNetworkManagerRequest,
4661                            fidl::encoding::DefaultFuchsiaResourceDialect
4662                        );
4663                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkContextGetNetworkManagerRequest>(&header, _body_bytes, handles, &mut req)?;
4664                        let control_handle =
4665                            NetworkContextControlHandle { inner: this.inner.clone() };
4666                        Ok(NetworkContextRequest::GetNetworkManager {
4667                            net_manager: req.net_manager,
4668
4669                            control_handle,
4670                        })
4671                    }
4672                    0x5e64360363b9bd81 => {
4673                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4674                        let mut req = fidl::new_empty!(
4675                            NetworkContextGetEndpointManagerRequest,
4676                            fidl::encoding::DefaultFuchsiaResourceDialect
4677                        );
4678                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkContextGetEndpointManagerRequest>(&header, _body_bytes, handles, &mut req)?;
4679                        let control_handle =
4680                            NetworkContextControlHandle { inner: this.inner.clone() };
4681                        Ok(NetworkContextRequest::GetEndpointManager {
4682                            endp_manager: req.endp_manager,
4683
4684                            control_handle,
4685                        })
4686                    }
4687                    0x1680e0b13823fc8c => {
4688                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4689                        let mut req = fidl::new_empty!(
4690                            NetworkContextSetupRequest,
4691                            fidl::encoding::DefaultFuchsiaResourceDialect
4692                        );
4693                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkContextSetupRequest>(&header, _body_bytes, handles, &mut req)?;
4694                        let control_handle =
4695                            NetworkContextControlHandle { inner: this.inner.clone() };
4696                        Ok(NetworkContextRequest::Setup {
4697                            networks: req.networks,
4698
4699                            responder: NetworkContextSetupResponder {
4700                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4701                                tx_id: header.tx_id,
4702                            },
4703                        })
4704                    }
4705                    _ => Err(fidl::Error::UnknownOrdinal {
4706                        ordinal: header.ordinal,
4707                        protocol_name:
4708                            <NetworkContextMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4709                    }),
4710                }))
4711            },
4712        )
4713    }
4714}
4715
4716/// Main entry point to manage virtual networks and endpoints.
4717///
4718/// Every new connection to NetworkContext provides access to a an isolated
4719/// namespace for networks and endpoints. `Clone` is the only means by which a
4720/// client can acquire a new connection to the same network context.
4721#[derive(Debug)]
4722pub enum NetworkContextRequest {
4723    Clone {
4724        network_context: fidl::endpoints::ServerEnd<NetworkContextMarker>,
4725        control_handle: NetworkContextControlHandle,
4726    },
4727    GetNetworkManager {
4728        net_manager: fidl::endpoints::ServerEnd<NetworkManagerMarker>,
4729        control_handle: NetworkContextControlHandle,
4730    },
4731    GetEndpointManager {
4732        endp_manager: fidl::endpoints::ServerEnd<EndpointManagerMarker>,
4733        control_handle: NetworkContextControlHandle,
4734    },
4735    /// Creates a collection of networks described by `networks`.
4736    /// `status` is `ZX_OK` for success
4737    /// `setup_handle` is a resource that references and maintains the lifecycle of
4738    ///                the created networks and endpoints.
4739    Setup { networks: Vec<NetworkSetup>, responder: NetworkContextSetupResponder },
4740}
4741
4742impl NetworkContextRequest {
4743    #[allow(irrefutable_let_patterns)]
4744    pub fn into_clone(
4745        self,
4746    ) -> Option<(fidl::endpoints::ServerEnd<NetworkContextMarker>, NetworkContextControlHandle)>
4747    {
4748        if let NetworkContextRequest::Clone { network_context, control_handle } = self {
4749            Some((network_context, control_handle))
4750        } else {
4751            None
4752        }
4753    }
4754
4755    #[allow(irrefutable_let_patterns)]
4756    pub fn into_get_network_manager(
4757        self,
4758    ) -> Option<(fidl::endpoints::ServerEnd<NetworkManagerMarker>, NetworkContextControlHandle)>
4759    {
4760        if let NetworkContextRequest::GetNetworkManager { net_manager, control_handle } = self {
4761            Some((net_manager, control_handle))
4762        } else {
4763            None
4764        }
4765    }
4766
4767    #[allow(irrefutable_let_patterns)]
4768    pub fn into_get_endpoint_manager(
4769        self,
4770    ) -> Option<(fidl::endpoints::ServerEnd<EndpointManagerMarker>, NetworkContextControlHandle)>
4771    {
4772        if let NetworkContextRequest::GetEndpointManager { endp_manager, control_handle } = self {
4773            Some((endp_manager, control_handle))
4774        } else {
4775            None
4776        }
4777    }
4778
4779    #[allow(irrefutable_let_patterns)]
4780    pub fn into_setup(self) -> Option<(Vec<NetworkSetup>, NetworkContextSetupResponder)> {
4781        if let NetworkContextRequest::Setup { networks, responder } = self {
4782            Some((networks, responder))
4783        } else {
4784            None
4785        }
4786    }
4787
4788    /// Name of the method defined in FIDL
4789    pub fn method_name(&self) -> &'static str {
4790        match *self {
4791            NetworkContextRequest::Clone { .. } => "clone",
4792            NetworkContextRequest::GetNetworkManager { .. } => "get_network_manager",
4793            NetworkContextRequest::GetEndpointManager { .. } => "get_endpoint_manager",
4794            NetworkContextRequest::Setup { .. } => "setup",
4795        }
4796    }
4797}
4798
4799#[derive(Debug, Clone)]
4800pub struct NetworkContextControlHandle {
4801    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4802}
4803
4804impl fidl::endpoints::ControlHandle for NetworkContextControlHandle {
4805    fn shutdown(&self) {
4806        self.inner.shutdown()
4807    }
4808    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4809        self.inner.shutdown_with_epitaph(status)
4810    }
4811
4812    fn is_closed(&self) -> bool {
4813        self.inner.channel().is_closed()
4814    }
4815    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4816        self.inner.channel().on_closed()
4817    }
4818
4819    #[cfg(target_os = "fuchsia")]
4820    fn signal_peer(
4821        &self,
4822        clear_mask: zx::Signals,
4823        set_mask: zx::Signals,
4824    ) -> Result<(), zx_status::Status> {
4825        use fidl::Peered;
4826        self.inner.channel().signal_peer(clear_mask, set_mask)
4827    }
4828}
4829
4830impl NetworkContextControlHandle {}
4831
4832#[must_use = "FIDL methods require a response to be sent"]
4833#[derive(Debug)]
4834pub struct NetworkContextSetupResponder {
4835    control_handle: std::mem::ManuallyDrop<NetworkContextControlHandle>,
4836    tx_id: u32,
4837}
4838
4839/// Set the the channel to be shutdown (see [`NetworkContextControlHandle::shutdown`])
4840/// if the responder is dropped without sending a response, so that the client
4841/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4842impl std::ops::Drop for NetworkContextSetupResponder {
4843    fn drop(&mut self) {
4844        self.control_handle.shutdown();
4845        // Safety: drops once, never accessed again
4846        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4847    }
4848}
4849
4850impl fidl::endpoints::Responder for NetworkContextSetupResponder {
4851    type ControlHandle = NetworkContextControlHandle;
4852
4853    fn control_handle(&self) -> &NetworkContextControlHandle {
4854        &self.control_handle
4855    }
4856
4857    fn drop_without_shutdown(mut self) {
4858        // Safety: drops once, never accessed again due to mem::forget
4859        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4860        // Prevent Drop from running (which would shut down the channel)
4861        std::mem::forget(self);
4862    }
4863}
4864
4865impl NetworkContextSetupResponder {
4866    /// Sends a response to the FIDL transaction.
4867    ///
4868    /// Sets the channel to shutdown if an error occurs.
4869    pub fn send(
4870        self,
4871        mut status: i32,
4872        mut setup_handle: Option<fidl::endpoints::ClientEnd<SetupHandleMarker>>,
4873    ) -> Result<(), fidl::Error> {
4874        let _result = self.send_raw(status, setup_handle);
4875        if _result.is_err() {
4876            self.control_handle.shutdown();
4877        }
4878        self.drop_without_shutdown();
4879        _result
4880    }
4881
4882    /// Similar to "send" but does not shutdown the channel if an error occurs.
4883    pub fn send_no_shutdown_on_err(
4884        self,
4885        mut status: i32,
4886        mut setup_handle: Option<fidl::endpoints::ClientEnd<SetupHandleMarker>>,
4887    ) -> Result<(), fidl::Error> {
4888        let _result = self.send_raw(status, setup_handle);
4889        self.drop_without_shutdown();
4890        _result
4891    }
4892
4893    fn send_raw(
4894        &self,
4895        mut status: i32,
4896        mut setup_handle: Option<fidl::endpoints::ClientEnd<SetupHandleMarker>>,
4897    ) -> Result<(), fidl::Error> {
4898        self.control_handle.inner.send::<NetworkContextSetupResponse>(
4899            (status, setup_handle),
4900            self.tx_id,
4901            0x1680e0b13823fc8c,
4902            fidl::encoding::DynamicFlags::empty(),
4903        )
4904    }
4905}
4906
4907#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4908pub struct NetworkManagerMarker;
4909
4910impl fidl::endpoints::ProtocolMarker for NetworkManagerMarker {
4911    type Proxy = NetworkManagerProxy;
4912    type RequestStream = NetworkManagerRequestStream;
4913    #[cfg(target_os = "fuchsia")]
4914    type SynchronousProxy = NetworkManagerSynchronousProxy;
4915
4916    const DEBUG_NAME: &'static str = "(anonymous) NetworkManager";
4917}
4918
4919pub trait NetworkManagerProxyInterface: Send + Sync {
4920    type ListNetworksResponseFut: std::future::Future<Output = Result<Vec<String>, fidl::Error>>
4921        + Send;
4922    fn r#list_networks(&self) -> Self::ListNetworksResponseFut;
4923    type CreateNetworkResponseFut: std::future::Future<
4924            Output = Result<(i32, Option<fidl::endpoints::ClientEnd<NetworkMarker>>), fidl::Error>,
4925        > + Send;
4926    fn r#create_network(
4927        &self,
4928        name: &str,
4929        config: &NetworkConfig,
4930    ) -> Self::CreateNetworkResponseFut;
4931    type GetNetworkResponseFut: std::future::Future<
4932            Output = Result<Option<fidl::endpoints::ClientEnd<NetworkMarker>>, fidl::Error>,
4933        > + Send;
4934    fn r#get_network(&self, name: &str) -> Self::GetNetworkResponseFut;
4935}
4936#[derive(Debug)]
4937#[cfg(target_os = "fuchsia")]
4938pub struct NetworkManagerSynchronousProxy {
4939    client: fidl::client::sync::Client,
4940}
4941
4942#[cfg(target_os = "fuchsia")]
4943impl fidl::endpoints::SynchronousProxy for NetworkManagerSynchronousProxy {
4944    type Proxy = NetworkManagerProxy;
4945    type Protocol = NetworkManagerMarker;
4946
4947    fn from_channel(inner: fidl::Channel) -> Self {
4948        Self::new(inner)
4949    }
4950
4951    fn into_channel(self) -> fidl::Channel {
4952        self.client.into_channel()
4953    }
4954
4955    fn as_channel(&self) -> &fidl::Channel {
4956        self.client.as_channel()
4957    }
4958}
4959
4960#[cfg(target_os = "fuchsia")]
4961impl NetworkManagerSynchronousProxy {
4962    pub fn new(channel: fidl::Channel) -> Self {
4963        let protocol_name = <NetworkManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4964        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4965    }
4966
4967    pub fn into_channel(self) -> fidl::Channel {
4968        self.client.into_channel()
4969    }
4970
4971    /// Waits until an event arrives and returns it. It is safe for other
4972    /// threads to make concurrent requests while waiting for an event.
4973    pub fn wait_for_event(
4974        &self,
4975        deadline: zx::MonotonicInstant,
4976    ) -> Result<NetworkManagerEvent, fidl::Error> {
4977        NetworkManagerEvent::decode(self.client.wait_for_event(deadline)?)
4978    }
4979
4980    /// Lists emulated networks by name.
4981    pub fn r#list_networks(
4982        &self,
4983        ___deadline: zx::MonotonicInstant,
4984    ) -> Result<Vec<String>, fidl::Error> {
4985        let _response = self
4986            .client
4987            .send_query::<fidl::encoding::EmptyPayload, NetworkManagerListNetworksResponse>(
4988                (),
4989                0x2488653e0974cc62,
4990                fidl::encoding::DynamicFlags::empty(),
4991                ___deadline,
4992            )?;
4993        Ok(_response.nets)
4994    }
4995
4996    /// Creates a new network with given name and config.
4997    pub fn r#create_network(
4998        &self,
4999        mut name: &str,
5000        mut config: &NetworkConfig,
5001        ___deadline: zx::MonotonicInstant,
5002    ) -> Result<(i32, Option<fidl::endpoints::ClientEnd<NetworkMarker>>), fidl::Error> {
5003        let _response = self
5004            .client
5005            .send_query::<NetworkManagerCreateNetworkRequest, NetworkManagerCreateNetworkResponse>(
5006                (name, config),
5007                0x6052eb5ac709af,
5008                fidl::encoding::DynamicFlags::empty(),
5009                ___deadline,
5010            )?;
5011        Ok((_response.status, _response.net))
5012    }
5013
5014    /// Gets a handle to a network.
5015    pub fn r#get_network(
5016        &self,
5017        mut name: &str,
5018        ___deadline: zx::MonotonicInstant,
5019    ) -> Result<Option<fidl::endpoints::ClientEnd<NetworkMarker>>, fidl::Error> {
5020        let _response = self
5021            .client
5022            .send_query::<NetworkManagerGetNetworkRequest, NetworkManagerGetNetworkResponse>(
5023                (name,),
5024                0x59930bf23acc7d9a,
5025                fidl::encoding::DynamicFlags::empty(),
5026                ___deadline,
5027            )?;
5028        Ok(_response.net)
5029    }
5030}
5031
5032#[cfg(target_os = "fuchsia")]
5033impl From<NetworkManagerSynchronousProxy> for zx::Handle {
5034    fn from(value: NetworkManagerSynchronousProxy) -> Self {
5035        value.into_channel().into()
5036    }
5037}
5038
5039#[cfg(target_os = "fuchsia")]
5040impl From<fidl::Channel> for NetworkManagerSynchronousProxy {
5041    fn from(value: fidl::Channel) -> Self {
5042        Self::new(value)
5043    }
5044}
5045
5046#[derive(Debug, Clone)]
5047pub struct NetworkManagerProxy {
5048    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5049}
5050
5051impl fidl::endpoints::Proxy for NetworkManagerProxy {
5052    type Protocol = NetworkManagerMarker;
5053
5054    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5055        Self::new(inner)
5056    }
5057
5058    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5059        self.client.into_channel().map_err(|client| Self { client })
5060    }
5061
5062    fn as_channel(&self) -> &::fidl::AsyncChannel {
5063        self.client.as_channel()
5064    }
5065}
5066
5067impl NetworkManagerProxy {
5068    /// Create a new Proxy for fuchsia.netemul.network/NetworkManager.
5069    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5070        let protocol_name = <NetworkManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5071        Self { client: fidl::client::Client::new(channel, protocol_name) }
5072    }
5073
5074    /// Get a Stream of events from the remote end of the protocol.
5075    ///
5076    /// # Panics
5077    ///
5078    /// Panics if the event stream was already taken.
5079    pub fn take_event_stream(&self) -> NetworkManagerEventStream {
5080        NetworkManagerEventStream { event_receiver: self.client.take_event_receiver() }
5081    }
5082
5083    /// Lists emulated networks by name.
5084    pub fn r#list_networks(
5085        &self,
5086    ) -> fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>
5087    {
5088        NetworkManagerProxyInterface::r#list_networks(self)
5089    }
5090
5091    /// Creates a new network with given name and config.
5092    pub fn r#create_network(
5093        &self,
5094        mut name: &str,
5095        mut config: &NetworkConfig,
5096    ) -> fidl::client::QueryResponseFut<
5097        (i32, Option<fidl::endpoints::ClientEnd<NetworkMarker>>),
5098        fidl::encoding::DefaultFuchsiaResourceDialect,
5099    > {
5100        NetworkManagerProxyInterface::r#create_network(self, name, config)
5101    }
5102
5103    /// Gets a handle to a network.
5104    pub fn r#get_network(
5105        &self,
5106        mut name: &str,
5107    ) -> fidl::client::QueryResponseFut<
5108        Option<fidl::endpoints::ClientEnd<NetworkMarker>>,
5109        fidl::encoding::DefaultFuchsiaResourceDialect,
5110    > {
5111        NetworkManagerProxyInterface::r#get_network(self, name)
5112    }
5113}
5114
5115impl NetworkManagerProxyInterface for NetworkManagerProxy {
5116    type ListNetworksResponseFut =
5117        fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>;
5118    fn r#list_networks(&self) -> Self::ListNetworksResponseFut {
5119        fn _decode(
5120            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5121        ) -> Result<Vec<String>, fidl::Error> {
5122            let _response = fidl::client::decode_transaction_body::<
5123                NetworkManagerListNetworksResponse,
5124                fidl::encoding::DefaultFuchsiaResourceDialect,
5125                0x2488653e0974cc62,
5126            >(_buf?)?;
5127            Ok(_response.nets)
5128        }
5129        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<String>>(
5130            (),
5131            0x2488653e0974cc62,
5132            fidl::encoding::DynamicFlags::empty(),
5133            _decode,
5134        )
5135    }
5136
5137    type CreateNetworkResponseFut = fidl::client::QueryResponseFut<
5138        (i32, Option<fidl::endpoints::ClientEnd<NetworkMarker>>),
5139        fidl::encoding::DefaultFuchsiaResourceDialect,
5140    >;
5141    fn r#create_network(
5142        &self,
5143        mut name: &str,
5144        mut config: &NetworkConfig,
5145    ) -> Self::CreateNetworkResponseFut {
5146        fn _decode(
5147            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5148        ) -> Result<(i32, Option<fidl::endpoints::ClientEnd<NetworkMarker>>), fidl::Error> {
5149            let _response = fidl::client::decode_transaction_body::<
5150                NetworkManagerCreateNetworkResponse,
5151                fidl::encoding::DefaultFuchsiaResourceDialect,
5152                0x6052eb5ac709af,
5153            >(_buf?)?;
5154            Ok((_response.status, _response.net))
5155        }
5156        self.client.send_query_and_decode::<
5157            NetworkManagerCreateNetworkRequest,
5158            (i32, Option<fidl::endpoints::ClientEnd<NetworkMarker>>),
5159        >(
5160            (name, config,),
5161            0x6052eb5ac709af,
5162            fidl::encoding::DynamicFlags::empty(),
5163            _decode,
5164        )
5165    }
5166
5167    type GetNetworkResponseFut = fidl::client::QueryResponseFut<
5168        Option<fidl::endpoints::ClientEnd<NetworkMarker>>,
5169        fidl::encoding::DefaultFuchsiaResourceDialect,
5170    >;
5171    fn r#get_network(&self, mut name: &str) -> Self::GetNetworkResponseFut {
5172        fn _decode(
5173            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5174        ) -> Result<Option<fidl::endpoints::ClientEnd<NetworkMarker>>, fidl::Error> {
5175            let _response = fidl::client::decode_transaction_body::<
5176                NetworkManagerGetNetworkResponse,
5177                fidl::encoding::DefaultFuchsiaResourceDialect,
5178                0x59930bf23acc7d9a,
5179            >(_buf?)?;
5180            Ok(_response.net)
5181        }
5182        self.client.send_query_and_decode::<
5183            NetworkManagerGetNetworkRequest,
5184            Option<fidl::endpoints::ClientEnd<NetworkMarker>>,
5185        >(
5186            (name,),
5187            0x59930bf23acc7d9a,
5188            fidl::encoding::DynamicFlags::empty(),
5189            _decode,
5190        )
5191    }
5192}
5193
5194pub struct NetworkManagerEventStream {
5195    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5196}
5197
5198impl std::marker::Unpin for NetworkManagerEventStream {}
5199
5200impl futures::stream::FusedStream for NetworkManagerEventStream {
5201    fn is_terminated(&self) -> bool {
5202        self.event_receiver.is_terminated()
5203    }
5204}
5205
5206impl futures::Stream for NetworkManagerEventStream {
5207    type Item = Result<NetworkManagerEvent, fidl::Error>;
5208
5209    fn poll_next(
5210        mut self: std::pin::Pin<&mut Self>,
5211        cx: &mut std::task::Context<'_>,
5212    ) -> std::task::Poll<Option<Self::Item>> {
5213        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5214            &mut self.event_receiver,
5215            cx
5216        )?) {
5217            Some(buf) => std::task::Poll::Ready(Some(NetworkManagerEvent::decode(buf))),
5218            None => std::task::Poll::Ready(None),
5219        }
5220    }
5221}
5222
5223#[derive(Debug)]
5224pub enum NetworkManagerEvent {}
5225
5226impl NetworkManagerEvent {
5227    /// Decodes a message buffer as a [`NetworkManagerEvent`].
5228    fn decode(
5229        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5230    ) -> Result<NetworkManagerEvent, fidl::Error> {
5231        let (bytes, _handles) = buf.split_mut();
5232        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5233        debug_assert_eq!(tx_header.tx_id, 0);
5234        match tx_header.ordinal {
5235            _ => Err(fidl::Error::UnknownOrdinal {
5236                ordinal: tx_header.ordinal,
5237                protocol_name:
5238                    <NetworkManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5239            }),
5240        }
5241    }
5242}
5243
5244/// A Stream of incoming requests for fuchsia.netemul.network/NetworkManager.
5245pub struct NetworkManagerRequestStream {
5246    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5247    is_terminated: bool,
5248}
5249
5250impl std::marker::Unpin for NetworkManagerRequestStream {}
5251
5252impl futures::stream::FusedStream for NetworkManagerRequestStream {
5253    fn is_terminated(&self) -> bool {
5254        self.is_terminated
5255    }
5256}
5257
5258impl fidl::endpoints::RequestStream for NetworkManagerRequestStream {
5259    type Protocol = NetworkManagerMarker;
5260    type ControlHandle = NetworkManagerControlHandle;
5261
5262    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5263        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5264    }
5265
5266    fn control_handle(&self) -> Self::ControlHandle {
5267        NetworkManagerControlHandle { inner: self.inner.clone() }
5268    }
5269
5270    fn into_inner(
5271        self,
5272    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5273    {
5274        (self.inner, self.is_terminated)
5275    }
5276
5277    fn from_inner(
5278        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5279        is_terminated: bool,
5280    ) -> Self {
5281        Self { inner, is_terminated }
5282    }
5283}
5284
5285impl futures::Stream for NetworkManagerRequestStream {
5286    type Item = Result<NetworkManagerRequest, fidl::Error>;
5287
5288    fn poll_next(
5289        mut self: std::pin::Pin<&mut Self>,
5290        cx: &mut std::task::Context<'_>,
5291    ) -> std::task::Poll<Option<Self::Item>> {
5292        let this = &mut *self;
5293        if this.inner.check_shutdown(cx) {
5294            this.is_terminated = true;
5295            return std::task::Poll::Ready(None);
5296        }
5297        if this.is_terminated {
5298            panic!("polled NetworkManagerRequestStream after completion");
5299        }
5300        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5301            |bytes, handles| {
5302                match this.inner.channel().read_etc(cx, bytes, handles) {
5303                    std::task::Poll::Ready(Ok(())) => {}
5304                    std::task::Poll::Pending => return std::task::Poll::Pending,
5305                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5306                        this.is_terminated = true;
5307                        return std::task::Poll::Ready(None);
5308                    }
5309                    std::task::Poll::Ready(Err(e)) => {
5310                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5311                            e.into(),
5312                        ))))
5313                    }
5314                }
5315
5316                // A message has been received from the channel
5317                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5318
5319                std::task::Poll::Ready(Some(match header.ordinal {
5320                    0x2488653e0974cc62 => {
5321                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5322                        let mut req = fidl::new_empty!(
5323                            fidl::encoding::EmptyPayload,
5324                            fidl::encoding::DefaultFuchsiaResourceDialect
5325                        );
5326                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5327                        let control_handle =
5328                            NetworkManagerControlHandle { inner: this.inner.clone() };
5329                        Ok(NetworkManagerRequest::ListNetworks {
5330                            responder: NetworkManagerListNetworksResponder {
5331                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5332                                tx_id: header.tx_id,
5333                            },
5334                        })
5335                    }
5336                    0x6052eb5ac709af => {
5337                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5338                        let mut req = fidl::new_empty!(
5339                            NetworkManagerCreateNetworkRequest,
5340                            fidl::encoding::DefaultFuchsiaResourceDialect
5341                        );
5342                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkManagerCreateNetworkRequest>(&header, _body_bytes, handles, &mut req)?;
5343                        let control_handle =
5344                            NetworkManagerControlHandle { inner: this.inner.clone() };
5345                        Ok(NetworkManagerRequest::CreateNetwork {
5346                            name: req.name,
5347                            config: req.config,
5348
5349                            responder: NetworkManagerCreateNetworkResponder {
5350                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5351                                tx_id: header.tx_id,
5352                            },
5353                        })
5354                    }
5355                    0x59930bf23acc7d9a => {
5356                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5357                        let mut req = fidl::new_empty!(
5358                            NetworkManagerGetNetworkRequest,
5359                            fidl::encoding::DefaultFuchsiaResourceDialect
5360                        );
5361                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkManagerGetNetworkRequest>(&header, _body_bytes, handles, &mut req)?;
5362                        let control_handle =
5363                            NetworkManagerControlHandle { inner: this.inner.clone() };
5364                        Ok(NetworkManagerRequest::GetNetwork {
5365                            name: req.name,
5366
5367                            responder: NetworkManagerGetNetworkResponder {
5368                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5369                                tx_id: header.tx_id,
5370                            },
5371                        })
5372                    }
5373                    _ => Err(fidl::Error::UnknownOrdinal {
5374                        ordinal: header.ordinal,
5375                        protocol_name:
5376                            <NetworkManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5377                    }),
5378                }))
5379            },
5380        )
5381    }
5382}
5383
5384/// Manages virtual networks.
5385#[derive(Debug)]
5386pub enum NetworkManagerRequest {
5387    /// Lists emulated networks by name.
5388    ListNetworks { responder: NetworkManagerListNetworksResponder },
5389    /// Creates a new network with given name and config.
5390    CreateNetwork {
5391        name: String,
5392        config: NetworkConfig,
5393        responder: NetworkManagerCreateNetworkResponder,
5394    },
5395    /// Gets a handle to a network.
5396    GetNetwork { name: String, responder: NetworkManagerGetNetworkResponder },
5397}
5398
5399impl NetworkManagerRequest {
5400    #[allow(irrefutable_let_patterns)]
5401    pub fn into_list_networks(self) -> Option<(NetworkManagerListNetworksResponder)> {
5402        if let NetworkManagerRequest::ListNetworks { responder } = self {
5403            Some((responder))
5404        } else {
5405            None
5406        }
5407    }
5408
5409    #[allow(irrefutable_let_patterns)]
5410    pub fn into_create_network(
5411        self,
5412    ) -> Option<(String, NetworkConfig, NetworkManagerCreateNetworkResponder)> {
5413        if let NetworkManagerRequest::CreateNetwork { name, config, responder } = self {
5414            Some((name, config, responder))
5415        } else {
5416            None
5417        }
5418    }
5419
5420    #[allow(irrefutable_let_patterns)]
5421    pub fn into_get_network(self) -> Option<(String, NetworkManagerGetNetworkResponder)> {
5422        if let NetworkManagerRequest::GetNetwork { name, responder } = self {
5423            Some((name, responder))
5424        } else {
5425            None
5426        }
5427    }
5428
5429    /// Name of the method defined in FIDL
5430    pub fn method_name(&self) -> &'static str {
5431        match *self {
5432            NetworkManagerRequest::ListNetworks { .. } => "list_networks",
5433            NetworkManagerRequest::CreateNetwork { .. } => "create_network",
5434            NetworkManagerRequest::GetNetwork { .. } => "get_network",
5435        }
5436    }
5437}
5438
5439#[derive(Debug, Clone)]
5440pub struct NetworkManagerControlHandle {
5441    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5442}
5443
5444impl fidl::endpoints::ControlHandle for NetworkManagerControlHandle {
5445    fn shutdown(&self) {
5446        self.inner.shutdown()
5447    }
5448    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5449        self.inner.shutdown_with_epitaph(status)
5450    }
5451
5452    fn is_closed(&self) -> bool {
5453        self.inner.channel().is_closed()
5454    }
5455    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5456        self.inner.channel().on_closed()
5457    }
5458
5459    #[cfg(target_os = "fuchsia")]
5460    fn signal_peer(
5461        &self,
5462        clear_mask: zx::Signals,
5463        set_mask: zx::Signals,
5464    ) -> Result<(), zx_status::Status> {
5465        use fidl::Peered;
5466        self.inner.channel().signal_peer(clear_mask, set_mask)
5467    }
5468}
5469
5470impl NetworkManagerControlHandle {}
5471
5472#[must_use = "FIDL methods require a response to be sent"]
5473#[derive(Debug)]
5474pub struct NetworkManagerListNetworksResponder {
5475    control_handle: std::mem::ManuallyDrop<NetworkManagerControlHandle>,
5476    tx_id: u32,
5477}
5478
5479/// Set the the channel to be shutdown (see [`NetworkManagerControlHandle::shutdown`])
5480/// if the responder is dropped without sending a response, so that the client
5481/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5482impl std::ops::Drop for NetworkManagerListNetworksResponder {
5483    fn drop(&mut self) {
5484        self.control_handle.shutdown();
5485        // Safety: drops once, never accessed again
5486        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5487    }
5488}
5489
5490impl fidl::endpoints::Responder for NetworkManagerListNetworksResponder {
5491    type ControlHandle = NetworkManagerControlHandle;
5492
5493    fn control_handle(&self) -> &NetworkManagerControlHandle {
5494        &self.control_handle
5495    }
5496
5497    fn drop_without_shutdown(mut self) {
5498        // Safety: drops once, never accessed again due to mem::forget
5499        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5500        // Prevent Drop from running (which would shut down the channel)
5501        std::mem::forget(self);
5502    }
5503}
5504
5505impl NetworkManagerListNetworksResponder {
5506    /// Sends a response to the FIDL transaction.
5507    ///
5508    /// Sets the channel to shutdown if an error occurs.
5509    pub fn send(self, mut nets: &[String]) -> Result<(), fidl::Error> {
5510        let _result = self.send_raw(nets);
5511        if _result.is_err() {
5512            self.control_handle.shutdown();
5513        }
5514        self.drop_without_shutdown();
5515        _result
5516    }
5517
5518    /// Similar to "send" but does not shutdown the channel if an error occurs.
5519    pub fn send_no_shutdown_on_err(self, mut nets: &[String]) -> Result<(), fidl::Error> {
5520        let _result = self.send_raw(nets);
5521        self.drop_without_shutdown();
5522        _result
5523    }
5524
5525    fn send_raw(&self, mut nets: &[String]) -> Result<(), fidl::Error> {
5526        self.control_handle.inner.send::<NetworkManagerListNetworksResponse>(
5527            (nets,),
5528            self.tx_id,
5529            0x2488653e0974cc62,
5530            fidl::encoding::DynamicFlags::empty(),
5531        )
5532    }
5533}
5534
5535#[must_use = "FIDL methods require a response to be sent"]
5536#[derive(Debug)]
5537pub struct NetworkManagerCreateNetworkResponder {
5538    control_handle: std::mem::ManuallyDrop<NetworkManagerControlHandle>,
5539    tx_id: u32,
5540}
5541
5542/// Set the the channel to be shutdown (see [`NetworkManagerControlHandle::shutdown`])
5543/// if the responder is dropped without sending a response, so that the client
5544/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5545impl std::ops::Drop for NetworkManagerCreateNetworkResponder {
5546    fn drop(&mut self) {
5547        self.control_handle.shutdown();
5548        // Safety: drops once, never accessed again
5549        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5550    }
5551}
5552
5553impl fidl::endpoints::Responder for NetworkManagerCreateNetworkResponder {
5554    type ControlHandle = NetworkManagerControlHandle;
5555
5556    fn control_handle(&self) -> &NetworkManagerControlHandle {
5557        &self.control_handle
5558    }
5559
5560    fn drop_without_shutdown(mut self) {
5561        // Safety: drops once, never accessed again due to mem::forget
5562        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5563        // Prevent Drop from running (which would shut down the channel)
5564        std::mem::forget(self);
5565    }
5566}
5567
5568impl NetworkManagerCreateNetworkResponder {
5569    /// Sends a response to the FIDL transaction.
5570    ///
5571    /// Sets the channel to shutdown if an error occurs.
5572    pub fn send(
5573        self,
5574        mut status: i32,
5575        mut net: Option<fidl::endpoints::ClientEnd<NetworkMarker>>,
5576    ) -> Result<(), fidl::Error> {
5577        let _result = self.send_raw(status, net);
5578        if _result.is_err() {
5579            self.control_handle.shutdown();
5580        }
5581        self.drop_without_shutdown();
5582        _result
5583    }
5584
5585    /// Similar to "send" but does not shutdown the channel if an error occurs.
5586    pub fn send_no_shutdown_on_err(
5587        self,
5588        mut status: i32,
5589        mut net: Option<fidl::endpoints::ClientEnd<NetworkMarker>>,
5590    ) -> Result<(), fidl::Error> {
5591        let _result = self.send_raw(status, net);
5592        self.drop_without_shutdown();
5593        _result
5594    }
5595
5596    fn send_raw(
5597        &self,
5598        mut status: i32,
5599        mut net: Option<fidl::endpoints::ClientEnd<NetworkMarker>>,
5600    ) -> Result<(), fidl::Error> {
5601        self.control_handle.inner.send::<NetworkManagerCreateNetworkResponse>(
5602            (status, net),
5603            self.tx_id,
5604            0x6052eb5ac709af,
5605            fidl::encoding::DynamicFlags::empty(),
5606        )
5607    }
5608}
5609
5610#[must_use = "FIDL methods require a response to be sent"]
5611#[derive(Debug)]
5612pub struct NetworkManagerGetNetworkResponder {
5613    control_handle: std::mem::ManuallyDrop<NetworkManagerControlHandle>,
5614    tx_id: u32,
5615}
5616
5617/// Set the the channel to be shutdown (see [`NetworkManagerControlHandle::shutdown`])
5618/// if the responder is dropped without sending a response, so that the client
5619/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5620impl std::ops::Drop for NetworkManagerGetNetworkResponder {
5621    fn drop(&mut self) {
5622        self.control_handle.shutdown();
5623        // Safety: drops once, never accessed again
5624        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5625    }
5626}
5627
5628impl fidl::endpoints::Responder for NetworkManagerGetNetworkResponder {
5629    type ControlHandle = NetworkManagerControlHandle;
5630
5631    fn control_handle(&self) -> &NetworkManagerControlHandle {
5632        &self.control_handle
5633    }
5634
5635    fn drop_without_shutdown(mut self) {
5636        // Safety: drops once, never accessed again due to mem::forget
5637        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5638        // Prevent Drop from running (which would shut down the channel)
5639        std::mem::forget(self);
5640    }
5641}
5642
5643impl NetworkManagerGetNetworkResponder {
5644    /// Sends a response to the FIDL transaction.
5645    ///
5646    /// Sets the channel to shutdown if an error occurs.
5647    pub fn send(
5648        self,
5649        mut net: Option<fidl::endpoints::ClientEnd<NetworkMarker>>,
5650    ) -> Result<(), fidl::Error> {
5651        let _result = self.send_raw(net);
5652        if _result.is_err() {
5653            self.control_handle.shutdown();
5654        }
5655        self.drop_without_shutdown();
5656        _result
5657    }
5658
5659    /// Similar to "send" but does not shutdown the channel if an error occurs.
5660    pub fn send_no_shutdown_on_err(
5661        self,
5662        mut net: Option<fidl::endpoints::ClientEnd<NetworkMarker>>,
5663    ) -> Result<(), fidl::Error> {
5664        let _result = self.send_raw(net);
5665        self.drop_without_shutdown();
5666        _result
5667    }
5668
5669    fn send_raw(
5670        &self,
5671        mut net: Option<fidl::endpoints::ClientEnd<NetworkMarker>>,
5672    ) -> Result<(), fidl::Error> {
5673        self.control_handle.inner.send::<NetworkManagerGetNetworkResponse>(
5674            (net,),
5675            self.tx_id,
5676            0x59930bf23acc7d9a,
5677            fidl::encoding::DynamicFlags::empty(),
5678        )
5679    }
5680}
5681
5682#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5683pub struct SetupHandleMarker;
5684
5685impl fidl::endpoints::ProtocolMarker for SetupHandleMarker {
5686    type Proxy = SetupHandleProxy;
5687    type RequestStream = SetupHandleRequestStream;
5688    #[cfg(target_os = "fuchsia")]
5689    type SynchronousProxy = SetupHandleSynchronousProxy;
5690
5691    const DEBUG_NAME: &'static str = "(anonymous) SetupHandle";
5692}
5693
5694pub trait SetupHandleProxyInterface: Send + Sync {}
5695#[derive(Debug)]
5696#[cfg(target_os = "fuchsia")]
5697pub struct SetupHandleSynchronousProxy {
5698    client: fidl::client::sync::Client,
5699}
5700
5701#[cfg(target_os = "fuchsia")]
5702impl fidl::endpoints::SynchronousProxy for SetupHandleSynchronousProxy {
5703    type Proxy = SetupHandleProxy;
5704    type Protocol = SetupHandleMarker;
5705
5706    fn from_channel(inner: fidl::Channel) -> Self {
5707        Self::new(inner)
5708    }
5709
5710    fn into_channel(self) -> fidl::Channel {
5711        self.client.into_channel()
5712    }
5713
5714    fn as_channel(&self) -> &fidl::Channel {
5715        self.client.as_channel()
5716    }
5717}
5718
5719#[cfg(target_os = "fuchsia")]
5720impl SetupHandleSynchronousProxy {
5721    pub fn new(channel: fidl::Channel) -> Self {
5722        let protocol_name = <SetupHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5723        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5724    }
5725
5726    pub fn into_channel(self) -> fidl::Channel {
5727        self.client.into_channel()
5728    }
5729
5730    /// Waits until an event arrives and returns it. It is safe for other
5731    /// threads to make concurrent requests while waiting for an event.
5732    pub fn wait_for_event(
5733        &self,
5734        deadline: zx::MonotonicInstant,
5735    ) -> Result<SetupHandleEvent, fidl::Error> {
5736        SetupHandleEvent::decode(self.client.wait_for_event(deadline)?)
5737    }
5738}
5739
5740#[cfg(target_os = "fuchsia")]
5741impl From<SetupHandleSynchronousProxy> for zx::Handle {
5742    fn from(value: SetupHandleSynchronousProxy) -> Self {
5743        value.into_channel().into()
5744    }
5745}
5746
5747#[cfg(target_os = "fuchsia")]
5748impl From<fidl::Channel> for SetupHandleSynchronousProxy {
5749    fn from(value: fidl::Channel) -> Self {
5750        Self::new(value)
5751    }
5752}
5753
5754#[derive(Debug, Clone)]
5755pub struct SetupHandleProxy {
5756    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5757}
5758
5759impl fidl::endpoints::Proxy for SetupHandleProxy {
5760    type Protocol = SetupHandleMarker;
5761
5762    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5763        Self::new(inner)
5764    }
5765
5766    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5767        self.client.into_channel().map_err(|client| Self { client })
5768    }
5769
5770    fn as_channel(&self) -> &::fidl::AsyncChannel {
5771        self.client.as_channel()
5772    }
5773}
5774
5775impl SetupHandleProxy {
5776    /// Create a new Proxy for fuchsia.netemul.network/SetupHandle.
5777    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5778        let protocol_name = <SetupHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5779        Self { client: fidl::client::Client::new(channel, protocol_name) }
5780    }
5781
5782    /// Get a Stream of events from the remote end of the protocol.
5783    ///
5784    /// # Panics
5785    ///
5786    /// Panics if the event stream was already taken.
5787    pub fn take_event_stream(&self) -> SetupHandleEventStream {
5788        SetupHandleEventStream { event_receiver: self.client.take_event_receiver() }
5789    }
5790}
5791
5792impl SetupHandleProxyInterface for SetupHandleProxy {}
5793
5794pub struct SetupHandleEventStream {
5795    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5796}
5797
5798impl std::marker::Unpin for SetupHandleEventStream {}
5799
5800impl futures::stream::FusedStream for SetupHandleEventStream {
5801    fn is_terminated(&self) -> bool {
5802        self.event_receiver.is_terminated()
5803    }
5804}
5805
5806impl futures::Stream for SetupHandleEventStream {
5807    type Item = Result<SetupHandleEvent, fidl::Error>;
5808
5809    fn poll_next(
5810        mut self: std::pin::Pin<&mut Self>,
5811        cx: &mut std::task::Context<'_>,
5812    ) -> std::task::Poll<Option<Self::Item>> {
5813        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5814            &mut self.event_receiver,
5815            cx
5816        )?) {
5817            Some(buf) => std::task::Poll::Ready(Some(SetupHandleEvent::decode(buf))),
5818            None => std::task::Poll::Ready(None),
5819        }
5820    }
5821}
5822
5823#[derive(Debug)]
5824pub enum SetupHandleEvent {}
5825
5826impl SetupHandleEvent {
5827    /// Decodes a message buffer as a [`SetupHandleEvent`].
5828    fn decode(
5829        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5830    ) -> Result<SetupHandleEvent, fidl::Error> {
5831        let (bytes, _handles) = buf.split_mut();
5832        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5833        debug_assert_eq!(tx_header.tx_id, 0);
5834        match tx_header.ordinal {
5835            _ => Err(fidl::Error::UnknownOrdinal {
5836                ordinal: tx_header.ordinal,
5837                protocol_name: <SetupHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5838            }),
5839        }
5840    }
5841}
5842
5843/// A Stream of incoming requests for fuchsia.netemul.network/SetupHandle.
5844pub struct SetupHandleRequestStream {
5845    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5846    is_terminated: bool,
5847}
5848
5849impl std::marker::Unpin for SetupHandleRequestStream {}
5850
5851impl futures::stream::FusedStream for SetupHandleRequestStream {
5852    fn is_terminated(&self) -> bool {
5853        self.is_terminated
5854    }
5855}
5856
5857impl fidl::endpoints::RequestStream for SetupHandleRequestStream {
5858    type Protocol = SetupHandleMarker;
5859    type ControlHandle = SetupHandleControlHandle;
5860
5861    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5862        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5863    }
5864
5865    fn control_handle(&self) -> Self::ControlHandle {
5866        SetupHandleControlHandle { inner: self.inner.clone() }
5867    }
5868
5869    fn into_inner(
5870        self,
5871    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5872    {
5873        (self.inner, self.is_terminated)
5874    }
5875
5876    fn from_inner(
5877        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5878        is_terminated: bool,
5879    ) -> Self {
5880        Self { inner, is_terminated }
5881    }
5882}
5883
5884impl futures::Stream for SetupHandleRequestStream {
5885    type Item = Result<SetupHandleRequest, fidl::Error>;
5886
5887    fn poll_next(
5888        mut self: std::pin::Pin<&mut Self>,
5889        cx: &mut std::task::Context<'_>,
5890    ) -> std::task::Poll<Option<Self::Item>> {
5891        let this = &mut *self;
5892        if this.inner.check_shutdown(cx) {
5893            this.is_terminated = true;
5894            return std::task::Poll::Ready(None);
5895        }
5896        if this.is_terminated {
5897            panic!("polled SetupHandleRequestStream after completion");
5898        }
5899        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5900            |bytes, handles| {
5901                match this.inner.channel().read_etc(cx, bytes, handles) {
5902                    std::task::Poll::Ready(Ok(())) => {}
5903                    std::task::Poll::Pending => return std::task::Poll::Pending,
5904                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5905                        this.is_terminated = true;
5906                        return std::task::Poll::Ready(None);
5907                    }
5908                    std::task::Poll::Ready(Err(e)) => {
5909                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5910                            e.into(),
5911                        ))))
5912                    }
5913                }
5914
5915                // A message has been received from the channel
5916                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5917
5918                std::task::Poll::Ready(Some(match header.ordinal {
5919                    _ => Err(fidl::Error::UnknownOrdinal {
5920                        ordinal: header.ordinal,
5921                        protocol_name:
5922                            <SetupHandleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5923                    }),
5924                }))
5925            },
5926        )
5927    }
5928}
5929
5930/// Handle returned when using NetworkContext.Setup for quick network configuration.
5931/// Networks and endpoints created by Setup are tied to the lifecycle of the SetupHandle's channel.
5932#[derive(Debug)]
5933pub enum SetupHandleRequest {}
5934
5935impl SetupHandleRequest {
5936    /// Name of the method defined in FIDL
5937    pub fn method_name(&self) -> &'static str {
5938        match *self {}
5939    }
5940}
5941
5942#[derive(Debug, Clone)]
5943pub struct SetupHandleControlHandle {
5944    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5945}
5946
5947impl fidl::endpoints::ControlHandle for SetupHandleControlHandle {
5948    fn shutdown(&self) {
5949        self.inner.shutdown()
5950    }
5951    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5952        self.inner.shutdown_with_epitaph(status)
5953    }
5954
5955    fn is_closed(&self) -> bool {
5956        self.inner.channel().is_closed()
5957    }
5958    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5959        self.inner.channel().on_closed()
5960    }
5961
5962    #[cfg(target_os = "fuchsia")]
5963    fn signal_peer(
5964        &self,
5965        clear_mask: zx::Signals,
5966        set_mask: zx::Signals,
5967    ) -> Result<(), zx_status::Status> {
5968        use fidl::Peered;
5969        self.inner.channel().signal_peer(clear_mask, set_mask)
5970    }
5971}
5972
5973impl SetupHandleControlHandle {}
5974
5975mod internal {
5976    use super::*;
5977
5978    impl fidl::encoding::ResourceTypeMarker for DeviceProxyServeControllerRequest {
5979        type Borrowed<'a> = &'a mut Self;
5980        fn take_or_borrow<'a>(
5981            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5982        ) -> Self::Borrowed<'a> {
5983            value
5984        }
5985    }
5986
5987    unsafe impl fidl::encoding::TypeMarker for DeviceProxyServeControllerRequest {
5988        type Owned = Self;
5989
5990        #[inline(always)]
5991        fn inline_align(_context: fidl::encoding::Context) -> usize {
5992            4
5993        }
5994
5995        #[inline(always)]
5996        fn inline_size(_context: fidl::encoding::Context) -> usize {
5997            4
5998        }
5999    }
6000
6001    unsafe impl
6002        fidl::encoding::Encode<
6003            DeviceProxyServeControllerRequest,
6004            fidl::encoding::DefaultFuchsiaResourceDialect,
6005        > for &mut DeviceProxyServeControllerRequest
6006    {
6007        #[inline]
6008        unsafe fn encode(
6009            self,
6010            encoder: &mut fidl::encoding::Encoder<
6011                '_,
6012                fidl::encoding::DefaultFuchsiaResourceDialect,
6013            >,
6014            offset: usize,
6015            _depth: fidl::encoding::Depth,
6016        ) -> fidl::Result<()> {
6017            encoder.debug_check_bounds::<DeviceProxyServeControllerRequest>(offset);
6018            // Delegate to tuple encoding.
6019            fidl::encoding::Encode::<
6020                DeviceProxyServeControllerRequest,
6021                fidl::encoding::DefaultFuchsiaResourceDialect,
6022            >::encode(
6023                (<fidl::encoding::Endpoint<
6024                    fidl::endpoints::ServerEnd<fidl_fuchsia_device::ControllerMarker>,
6025                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6026                    &mut self.req
6027                ),),
6028                encoder,
6029                offset,
6030                _depth,
6031            )
6032        }
6033    }
6034    unsafe impl<
6035            T0: fidl::encoding::Encode<
6036                fidl::encoding::Endpoint<
6037                    fidl::endpoints::ServerEnd<fidl_fuchsia_device::ControllerMarker>,
6038                >,
6039                fidl::encoding::DefaultFuchsiaResourceDialect,
6040            >,
6041        >
6042        fidl::encoding::Encode<
6043            DeviceProxyServeControllerRequest,
6044            fidl::encoding::DefaultFuchsiaResourceDialect,
6045        > for (T0,)
6046    {
6047        #[inline]
6048        unsafe fn encode(
6049            self,
6050            encoder: &mut fidl::encoding::Encoder<
6051                '_,
6052                fidl::encoding::DefaultFuchsiaResourceDialect,
6053            >,
6054            offset: usize,
6055            depth: fidl::encoding::Depth,
6056        ) -> fidl::Result<()> {
6057            encoder.debug_check_bounds::<DeviceProxyServeControllerRequest>(offset);
6058            // Zero out padding regions. There's no need to apply masks
6059            // because the unmasked parts will be overwritten by fields.
6060            // Write the fields.
6061            self.0.encode(encoder, offset + 0, depth)?;
6062            Ok(())
6063        }
6064    }
6065
6066    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6067        for DeviceProxyServeControllerRequest
6068    {
6069        #[inline(always)]
6070        fn new_empty() -> Self {
6071            Self {
6072                req: fidl::new_empty!(
6073                    fidl::encoding::Endpoint<
6074                        fidl::endpoints::ServerEnd<fidl_fuchsia_device::ControllerMarker>,
6075                    >,
6076                    fidl::encoding::DefaultFuchsiaResourceDialect
6077                ),
6078            }
6079        }
6080
6081        #[inline]
6082        unsafe fn decode(
6083            &mut self,
6084            decoder: &mut fidl::encoding::Decoder<
6085                '_,
6086                fidl::encoding::DefaultFuchsiaResourceDialect,
6087            >,
6088            offset: usize,
6089            _depth: fidl::encoding::Depth,
6090        ) -> fidl::Result<()> {
6091            decoder.debug_check_bounds::<Self>(offset);
6092            // Verify that padding bytes are zero.
6093            fidl::decode!(
6094                fidl::encoding::Endpoint<
6095                    fidl::endpoints::ServerEnd<fidl_fuchsia_device::ControllerMarker>,
6096                >,
6097                fidl::encoding::DefaultFuchsiaResourceDialect,
6098                &mut self.req,
6099                decoder,
6100                offset + 0,
6101                _depth
6102            )?;
6103            Ok(())
6104        }
6105    }
6106
6107    impl fidl::encoding::ResourceTypeMarker for DeviceProxyServeDeviceRequest {
6108        type Borrowed<'a> = &'a mut Self;
6109        fn take_or_borrow<'a>(
6110            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6111        ) -> Self::Borrowed<'a> {
6112            value
6113        }
6114    }
6115
6116    unsafe impl fidl::encoding::TypeMarker for DeviceProxyServeDeviceRequest {
6117        type Owned = Self;
6118
6119        #[inline(always)]
6120        fn inline_align(_context: fidl::encoding::Context) -> usize {
6121            4
6122        }
6123
6124        #[inline(always)]
6125        fn inline_size(_context: fidl::encoding::Context) -> usize {
6126            4
6127        }
6128    }
6129
6130    unsafe impl
6131        fidl::encoding::Encode<
6132            DeviceProxyServeDeviceRequest,
6133            fidl::encoding::DefaultFuchsiaResourceDialect,
6134        > for &mut DeviceProxyServeDeviceRequest
6135    {
6136        #[inline]
6137        unsafe fn encode(
6138            self,
6139            encoder: &mut fidl::encoding::Encoder<
6140                '_,
6141                fidl::encoding::DefaultFuchsiaResourceDialect,
6142            >,
6143            offset: usize,
6144            _depth: fidl::encoding::Depth,
6145        ) -> fidl::Result<()> {
6146            encoder.debug_check_bounds::<DeviceProxyServeDeviceRequest>(offset);
6147            // Delegate to tuple encoding.
6148            fidl::encoding::Encode::<
6149                DeviceProxyServeDeviceRequest,
6150                fidl::encoding::DefaultFuchsiaResourceDialect,
6151            >::encode(
6152                (<fidl::encoding::Endpoint<
6153                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceInstanceMarker>,
6154                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6155                    &mut self.req
6156                ),),
6157                encoder,
6158                offset,
6159                _depth,
6160            )
6161        }
6162    }
6163    unsafe impl<
6164            T0: fidl::encoding::Encode<
6165                fidl::encoding::Endpoint<
6166                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceInstanceMarker>,
6167                >,
6168                fidl::encoding::DefaultFuchsiaResourceDialect,
6169            >,
6170        >
6171        fidl::encoding::Encode<
6172            DeviceProxyServeDeviceRequest,
6173            fidl::encoding::DefaultFuchsiaResourceDialect,
6174        > for (T0,)
6175    {
6176        #[inline]
6177        unsafe fn encode(
6178            self,
6179            encoder: &mut fidl::encoding::Encoder<
6180                '_,
6181                fidl::encoding::DefaultFuchsiaResourceDialect,
6182            >,
6183            offset: usize,
6184            depth: fidl::encoding::Depth,
6185        ) -> fidl::Result<()> {
6186            encoder.debug_check_bounds::<DeviceProxyServeDeviceRequest>(offset);
6187            // Zero out padding regions. There's no need to apply masks
6188            // because the unmasked parts will be overwritten by fields.
6189            // Write the fields.
6190            self.0.encode(encoder, offset + 0, depth)?;
6191            Ok(())
6192        }
6193    }
6194
6195    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6196        for DeviceProxyServeDeviceRequest
6197    {
6198        #[inline(always)]
6199        fn new_empty() -> Self {
6200            Self {
6201                req: fidl::new_empty!(
6202                    fidl::encoding::Endpoint<
6203                        fidl::endpoints::ServerEnd<
6204                            fidl_fuchsia_hardware_network::DeviceInstanceMarker,
6205                        >,
6206                    >,
6207                    fidl::encoding::DefaultFuchsiaResourceDialect
6208                ),
6209            }
6210        }
6211
6212        #[inline]
6213        unsafe fn decode(
6214            &mut self,
6215            decoder: &mut fidl::encoding::Decoder<
6216                '_,
6217                fidl::encoding::DefaultFuchsiaResourceDialect,
6218            >,
6219            offset: usize,
6220            _depth: fidl::encoding::Depth,
6221        ) -> fidl::Result<()> {
6222            decoder.debug_check_bounds::<Self>(offset);
6223            // Verify that padding bytes are zero.
6224            fidl::decode!(
6225                fidl::encoding::Endpoint<
6226                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::DeviceInstanceMarker>,
6227                >,
6228                fidl::encoding::DefaultFuchsiaResourceDialect,
6229                &mut self.req,
6230                decoder,
6231                offset + 0,
6232                _depth
6233            )?;
6234            Ok(())
6235        }
6236    }
6237
6238    impl fidl::encoding::ResourceTypeMarker for EndpointGetPortRequest {
6239        type Borrowed<'a> = &'a mut Self;
6240        fn take_or_borrow<'a>(
6241            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6242        ) -> Self::Borrowed<'a> {
6243            value
6244        }
6245    }
6246
6247    unsafe impl fidl::encoding::TypeMarker for EndpointGetPortRequest {
6248        type Owned = Self;
6249
6250        #[inline(always)]
6251        fn inline_align(_context: fidl::encoding::Context) -> usize {
6252            4
6253        }
6254
6255        #[inline(always)]
6256        fn inline_size(_context: fidl::encoding::Context) -> usize {
6257            4
6258        }
6259    }
6260
6261    unsafe impl
6262        fidl::encoding::Encode<
6263            EndpointGetPortRequest,
6264            fidl::encoding::DefaultFuchsiaResourceDialect,
6265        > for &mut EndpointGetPortRequest
6266    {
6267        #[inline]
6268        unsafe fn encode(
6269            self,
6270            encoder: &mut fidl::encoding::Encoder<
6271                '_,
6272                fidl::encoding::DefaultFuchsiaResourceDialect,
6273            >,
6274            offset: usize,
6275            _depth: fidl::encoding::Depth,
6276        ) -> fidl::Result<()> {
6277            encoder.debug_check_bounds::<EndpointGetPortRequest>(offset);
6278            // Delegate to tuple encoding.
6279            fidl::encoding::Encode::<
6280                EndpointGetPortRequest,
6281                fidl::encoding::DefaultFuchsiaResourceDialect,
6282            >::encode(
6283                (<fidl::encoding::Endpoint<
6284                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
6285                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6286                    &mut self.port
6287                ),),
6288                encoder,
6289                offset,
6290                _depth,
6291            )
6292        }
6293    }
6294    unsafe impl<
6295            T0: fidl::encoding::Encode<
6296                fidl::encoding::Endpoint<
6297                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
6298                >,
6299                fidl::encoding::DefaultFuchsiaResourceDialect,
6300            >,
6301        >
6302        fidl::encoding::Encode<
6303            EndpointGetPortRequest,
6304            fidl::encoding::DefaultFuchsiaResourceDialect,
6305        > for (T0,)
6306    {
6307        #[inline]
6308        unsafe fn encode(
6309            self,
6310            encoder: &mut fidl::encoding::Encoder<
6311                '_,
6312                fidl::encoding::DefaultFuchsiaResourceDialect,
6313            >,
6314            offset: usize,
6315            depth: fidl::encoding::Depth,
6316        ) -> fidl::Result<()> {
6317            encoder.debug_check_bounds::<EndpointGetPortRequest>(offset);
6318            // Zero out padding regions. There's no need to apply masks
6319            // because the unmasked parts will be overwritten by fields.
6320            // Write the fields.
6321            self.0.encode(encoder, offset + 0, depth)?;
6322            Ok(())
6323        }
6324    }
6325
6326    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6327        for EndpointGetPortRequest
6328    {
6329        #[inline(always)]
6330        fn new_empty() -> Self {
6331            Self {
6332                port: fidl::new_empty!(
6333                    fidl::encoding::Endpoint<
6334                        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
6335                    >,
6336                    fidl::encoding::DefaultFuchsiaResourceDialect
6337                ),
6338            }
6339        }
6340
6341        #[inline]
6342        unsafe fn decode(
6343            &mut self,
6344            decoder: &mut fidl::encoding::Decoder<
6345                '_,
6346                fidl::encoding::DefaultFuchsiaResourceDialect,
6347            >,
6348            offset: usize,
6349            _depth: fidl::encoding::Depth,
6350        ) -> fidl::Result<()> {
6351            decoder.debug_check_bounds::<Self>(offset);
6352            // Verify that padding bytes are zero.
6353            fidl::decode!(
6354                fidl::encoding::Endpoint<
6355                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_network::PortMarker>,
6356                >,
6357                fidl::encoding::DefaultFuchsiaResourceDialect,
6358                &mut self.port,
6359                decoder,
6360                offset + 0,
6361                _depth
6362            )?;
6363            Ok(())
6364        }
6365    }
6366
6367    impl fidl::encoding::ResourceTypeMarker for EndpointGetProxyRequest {
6368        type Borrowed<'a> = &'a mut Self;
6369        fn take_or_borrow<'a>(
6370            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6371        ) -> Self::Borrowed<'a> {
6372            value
6373        }
6374    }
6375
6376    unsafe impl fidl::encoding::TypeMarker for EndpointGetProxyRequest {
6377        type Owned = Self;
6378
6379        #[inline(always)]
6380        fn inline_align(_context: fidl::encoding::Context) -> usize {
6381            4
6382        }
6383
6384        #[inline(always)]
6385        fn inline_size(_context: fidl::encoding::Context) -> usize {
6386            4
6387        }
6388    }
6389
6390    unsafe impl
6391        fidl::encoding::Encode<
6392            EndpointGetProxyRequest,
6393            fidl::encoding::DefaultFuchsiaResourceDialect,
6394        > for &mut EndpointGetProxyRequest
6395    {
6396        #[inline]
6397        unsafe fn encode(
6398            self,
6399            encoder: &mut fidl::encoding::Encoder<
6400                '_,
6401                fidl::encoding::DefaultFuchsiaResourceDialect,
6402            >,
6403            offset: usize,
6404            _depth: fidl::encoding::Depth,
6405        ) -> fidl::Result<()> {
6406            encoder.debug_check_bounds::<EndpointGetProxyRequest>(offset);
6407            // Delegate to tuple encoding.
6408            fidl::encoding::Encode::<EndpointGetProxyRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6409                (
6410                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceProxy_Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.proxy),
6411                ),
6412                encoder, offset, _depth
6413            )
6414        }
6415    }
6416    unsafe impl<
6417            T0: fidl::encoding::Encode<
6418                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceProxy_Marker>>,
6419                fidl::encoding::DefaultFuchsiaResourceDialect,
6420            >,
6421        >
6422        fidl::encoding::Encode<
6423            EndpointGetProxyRequest,
6424            fidl::encoding::DefaultFuchsiaResourceDialect,
6425        > for (T0,)
6426    {
6427        #[inline]
6428        unsafe fn encode(
6429            self,
6430            encoder: &mut fidl::encoding::Encoder<
6431                '_,
6432                fidl::encoding::DefaultFuchsiaResourceDialect,
6433            >,
6434            offset: usize,
6435            depth: fidl::encoding::Depth,
6436        ) -> fidl::Result<()> {
6437            encoder.debug_check_bounds::<EndpointGetProxyRequest>(offset);
6438            // Zero out padding regions. There's no need to apply masks
6439            // because the unmasked parts will be overwritten by fields.
6440            // Write the fields.
6441            self.0.encode(encoder, offset + 0, depth)?;
6442            Ok(())
6443        }
6444    }
6445
6446    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6447        for EndpointGetProxyRequest
6448    {
6449        #[inline(always)]
6450        fn new_empty() -> Self {
6451            Self {
6452                proxy: fidl::new_empty!(
6453                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceProxy_Marker>>,
6454                    fidl::encoding::DefaultFuchsiaResourceDialect
6455                ),
6456            }
6457        }
6458
6459        #[inline]
6460        unsafe fn decode(
6461            &mut self,
6462            decoder: &mut fidl::encoding::Decoder<
6463                '_,
6464                fidl::encoding::DefaultFuchsiaResourceDialect,
6465            >,
6466            offset: usize,
6467            _depth: fidl::encoding::Depth,
6468        ) -> fidl::Result<()> {
6469            decoder.debug_check_bounds::<Self>(offset);
6470            // Verify that padding bytes are zero.
6471            fidl::decode!(
6472                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceProxy_Marker>>,
6473                fidl::encoding::DefaultFuchsiaResourceDialect,
6474                &mut self.proxy,
6475                decoder,
6476                offset + 0,
6477                _depth
6478            )?;
6479            Ok(())
6480        }
6481    }
6482
6483    impl fidl::encoding::ResourceTypeMarker for EndpointManagerCreateEndpointResponse {
6484        type Borrowed<'a> = &'a mut Self;
6485        fn take_or_borrow<'a>(
6486            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6487        ) -> Self::Borrowed<'a> {
6488            value
6489        }
6490    }
6491
6492    unsafe impl fidl::encoding::TypeMarker for EndpointManagerCreateEndpointResponse {
6493        type Owned = Self;
6494
6495        #[inline(always)]
6496        fn inline_align(_context: fidl::encoding::Context) -> usize {
6497            4
6498        }
6499
6500        #[inline(always)]
6501        fn inline_size(_context: fidl::encoding::Context) -> usize {
6502            8
6503        }
6504    }
6505
6506    unsafe impl
6507        fidl::encoding::Encode<
6508            EndpointManagerCreateEndpointResponse,
6509            fidl::encoding::DefaultFuchsiaResourceDialect,
6510        > for &mut EndpointManagerCreateEndpointResponse
6511    {
6512        #[inline]
6513        unsafe fn encode(
6514            self,
6515            encoder: &mut fidl::encoding::Encoder<
6516                '_,
6517                fidl::encoding::DefaultFuchsiaResourceDialect,
6518            >,
6519            offset: usize,
6520            _depth: fidl::encoding::Depth,
6521        ) -> fidl::Result<()> {
6522            encoder.debug_check_bounds::<EndpointManagerCreateEndpointResponse>(offset);
6523            // Delegate to tuple encoding.
6524            fidl::encoding::Encode::<
6525                EndpointManagerCreateEndpointResponse,
6526                fidl::encoding::DefaultFuchsiaResourceDialect,
6527            >::encode(
6528                (
6529                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
6530                    <fidl::encoding::Optional<
6531                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<EndpointMarker>>,
6532                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6533                        &mut self.endpoint
6534                    ),
6535                ),
6536                encoder,
6537                offset,
6538                _depth,
6539            )
6540        }
6541    }
6542    unsafe impl<
6543            T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
6544            T1: fidl::encoding::Encode<
6545                fidl::encoding::Optional<
6546                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<EndpointMarker>>,
6547                >,
6548                fidl::encoding::DefaultFuchsiaResourceDialect,
6549            >,
6550        >
6551        fidl::encoding::Encode<
6552            EndpointManagerCreateEndpointResponse,
6553            fidl::encoding::DefaultFuchsiaResourceDialect,
6554        > for (T0, T1)
6555    {
6556        #[inline]
6557        unsafe fn encode(
6558            self,
6559            encoder: &mut fidl::encoding::Encoder<
6560                '_,
6561                fidl::encoding::DefaultFuchsiaResourceDialect,
6562            >,
6563            offset: usize,
6564            depth: fidl::encoding::Depth,
6565        ) -> fidl::Result<()> {
6566            encoder.debug_check_bounds::<EndpointManagerCreateEndpointResponse>(offset);
6567            // Zero out padding regions. There's no need to apply masks
6568            // because the unmasked parts will be overwritten by fields.
6569            // Write the fields.
6570            self.0.encode(encoder, offset + 0, depth)?;
6571            self.1.encode(encoder, offset + 4, depth)?;
6572            Ok(())
6573        }
6574    }
6575
6576    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6577        for EndpointManagerCreateEndpointResponse
6578    {
6579        #[inline(always)]
6580        fn new_empty() -> Self {
6581            Self {
6582                status: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
6583                endpoint: fidl::new_empty!(
6584                    fidl::encoding::Optional<
6585                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<EndpointMarker>>,
6586                    >,
6587                    fidl::encoding::DefaultFuchsiaResourceDialect
6588                ),
6589            }
6590        }
6591
6592        #[inline]
6593        unsafe fn decode(
6594            &mut self,
6595            decoder: &mut fidl::encoding::Decoder<
6596                '_,
6597                fidl::encoding::DefaultFuchsiaResourceDialect,
6598            >,
6599            offset: usize,
6600            _depth: fidl::encoding::Depth,
6601        ) -> fidl::Result<()> {
6602            decoder.debug_check_bounds::<Self>(offset);
6603            // Verify that padding bytes are zero.
6604            fidl::decode!(
6605                i32,
6606                fidl::encoding::DefaultFuchsiaResourceDialect,
6607                &mut self.status,
6608                decoder,
6609                offset + 0,
6610                _depth
6611            )?;
6612            fidl::decode!(
6613                fidl::encoding::Optional<
6614                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<EndpointMarker>>,
6615                >,
6616                fidl::encoding::DefaultFuchsiaResourceDialect,
6617                &mut self.endpoint,
6618                decoder,
6619                offset + 4,
6620                _depth
6621            )?;
6622            Ok(())
6623        }
6624    }
6625
6626    impl fidl::encoding::ResourceTypeMarker for EndpointManagerGetEndpointResponse {
6627        type Borrowed<'a> = &'a mut Self;
6628        fn take_or_borrow<'a>(
6629            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6630        ) -> Self::Borrowed<'a> {
6631            value
6632        }
6633    }
6634
6635    unsafe impl fidl::encoding::TypeMarker for EndpointManagerGetEndpointResponse {
6636        type Owned = Self;
6637
6638        #[inline(always)]
6639        fn inline_align(_context: fidl::encoding::Context) -> usize {
6640            4
6641        }
6642
6643        #[inline(always)]
6644        fn inline_size(_context: fidl::encoding::Context) -> usize {
6645            4
6646        }
6647    }
6648
6649    unsafe impl
6650        fidl::encoding::Encode<
6651            EndpointManagerGetEndpointResponse,
6652            fidl::encoding::DefaultFuchsiaResourceDialect,
6653        > for &mut EndpointManagerGetEndpointResponse
6654    {
6655        #[inline]
6656        unsafe fn encode(
6657            self,
6658            encoder: &mut fidl::encoding::Encoder<
6659                '_,
6660                fidl::encoding::DefaultFuchsiaResourceDialect,
6661            >,
6662            offset: usize,
6663            _depth: fidl::encoding::Depth,
6664        ) -> fidl::Result<()> {
6665            encoder.debug_check_bounds::<EndpointManagerGetEndpointResponse>(offset);
6666            // Delegate to tuple encoding.
6667            fidl::encoding::Encode::<
6668                EndpointManagerGetEndpointResponse,
6669                fidl::encoding::DefaultFuchsiaResourceDialect,
6670            >::encode(
6671                (<fidl::encoding::Optional<
6672                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<EndpointMarker>>,
6673                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6674                    &mut self.endpoint
6675                ),),
6676                encoder,
6677                offset,
6678                _depth,
6679            )
6680        }
6681    }
6682    unsafe impl<
6683            T0: fidl::encoding::Encode<
6684                fidl::encoding::Optional<
6685                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<EndpointMarker>>,
6686                >,
6687                fidl::encoding::DefaultFuchsiaResourceDialect,
6688            >,
6689        >
6690        fidl::encoding::Encode<
6691            EndpointManagerGetEndpointResponse,
6692            fidl::encoding::DefaultFuchsiaResourceDialect,
6693        > for (T0,)
6694    {
6695        #[inline]
6696        unsafe fn encode(
6697            self,
6698            encoder: &mut fidl::encoding::Encoder<
6699                '_,
6700                fidl::encoding::DefaultFuchsiaResourceDialect,
6701            >,
6702            offset: usize,
6703            depth: fidl::encoding::Depth,
6704        ) -> fidl::Result<()> {
6705            encoder.debug_check_bounds::<EndpointManagerGetEndpointResponse>(offset);
6706            // Zero out padding regions. There's no need to apply masks
6707            // because the unmasked parts will be overwritten by fields.
6708            // Write the fields.
6709            self.0.encode(encoder, offset + 0, depth)?;
6710            Ok(())
6711        }
6712    }
6713
6714    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6715        for EndpointManagerGetEndpointResponse
6716    {
6717        #[inline(always)]
6718        fn new_empty() -> Self {
6719            Self {
6720                endpoint: fidl::new_empty!(
6721                    fidl::encoding::Optional<
6722                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<EndpointMarker>>,
6723                    >,
6724                    fidl::encoding::DefaultFuchsiaResourceDialect
6725                ),
6726            }
6727        }
6728
6729        #[inline]
6730        unsafe fn decode(
6731            &mut self,
6732            decoder: &mut fidl::encoding::Decoder<
6733                '_,
6734                fidl::encoding::DefaultFuchsiaResourceDialect,
6735            >,
6736            offset: usize,
6737            _depth: fidl::encoding::Depth,
6738        ) -> fidl::Result<()> {
6739            decoder.debug_check_bounds::<Self>(offset);
6740            // Verify that padding bytes are zero.
6741            fidl::decode!(
6742                fidl::encoding::Optional<
6743                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<EndpointMarker>>,
6744                >,
6745                fidl::encoding::DefaultFuchsiaResourceDialect,
6746                &mut self.endpoint,
6747                decoder,
6748                offset + 0,
6749                _depth
6750            )?;
6751            Ok(())
6752        }
6753    }
6754
6755    impl fidl::encoding::ResourceTypeMarker for NetworkContextCloneRequest {
6756        type Borrowed<'a> = &'a mut Self;
6757        fn take_or_borrow<'a>(
6758            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6759        ) -> Self::Borrowed<'a> {
6760            value
6761        }
6762    }
6763
6764    unsafe impl fidl::encoding::TypeMarker for NetworkContextCloneRequest {
6765        type Owned = Self;
6766
6767        #[inline(always)]
6768        fn inline_align(_context: fidl::encoding::Context) -> usize {
6769            4
6770        }
6771
6772        #[inline(always)]
6773        fn inline_size(_context: fidl::encoding::Context) -> usize {
6774            4
6775        }
6776    }
6777
6778    unsafe impl
6779        fidl::encoding::Encode<
6780            NetworkContextCloneRequest,
6781            fidl::encoding::DefaultFuchsiaResourceDialect,
6782        > for &mut NetworkContextCloneRequest
6783    {
6784        #[inline]
6785        unsafe fn encode(
6786            self,
6787            encoder: &mut fidl::encoding::Encoder<
6788                '_,
6789                fidl::encoding::DefaultFuchsiaResourceDialect,
6790            >,
6791            offset: usize,
6792            _depth: fidl::encoding::Depth,
6793        ) -> fidl::Result<()> {
6794            encoder.debug_check_bounds::<NetworkContextCloneRequest>(offset);
6795            // Delegate to tuple encoding.
6796            fidl::encoding::Encode::<NetworkContextCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6797                (
6798                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NetworkContextMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.network_context),
6799                ),
6800                encoder, offset, _depth
6801            )
6802        }
6803    }
6804    unsafe impl<
6805            T0: fidl::encoding::Encode<
6806                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NetworkContextMarker>>,
6807                fidl::encoding::DefaultFuchsiaResourceDialect,
6808            >,
6809        >
6810        fidl::encoding::Encode<
6811            NetworkContextCloneRequest,
6812            fidl::encoding::DefaultFuchsiaResourceDialect,
6813        > for (T0,)
6814    {
6815        #[inline]
6816        unsafe fn encode(
6817            self,
6818            encoder: &mut fidl::encoding::Encoder<
6819                '_,
6820                fidl::encoding::DefaultFuchsiaResourceDialect,
6821            >,
6822            offset: usize,
6823            depth: fidl::encoding::Depth,
6824        ) -> fidl::Result<()> {
6825            encoder.debug_check_bounds::<NetworkContextCloneRequest>(offset);
6826            // Zero out padding regions. There's no need to apply masks
6827            // because the unmasked parts will be overwritten by fields.
6828            // Write the fields.
6829            self.0.encode(encoder, offset + 0, depth)?;
6830            Ok(())
6831        }
6832    }
6833
6834    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6835        for NetworkContextCloneRequest
6836    {
6837        #[inline(always)]
6838        fn new_empty() -> Self {
6839            Self {
6840                network_context: fidl::new_empty!(
6841                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NetworkContextMarker>>,
6842                    fidl::encoding::DefaultFuchsiaResourceDialect
6843                ),
6844            }
6845        }
6846
6847        #[inline]
6848        unsafe fn decode(
6849            &mut self,
6850            decoder: &mut fidl::encoding::Decoder<
6851                '_,
6852                fidl::encoding::DefaultFuchsiaResourceDialect,
6853            >,
6854            offset: usize,
6855            _depth: fidl::encoding::Depth,
6856        ) -> fidl::Result<()> {
6857            decoder.debug_check_bounds::<Self>(offset);
6858            // Verify that padding bytes are zero.
6859            fidl::decode!(
6860                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NetworkContextMarker>>,
6861                fidl::encoding::DefaultFuchsiaResourceDialect,
6862                &mut self.network_context,
6863                decoder,
6864                offset + 0,
6865                _depth
6866            )?;
6867            Ok(())
6868        }
6869    }
6870
6871    impl fidl::encoding::ResourceTypeMarker for NetworkContextGetEndpointManagerRequest {
6872        type Borrowed<'a> = &'a mut Self;
6873        fn take_or_borrow<'a>(
6874            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6875        ) -> Self::Borrowed<'a> {
6876            value
6877        }
6878    }
6879
6880    unsafe impl fidl::encoding::TypeMarker for NetworkContextGetEndpointManagerRequest {
6881        type Owned = Self;
6882
6883        #[inline(always)]
6884        fn inline_align(_context: fidl::encoding::Context) -> usize {
6885            4
6886        }
6887
6888        #[inline(always)]
6889        fn inline_size(_context: fidl::encoding::Context) -> usize {
6890            4
6891        }
6892    }
6893
6894    unsafe impl
6895        fidl::encoding::Encode<
6896            NetworkContextGetEndpointManagerRequest,
6897            fidl::encoding::DefaultFuchsiaResourceDialect,
6898        > for &mut NetworkContextGetEndpointManagerRequest
6899    {
6900        #[inline]
6901        unsafe fn encode(
6902            self,
6903            encoder: &mut fidl::encoding::Encoder<
6904                '_,
6905                fidl::encoding::DefaultFuchsiaResourceDialect,
6906            >,
6907            offset: usize,
6908            _depth: fidl::encoding::Depth,
6909        ) -> fidl::Result<()> {
6910            encoder.debug_check_bounds::<NetworkContextGetEndpointManagerRequest>(offset);
6911            // Delegate to tuple encoding.
6912            fidl::encoding::Encode::<NetworkContextGetEndpointManagerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6913                (
6914                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<EndpointManagerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.endp_manager),
6915                ),
6916                encoder, offset, _depth
6917            )
6918        }
6919    }
6920    unsafe impl<
6921            T0: fidl::encoding::Encode<
6922                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<EndpointManagerMarker>>,
6923                fidl::encoding::DefaultFuchsiaResourceDialect,
6924            >,
6925        >
6926        fidl::encoding::Encode<
6927            NetworkContextGetEndpointManagerRequest,
6928            fidl::encoding::DefaultFuchsiaResourceDialect,
6929        > for (T0,)
6930    {
6931        #[inline]
6932        unsafe fn encode(
6933            self,
6934            encoder: &mut fidl::encoding::Encoder<
6935                '_,
6936                fidl::encoding::DefaultFuchsiaResourceDialect,
6937            >,
6938            offset: usize,
6939            depth: fidl::encoding::Depth,
6940        ) -> fidl::Result<()> {
6941            encoder.debug_check_bounds::<NetworkContextGetEndpointManagerRequest>(offset);
6942            // Zero out padding regions. There's no need to apply masks
6943            // because the unmasked parts will be overwritten by fields.
6944            // Write the fields.
6945            self.0.encode(encoder, offset + 0, depth)?;
6946            Ok(())
6947        }
6948    }
6949
6950    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6951        for NetworkContextGetEndpointManagerRequest
6952    {
6953        #[inline(always)]
6954        fn new_empty() -> Self {
6955            Self {
6956                endp_manager: fidl::new_empty!(
6957                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<EndpointManagerMarker>>,
6958                    fidl::encoding::DefaultFuchsiaResourceDialect
6959                ),
6960            }
6961        }
6962
6963        #[inline]
6964        unsafe fn decode(
6965            &mut self,
6966            decoder: &mut fidl::encoding::Decoder<
6967                '_,
6968                fidl::encoding::DefaultFuchsiaResourceDialect,
6969            >,
6970            offset: usize,
6971            _depth: fidl::encoding::Depth,
6972        ) -> fidl::Result<()> {
6973            decoder.debug_check_bounds::<Self>(offset);
6974            // Verify that padding bytes are zero.
6975            fidl::decode!(
6976                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<EndpointManagerMarker>>,
6977                fidl::encoding::DefaultFuchsiaResourceDialect,
6978                &mut self.endp_manager,
6979                decoder,
6980                offset + 0,
6981                _depth
6982            )?;
6983            Ok(())
6984        }
6985    }
6986
6987    impl fidl::encoding::ResourceTypeMarker for NetworkContextGetNetworkManagerRequest {
6988        type Borrowed<'a> = &'a mut Self;
6989        fn take_or_borrow<'a>(
6990            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6991        ) -> Self::Borrowed<'a> {
6992            value
6993        }
6994    }
6995
6996    unsafe impl fidl::encoding::TypeMarker for NetworkContextGetNetworkManagerRequest {
6997        type Owned = Self;
6998
6999        #[inline(always)]
7000        fn inline_align(_context: fidl::encoding::Context) -> usize {
7001            4
7002        }
7003
7004        #[inline(always)]
7005        fn inline_size(_context: fidl::encoding::Context) -> usize {
7006            4
7007        }
7008    }
7009
7010    unsafe impl
7011        fidl::encoding::Encode<
7012            NetworkContextGetNetworkManagerRequest,
7013            fidl::encoding::DefaultFuchsiaResourceDialect,
7014        > for &mut NetworkContextGetNetworkManagerRequest
7015    {
7016        #[inline]
7017        unsafe fn encode(
7018            self,
7019            encoder: &mut fidl::encoding::Encoder<
7020                '_,
7021                fidl::encoding::DefaultFuchsiaResourceDialect,
7022            >,
7023            offset: usize,
7024            _depth: fidl::encoding::Depth,
7025        ) -> fidl::Result<()> {
7026            encoder.debug_check_bounds::<NetworkContextGetNetworkManagerRequest>(offset);
7027            // Delegate to tuple encoding.
7028            fidl::encoding::Encode::<NetworkContextGetNetworkManagerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7029                (
7030                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NetworkManagerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.net_manager),
7031                ),
7032                encoder, offset, _depth
7033            )
7034        }
7035    }
7036    unsafe impl<
7037            T0: fidl::encoding::Encode<
7038                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NetworkManagerMarker>>,
7039                fidl::encoding::DefaultFuchsiaResourceDialect,
7040            >,
7041        >
7042        fidl::encoding::Encode<
7043            NetworkContextGetNetworkManagerRequest,
7044            fidl::encoding::DefaultFuchsiaResourceDialect,
7045        > for (T0,)
7046    {
7047        #[inline]
7048        unsafe fn encode(
7049            self,
7050            encoder: &mut fidl::encoding::Encoder<
7051                '_,
7052                fidl::encoding::DefaultFuchsiaResourceDialect,
7053            >,
7054            offset: usize,
7055            depth: fidl::encoding::Depth,
7056        ) -> fidl::Result<()> {
7057            encoder.debug_check_bounds::<NetworkContextGetNetworkManagerRequest>(offset);
7058            // Zero out padding regions. There's no need to apply masks
7059            // because the unmasked parts will be overwritten by fields.
7060            // Write the fields.
7061            self.0.encode(encoder, offset + 0, depth)?;
7062            Ok(())
7063        }
7064    }
7065
7066    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7067        for NetworkContextGetNetworkManagerRequest
7068    {
7069        #[inline(always)]
7070        fn new_empty() -> Self {
7071            Self {
7072                net_manager: fidl::new_empty!(
7073                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NetworkManagerMarker>>,
7074                    fidl::encoding::DefaultFuchsiaResourceDialect
7075                ),
7076            }
7077        }
7078
7079        #[inline]
7080        unsafe fn decode(
7081            &mut self,
7082            decoder: &mut fidl::encoding::Decoder<
7083                '_,
7084                fidl::encoding::DefaultFuchsiaResourceDialect,
7085            >,
7086            offset: usize,
7087            _depth: fidl::encoding::Depth,
7088        ) -> fidl::Result<()> {
7089            decoder.debug_check_bounds::<Self>(offset);
7090            // Verify that padding bytes are zero.
7091            fidl::decode!(
7092                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NetworkManagerMarker>>,
7093                fidl::encoding::DefaultFuchsiaResourceDialect,
7094                &mut self.net_manager,
7095                decoder,
7096                offset + 0,
7097                _depth
7098            )?;
7099            Ok(())
7100        }
7101    }
7102
7103    impl fidl::encoding::ResourceTypeMarker for NetworkContextSetupResponse {
7104        type Borrowed<'a> = &'a mut Self;
7105        fn take_or_borrow<'a>(
7106            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7107        ) -> Self::Borrowed<'a> {
7108            value
7109        }
7110    }
7111
7112    unsafe impl fidl::encoding::TypeMarker for NetworkContextSetupResponse {
7113        type Owned = Self;
7114
7115        #[inline(always)]
7116        fn inline_align(_context: fidl::encoding::Context) -> usize {
7117            4
7118        }
7119
7120        #[inline(always)]
7121        fn inline_size(_context: fidl::encoding::Context) -> usize {
7122            8
7123        }
7124    }
7125
7126    unsafe impl
7127        fidl::encoding::Encode<
7128            NetworkContextSetupResponse,
7129            fidl::encoding::DefaultFuchsiaResourceDialect,
7130        > for &mut NetworkContextSetupResponse
7131    {
7132        #[inline]
7133        unsafe fn encode(
7134            self,
7135            encoder: &mut fidl::encoding::Encoder<
7136                '_,
7137                fidl::encoding::DefaultFuchsiaResourceDialect,
7138            >,
7139            offset: usize,
7140            _depth: fidl::encoding::Depth,
7141        ) -> fidl::Result<()> {
7142            encoder.debug_check_bounds::<NetworkContextSetupResponse>(offset);
7143            // Delegate to tuple encoding.
7144            fidl::encoding::Encode::<
7145                NetworkContextSetupResponse,
7146                fidl::encoding::DefaultFuchsiaResourceDialect,
7147            >::encode(
7148                (
7149                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
7150                    <fidl::encoding::Optional<
7151                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SetupHandleMarker>>,
7152                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7153                        &mut self.setup_handle,
7154                    ),
7155                ),
7156                encoder,
7157                offset,
7158                _depth,
7159            )
7160        }
7161    }
7162    unsafe impl<
7163            T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
7164            T1: fidl::encoding::Encode<
7165                fidl::encoding::Optional<
7166                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SetupHandleMarker>>,
7167                >,
7168                fidl::encoding::DefaultFuchsiaResourceDialect,
7169            >,
7170        >
7171        fidl::encoding::Encode<
7172            NetworkContextSetupResponse,
7173            fidl::encoding::DefaultFuchsiaResourceDialect,
7174        > for (T0, T1)
7175    {
7176        #[inline]
7177        unsafe fn encode(
7178            self,
7179            encoder: &mut fidl::encoding::Encoder<
7180                '_,
7181                fidl::encoding::DefaultFuchsiaResourceDialect,
7182            >,
7183            offset: usize,
7184            depth: fidl::encoding::Depth,
7185        ) -> fidl::Result<()> {
7186            encoder.debug_check_bounds::<NetworkContextSetupResponse>(offset);
7187            // Zero out padding regions. There's no need to apply masks
7188            // because the unmasked parts will be overwritten by fields.
7189            // Write the fields.
7190            self.0.encode(encoder, offset + 0, depth)?;
7191            self.1.encode(encoder, offset + 4, depth)?;
7192            Ok(())
7193        }
7194    }
7195
7196    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7197        for NetworkContextSetupResponse
7198    {
7199        #[inline(always)]
7200        fn new_empty() -> Self {
7201            Self {
7202                status: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
7203                setup_handle: fidl::new_empty!(
7204                    fidl::encoding::Optional<
7205                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SetupHandleMarker>>,
7206                    >,
7207                    fidl::encoding::DefaultFuchsiaResourceDialect
7208                ),
7209            }
7210        }
7211
7212        #[inline]
7213        unsafe fn decode(
7214            &mut self,
7215            decoder: &mut fidl::encoding::Decoder<
7216                '_,
7217                fidl::encoding::DefaultFuchsiaResourceDialect,
7218            >,
7219            offset: usize,
7220            _depth: fidl::encoding::Depth,
7221        ) -> fidl::Result<()> {
7222            decoder.debug_check_bounds::<Self>(offset);
7223            // Verify that padding bytes are zero.
7224            fidl::decode!(
7225                i32,
7226                fidl::encoding::DefaultFuchsiaResourceDialect,
7227                &mut self.status,
7228                decoder,
7229                offset + 0,
7230                _depth
7231            )?;
7232            fidl::decode!(
7233                fidl::encoding::Optional<
7234                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SetupHandleMarker>>,
7235                >,
7236                fidl::encoding::DefaultFuchsiaResourceDialect,
7237                &mut self.setup_handle,
7238                decoder,
7239                offset + 4,
7240                _depth
7241            )?;
7242            Ok(())
7243        }
7244    }
7245
7246    impl fidl::encoding::ResourceTypeMarker for NetworkCreateFakeEndpointRequest {
7247        type Borrowed<'a> = &'a mut Self;
7248        fn take_or_borrow<'a>(
7249            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7250        ) -> Self::Borrowed<'a> {
7251            value
7252        }
7253    }
7254
7255    unsafe impl fidl::encoding::TypeMarker for NetworkCreateFakeEndpointRequest {
7256        type Owned = Self;
7257
7258        #[inline(always)]
7259        fn inline_align(_context: fidl::encoding::Context) -> usize {
7260            4
7261        }
7262
7263        #[inline(always)]
7264        fn inline_size(_context: fidl::encoding::Context) -> usize {
7265            4
7266        }
7267    }
7268
7269    unsafe impl
7270        fidl::encoding::Encode<
7271            NetworkCreateFakeEndpointRequest,
7272            fidl::encoding::DefaultFuchsiaResourceDialect,
7273        > for &mut NetworkCreateFakeEndpointRequest
7274    {
7275        #[inline]
7276        unsafe fn encode(
7277            self,
7278            encoder: &mut fidl::encoding::Encoder<
7279                '_,
7280                fidl::encoding::DefaultFuchsiaResourceDialect,
7281            >,
7282            offset: usize,
7283            _depth: fidl::encoding::Depth,
7284        ) -> fidl::Result<()> {
7285            encoder.debug_check_bounds::<NetworkCreateFakeEndpointRequest>(offset);
7286            // Delegate to tuple encoding.
7287            fidl::encoding::Encode::<NetworkCreateFakeEndpointRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7288                (
7289                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FakeEndpointMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.ep),
7290                ),
7291                encoder, offset, _depth
7292            )
7293        }
7294    }
7295    unsafe impl<
7296            T0: fidl::encoding::Encode<
7297                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FakeEndpointMarker>>,
7298                fidl::encoding::DefaultFuchsiaResourceDialect,
7299            >,
7300        >
7301        fidl::encoding::Encode<
7302            NetworkCreateFakeEndpointRequest,
7303            fidl::encoding::DefaultFuchsiaResourceDialect,
7304        > for (T0,)
7305    {
7306        #[inline]
7307        unsafe fn encode(
7308            self,
7309            encoder: &mut fidl::encoding::Encoder<
7310                '_,
7311                fidl::encoding::DefaultFuchsiaResourceDialect,
7312            >,
7313            offset: usize,
7314            depth: fidl::encoding::Depth,
7315        ) -> fidl::Result<()> {
7316            encoder.debug_check_bounds::<NetworkCreateFakeEndpointRequest>(offset);
7317            // Zero out padding regions. There's no need to apply masks
7318            // because the unmasked parts will be overwritten by fields.
7319            // Write the fields.
7320            self.0.encode(encoder, offset + 0, depth)?;
7321            Ok(())
7322        }
7323    }
7324
7325    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7326        for NetworkCreateFakeEndpointRequest
7327    {
7328        #[inline(always)]
7329        fn new_empty() -> Self {
7330            Self {
7331                ep: fidl::new_empty!(
7332                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FakeEndpointMarker>>,
7333                    fidl::encoding::DefaultFuchsiaResourceDialect
7334                ),
7335            }
7336        }
7337
7338        #[inline]
7339        unsafe fn decode(
7340            &mut self,
7341            decoder: &mut fidl::encoding::Decoder<
7342                '_,
7343                fidl::encoding::DefaultFuchsiaResourceDialect,
7344            >,
7345            offset: usize,
7346            _depth: fidl::encoding::Depth,
7347        ) -> fidl::Result<()> {
7348            decoder.debug_check_bounds::<Self>(offset);
7349            // Verify that padding bytes are zero.
7350            fidl::decode!(
7351                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FakeEndpointMarker>>,
7352                fidl::encoding::DefaultFuchsiaResourceDialect,
7353                &mut self.ep,
7354                decoder,
7355                offset + 0,
7356                _depth
7357            )?;
7358            Ok(())
7359        }
7360    }
7361
7362    impl fidl::encoding::ResourceTypeMarker for NetworkManagerCreateNetworkResponse {
7363        type Borrowed<'a> = &'a mut Self;
7364        fn take_or_borrow<'a>(
7365            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7366        ) -> Self::Borrowed<'a> {
7367            value
7368        }
7369    }
7370
7371    unsafe impl fidl::encoding::TypeMarker for NetworkManagerCreateNetworkResponse {
7372        type Owned = Self;
7373
7374        #[inline(always)]
7375        fn inline_align(_context: fidl::encoding::Context) -> usize {
7376            4
7377        }
7378
7379        #[inline(always)]
7380        fn inline_size(_context: fidl::encoding::Context) -> usize {
7381            8
7382        }
7383    }
7384
7385    unsafe impl
7386        fidl::encoding::Encode<
7387            NetworkManagerCreateNetworkResponse,
7388            fidl::encoding::DefaultFuchsiaResourceDialect,
7389        > for &mut NetworkManagerCreateNetworkResponse
7390    {
7391        #[inline]
7392        unsafe fn encode(
7393            self,
7394            encoder: &mut fidl::encoding::Encoder<
7395                '_,
7396                fidl::encoding::DefaultFuchsiaResourceDialect,
7397            >,
7398            offset: usize,
7399            _depth: fidl::encoding::Depth,
7400        ) -> fidl::Result<()> {
7401            encoder.debug_check_bounds::<NetworkManagerCreateNetworkResponse>(offset);
7402            // Delegate to tuple encoding.
7403            fidl::encoding::Encode::<
7404                NetworkManagerCreateNetworkResponse,
7405                fidl::encoding::DefaultFuchsiaResourceDialect,
7406            >::encode(
7407                (
7408                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
7409                    <fidl::encoding::Optional<
7410                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NetworkMarker>>,
7411                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7412                        &mut self.net
7413                    ),
7414                ),
7415                encoder,
7416                offset,
7417                _depth,
7418            )
7419        }
7420    }
7421    unsafe impl<
7422            T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
7423            T1: fidl::encoding::Encode<
7424                fidl::encoding::Optional<
7425                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NetworkMarker>>,
7426                >,
7427                fidl::encoding::DefaultFuchsiaResourceDialect,
7428            >,
7429        >
7430        fidl::encoding::Encode<
7431            NetworkManagerCreateNetworkResponse,
7432            fidl::encoding::DefaultFuchsiaResourceDialect,
7433        > for (T0, T1)
7434    {
7435        #[inline]
7436        unsafe fn encode(
7437            self,
7438            encoder: &mut fidl::encoding::Encoder<
7439                '_,
7440                fidl::encoding::DefaultFuchsiaResourceDialect,
7441            >,
7442            offset: usize,
7443            depth: fidl::encoding::Depth,
7444        ) -> fidl::Result<()> {
7445            encoder.debug_check_bounds::<NetworkManagerCreateNetworkResponse>(offset);
7446            // Zero out padding regions. There's no need to apply masks
7447            // because the unmasked parts will be overwritten by fields.
7448            // Write the fields.
7449            self.0.encode(encoder, offset + 0, depth)?;
7450            self.1.encode(encoder, offset + 4, depth)?;
7451            Ok(())
7452        }
7453    }
7454
7455    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7456        for NetworkManagerCreateNetworkResponse
7457    {
7458        #[inline(always)]
7459        fn new_empty() -> Self {
7460            Self {
7461                status: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
7462                net: fidl::new_empty!(
7463                    fidl::encoding::Optional<
7464                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NetworkMarker>>,
7465                    >,
7466                    fidl::encoding::DefaultFuchsiaResourceDialect
7467                ),
7468            }
7469        }
7470
7471        #[inline]
7472        unsafe fn decode(
7473            &mut self,
7474            decoder: &mut fidl::encoding::Decoder<
7475                '_,
7476                fidl::encoding::DefaultFuchsiaResourceDialect,
7477            >,
7478            offset: usize,
7479            _depth: fidl::encoding::Depth,
7480        ) -> fidl::Result<()> {
7481            decoder.debug_check_bounds::<Self>(offset);
7482            // Verify that padding bytes are zero.
7483            fidl::decode!(
7484                i32,
7485                fidl::encoding::DefaultFuchsiaResourceDialect,
7486                &mut self.status,
7487                decoder,
7488                offset + 0,
7489                _depth
7490            )?;
7491            fidl::decode!(
7492                fidl::encoding::Optional<
7493                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NetworkMarker>>,
7494                >,
7495                fidl::encoding::DefaultFuchsiaResourceDialect,
7496                &mut self.net,
7497                decoder,
7498                offset + 4,
7499                _depth
7500            )?;
7501            Ok(())
7502        }
7503    }
7504
7505    impl fidl::encoding::ResourceTypeMarker for NetworkManagerGetNetworkResponse {
7506        type Borrowed<'a> = &'a mut Self;
7507        fn take_or_borrow<'a>(
7508            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7509        ) -> Self::Borrowed<'a> {
7510            value
7511        }
7512    }
7513
7514    unsafe impl fidl::encoding::TypeMarker for NetworkManagerGetNetworkResponse {
7515        type Owned = Self;
7516
7517        #[inline(always)]
7518        fn inline_align(_context: fidl::encoding::Context) -> usize {
7519            4
7520        }
7521
7522        #[inline(always)]
7523        fn inline_size(_context: fidl::encoding::Context) -> usize {
7524            4
7525        }
7526    }
7527
7528    unsafe impl
7529        fidl::encoding::Encode<
7530            NetworkManagerGetNetworkResponse,
7531            fidl::encoding::DefaultFuchsiaResourceDialect,
7532        > for &mut NetworkManagerGetNetworkResponse
7533    {
7534        #[inline]
7535        unsafe fn encode(
7536            self,
7537            encoder: &mut fidl::encoding::Encoder<
7538                '_,
7539                fidl::encoding::DefaultFuchsiaResourceDialect,
7540            >,
7541            offset: usize,
7542            _depth: fidl::encoding::Depth,
7543        ) -> fidl::Result<()> {
7544            encoder.debug_check_bounds::<NetworkManagerGetNetworkResponse>(offset);
7545            // Delegate to tuple encoding.
7546            fidl::encoding::Encode::<
7547                NetworkManagerGetNetworkResponse,
7548                fidl::encoding::DefaultFuchsiaResourceDialect,
7549            >::encode(
7550                (<fidl::encoding::Optional<
7551                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NetworkMarker>>,
7552                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7553                    &mut self.net
7554                ),),
7555                encoder,
7556                offset,
7557                _depth,
7558            )
7559        }
7560    }
7561    unsafe impl<
7562            T0: fidl::encoding::Encode<
7563                fidl::encoding::Optional<
7564                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NetworkMarker>>,
7565                >,
7566                fidl::encoding::DefaultFuchsiaResourceDialect,
7567            >,
7568        >
7569        fidl::encoding::Encode<
7570            NetworkManagerGetNetworkResponse,
7571            fidl::encoding::DefaultFuchsiaResourceDialect,
7572        > for (T0,)
7573    {
7574        #[inline]
7575        unsafe fn encode(
7576            self,
7577            encoder: &mut fidl::encoding::Encoder<
7578                '_,
7579                fidl::encoding::DefaultFuchsiaResourceDialect,
7580            >,
7581            offset: usize,
7582            depth: fidl::encoding::Depth,
7583        ) -> fidl::Result<()> {
7584            encoder.debug_check_bounds::<NetworkManagerGetNetworkResponse>(offset);
7585            // Zero out padding regions. There's no need to apply masks
7586            // because the unmasked parts will be overwritten by fields.
7587            // Write the fields.
7588            self.0.encode(encoder, offset + 0, depth)?;
7589            Ok(())
7590        }
7591    }
7592
7593    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7594        for NetworkManagerGetNetworkResponse
7595    {
7596        #[inline(always)]
7597        fn new_empty() -> Self {
7598            Self {
7599                net: fidl::new_empty!(
7600                    fidl::encoding::Optional<
7601                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NetworkMarker>>,
7602                    >,
7603                    fidl::encoding::DefaultFuchsiaResourceDialect
7604                ),
7605            }
7606        }
7607
7608        #[inline]
7609        unsafe fn decode(
7610            &mut self,
7611            decoder: &mut fidl::encoding::Decoder<
7612                '_,
7613                fidl::encoding::DefaultFuchsiaResourceDialect,
7614            >,
7615            offset: usize,
7616            _depth: fidl::encoding::Depth,
7617        ) -> fidl::Result<()> {
7618            decoder.debug_check_bounds::<Self>(offset);
7619            // Verify that padding bytes are zero.
7620            fidl::decode!(
7621                fidl::encoding::Optional<
7622                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NetworkMarker>>,
7623                >,
7624                fidl::encoding::DefaultFuchsiaResourceDialect,
7625                &mut self.net,
7626                decoder,
7627                offset + 0,
7628                _depth
7629            )?;
7630            Ok(())
7631        }
7632    }
7633}