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_policy_testing__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct FakeNetcfgMarker;
16
17impl fidl::endpoints::ProtocolMarker for FakeNetcfgMarker {
18 type Proxy = FakeNetcfgProxy;
19 type RequestStream = FakeNetcfgRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = FakeNetcfgSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.net.policy.testing.FakeNetcfg";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for FakeNetcfgMarker {}
26
27pub trait FakeNetcfgProxyInterface: Send + Sync {
28 type SetDnsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
29 fn r#set_dns(&self, servers: &[fidl_fuchsia_net_name::DnsServer_]) -> Self::SetDnsResponseFut;
30}
31#[derive(Debug)]
32#[cfg(target_os = "fuchsia")]
33pub struct FakeNetcfgSynchronousProxy {
34 client: fidl::client::sync::Client,
35}
36
37#[cfg(target_os = "fuchsia")]
38impl fidl::endpoints::SynchronousProxy for FakeNetcfgSynchronousProxy {
39 type Proxy = FakeNetcfgProxy;
40 type Protocol = FakeNetcfgMarker;
41
42 fn from_channel(inner: fidl::Channel) -> Self {
43 Self::new(inner)
44 }
45
46 fn into_channel(self) -> fidl::Channel {
47 self.client.into_channel()
48 }
49
50 fn as_channel(&self) -> &fidl::Channel {
51 self.client.as_channel()
52 }
53}
54
55#[cfg(target_os = "fuchsia")]
56impl FakeNetcfgSynchronousProxy {
57 pub fn new(channel: fidl::Channel) -> Self {
58 Self { client: fidl::client::sync::Client::new(channel) }
59 }
60
61 pub fn into_channel(self) -> fidl::Channel {
62 self.client.into_channel()
63 }
64
65 pub fn wait_for_event(
68 &self,
69 deadline: zx::MonotonicInstant,
70 ) -> Result<FakeNetcfgEvent, fidl::Error> {
71 FakeNetcfgEvent::decode(self.client.wait_for_event::<FakeNetcfgMarker>(deadline)?)
72 }
73
74 pub fn r#set_dns(
78 &self,
79 mut servers: &[fidl_fuchsia_net_name::DnsServer_],
80 ___deadline: zx::MonotonicInstant,
81 ) -> Result<(), fidl::Error> {
82 let _response = self
83 .client
84 .send_query::<FakeNetcfgSetDnsRequest, fidl::encoding::EmptyPayload, FakeNetcfgMarker>(
85 (servers,),
86 0x421f1e5625f36896,
87 fidl::encoding::DynamicFlags::empty(),
88 ___deadline,
89 )?;
90 Ok(_response)
91 }
92}
93
94#[cfg(target_os = "fuchsia")]
95impl From<FakeNetcfgSynchronousProxy> for zx::NullableHandle {
96 fn from(value: FakeNetcfgSynchronousProxy) -> Self {
97 value.into_channel().into()
98 }
99}
100
101#[cfg(target_os = "fuchsia")]
102impl From<fidl::Channel> for FakeNetcfgSynchronousProxy {
103 fn from(value: fidl::Channel) -> Self {
104 Self::new(value)
105 }
106}
107
108#[cfg(target_os = "fuchsia")]
109impl fidl::endpoints::FromClient for FakeNetcfgSynchronousProxy {
110 type Protocol = FakeNetcfgMarker;
111
112 fn from_client(value: fidl::endpoints::ClientEnd<FakeNetcfgMarker>) -> Self {
113 Self::new(value.into_channel())
114 }
115}
116
117#[derive(Debug, Clone)]
118pub struct FakeNetcfgProxy {
119 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
120}
121
122impl fidl::endpoints::Proxy for FakeNetcfgProxy {
123 type Protocol = FakeNetcfgMarker;
124
125 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
126 Self::new(inner)
127 }
128
129 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
130 self.client.into_channel().map_err(|client| Self { client })
131 }
132
133 fn as_channel(&self) -> &::fidl::AsyncChannel {
134 self.client.as_channel()
135 }
136}
137
138impl FakeNetcfgProxy {
139 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
141 let protocol_name = <FakeNetcfgMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
142 Self { client: fidl::client::Client::new(channel, protocol_name) }
143 }
144
145 pub fn take_event_stream(&self) -> FakeNetcfgEventStream {
151 FakeNetcfgEventStream { event_receiver: self.client.take_event_receiver() }
152 }
153
154 pub fn r#set_dns(
158 &self,
159 mut servers: &[fidl_fuchsia_net_name::DnsServer_],
160 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
161 FakeNetcfgProxyInterface::r#set_dns(self, servers)
162 }
163}
164
165impl FakeNetcfgProxyInterface for FakeNetcfgProxy {
166 type SetDnsResponseFut =
167 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
168 fn r#set_dns(
169 &self,
170 mut servers: &[fidl_fuchsia_net_name::DnsServer_],
171 ) -> Self::SetDnsResponseFut {
172 fn _decode(
173 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
174 ) -> Result<(), fidl::Error> {
175 let _response = fidl::client::decode_transaction_body::<
176 fidl::encoding::EmptyPayload,
177 fidl::encoding::DefaultFuchsiaResourceDialect,
178 0x421f1e5625f36896,
179 >(_buf?)?;
180 Ok(_response)
181 }
182 self.client.send_query_and_decode::<FakeNetcfgSetDnsRequest, ()>(
183 (servers,),
184 0x421f1e5625f36896,
185 fidl::encoding::DynamicFlags::empty(),
186 _decode,
187 )
188 }
189}
190
191pub struct FakeNetcfgEventStream {
192 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
193}
194
195impl std::marker::Unpin for FakeNetcfgEventStream {}
196
197impl futures::stream::FusedStream for FakeNetcfgEventStream {
198 fn is_terminated(&self) -> bool {
199 self.event_receiver.is_terminated()
200 }
201}
202
203impl futures::Stream for FakeNetcfgEventStream {
204 type Item = Result<FakeNetcfgEvent, fidl::Error>;
205
206 fn poll_next(
207 mut self: std::pin::Pin<&mut Self>,
208 cx: &mut std::task::Context<'_>,
209 ) -> std::task::Poll<Option<Self::Item>> {
210 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
211 &mut self.event_receiver,
212 cx
213 )?) {
214 Some(buf) => std::task::Poll::Ready(Some(FakeNetcfgEvent::decode(buf))),
215 None => std::task::Poll::Ready(None),
216 }
217 }
218}
219
220#[derive(Debug)]
221pub enum FakeNetcfgEvent {}
222
223impl FakeNetcfgEvent {
224 fn decode(
226 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
227 ) -> Result<FakeNetcfgEvent, fidl::Error> {
228 let (bytes, _handles) = buf.split_mut();
229 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
230 debug_assert_eq!(tx_header.tx_id, 0);
231 match tx_header.ordinal {
232 _ => Err(fidl::Error::UnknownOrdinal {
233 ordinal: tx_header.ordinal,
234 protocol_name: <FakeNetcfgMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
235 }),
236 }
237 }
238}
239
240pub struct FakeNetcfgRequestStream {
242 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
243 is_terminated: bool,
244}
245
246impl std::marker::Unpin for FakeNetcfgRequestStream {}
247
248impl futures::stream::FusedStream for FakeNetcfgRequestStream {
249 fn is_terminated(&self) -> bool {
250 self.is_terminated
251 }
252}
253
254impl fidl::endpoints::RequestStream for FakeNetcfgRequestStream {
255 type Protocol = FakeNetcfgMarker;
256 type ControlHandle = FakeNetcfgControlHandle;
257
258 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
259 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
260 }
261
262 fn control_handle(&self) -> Self::ControlHandle {
263 FakeNetcfgControlHandle { inner: self.inner.clone() }
264 }
265
266 fn into_inner(
267 self,
268 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
269 {
270 (self.inner, self.is_terminated)
271 }
272
273 fn from_inner(
274 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
275 is_terminated: bool,
276 ) -> Self {
277 Self { inner, is_terminated }
278 }
279}
280
281impl futures::Stream for FakeNetcfgRequestStream {
282 type Item = Result<FakeNetcfgRequest, fidl::Error>;
283
284 fn poll_next(
285 mut self: std::pin::Pin<&mut Self>,
286 cx: &mut std::task::Context<'_>,
287 ) -> std::task::Poll<Option<Self::Item>> {
288 let this = &mut *self;
289 if this.inner.check_shutdown(cx) {
290 this.is_terminated = true;
291 return std::task::Poll::Ready(None);
292 }
293 if this.is_terminated {
294 panic!("polled FakeNetcfgRequestStream after completion");
295 }
296 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
297 |bytes, handles| {
298 match this.inner.channel().read_etc(cx, bytes, handles) {
299 std::task::Poll::Ready(Ok(())) => {}
300 std::task::Poll::Pending => return std::task::Poll::Pending,
301 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
302 this.is_terminated = true;
303 return std::task::Poll::Ready(None);
304 }
305 std::task::Poll::Ready(Err(e)) => {
306 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
307 e.into(),
308 ))));
309 }
310 }
311
312 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
314
315 std::task::Poll::Ready(Some(match header.ordinal {
316 0x421f1e5625f36896 => {
317 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
318 let mut req = fidl::new_empty!(
319 FakeNetcfgSetDnsRequest,
320 fidl::encoding::DefaultFuchsiaResourceDialect
321 );
322 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeNetcfgSetDnsRequest>(&header, _body_bytes, handles, &mut req)?;
323 let control_handle = FakeNetcfgControlHandle { inner: this.inner.clone() };
324 Ok(FakeNetcfgRequest::SetDns {
325 servers: req.servers,
326
327 responder: FakeNetcfgSetDnsResponder {
328 control_handle: std::mem::ManuallyDrop::new(control_handle),
329 tx_id: header.tx_id,
330 },
331 })
332 }
333 _ => Err(fidl::Error::UnknownOrdinal {
334 ordinal: header.ordinal,
335 protocol_name:
336 <FakeNetcfgMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
337 }),
338 }))
339 },
340 )
341 }
342}
343
344#[derive(Debug)]
345pub enum FakeNetcfgRequest {
346 SetDns { servers: Vec<fidl_fuchsia_net_name::DnsServer_>, responder: FakeNetcfgSetDnsResponder },
350}
351
352impl FakeNetcfgRequest {
353 #[allow(irrefutable_let_patterns)]
354 pub fn into_set_dns(
355 self,
356 ) -> Option<(Vec<fidl_fuchsia_net_name::DnsServer_>, FakeNetcfgSetDnsResponder)> {
357 if let FakeNetcfgRequest::SetDns { servers, responder } = self {
358 Some((servers, responder))
359 } else {
360 None
361 }
362 }
363
364 pub fn method_name(&self) -> &'static str {
366 match *self {
367 FakeNetcfgRequest::SetDns { .. } => "set_dns",
368 }
369 }
370}
371
372#[derive(Debug, Clone)]
373pub struct FakeNetcfgControlHandle {
374 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
375}
376
377impl fidl::endpoints::ControlHandle for FakeNetcfgControlHandle {
378 fn shutdown(&self) {
379 self.inner.shutdown()
380 }
381
382 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
383 self.inner.shutdown_with_epitaph(status)
384 }
385
386 fn is_closed(&self) -> bool {
387 self.inner.channel().is_closed()
388 }
389 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
390 self.inner.channel().on_closed()
391 }
392
393 #[cfg(target_os = "fuchsia")]
394 fn signal_peer(
395 &self,
396 clear_mask: zx::Signals,
397 set_mask: zx::Signals,
398 ) -> Result<(), zx_status::Status> {
399 use fidl::Peered;
400 self.inner.channel().signal_peer(clear_mask, set_mask)
401 }
402}
403
404impl FakeNetcfgControlHandle {}
405
406#[must_use = "FIDL methods require a response to be sent"]
407#[derive(Debug)]
408pub struct FakeNetcfgSetDnsResponder {
409 control_handle: std::mem::ManuallyDrop<FakeNetcfgControlHandle>,
410 tx_id: u32,
411}
412
413impl std::ops::Drop for FakeNetcfgSetDnsResponder {
417 fn drop(&mut self) {
418 self.control_handle.shutdown();
419 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
421 }
422}
423
424impl fidl::endpoints::Responder for FakeNetcfgSetDnsResponder {
425 type ControlHandle = FakeNetcfgControlHandle;
426
427 fn control_handle(&self) -> &FakeNetcfgControlHandle {
428 &self.control_handle
429 }
430
431 fn drop_without_shutdown(mut self) {
432 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
434 std::mem::forget(self);
436 }
437}
438
439impl FakeNetcfgSetDnsResponder {
440 pub fn send(self) -> Result<(), fidl::Error> {
444 let _result = self.send_raw();
445 if _result.is_err() {
446 self.control_handle.shutdown();
447 }
448 self.drop_without_shutdown();
449 _result
450 }
451
452 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
454 let _result = self.send_raw();
455 self.drop_without_shutdown();
456 _result
457 }
458
459 fn send_raw(&self) -> Result<(), fidl::Error> {
460 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
461 (),
462 self.tx_id,
463 0x421f1e5625f36896,
464 fidl::encoding::DynamicFlags::empty(),
465 )
466 }
467}
468
469#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
470pub struct FakeSocketProxy_Marker;
471
472impl fidl::endpoints::ProtocolMarker for FakeSocketProxy_Marker {
473 type Proxy = FakeSocketProxy_Proxy;
474 type RequestStream = FakeSocketProxy_RequestStream;
475 #[cfg(target_os = "fuchsia")]
476 type SynchronousProxy = FakeSocketProxy_SynchronousProxy;
477
478 const DEBUG_NAME: &'static str = "fuchsia.net.policy.testing.FakeSocketProxy";
479}
480impl fidl::endpoints::DiscoverableProtocolMarker for FakeSocketProxy_Marker {}
481
482pub trait FakeSocketProxy_ProxyInterface: Send + Sync {
483 type SetDnsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
484 fn r#set_dns(
485 &self,
486 servers: &[fidl_fuchsia_net_policy_socketproxy::DnsServerList],
487 ) -> Self::SetDnsResponseFut;
488}
489#[derive(Debug)]
490#[cfg(target_os = "fuchsia")]
491pub struct FakeSocketProxy_SynchronousProxy {
492 client: fidl::client::sync::Client,
493}
494
495#[cfg(target_os = "fuchsia")]
496impl fidl::endpoints::SynchronousProxy for FakeSocketProxy_SynchronousProxy {
497 type Proxy = FakeSocketProxy_Proxy;
498 type Protocol = FakeSocketProxy_Marker;
499
500 fn from_channel(inner: fidl::Channel) -> Self {
501 Self::new(inner)
502 }
503
504 fn into_channel(self) -> fidl::Channel {
505 self.client.into_channel()
506 }
507
508 fn as_channel(&self) -> &fidl::Channel {
509 self.client.as_channel()
510 }
511}
512
513#[cfg(target_os = "fuchsia")]
514impl FakeSocketProxy_SynchronousProxy {
515 pub fn new(channel: fidl::Channel) -> Self {
516 Self { client: fidl::client::sync::Client::new(channel) }
517 }
518
519 pub fn into_channel(self) -> fidl::Channel {
520 self.client.into_channel()
521 }
522
523 pub fn wait_for_event(
526 &self,
527 deadline: zx::MonotonicInstant,
528 ) -> Result<FakeSocketProxy_Event, fidl::Error> {
529 FakeSocketProxy_Event::decode(
530 self.client.wait_for_event::<FakeSocketProxy_Marker>(deadline)?,
531 )
532 }
533
534 pub fn r#set_dns(
537 &self,
538 mut servers: &[fidl_fuchsia_net_policy_socketproxy::DnsServerList],
539 ___deadline: zx::MonotonicInstant,
540 ) -> Result<(), fidl::Error> {
541 let _response = self.client.send_query::<
542 FakeSocketProxySetDnsRequest,
543 fidl::encoding::EmptyPayload,
544 FakeSocketProxy_Marker,
545 >(
546 (servers,),
547 0x5b24fd7a0d73c2d1,
548 fidl::encoding::DynamicFlags::empty(),
549 ___deadline,
550 )?;
551 Ok(_response)
552 }
553}
554
555#[cfg(target_os = "fuchsia")]
556impl From<FakeSocketProxy_SynchronousProxy> for zx::NullableHandle {
557 fn from(value: FakeSocketProxy_SynchronousProxy) -> Self {
558 value.into_channel().into()
559 }
560}
561
562#[cfg(target_os = "fuchsia")]
563impl From<fidl::Channel> for FakeSocketProxy_SynchronousProxy {
564 fn from(value: fidl::Channel) -> Self {
565 Self::new(value)
566 }
567}
568
569#[cfg(target_os = "fuchsia")]
570impl fidl::endpoints::FromClient for FakeSocketProxy_SynchronousProxy {
571 type Protocol = FakeSocketProxy_Marker;
572
573 fn from_client(value: fidl::endpoints::ClientEnd<FakeSocketProxy_Marker>) -> Self {
574 Self::new(value.into_channel())
575 }
576}
577
578#[derive(Debug, Clone)]
579pub struct FakeSocketProxy_Proxy {
580 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
581}
582
583impl fidl::endpoints::Proxy for FakeSocketProxy_Proxy {
584 type Protocol = FakeSocketProxy_Marker;
585
586 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
587 Self::new(inner)
588 }
589
590 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
591 self.client.into_channel().map_err(|client| Self { client })
592 }
593
594 fn as_channel(&self) -> &::fidl::AsyncChannel {
595 self.client.as_channel()
596 }
597}
598
599impl FakeSocketProxy_Proxy {
600 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
602 let protocol_name = <FakeSocketProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
603 Self { client: fidl::client::Client::new(channel, protocol_name) }
604 }
605
606 pub fn take_event_stream(&self) -> FakeSocketProxy_EventStream {
612 FakeSocketProxy_EventStream { event_receiver: self.client.take_event_receiver() }
613 }
614
615 pub fn r#set_dns(
618 &self,
619 mut servers: &[fidl_fuchsia_net_policy_socketproxy::DnsServerList],
620 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
621 FakeSocketProxy_ProxyInterface::r#set_dns(self, servers)
622 }
623}
624
625impl FakeSocketProxy_ProxyInterface for FakeSocketProxy_Proxy {
626 type SetDnsResponseFut =
627 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
628 fn r#set_dns(
629 &self,
630 mut servers: &[fidl_fuchsia_net_policy_socketproxy::DnsServerList],
631 ) -> Self::SetDnsResponseFut {
632 fn _decode(
633 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
634 ) -> Result<(), fidl::Error> {
635 let _response = fidl::client::decode_transaction_body::<
636 fidl::encoding::EmptyPayload,
637 fidl::encoding::DefaultFuchsiaResourceDialect,
638 0x5b24fd7a0d73c2d1,
639 >(_buf?)?;
640 Ok(_response)
641 }
642 self.client.send_query_and_decode::<FakeSocketProxySetDnsRequest, ()>(
643 (servers,),
644 0x5b24fd7a0d73c2d1,
645 fidl::encoding::DynamicFlags::empty(),
646 _decode,
647 )
648 }
649}
650
651pub struct FakeSocketProxy_EventStream {
652 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
653}
654
655impl std::marker::Unpin for FakeSocketProxy_EventStream {}
656
657impl futures::stream::FusedStream for FakeSocketProxy_EventStream {
658 fn is_terminated(&self) -> bool {
659 self.event_receiver.is_terminated()
660 }
661}
662
663impl futures::Stream for FakeSocketProxy_EventStream {
664 type Item = Result<FakeSocketProxy_Event, fidl::Error>;
665
666 fn poll_next(
667 mut self: std::pin::Pin<&mut Self>,
668 cx: &mut std::task::Context<'_>,
669 ) -> std::task::Poll<Option<Self::Item>> {
670 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
671 &mut self.event_receiver,
672 cx
673 )?) {
674 Some(buf) => std::task::Poll::Ready(Some(FakeSocketProxy_Event::decode(buf))),
675 None => std::task::Poll::Ready(None),
676 }
677 }
678}
679
680#[derive(Debug)]
681pub enum FakeSocketProxy_Event {}
682
683impl FakeSocketProxy_Event {
684 fn decode(
686 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
687 ) -> Result<FakeSocketProxy_Event, fidl::Error> {
688 let (bytes, _handles) = buf.split_mut();
689 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
690 debug_assert_eq!(tx_header.tx_id, 0);
691 match tx_header.ordinal {
692 _ => Err(fidl::Error::UnknownOrdinal {
693 ordinal: tx_header.ordinal,
694 protocol_name:
695 <FakeSocketProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
696 }),
697 }
698 }
699}
700
701pub struct FakeSocketProxy_RequestStream {
703 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
704 is_terminated: bool,
705}
706
707impl std::marker::Unpin for FakeSocketProxy_RequestStream {}
708
709impl futures::stream::FusedStream for FakeSocketProxy_RequestStream {
710 fn is_terminated(&self) -> bool {
711 self.is_terminated
712 }
713}
714
715impl fidl::endpoints::RequestStream for FakeSocketProxy_RequestStream {
716 type Protocol = FakeSocketProxy_Marker;
717 type ControlHandle = FakeSocketProxy_ControlHandle;
718
719 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
720 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
721 }
722
723 fn control_handle(&self) -> Self::ControlHandle {
724 FakeSocketProxy_ControlHandle { inner: self.inner.clone() }
725 }
726
727 fn into_inner(
728 self,
729 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
730 {
731 (self.inner, self.is_terminated)
732 }
733
734 fn from_inner(
735 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
736 is_terminated: bool,
737 ) -> Self {
738 Self { inner, is_terminated }
739 }
740}
741
742impl futures::Stream for FakeSocketProxy_RequestStream {
743 type Item = Result<FakeSocketProxy_Request, fidl::Error>;
744
745 fn poll_next(
746 mut self: std::pin::Pin<&mut Self>,
747 cx: &mut std::task::Context<'_>,
748 ) -> std::task::Poll<Option<Self::Item>> {
749 let this = &mut *self;
750 if this.inner.check_shutdown(cx) {
751 this.is_terminated = true;
752 return std::task::Poll::Ready(None);
753 }
754 if this.is_terminated {
755 panic!("polled FakeSocketProxy_RequestStream after completion");
756 }
757 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
758 |bytes, handles| {
759 match this.inner.channel().read_etc(cx, bytes, handles) {
760 std::task::Poll::Ready(Ok(())) => {}
761 std::task::Poll::Pending => return std::task::Poll::Pending,
762 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
763 this.is_terminated = true;
764 return std::task::Poll::Ready(None);
765 }
766 std::task::Poll::Ready(Err(e)) => {
767 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
768 e.into(),
769 ))));
770 }
771 }
772
773 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
775
776 std::task::Poll::Ready(Some(match header.ordinal {
777 0x5b24fd7a0d73c2d1 => {
778 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
779 let mut req = fidl::new_empty!(
780 FakeSocketProxySetDnsRequest,
781 fidl::encoding::DefaultFuchsiaResourceDialect
782 );
783 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeSocketProxySetDnsRequest>(&header, _body_bytes, handles, &mut req)?;
784 let control_handle =
785 FakeSocketProxy_ControlHandle { inner: this.inner.clone() };
786 Ok(FakeSocketProxy_Request::SetDns {
787 servers: req.servers,
788
789 responder: FakeSocketProxy_SetDnsResponder {
790 control_handle: std::mem::ManuallyDrop::new(control_handle),
791 tx_id: header.tx_id,
792 },
793 })
794 }
795 _ => Err(fidl::Error::UnknownOrdinal {
796 ordinal: header.ordinal,
797 protocol_name:
798 <FakeSocketProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
799 }),
800 }))
801 },
802 )
803 }
804}
805
806#[derive(Debug)]
807pub enum FakeSocketProxy_Request {
808 SetDns {
811 servers: Vec<fidl_fuchsia_net_policy_socketproxy::DnsServerList>,
812 responder: FakeSocketProxy_SetDnsResponder,
813 },
814}
815
816impl FakeSocketProxy_Request {
817 #[allow(irrefutable_let_patterns)]
818 pub fn into_set_dns(
819 self,
820 ) -> Option<(
821 Vec<fidl_fuchsia_net_policy_socketproxy::DnsServerList>,
822 FakeSocketProxy_SetDnsResponder,
823 )> {
824 if let FakeSocketProxy_Request::SetDns { servers, responder } = self {
825 Some((servers, responder))
826 } else {
827 None
828 }
829 }
830
831 pub fn method_name(&self) -> &'static str {
833 match *self {
834 FakeSocketProxy_Request::SetDns { .. } => "set_dns",
835 }
836 }
837}
838
839#[derive(Debug, Clone)]
840pub struct FakeSocketProxy_ControlHandle {
841 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
842}
843
844impl fidl::endpoints::ControlHandle for FakeSocketProxy_ControlHandle {
845 fn shutdown(&self) {
846 self.inner.shutdown()
847 }
848
849 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
850 self.inner.shutdown_with_epitaph(status)
851 }
852
853 fn is_closed(&self) -> bool {
854 self.inner.channel().is_closed()
855 }
856 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
857 self.inner.channel().on_closed()
858 }
859
860 #[cfg(target_os = "fuchsia")]
861 fn signal_peer(
862 &self,
863 clear_mask: zx::Signals,
864 set_mask: zx::Signals,
865 ) -> Result<(), zx_status::Status> {
866 use fidl::Peered;
867 self.inner.channel().signal_peer(clear_mask, set_mask)
868 }
869}
870
871impl FakeSocketProxy_ControlHandle {}
872
873#[must_use = "FIDL methods require a response to be sent"]
874#[derive(Debug)]
875pub struct FakeSocketProxy_SetDnsResponder {
876 control_handle: std::mem::ManuallyDrop<FakeSocketProxy_ControlHandle>,
877 tx_id: u32,
878}
879
880impl std::ops::Drop for FakeSocketProxy_SetDnsResponder {
884 fn drop(&mut self) {
885 self.control_handle.shutdown();
886 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
888 }
889}
890
891impl fidl::endpoints::Responder for FakeSocketProxy_SetDnsResponder {
892 type ControlHandle = FakeSocketProxy_ControlHandle;
893
894 fn control_handle(&self) -> &FakeSocketProxy_ControlHandle {
895 &self.control_handle
896 }
897
898 fn drop_without_shutdown(mut self) {
899 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
901 std::mem::forget(self);
903 }
904}
905
906impl FakeSocketProxy_SetDnsResponder {
907 pub fn send(self) -> Result<(), fidl::Error> {
911 let _result = self.send_raw();
912 if _result.is_err() {
913 self.control_handle.shutdown();
914 }
915 self.drop_without_shutdown();
916 _result
917 }
918
919 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
921 let _result = self.send_raw();
922 self.drop_without_shutdown();
923 _result
924 }
925
926 fn send_raw(&self) -> Result<(), fidl::Error> {
927 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
928 (),
929 self.tx_id,
930 0x5b24fd7a0d73c2d1,
931 fidl::encoding::DynamicFlags::empty(),
932 )
933 }
934}
935
936mod internal {
937 use super::*;
938}