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