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_stackmigrationdeprecated_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ControlMarker;
16
17impl fidl::endpoints::ProtocolMarker for ControlMarker {
18 type Proxy = ControlProxy;
19 type RequestStream = ControlRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = ControlSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.net.stackmigrationdeprecated.Control";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for ControlMarker {}
26
27pub trait ControlProxyInterface: Send + Sync {
28 type SetAutomatedNetstackVersionResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
29 + Send;
30 fn r#set_automated_netstack_version(
31 &self,
32 version: Option<&VersionSetting>,
33 ) -> Self::SetAutomatedNetstackVersionResponseFut;
34 type SetUserNetstackVersionResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
35 + Send;
36 fn r#set_user_netstack_version(
37 &self,
38 version: Option<&VersionSetting>,
39 ) -> Self::SetUserNetstackVersionResponseFut;
40}
41#[derive(Debug)]
42#[cfg(target_os = "fuchsia")]
43pub struct ControlSynchronousProxy {
44 client: fidl::client::sync::Client,
45}
46
47#[cfg(target_os = "fuchsia")]
48impl fidl::endpoints::SynchronousProxy for ControlSynchronousProxy {
49 type Proxy = ControlProxy;
50 type Protocol = ControlMarker;
51
52 fn from_channel(inner: fidl::Channel) -> Self {
53 Self::new(inner)
54 }
55
56 fn into_channel(self) -> fidl::Channel {
57 self.client.into_channel()
58 }
59
60 fn as_channel(&self) -> &fidl::Channel {
61 self.client.as_channel()
62 }
63}
64
65#[cfg(target_os = "fuchsia")]
66impl ControlSynchronousProxy {
67 pub fn new(channel: fidl::Channel) -> Self {
68 Self { client: fidl::client::sync::Client::new(channel) }
69 }
70
71 pub fn into_channel(self) -> fidl::Channel {
72 self.client.into_channel()
73 }
74
75 pub fn wait_for_event(
78 &self,
79 deadline: zx::MonotonicInstant,
80 ) -> Result<ControlEvent, fidl::Error> {
81 ControlEvent::decode(self.client.wait_for_event::<ControlMarker>(deadline)?)
82 }
83
84 pub fn r#set_automated_netstack_version(
91 &self,
92 mut version: Option<&VersionSetting>,
93 ___deadline: zx::MonotonicInstant,
94 ) -> Result<(), fidl::Error> {
95 let _response = self.client.send_query::<
96 ControlSetAutomatedNetstackVersionRequest,
97 fidl::encoding::EmptyPayload,
98 ControlMarker,
99 >(
100 (version,),
101 0x643e4cfaf3bb5fea,
102 fidl::encoding::DynamicFlags::empty(),
103 ___deadline,
104 )?;
105 Ok(_response)
106 }
107
108 pub fn r#set_user_netstack_version(
118 &self,
119 mut version: Option<&VersionSetting>,
120 ___deadline: zx::MonotonicInstant,
121 ) -> Result<(), fidl::Error> {
122 let _response = self.client.send_query::<
123 ControlSetUserNetstackVersionRequest,
124 fidl::encoding::EmptyPayload,
125 ControlMarker,
126 >(
127 (version,),
128 0x5ffd36d5fcea08b0,
129 fidl::encoding::DynamicFlags::empty(),
130 ___deadline,
131 )?;
132 Ok(_response)
133 }
134}
135
136#[cfg(target_os = "fuchsia")]
137impl From<ControlSynchronousProxy> for zx::NullableHandle {
138 fn from(value: ControlSynchronousProxy) -> Self {
139 value.into_channel().into()
140 }
141}
142
143#[cfg(target_os = "fuchsia")]
144impl From<fidl::Channel> for ControlSynchronousProxy {
145 fn from(value: fidl::Channel) -> Self {
146 Self::new(value)
147 }
148}
149
150#[cfg(target_os = "fuchsia")]
151impl fidl::endpoints::FromClient for ControlSynchronousProxy {
152 type Protocol = ControlMarker;
153
154 fn from_client(value: fidl::endpoints::ClientEnd<ControlMarker>) -> Self {
155 Self::new(value.into_channel())
156 }
157}
158
159#[derive(Debug, Clone)]
160pub struct ControlProxy {
161 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
162}
163
164impl fidl::endpoints::Proxy for ControlProxy {
165 type Protocol = ControlMarker;
166
167 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
168 Self::new(inner)
169 }
170
171 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
172 self.client.into_channel().map_err(|client| Self { client })
173 }
174
175 fn as_channel(&self) -> &::fidl::AsyncChannel {
176 self.client.as_channel()
177 }
178}
179
180impl ControlProxy {
181 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
183 let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
184 Self { client: fidl::client::Client::new(channel, protocol_name) }
185 }
186
187 pub fn take_event_stream(&self) -> ControlEventStream {
193 ControlEventStream { event_receiver: self.client.take_event_receiver() }
194 }
195
196 pub fn r#set_automated_netstack_version(
203 &self,
204 mut version: Option<&VersionSetting>,
205 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
206 ControlProxyInterface::r#set_automated_netstack_version(self, version)
207 }
208
209 pub fn r#set_user_netstack_version(
219 &self,
220 mut version: Option<&VersionSetting>,
221 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
222 ControlProxyInterface::r#set_user_netstack_version(self, version)
223 }
224}
225
226impl ControlProxyInterface for ControlProxy {
227 type SetAutomatedNetstackVersionResponseFut =
228 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
229 fn r#set_automated_netstack_version(
230 &self,
231 mut version: Option<&VersionSetting>,
232 ) -> Self::SetAutomatedNetstackVersionResponseFut {
233 fn _decode(
234 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
235 ) -> Result<(), fidl::Error> {
236 let _response = fidl::client::decode_transaction_body::<
237 fidl::encoding::EmptyPayload,
238 fidl::encoding::DefaultFuchsiaResourceDialect,
239 0x643e4cfaf3bb5fea,
240 >(_buf?)?;
241 Ok(_response)
242 }
243 self.client.send_query_and_decode::<ControlSetAutomatedNetstackVersionRequest, ()>(
244 (version,),
245 0x643e4cfaf3bb5fea,
246 fidl::encoding::DynamicFlags::empty(),
247 _decode,
248 )
249 }
250
251 type SetUserNetstackVersionResponseFut =
252 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
253 fn r#set_user_netstack_version(
254 &self,
255 mut version: Option<&VersionSetting>,
256 ) -> Self::SetUserNetstackVersionResponseFut {
257 fn _decode(
258 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
259 ) -> Result<(), fidl::Error> {
260 let _response = fidl::client::decode_transaction_body::<
261 fidl::encoding::EmptyPayload,
262 fidl::encoding::DefaultFuchsiaResourceDialect,
263 0x5ffd36d5fcea08b0,
264 >(_buf?)?;
265 Ok(_response)
266 }
267 self.client.send_query_and_decode::<ControlSetUserNetstackVersionRequest, ()>(
268 (version,),
269 0x5ffd36d5fcea08b0,
270 fidl::encoding::DynamicFlags::empty(),
271 _decode,
272 )
273 }
274}
275
276pub struct ControlEventStream {
277 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
278}
279
280impl std::marker::Unpin for ControlEventStream {}
281
282impl futures::stream::FusedStream for ControlEventStream {
283 fn is_terminated(&self) -> bool {
284 self.event_receiver.is_terminated()
285 }
286}
287
288impl futures::Stream for ControlEventStream {
289 type Item = Result<ControlEvent, fidl::Error>;
290
291 fn poll_next(
292 mut self: std::pin::Pin<&mut Self>,
293 cx: &mut std::task::Context<'_>,
294 ) -> std::task::Poll<Option<Self::Item>> {
295 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
296 &mut self.event_receiver,
297 cx
298 )?) {
299 Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
300 None => std::task::Poll::Ready(None),
301 }
302 }
303}
304
305#[derive(Debug)]
306pub enum ControlEvent {}
307
308impl ControlEvent {
309 fn decode(
311 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
312 ) -> Result<ControlEvent, fidl::Error> {
313 let (bytes, _handles) = buf.split_mut();
314 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
315 debug_assert_eq!(tx_header.tx_id, 0);
316 match tx_header.ordinal {
317 _ => Err(fidl::Error::UnknownOrdinal {
318 ordinal: tx_header.ordinal,
319 protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
320 }),
321 }
322 }
323}
324
325pub struct ControlRequestStream {
327 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
328 is_terminated: bool,
329}
330
331impl std::marker::Unpin for ControlRequestStream {}
332
333impl futures::stream::FusedStream for ControlRequestStream {
334 fn is_terminated(&self) -> bool {
335 self.is_terminated
336 }
337}
338
339impl fidl::endpoints::RequestStream for ControlRequestStream {
340 type Protocol = ControlMarker;
341 type ControlHandle = ControlControlHandle;
342
343 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
344 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
345 }
346
347 fn control_handle(&self) -> Self::ControlHandle {
348 ControlControlHandle { inner: self.inner.clone() }
349 }
350
351 fn into_inner(
352 self,
353 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
354 {
355 (self.inner, self.is_terminated)
356 }
357
358 fn from_inner(
359 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
360 is_terminated: bool,
361 ) -> Self {
362 Self { inner, is_terminated }
363 }
364}
365
366impl futures::Stream for ControlRequestStream {
367 type Item = Result<ControlRequest, fidl::Error>;
368
369 fn poll_next(
370 mut self: std::pin::Pin<&mut Self>,
371 cx: &mut std::task::Context<'_>,
372 ) -> std::task::Poll<Option<Self::Item>> {
373 let this = &mut *self;
374 if this.inner.check_shutdown(cx) {
375 this.is_terminated = true;
376 return std::task::Poll::Ready(None);
377 }
378 if this.is_terminated {
379 panic!("polled ControlRequestStream after completion");
380 }
381 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
382 |bytes, handles| {
383 match this.inner.channel().read_etc(cx, bytes, handles) {
384 std::task::Poll::Ready(Ok(())) => {}
385 std::task::Poll::Pending => return std::task::Poll::Pending,
386 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
387 this.is_terminated = true;
388 return std::task::Poll::Ready(None);
389 }
390 std::task::Poll::Ready(Err(e)) => {
391 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
392 e.into(),
393 ))));
394 }
395 }
396
397 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
399
400 std::task::Poll::Ready(Some(match header.ordinal {
401 0x643e4cfaf3bb5fea => {
402 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
403 let mut req = fidl::new_empty!(
404 ControlSetAutomatedNetstackVersionRequest,
405 fidl::encoding::DefaultFuchsiaResourceDialect
406 );
407 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetAutomatedNetstackVersionRequest>(&header, _body_bytes, handles, &mut req)?;
408 let control_handle = ControlControlHandle { inner: this.inner.clone() };
409 Ok(ControlRequest::SetAutomatedNetstackVersion {
410 version: req.version,
411
412 responder: ControlSetAutomatedNetstackVersionResponder {
413 control_handle: std::mem::ManuallyDrop::new(control_handle),
414 tx_id: header.tx_id,
415 },
416 })
417 }
418 0x5ffd36d5fcea08b0 => {
419 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
420 let mut req = fidl::new_empty!(
421 ControlSetUserNetstackVersionRequest,
422 fidl::encoding::DefaultFuchsiaResourceDialect
423 );
424 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetUserNetstackVersionRequest>(&header, _body_bytes, handles, &mut req)?;
425 let control_handle = ControlControlHandle { inner: this.inner.clone() };
426 Ok(ControlRequest::SetUserNetstackVersion {
427 version: req.version,
428
429 responder: ControlSetUserNetstackVersionResponder {
430 control_handle: std::mem::ManuallyDrop::new(control_handle),
431 tx_id: header.tx_id,
432 },
433 })
434 }
435 _ => Err(fidl::Error::UnknownOrdinal {
436 ordinal: header.ordinal,
437 protocol_name:
438 <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
439 }),
440 }))
441 },
442 )
443 }
444}
445
446#[derive(Debug)]
448pub enum ControlRequest {
449 SetAutomatedNetstackVersion {
456 version: Option<Box<VersionSetting>>,
457 responder: ControlSetAutomatedNetstackVersionResponder,
458 },
459 SetUserNetstackVersion {
469 version: Option<Box<VersionSetting>>,
470 responder: ControlSetUserNetstackVersionResponder,
471 },
472}
473
474impl ControlRequest {
475 #[allow(irrefutable_let_patterns)]
476 pub fn into_set_automated_netstack_version(
477 self,
478 ) -> Option<(Option<Box<VersionSetting>>, ControlSetAutomatedNetstackVersionResponder)> {
479 if let ControlRequest::SetAutomatedNetstackVersion { version, responder } = self {
480 Some((version, responder))
481 } else {
482 None
483 }
484 }
485
486 #[allow(irrefutable_let_patterns)]
487 pub fn into_set_user_netstack_version(
488 self,
489 ) -> Option<(Option<Box<VersionSetting>>, ControlSetUserNetstackVersionResponder)> {
490 if let ControlRequest::SetUserNetstackVersion { version, responder } = self {
491 Some((version, responder))
492 } else {
493 None
494 }
495 }
496
497 pub fn method_name(&self) -> &'static str {
499 match *self {
500 ControlRequest::SetAutomatedNetstackVersion { .. } => "set_automated_netstack_version",
501 ControlRequest::SetUserNetstackVersion { .. } => "set_user_netstack_version",
502 }
503 }
504}
505
506#[derive(Debug, Clone)]
507pub struct ControlControlHandle {
508 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
509}
510
511impl ControlControlHandle {
512 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
513 self.inner.shutdown_with_epitaph(status.into())
514 }
515}
516
517impl fidl::endpoints::ControlHandle for ControlControlHandle {
518 fn shutdown(&self) {
519 self.inner.shutdown()
520 }
521
522 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
523 self.inner.shutdown_with_epitaph(status)
524 }
525
526 fn is_closed(&self) -> bool {
527 self.inner.channel().is_closed()
528 }
529 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
530 self.inner.channel().on_closed()
531 }
532
533 #[cfg(target_os = "fuchsia")]
534 fn signal_peer(
535 &self,
536 clear_mask: zx::Signals,
537 set_mask: zx::Signals,
538 ) -> Result<(), zx_status::Status> {
539 use fidl::Peered;
540 self.inner.channel().signal_peer(clear_mask, set_mask)
541 }
542}
543
544impl ControlControlHandle {}
545
546#[must_use = "FIDL methods require a response to be sent"]
547#[derive(Debug)]
548pub struct ControlSetAutomatedNetstackVersionResponder {
549 control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
550 tx_id: u32,
551}
552
553impl std::ops::Drop for ControlSetAutomatedNetstackVersionResponder {
557 fn drop(&mut self) {
558 self.control_handle.shutdown();
559 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
561 }
562}
563
564impl fidl::endpoints::Responder for ControlSetAutomatedNetstackVersionResponder {
565 type ControlHandle = ControlControlHandle;
566
567 fn control_handle(&self) -> &ControlControlHandle {
568 &self.control_handle
569 }
570
571 fn drop_without_shutdown(mut self) {
572 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
574 std::mem::forget(self);
576 }
577}
578
579impl ControlSetAutomatedNetstackVersionResponder {
580 pub fn send(self) -> Result<(), fidl::Error> {
584 let _result = self.send_raw();
585 if _result.is_err() {
586 self.control_handle.shutdown();
587 }
588 self.drop_without_shutdown();
589 _result
590 }
591
592 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
594 let _result = self.send_raw();
595 self.drop_without_shutdown();
596 _result
597 }
598
599 fn send_raw(&self) -> Result<(), fidl::Error> {
600 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
601 (),
602 self.tx_id,
603 0x643e4cfaf3bb5fea,
604 fidl::encoding::DynamicFlags::empty(),
605 )
606 }
607}
608
609#[must_use = "FIDL methods require a response to be sent"]
610#[derive(Debug)]
611pub struct ControlSetUserNetstackVersionResponder {
612 control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
613 tx_id: u32,
614}
615
616impl std::ops::Drop for ControlSetUserNetstackVersionResponder {
620 fn drop(&mut self) {
621 self.control_handle.shutdown();
622 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
624 }
625}
626
627impl fidl::endpoints::Responder for ControlSetUserNetstackVersionResponder {
628 type ControlHandle = ControlControlHandle;
629
630 fn control_handle(&self) -> &ControlControlHandle {
631 &self.control_handle
632 }
633
634 fn drop_without_shutdown(mut self) {
635 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
637 std::mem::forget(self);
639 }
640}
641
642impl ControlSetUserNetstackVersionResponder {
643 pub fn send(self) -> Result<(), fidl::Error> {
647 let _result = self.send_raw();
648 if _result.is_err() {
649 self.control_handle.shutdown();
650 }
651 self.drop_without_shutdown();
652 _result
653 }
654
655 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
657 let _result = self.send_raw();
658 self.drop_without_shutdown();
659 _result
660 }
661
662 fn send_raw(&self) -> Result<(), fidl::Error> {
663 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
664 (),
665 self.tx_id,
666 0x5ffd36d5fcea08b0,
667 fidl::encoding::DynamicFlags::empty(),
668 )
669 }
670}
671
672#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
673pub struct StateMarker;
674
675impl fidl::endpoints::ProtocolMarker for StateMarker {
676 type Proxy = StateProxy;
677 type RequestStream = StateRequestStream;
678 #[cfg(target_os = "fuchsia")]
679 type SynchronousProxy = StateSynchronousProxy;
680
681 const DEBUG_NAME: &'static str = "fuchsia.net.stackmigrationdeprecated.State";
682}
683impl fidl::endpoints::DiscoverableProtocolMarker for StateMarker {}
684
685pub trait StateProxyInterface: Send + Sync {
686 type GetNetstackVersionResponseFut: std::future::Future<Output = Result<InEffectVersion, fidl::Error>>
687 + Send;
688 fn r#get_netstack_version(&self) -> Self::GetNetstackVersionResponseFut;
689}
690#[derive(Debug)]
691#[cfg(target_os = "fuchsia")]
692pub struct StateSynchronousProxy {
693 client: fidl::client::sync::Client,
694}
695
696#[cfg(target_os = "fuchsia")]
697impl fidl::endpoints::SynchronousProxy for StateSynchronousProxy {
698 type Proxy = StateProxy;
699 type Protocol = StateMarker;
700
701 fn from_channel(inner: fidl::Channel) -> Self {
702 Self::new(inner)
703 }
704
705 fn into_channel(self) -> fidl::Channel {
706 self.client.into_channel()
707 }
708
709 fn as_channel(&self) -> &fidl::Channel {
710 self.client.as_channel()
711 }
712}
713
714#[cfg(target_os = "fuchsia")]
715impl StateSynchronousProxy {
716 pub fn new(channel: fidl::Channel) -> Self {
717 Self { client: fidl::client::sync::Client::new(channel) }
718 }
719
720 pub fn into_channel(self) -> fidl::Channel {
721 self.client.into_channel()
722 }
723
724 pub fn wait_for_event(
727 &self,
728 deadline: zx::MonotonicInstant,
729 ) -> Result<StateEvent, fidl::Error> {
730 StateEvent::decode(self.client.wait_for_event::<StateMarker>(deadline)?)
731 }
732
733 pub fn r#get_netstack_version(
737 &self,
738 ___deadline: zx::MonotonicInstant,
739 ) -> Result<InEffectVersion, fidl::Error> {
740 let _response = self.client.send_query::<
741 fidl::encoding::EmptyPayload,
742 StateGetNetstackVersionResponse,
743 StateMarker,
744 >(
745 (),
746 0x67053bfebb619ba1,
747 fidl::encoding::DynamicFlags::empty(),
748 ___deadline,
749 )?;
750 Ok(_response.in_effect_version)
751 }
752}
753
754#[cfg(target_os = "fuchsia")]
755impl From<StateSynchronousProxy> for zx::NullableHandle {
756 fn from(value: StateSynchronousProxy) -> Self {
757 value.into_channel().into()
758 }
759}
760
761#[cfg(target_os = "fuchsia")]
762impl From<fidl::Channel> for StateSynchronousProxy {
763 fn from(value: fidl::Channel) -> Self {
764 Self::new(value)
765 }
766}
767
768#[cfg(target_os = "fuchsia")]
769impl fidl::endpoints::FromClient for StateSynchronousProxy {
770 type Protocol = StateMarker;
771
772 fn from_client(value: fidl::endpoints::ClientEnd<StateMarker>) -> Self {
773 Self::new(value.into_channel())
774 }
775}
776
777#[derive(Debug, Clone)]
778pub struct StateProxy {
779 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
780}
781
782impl fidl::endpoints::Proxy for StateProxy {
783 type Protocol = StateMarker;
784
785 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
786 Self::new(inner)
787 }
788
789 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
790 self.client.into_channel().map_err(|client| Self { client })
791 }
792
793 fn as_channel(&self) -> &::fidl::AsyncChannel {
794 self.client.as_channel()
795 }
796}
797
798impl StateProxy {
799 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
801 let protocol_name = <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
802 Self { client: fidl::client::Client::new(channel, protocol_name) }
803 }
804
805 pub fn take_event_stream(&self) -> StateEventStream {
811 StateEventStream { event_receiver: self.client.take_event_receiver() }
812 }
813
814 pub fn r#get_netstack_version(
818 &self,
819 ) -> fidl::client::QueryResponseFut<
820 InEffectVersion,
821 fidl::encoding::DefaultFuchsiaResourceDialect,
822 > {
823 StateProxyInterface::r#get_netstack_version(self)
824 }
825}
826
827impl StateProxyInterface for StateProxy {
828 type GetNetstackVersionResponseFut = fidl::client::QueryResponseFut<
829 InEffectVersion,
830 fidl::encoding::DefaultFuchsiaResourceDialect,
831 >;
832 fn r#get_netstack_version(&self) -> Self::GetNetstackVersionResponseFut {
833 fn _decode(
834 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
835 ) -> Result<InEffectVersion, fidl::Error> {
836 let _response = fidl::client::decode_transaction_body::<
837 StateGetNetstackVersionResponse,
838 fidl::encoding::DefaultFuchsiaResourceDialect,
839 0x67053bfebb619ba1,
840 >(_buf?)?;
841 Ok(_response.in_effect_version)
842 }
843 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, InEffectVersion>(
844 (),
845 0x67053bfebb619ba1,
846 fidl::encoding::DynamicFlags::empty(),
847 _decode,
848 )
849 }
850}
851
852pub struct StateEventStream {
853 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
854}
855
856impl std::marker::Unpin for StateEventStream {}
857
858impl futures::stream::FusedStream for StateEventStream {
859 fn is_terminated(&self) -> bool {
860 self.event_receiver.is_terminated()
861 }
862}
863
864impl futures::Stream for StateEventStream {
865 type Item = Result<StateEvent, fidl::Error>;
866
867 fn poll_next(
868 mut self: std::pin::Pin<&mut Self>,
869 cx: &mut std::task::Context<'_>,
870 ) -> std::task::Poll<Option<Self::Item>> {
871 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
872 &mut self.event_receiver,
873 cx
874 )?) {
875 Some(buf) => std::task::Poll::Ready(Some(StateEvent::decode(buf))),
876 None => std::task::Poll::Ready(None),
877 }
878 }
879}
880
881#[derive(Debug)]
882pub enum StateEvent {}
883
884impl StateEvent {
885 fn decode(
887 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
888 ) -> Result<StateEvent, fidl::Error> {
889 let (bytes, _handles) = buf.split_mut();
890 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
891 debug_assert_eq!(tx_header.tx_id, 0);
892 match tx_header.ordinal {
893 _ => Err(fidl::Error::UnknownOrdinal {
894 ordinal: tx_header.ordinal,
895 protocol_name: <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
896 }),
897 }
898 }
899}
900
901pub struct StateRequestStream {
903 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
904 is_terminated: bool,
905}
906
907impl std::marker::Unpin for StateRequestStream {}
908
909impl futures::stream::FusedStream for StateRequestStream {
910 fn is_terminated(&self) -> bool {
911 self.is_terminated
912 }
913}
914
915impl fidl::endpoints::RequestStream for StateRequestStream {
916 type Protocol = StateMarker;
917 type ControlHandle = StateControlHandle;
918
919 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
920 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
921 }
922
923 fn control_handle(&self) -> Self::ControlHandle {
924 StateControlHandle { inner: self.inner.clone() }
925 }
926
927 fn into_inner(
928 self,
929 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
930 {
931 (self.inner, self.is_terminated)
932 }
933
934 fn from_inner(
935 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
936 is_terminated: bool,
937 ) -> Self {
938 Self { inner, is_terminated }
939 }
940}
941
942impl futures::Stream for StateRequestStream {
943 type Item = Result<StateRequest, fidl::Error>;
944
945 fn poll_next(
946 mut self: std::pin::Pin<&mut Self>,
947 cx: &mut std::task::Context<'_>,
948 ) -> std::task::Poll<Option<Self::Item>> {
949 let this = &mut *self;
950 if this.inner.check_shutdown(cx) {
951 this.is_terminated = true;
952 return std::task::Poll::Ready(None);
953 }
954 if this.is_terminated {
955 panic!("polled StateRequestStream after completion");
956 }
957 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
958 |bytes, handles| {
959 match this.inner.channel().read_etc(cx, bytes, handles) {
960 std::task::Poll::Ready(Ok(())) => {}
961 std::task::Poll::Pending => return std::task::Poll::Pending,
962 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
963 this.is_terminated = true;
964 return std::task::Poll::Ready(None);
965 }
966 std::task::Poll::Ready(Err(e)) => {
967 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
968 e.into(),
969 ))));
970 }
971 }
972
973 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
975
976 std::task::Poll::Ready(Some(match header.ordinal {
977 0x67053bfebb619ba1 => {
978 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
979 let mut req = fidl::new_empty!(
980 fidl::encoding::EmptyPayload,
981 fidl::encoding::DefaultFuchsiaResourceDialect
982 );
983 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
984 let control_handle = StateControlHandle { inner: this.inner.clone() };
985 Ok(StateRequest::GetNetstackVersion {
986 responder: StateGetNetstackVersionResponder {
987 control_handle: std::mem::ManuallyDrop::new(control_handle),
988 tx_id: header.tx_id,
989 },
990 })
991 }
992 _ => Err(fidl::Error::UnknownOrdinal {
993 ordinal: header.ordinal,
994 protocol_name: <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
995 }),
996 }))
997 },
998 )
999 }
1000}
1001
1002#[derive(Debug)]
1004pub enum StateRequest {
1005 GetNetstackVersion { responder: StateGetNetstackVersionResponder },
1009}
1010
1011impl StateRequest {
1012 #[allow(irrefutable_let_patterns)]
1013 pub fn into_get_netstack_version(self) -> Option<(StateGetNetstackVersionResponder)> {
1014 if let StateRequest::GetNetstackVersion { responder } = self {
1015 Some((responder))
1016 } else {
1017 None
1018 }
1019 }
1020
1021 pub fn method_name(&self) -> &'static str {
1023 match *self {
1024 StateRequest::GetNetstackVersion { .. } => "get_netstack_version",
1025 }
1026 }
1027}
1028
1029#[derive(Debug, Clone)]
1030pub struct StateControlHandle {
1031 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1032}
1033
1034impl StateControlHandle {
1035 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1036 self.inner.shutdown_with_epitaph(status.into())
1037 }
1038}
1039
1040impl fidl::endpoints::ControlHandle for StateControlHandle {
1041 fn shutdown(&self) {
1042 self.inner.shutdown()
1043 }
1044
1045 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1046 self.inner.shutdown_with_epitaph(status)
1047 }
1048
1049 fn is_closed(&self) -> bool {
1050 self.inner.channel().is_closed()
1051 }
1052 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1053 self.inner.channel().on_closed()
1054 }
1055
1056 #[cfg(target_os = "fuchsia")]
1057 fn signal_peer(
1058 &self,
1059 clear_mask: zx::Signals,
1060 set_mask: zx::Signals,
1061 ) -> Result<(), zx_status::Status> {
1062 use fidl::Peered;
1063 self.inner.channel().signal_peer(clear_mask, set_mask)
1064 }
1065}
1066
1067impl StateControlHandle {}
1068
1069#[must_use = "FIDL methods require a response to be sent"]
1070#[derive(Debug)]
1071pub struct StateGetNetstackVersionResponder {
1072 control_handle: std::mem::ManuallyDrop<StateControlHandle>,
1073 tx_id: u32,
1074}
1075
1076impl std::ops::Drop for StateGetNetstackVersionResponder {
1080 fn drop(&mut self) {
1081 self.control_handle.shutdown();
1082 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1084 }
1085}
1086
1087impl fidl::endpoints::Responder for StateGetNetstackVersionResponder {
1088 type ControlHandle = StateControlHandle;
1089
1090 fn control_handle(&self) -> &StateControlHandle {
1091 &self.control_handle
1092 }
1093
1094 fn drop_without_shutdown(mut self) {
1095 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1097 std::mem::forget(self);
1099 }
1100}
1101
1102impl StateGetNetstackVersionResponder {
1103 pub fn send(self, mut in_effect_version: &InEffectVersion) -> Result<(), fidl::Error> {
1107 let _result = self.send_raw(in_effect_version);
1108 if _result.is_err() {
1109 self.control_handle.shutdown();
1110 }
1111 self.drop_without_shutdown();
1112 _result
1113 }
1114
1115 pub fn send_no_shutdown_on_err(
1117 self,
1118 mut in_effect_version: &InEffectVersion,
1119 ) -> Result<(), fidl::Error> {
1120 let _result = self.send_raw(in_effect_version);
1121 self.drop_without_shutdown();
1122 _result
1123 }
1124
1125 fn send_raw(&self, mut in_effect_version: &InEffectVersion) -> Result<(), fidl::Error> {
1126 self.control_handle.inner.send::<StateGetNetstackVersionResponse>(
1127 (in_effect_version,),
1128 self.tx_id,
1129 0x67053bfebb619ba1,
1130 fidl::encoding::DynamicFlags::empty(),
1131 )
1132 }
1133}
1134
1135mod internal {
1136 use super::*;
1137}