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