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 let protocol_name = <FakeNetcfgMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
59 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
60 }
61
62 pub fn into_channel(self) -> fidl::Channel {
63 self.client.into_channel()
64 }
65
66 pub fn wait_for_event(
69 &self,
70 deadline: zx::MonotonicInstant,
71 ) -> Result<FakeNetcfgEvent, fidl::Error> {
72 FakeNetcfgEvent::decode(self.client.wait_for_event(deadline)?)
73 }
74
75 pub fn r#set_dns(
79 &self,
80 mut servers: &[fidl_fuchsia_net_name::DnsServer_],
81 ___deadline: zx::MonotonicInstant,
82 ) -> Result<(), fidl::Error> {
83 let _response =
84 self.client.send_query::<FakeNetcfgSetDnsRequest, fidl::encoding::EmptyPayload>(
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 let protocol_name = <FakeSocketProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
517 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
518 }
519
520 pub fn into_channel(self) -> fidl::Channel {
521 self.client.into_channel()
522 }
523
524 pub fn wait_for_event(
527 &self,
528 deadline: zx::MonotonicInstant,
529 ) -> Result<FakeSocketProxy_Event, fidl::Error> {
530 FakeSocketProxy_Event::decode(self.client.wait_for_event(deadline)?)
531 }
532
533 pub fn r#set_dns(
536 &self,
537 mut servers: &[fidl_fuchsia_net_policy_socketproxy::DnsServerList],
538 ___deadline: zx::MonotonicInstant,
539 ) -> Result<(), fidl::Error> {
540 let _response =
541 self.client.send_query::<FakeSocketProxySetDnsRequest, fidl::encoding::EmptyPayload>(
542 (servers,),
543 0x5b24fd7a0d73c2d1,
544 fidl::encoding::DynamicFlags::empty(),
545 ___deadline,
546 )?;
547 Ok(_response)
548 }
549}
550
551#[cfg(target_os = "fuchsia")]
552impl From<FakeSocketProxy_SynchronousProxy> for zx::NullableHandle {
553 fn from(value: FakeSocketProxy_SynchronousProxy) -> Self {
554 value.into_channel().into()
555 }
556}
557
558#[cfg(target_os = "fuchsia")]
559impl From<fidl::Channel> for FakeSocketProxy_SynchronousProxy {
560 fn from(value: fidl::Channel) -> Self {
561 Self::new(value)
562 }
563}
564
565#[cfg(target_os = "fuchsia")]
566impl fidl::endpoints::FromClient for FakeSocketProxy_SynchronousProxy {
567 type Protocol = FakeSocketProxy_Marker;
568
569 fn from_client(value: fidl::endpoints::ClientEnd<FakeSocketProxy_Marker>) -> Self {
570 Self::new(value.into_channel())
571 }
572}
573
574#[derive(Debug, Clone)]
575pub struct FakeSocketProxy_Proxy {
576 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
577}
578
579impl fidl::endpoints::Proxy for FakeSocketProxy_Proxy {
580 type Protocol = FakeSocketProxy_Marker;
581
582 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
583 Self::new(inner)
584 }
585
586 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
587 self.client.into_channel().map_err(|client| Self { client })
588 }
589
590 fn as_channel(&self) -> &::fidl::AsyncChannel {
591 self.client.as_channel()
592 }
593}
594
595impl FakeSocketProxy_Proxy {
596 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
598 let protocol_name = <FakeSocketProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
599 Self { client: fidl::client::Client::new(channel, protocol_name) }
600 }
601
602 pub fn take_event_stream(&self) -> FakeSocketProxy_EventStream {
608 FakeSocketProxy_EventStream { event_receiver: self.client.take_event_receiver() }
609 }
610
611 pub fn r#set_dns(
614 &self,
615 mut servers: &[fidl_fuchsia_net_policy_socketproxy::DnsServerList],
616 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
617 FakeSocketProxy_ProxyInterface::r#set_dns(self, servers)
618 }
619}
620
621impl FakeSocketProxy_ProxyInterface for FakeSocketProxy_Proxy {
622 type SetDnsResponseFut =
623 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
624 fn r#set_dns(
625 &self,
626 mut servers: &[fidl_fuchsia_net_policy_socketproxy::DnsServerList],
627 ) -> Self::SetDnsResponseFut {
628 fn _decode(
629 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
630 ) -> Result<(), fidl::Error> {
631 let _response = fidl::client::decode_transaction_body::<
632 fidl::encoding::EmptyPayload,
633 fidl::encoding::DefaultFuchsiaResourceDialect,
634 0x5b24fd7a0d73c2d1,
635 >(_buf?)?;
636 Ok(_response)
637 }
638 self.client.send_query_and_decode::<FakeSocketProxySetDnsRequest, ()>(
639 (servers,),
640 0x5b24fd7a0d73c2d1,
641 fidl::encoding::DynamicFlags::empty(),
642 _decode,
643 )
644 }
645}
646
647pub struct FakeSocketProxy_EventStream {
648 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
649}
650
651impl std::marker::Unpin for FakeSocketProxy_EventStream {}
652
653impl futures::stream::FusedStream for FakeSocketProxy_EventStream {
654 fn is_terminated(&self) -> bool {
655 self.event_receiver.is_terminated()
656 }
657}
658
659impl futures::Stream for FakeSocketProxy_EventStream {
660 type Item = Result<FakeSocketProxy_Event, fidl::Error>;
661
662 fn poll_next(
663 mut self: std::pin::Pin<&mut Self>,
664 cx: &mut std::task::Context<'_>,
665 ) -> std::task::Poll<Option<Self::Item>> {
666 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
667 &mut self.event_receiver,
668 cx
669 )?) {
670 Some(buf) => std::task::Poll::Ready(Some(FakeSocketProxy_Event::decode(buf))),
671 None => std::task::Poll::Ready(None),
672 }
673 }
674}
675
676#[derive(Debug)]
677pub enum FakeSocketProxy_Event {}
678
679impl FakeSocketProxy_Event {
680 fn decode(
682 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
683 ) -> Result<FakeSocketProxy_Event, fidl::Error> {
684 let (bytes, _handles) = buf.split_mut();
685 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
686 debug_assert_eq!(tx_header.tx_id, 0);
687 match tx_header.ordinal {
688 _ => Err(fidl::Error::UnknownOrdinal {
689 ordinal: tx_header.ordinal,
690 protocol_name:
691 <FakeSocketProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
692 }),
693 }
694 }
695}
696
697pub struct FakeSocketProxy_RequestStream {
699 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
700 is_terminated: bool,
701}
702
703impl std::marker::Unpin for FakeSocketProxy_RequestStream {}
704
705impl futures::stream::FusedStream for FakeSocketProxy_RequestStream {
706 fn is_terminated(&self) -> bool {
707 self.is_terminated
708 }
709}
710
711impl fidl::endpoints::RequestStream for FakeSocketProxy_RequestStream {
712 type Protocol = FakeSocketProxy_Marker;
713 type ControlHandle = FakeSocketProxy_ControlHandle;
714
715 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
716 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
717 }
718
719 fn control_handle(&self) -> Self::ControlHandle {
720 FakeSocketProxy_ControlHandle { inner: self.inner.clone() }
721 }
722
723 fn into_inner(
724 self,
725 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
726 {
727 (self.inner, self.is_terminated)
728 }
729
730 fn from_inner(
731 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
732 is_terminated: bool,
733 ) -> Self {
734 Self { inner, is_terminated }
735 }
736}
737
738impl futures::Stream for FakeSocketProxy_RequestStream {
739 type Item = Result<FakeSocketProxy_Request, fidl::Error>;
740
741 fn poll_next(
742 mut self: std::pin::Pin<&mut Self>,
743 cx: &mut std::task::Context<'_>,
744 ) -> std::task::Poll<Option<Self::Item>> {
745 let this = &mut *self;
746 if this.inner.check_shutdown(cx) {
747 this.is_terminated = true;
748 return std::task::Poll::Ready(None);
749 }
750 if this.is_terminated {
751 panic!("polled FakeSocketProxy_RequestStream after completion");
752 }
753 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
754 |bytes, handles| {
755 match this.inner.channel().read_etc(cx, bytes, handles) {
756 std::task::Poll::Ready(Ok(())) => {}
757 std::task::Poll::Pending => return std::task::Poll::Pending,
758 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
759 this.is_terminated = true;
760 return std::task::Poll::Ready(None);
761 }
762 std::task::Poll::Ready(Err(e)) => {
763 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
764 e.into(),
765 ))));
766 }
767 }
768
769 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
771
772 std::task::Poll::Ready(Some(match header.ordinal {
773 0x5b24fd7a0d73c2d1 => {
774 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
775 let mut req = fidl::new_empty!(
776 FakeSocketProxySetDnsRequest,
777 fidl::encoding::DefaultFuchsiaResourceDialect
778 );
779 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FakeSocketProxySetDnsRequest>(&header, _body_bytes, handles, &mut req)?;
780 let control_handle =
781 FakeSocketProxy_ControlHandle { inner: this.inner.clone() };
782 Ok(FakeSocketProxy_Request::SetDns {
783 servers: req.servers,
784
785 responder: FakeSocketProxy_SetDnsResponder {
786 control_handle: std::mem::ManuallyDrop::new(control_handle),
787 tx_id: header.tx_id,
788 },
789 })
790 }
791 _ => Err(fidl::Error::UnknownOrdinal {
792 ordinal: header.ordinal,
793 protocol_name:
794 <FakeSocketProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
795 }),
796 }))
797 },
798 )
799 }
800}
801
802#[derive(Debug)]
803pub enum FakeSocketProxy_Request {
804 SetDns {
807 servers: Vec<fidl_fuchsia_net_policy_socketproxy::DnsServerList>,
808 responder: FakeSocketProxy_SetDnsResponder,
809 },
810}
811
812impl FakeSocketProxy_Request {
813 #[allow(irrefutable_let_patterns)]
814 pub fn into_set_dns(
815 self,
816 ) -> Option<(
817 Vec<fidl_fuchsia_net_policy_socketproxy::DnsServerList>,
818 FakeSocketProxy_SetDnsResponder,
819 )> {
820 if let FakeSocketProxy_Request::SetDns { servers, responder } = self {
821 Some((servers, responder))
822 } else {
823 None
824 }
825 }
826
827 pub fn method_name(&self) -> &'static str {
829 match *self {
830 FakeSocketProxy_Request::SetDns { .. } => "set_dns",
831 }
832 }
833}
834
835#[derive(Debug, Clone)]
836pub struct FakeSocketProxy_ControlHandle {
837 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
838}
839
840impl fidl::endpoints::ControlHandle for FakeSocketProxy_ControlHandle {
841 fn shutdown(&self) {
842 self.inner.shutdown()
843 }
844
845 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
846 self.inner.shutdown_with_epitaph(status)
847 }
848
849 fn is_closed(&self) -> bool {
850 self.inner.channel().is_closed()
851 }
852 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
853 self.inner.channel().on_closed()
854 }
855
856 #[cfg(target_os = "fuchsia")]
857 fn signal_peer(
858 &self,
859 clear_mask: zx::Signals,
860 set_mask: zx::Signals,
861 ) -> Result<(), zx_status::Status> {
862 use fidl::Peered;
863 self.inner.channel().signal_peer(clear_mask, set_mask)
864 }
865}
866
867impl FakeSocketProxy_ControlHandle {}
868
869#[must_use = "FIDL methods require a response to be sent"]
870#[derive(Debug)]
871pub struct FakeSocketProxy_SetDnsResponder {
872 control_handle: std::mem::ManuallyDrop<FakeSocketProxy_ControlHandle>,
873 tx_id: u32,
874}
875
876impl std::ops::Drop for FakeSocketProxy_SetDnsResponder {
880 fn drop(&mut self) {
881 self.control_handle.shutdown();
882 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
884 }
885}
886
887impl fidl::endpoints::Responder for FakeSocketProxy_SetDnsResponder {
888 type ControlHandle = FakeSocketProxy_ControlHandle;
889
890 fn control_handle(&self) -> &FakeSocketProxy_ControlHandle {
891 &self.control_handle
892 }
893
894 fn drop_without_shutdown(mut self) {
895 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
897 std::mem::forget(self);
899 }
900}
901
902impl FakeSocketProxy_SetDnsResponder {
903 pub fn send(self) -> Result<(), fidl::Error> {
907 let _result = self.send_raw();
908 if _result.is_err() {
909 self.control_handle.shutdown();
910 }
911 self.drop_without_shutdown();
912 _result
913 }
914
915 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
917 let _result = self.send_raw();
918 self.drop_without_shutdown();
919 _result
920 }
921
922 fn send_raw(&self) -> Result<(), fidl::Error> {
923 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
924 (),
925 self.tx_id,
926 0x5b24fd7a0d73c2d1,
927 fidl::encoding::DynamicFlags::empty(),
928 )
929 }
930}
931
932mod internal {
933 use super::*;
934}