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 fidl::endpoints::ControlHandle for ControlControlHandle {
512 fn shutdown(&self) {
513 self.inner.shutdown()
514 }
515
516 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
517 self.inner.shutdown_with_epitaph(status)
518 }
519
520 fn is_closed(&self) -> bool {
521 self.inner.channel().is_closed()
522 }
523 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
524 self.inner.channel().on_closed()
525 }
526
527 #[cfg(target_os = "fuchsia")]
528 fn signal_peer(
529 &self,
530 clear_mask: zx::Signals,
531 set_mask: zx::Signals,
532 ) -> Result<(), zx_status::Status> {
533 use fidl::Peered;
534 self.inner.channel().signal_peer(clear_mask, set_mask)
535 }
536}
537
538impl ControlControlHandle {}
539
540#[must_use = "FIDL methods require a response to be sent"]
541#[derive(Debug)]
542pub struct ControlSetAutomatedNetstackVersionResponder {
543 control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
544 tx_id: u32,
545}
546
547impl std::ops::Drop for ControlSetAutomatedNetstackVersionResponder {
551 fn drop(&mut self) {
552 self.control_handle.shutdown();
553 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
555 }
556}
557
558impl fidl::endpoints::Responder for ControlSetAutomatedNetstackVersionResponder {
559 type ControlHandle = ControlControlHandle;
560
561 fn control_handle(&self) -> &ControlControlHandle {
562 &self.control_handle
563 }
564
565 fn drop_without_shutdown(mut self) {
566 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
568 std::mem::forget(self);
570 }
571}
572
573impl ControlSetAutomatedNetstackVersionResponder {
574 pub fn send(self) -> Result<(), fidl::Error> {
578 let _result = self.send_raw();
579 if _result.is_err() {
580 self.control_handle.shutdown();
581 }
582 self.drop_without_shutdown();
583 _result
584 }
585
586 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
588 let _result = self.send_raw();
589 self.drop_without_shutdown();
590 _result
591 }
592
593 fn send_raw(&self) -> Result<(), fidl::Error> {
594 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
595 (),
596 self.tx_id,
597 0x643e4cfaf3bb5fea,
598 fidl::encoding::DynamicFlags::empty(),
599 )
600 }
601}
602
603#[must_use = "FIDL methods require a response to be sent"]
604#[derive(Debug)]
605pub struct ControlSetUserNetstackVersionResponder {
606 control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
607 tx_id: u32,
608}
609
610impl std::ops::Drop for ControlSetUserNetstackVersionResponder {
614 fn drop(&mut self) {
615 self.control_handle.shutdown();
616 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
618 }
619}
620
621impl fidl::endpoints::Responder for ControlSetUserNetstackVersionResponder {
622 type ControlHandle = ControlControlHandle;
623
624 fn control_handle(&self) -> &ControlControlHandle {
625 &self.control_handle
626 }
627
628 fn drop_without_shutdown(mut self) {
629 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
631 std::mem::forget(self);
633 }
634}
635
636impl ControlSetUserNetstackVersionResponder {
637 pub fn send(self) -> Result<(), fidl::Error> {
641 let _result = self.send_raw();
642 if _result.is_err() {
643 self.control_handle.shutdown();
644 }
645 self.drop_without_shutdown();
646 _result
647 }
648
649 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
651 let _result = self.send_raw();
652 self.drop_without_shutdown();
653 _result
654 }
655
656 fn send_raw(&self) -> Result<(), fidl::Error> {
657 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
658 (),
659 self.tx_id,
660 0x5ffd36d5fcea08b0,
661 fidl::encoding::DynamicFlags::empty(),
662 )
663 }
664}
665
666#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
667pub struct StateMarker;
668
669impl fidl::endpoints::ProtocolMarker for StateMarker {
670 type Proxy = StateProxy;
671 type RequestStream = StateRequestStream;
672 #[cfg(target_os = "fuchsia")]
673 type SynchronousProxy = StateSynchronousProxy;
674
675 const DEBUG_NAME: &'static str = "fuchsia.net.stackmigrationdeprecated.State";
676}
677impl fidl::endpoints::DiscoverableProtocolMarker for StateMarker {}
678
679pub trait StateProxyInterface: Send + Sync {
680 type GetNetstackVersionResponseFut: std::future::Future<Output = Result<InEffectVersion, fidl::Error>>
681 + Send;
682 fn r#get_netstack_version(&self) -> Self::GetNetstackVersionResponseFut;
683}
684#[derive(Debug)]
685#[cfg(target_os = "fuchsia")]
686pub struct StateSynchronousProxy {
687 client: fidl::client::sync::Client,
688}
689
690#[cfg(target_os = "fuchsia")]
691impl fidl::endpoints::SynchronousProxy for StateSynchronousProxy {
692 type Proxy = StateProxy;
693 type Protocol = StateMarker;
694
695 fn from_channel(inner: fidl::Channel) -> Self {
696 Self::new(inner)
697 }
698
699 fn into_channel(self) -> fidl::Channel {
700 self.client.into_channel()
701 }
702
703 fn as_channel(&self) -> &fidl::Channel {
704 self.client.as_channel()
705 }
706}
707
708#[cfg(target_os = "fuchsia")]
709impl StateSynchronousProxy {
710 pub fn new(channel: fidl::Channel) -> Self {
711 Self { client: fidl::client::sync::Client::new(channel) }
712 }
713
714 pub fn into_channel(self) -> fidl::Channel {
715 self.client.into_channel()
716 }
717
718 pub fn wait_for_event(
721 &self,
722 deadline: zx::MonotonicInstant,
723 ) -> Result<StateEvent, fidl::Error> {
724 StateEvent::decode(self.client.wait_for_event::<StateMarker>(deadline)?)
725 }
726
727 pub fn r#get_netstack_version(
731 &self,
732 ___deadline: zx::MonotonicInstant,
733 ) -> Result<InEffectVersion, fidl::Error> {
734 let _response = self.client.send_query::<
735 fidl::encoding::EmptyPayload,
736 StateGetNetstackVersionResponse,
737 StateMarker,
738 >(
739 (),
740 0x67053bfebb619ba1,
741 fidl::encoding::DynamicFlags::empty(),
742 ___deadline,
743 )?;
744 Ok(_response.in_effect_version)
745 }
746}
747
748#[cfg(target_os = "fuchsia")]
749impl From<StateSynchronousProxy> for zx::NullableHandle {
750 fn from(value: StateSynchronousProxy) -> Self {
751 value.into_channel().into()
752 }
753}
754
755#[cfg(target_os = "fuchsia")]
756impl From<fidl::Channel> for StateSynchronousProxy {
757 fn from(value: fidl::Channel) -> Self {
758 Self::new(value)
759 }
760}
761
762#[cfg(target_os = "fuchsia")]
763impl fidl::endpoints::FromClient for StateSynchronousProxy {
764 type Protocol = StateMarker;
765
766 fn from_client(value: fidl::endpoints::ClientEnd<StateMarker>) -> Self {
767 Self::new(value.into_channel())
768 }
769}
770
771#[derive(Debug, Clone)]
772pub struct StateProxy {
773 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
774}
775
776impl fidl::endpoints::Proxy for StateProxy {
777 type Protocol = StateMarker;
778
779 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
780 Self::new(inner)
781 }
782
783 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
784 self.client.into_channel().map_err(|client| Self { client })
785 }
786
787 fn as_channel(&self) -> &::fidl::AsyncChannel {
788 self.client.as_channel()
789 }
790}
791
792impl StateProxy {
793 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
795 let protocol_name = <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
796 Self { client: fidl::client::Client::new(channel, protocol_name) }
797 }
798
799 pub fn take_event_stream(&self) -> StateEventStream {
805 StateEventStream { event_receiver: self.client.take_event_receiver() }
806 }
807
808 pub fn r#get_netstack_version(
812 &self,
813 ) -> fidl::client::QueryResponseFut<
814 InEffectVersion,
815 fidl::encoding::DefaultFuchsiaResourceDialect,
816 > {
817 StateProxyInterface::r#get_netstack_version(self)
818 }
819}
820
821impl StateProxyInterface for StateProxy {
822 type GetNetstackVersionResponseFut = fidl::client::QueryResponseFut<
823 InEffectVersion,
824 fidl::encoding::DefaultFuchsiaResourceDialect,
825 >;
826 fn r#get_netstack_version(&self) -> Self::GetNetstackVersionResponseFut {
827 fn _decode(
828 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
829 ) -> Result<InEffectVersion, fidl::Error> {
830 let _response = fidl::client::decode_transaction_body::<
831 StateGetNetstackVersionResponse,
832 fidl::encoding::DefaultFuchsiaResourceDialect,
833 0x67053bfebb619ba1,
834 >(_buf?)?;
835 Ok(_response.in_effect_version)
836 }
837 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, InEffectVersion>(
838 (),
839 0x67053bfebb619ba1,
840 fidl::encoding::DynamicFlags::empty(),
841 _decode,
842 )
843 }
844}
845
846pub struct StateEventStream {
847 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
848}
849
850impl std::marker::Unpin for StateEventStream {}
851
852impl futures::stream::FusedStream for StateEventStream {
853 fn is_terminated(&self) -> bool {
854 self.event_receiver.is_terminated()
855 }
856}
857
858impl futures::Stream for StateEventStream {
859 type Item = Result<StateEvent, fidl::Error>;
860
861 fn poll_next(
862 mut self: std::pin::Pin<&mut Self>,
863 cx: &mut std::task::Context<'_>,
864 ) -> std::task::Poll<Option<Self::Item>> {
865 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
866 &mut self.event_receiver,
867 cx
868 )?) {
869 Some(buf) => std::task::Poll::Ready(Some(StateEvent::decode(buf))),
870 None => std::task::Poll::Ready(None),
871 }
872 }
873}
874
875#[derive(Debug)]
876pub enum StateEvent {}
877
878impl StateEvent {
879 fn decode(
881 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
882 ) -> Result<StateEvent, fidl::Error> {
883 let (bytes, _handles) = buf.split_mut();
884 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
885 debug_assert_eq!(tx_header.tx_id, 0);
886 match tx_header.ordinal {
887 _ => Err(fidl::Error::UnknownOrdinal {
888 ordinal: tx_header.ordinal,
889 protocol_name: <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
890 }),
891 }
892 }
893}
894
895pub struct StateRequestStream {
897 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
898 is_terminated: bool,
899}
900
901impl std::marker::Unpin for StateRequestStream {}
902
903impl futures::stream::FusedStream for StateRequestStream {
904 fn is_terminated(&self) -> bool {
905 self.is_terminated
906 }
907}
908
909impl fidl::endpoints::RequestStream for StateRequestStream {
910 type Protocol = StateMarker;
911 type ControlHandle = StateControlHandle;
912
913 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
914 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
915 }
916
917 fn control_handle(&self) -> Self::ControlHandle {
918 StateControlHandle { inner: self.inner.clone() }
919 }
920
921 fn into_inner(
922 self,
923 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
924 {
925 (self.inner, self.is_terminated)
926 }
927
928 fn from_inner(
929 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
930 is_terminated: bool,
931 ) -> Self {
932 Self { inner, is_terminated }
933 }
934}
935
936impl futures::Stream for StateRequestStream {
937 type Item = Result<StateRequest, fidl::Error>;
938
939 fn poll_next(
940 mut self: std::pin::Pin<&mut Self>,
941 cx: &mut std::task::Context<'_>,
942 ) -> std::task::Poll<Option<Self::Item>> {
943 let this = &mut *self;
944 if this.inner.check_shutdown(cx) {
945 this.is_terminated = true;
946 return std::task::Poll::Ready(None);
947 }
948 if this.is_terminated {
949 panic!("polled StateRequestStream after completion");
950 }
951 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
952 |bytes, handles| {
953 match this.inner.channel().read_etc(cx, bytes, handles) {
954 std::task::Poll::Ready(Ok(())) => {}
955 std::task::Poll::Pending => return std::task::Poll::Pending,
956 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
957 this.is_terminated = true;
958 return std::task::Poll::Ready(None);
959 }
960 std::task::Poll::Ready(Err(e)) => {
961 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
962 e.into(),
963 ))));
964 }
965 }
966
967 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
969
970 std::task::Poll::Ready(Some(match header.ordinal {
971 0x67053bfebb619ba1 => {
972 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
973 let mut req = fidl::new_empty!(
974 fidl::encoding::EmptyPayload,
975 fidl::encoding::DefaultFuchsiaResourceDialect
976 );
977 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
978 let control_handle = StateControlHandle { inner: this.inner.clone() };
979 Ok(StateRequest::GetNetstackVersion {
980 responder: StateGetNetstackVersionResponder {
981 control_handle: std::mem::ManuallyDrop::new(control_handle),
982 tx_id: header.tx_id,
983 },
984 })
985 }
986 _ => Err(fidl::Error::UnknownOrdinal {
987 ordinal: header.ordinal,
988 protocol_name: <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
989 }),
990 }))
991 },
992 )
993 }
994}
995
996#[derive(Debug)]
998pub enum StateRequest {
999 GetNetstackVersion { responder: StateGetNetstackVersionResponder },
1003}
1004
1005impl StateRequest {
1006 #[allow(irrefutable_let_patterns)]
1007 pub fn into_get_netstack_version(self) -> Option<(StateGetNetstackVersionResponder)> {
1008 if let StateRequest::GetNetstackVersion { responder } = self {
1009 Some((responder))
1010 } else {
1011 None
1012 }
1013 }
1014
1015 pub fn method_name(&self) -> &'static str {
1017 match *self {
1018 StateRequest::GetNetstackVersion { .. } => "get_netstack_version",
1019 }
1020 }
1021}
1022
1023#[derive(Debug, Clone)]
1024pub struct StateControlHandle {
1025 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1026}
1027
1028impl fidl::endpoints::ControlHandle for StateControlHandle {
1029 fn shutdown(&self) {
1030 self.inner.shutdown()
1031 }
1032
1033 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1034 self.inner.shutdown_with_epitaph(status)
1035 }
1036
1037 fn is_closed(&self) -> bool {
1038 self.inner.channel().is_closed()
1039 }
1040 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1041 self.inner.channel().on_closed()
1042 }
1043
1044 #[cfg(target_os = "fuchsia")]
1045 fn signal_peer(
1046 &self,
1047 clear_mask: zx::Signals,
1048 set_mask: zx::Signals,
1049 ) -> Result<(), zx_status::Status> {
1050 use fidl::Peered;
1051 self.inner.channel().signal_peer(clear_mask, set_mask)
1052 }
1053}
1054
1055impl StateControlHandle {}
1056
1057#[must_use = "FIDL methods require a response to be sent"]
1058#[derive(Debug)]
1059pub struct StateGetNetstackVersionResponder {
1060 control_handle: std::mem::ManuallyDrop<StateControlHandle>,
1061 tx_id: u32,
1062}
1063
1064impl std::ops::Drop for StateGetNetstackVersionResponder {
1068 fn drop(&mut self) {
1069 self.control_handle.shutdown();
1070 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1072 }
1073}
1074
1075impl fidl::endpoints::Responder for StateGetNetstackVersionResponder {
1076 type ControlHandle = StateControlHandle;
1077
1078 fn control_handle(&self) -> &StateControlHandle {
1079 &self.control_handle
1080 }
1081
1082 fn drop_without_shutdown(mut self) {
1083 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1085 std::mem::forget(self);
1087 }
1088}
1089
1090impl StateGetNetstackVersionResponder {
1091 pub fn send(self, mut in_effect_version: &InEffectVersion) -> Result<(), fidl::Error> {
1095 let _result = self.send_raw(in_effect_version);
1096 if _result.is_err() {
1097 self.control_handle.shutdown();
1098 }
1099 self.drop_without_shutdown();
1100 _result
1101 }
1102
1103 pub fn send_no_shutdown_on_err(
1105 self,
1106 mut in_effect_version: &InEffectVersion,
1107 ) -> Result<(), fidl::Error> {
1108 let _result = self.send_raw(in_effect_version);
1109 self.drop_without_shutdown();
1110 _result
1111 }
1112
1113 fn send_raw(&self, mut in_effect_version: &InEffectVersion) -> Result<(), fidl::Error> {
1114 self.control_handle.inner.send::<StateGetNetstackVersionResponse>(
1115 (in_effect_version,),
1116 self.tx_id,
1117 0x67053bfebb619ba1,
1118 fidl::encoding::DynamicFlags::empty(),
1119 )
1120 }
1121}
1122
1123mod internal {
1124 use super::*;
1125}