fidl_fuchsia_net_stackmigrationdeprecated/
fidl_fuchsia_net_stackmigrationdeprecated.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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    /// Waits until an event arrives and returns it. It is safe for other
77    /// threads to make concurrent requests while waiting for an event.
78    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    /// Sets the automated target network stack version.
86    ///
87    /// Takes effect on next boot.
88    ///
89    /// + request `version` requested network stack version. If unset, the
90    ///   automated version preference is cleared.
91    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    /// Sets user selection target network stack version.
108    ///
109    /// Takes effect on next boot.
110    ///
111    /// If set, the user netstack version preference always takes precedence
112    /// over the automated version selection.
113    ///
114    /// + request `version` requested network stack version. If unset, the user
115    ///   version preference is cleared.
116    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#[derive(Debug, Clone)]
148pub struct ControlProxy {
149    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
150}
151
152impl fidl::endpoints::Proxy for ControlProxy {
153    type Protocol = ControlMarker;
154
155    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
156        Self::new(inner)
157    }
158
159    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
160        self.client.into_channel().map_err(|client| Self { client })
161    }
162
163    fn as_channel(&self) -> &::fidl::AsyncChannel {
164        self.client.as_channel()
165    }
166}
167
168impl ControlProxy {
169    /// Create a new Proxy for fuchsia.net.stackmigrationdeprecated/Control.
170    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
171        let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
172        Self { client: fidl::client::Client::new(channel, protocol_name) }
173    }
174
175    /// Get a Stream of events from the remote end of the protocol.
176    ///
177    /// # Panics
178    ///
179    /// Panics if the event stream was already taken.
180    pub fn take_event_stream(&self) -> ControlEventStream {
181        ControlEventStream { event_receiver: self.client.take_event_receiver() }
182    }
183
184    /// Sets the automated target network stack version.
185    ///
186    /// Takes effect on next boot.
187    ///
188    /// + request `version` requested network stack version. If unset, the
189    ///   automated version preference is cleared.
190    pub fn r#set_automated_netstack_version(
191        &self,
192        mut version: Option<&VersionSetting>,
193    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
194        ControlProxyInterface::r#set_automated_netstack_version(self, version)
195    }
196
197    /// Sets user selection target network stack version.
198    ///
199    /// Takes effect on next boot.
200    ///
201    /// If set, the user netstack version preference always takes precedence
202    /// over the automated version selection.
203    ///
204    /// + request `version` requested network stack version. If unset, the user
205    ///   version preference is cleared.
206    pub fn r#set_user_netstack_version(
207        &self,
208        mut version: Option<&VersionSetting>,
209    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
210        ControlProxyInterface::r#set_user_netstack_version(self, version)
211    }
212}
213
214impl ControlProxyInterface for ControlProxy {
215    type SetAutomatedNetstackVersionResponseFut =
216        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
217    fn r#set_automated_netstack_version(
218        &self,
219        mut version: Option<&VersionSetting>,
220    ) -> Self::SetAutomatedNetstackVersionResponseFut {
221        fn _decode(
222            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
223        ) -> Result<(), fidl::Error> {
224            let _response = fidl::client::decode_transaction_body::<
225                fidl::encoding::EmptyPayload,
226                fidl::encoding::DefaultFuchsiaResourceDialect,
227                0x643e4cfaf3bb5fea,
228            >(_buf?)?;
229            Ok(_response)
230        }
231        self.client.send_query_and_decode::<ControlSetAutomatedNetstackVersionRequest, ()>(
232            (version,),
233            0x643e4cfaf3bb5fea,
234            fidl::encoding::DynamicFlags::empty(),
235            _decode,
236        )
237    }
238
239    type SetUserNetstackVersionResponseFut =
240        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
241    fn r#set_user_netstack_version(
242        &self,
243        mut version: Option<&VersionSetting>,
244    ) -> Self::SetUserNetstackVersionResponseFut {
245        fn _decode(
246            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
247        ) -> Result<(), fidl::Error> {
248            let _response = fidl::client::decode_transaction_body::<
249                fidl::encoding::EmptyPayload,
250                fidl::encoding::DefaultFuchsiaResourceDialect,
251                0x5ffd36d5fcea08b0,
252            >(_buf?)?;
253            Ok(_response)
254        }
255        self.client.send_query_and_decode::<ControlSetUserNetstackVersionRequest, ()>(
256            (version,),
257            0x5ffd36d5fcea08b0,
258            fidl::encoding::DynamicFlags::empty(),
259            _decode,
260        )
261    }
262}
263
264pub struct ControlEventStream {
265    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
266}
267
268impl std::marker::Unpin for ControlEventStream {}
269
270impl futures::stream::FusedStream for ControlEventStream {
271    fn is_terminated(&self) -> bool {
272        self.event_receiver.is_terminated()
273    }
274}
275
276impl futures::Stream for ControlEventStream {
277    type Item = Result<ControlEvent, fidl::Error>;
278
279    fn poll_next(
280        mut self: std::pin::Pin<&mut Self>,
281        cx: &mut std::task::Context<'_>,
282    ) -> std::task::Poll<Option<Self::Item>> {
283        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
284            &mut self.event_receiver,
285            cx
286        )?) {
287            Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
288            None => std::task::Poll::Ready(None),
289        }
290    }
291}
292
293#[derive(Debug)]
294pub enum ControlEvent {}
295
296impl ControlEvent {
297    /// Decodes a message buffer as a [`ControlEvent`].
298    fn decode(
299        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
300    ) -> Result<ControlEvent, fidl::Error> {
301        let (bytes, _handles) = buf.split_mut();
302        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
303        debug_assert_eq!(tx_header.tx_id, 0);
304        match tx_header.ordinal {
305            _ => Err(fidl::Error::UnknownOrdinal {
306                ordinal: tx_header.ordinal,
307                protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
308            }),
309        }
310    }
311}
312
313/// A Stream of incoming requests for fuchsia.net.stackmigrationdeprecated/Control.
314pub struct ControlRequestStream {
315    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
316    is_terminated: bool,
317}
318
319impl std::marker::Unpin for ControlRequestStream {}
320
321impl futures::stream::FusedStream for ControlRequestStream {
322    fn is_terminated(&self) -> bool {
323        self.is_terminated
324    }
325}
326
327impl fidl::endpoints::RequestStream for ControlRequestStream {
328    type Protocol = ControlMarker;
329    type ControlHandle = ControlControlHandle;
330
331    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
332        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
333    }
334
335    fn control_handle(&self) -> Self::ControlHandle {
336        ControlControlHandle { inner: self.inner.clone() }
337    }
338
339    fn into_inner(
340        self,
341    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
342    {
343        (self.inner, self.is_terminated)
344    }
345
346    fn from_inner(
347        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
348        is_terminated: bool,
349    ) -> Self {
350        Self { inner, is_terminated }
351    }
352}
353
354impl futures::Stream for ControlRequestStream {
355    type Item = Result<ControlRequest, fidl::Error>;
356
357    fn poll_next(
358        mut self: std::pin::Pin<&mut Self>,
359        cx: &mut std::task::Context<'_>,
360    ) -> std::task::Poll<Option<Self::Item>> {
361        let this = &mut *self;
362        if this.inner.check_shutdown(cx) {
363            this.is_terminated = true;
364            return std::task::Poll::Ready(None);
365        }
366        if this.is_terminated {
367            panic!("polled ControlRequestStream after completion");
368        }
369        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
370            |bytes, handles| {
371                match this.inner.channel().read_etc(cx, bytes, handles) {
372                    std::task::Poll::Ready(Ok(())) => {}
373                    std::task::Poll::Pending => return std::task::Poll::Pending,
374                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
375                        this.is_terminated = true;
376                        return std::task::Poll::Ready(None);
377                    }
378                    std::task::Poll::Ready(Err(e)) => {
379                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
380                            e.into(),
381                        ))))
382                    }
383                }
384
385                // A message has been received from the channel
386                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
387
388                std::task::Poll::Ready(Some(match header.ordinal {
389                    0x643e4cfaf3bb5fea => {
390                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
391                        let mut req = fidl::new_empty!(
392                            ControlSetAutomatedNetstackVersionRequest,
393                            fidl::encoding::DefaultFuchsiaResourceDialect
394                        );
395                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetAutomatedNetstackVersionRequest>(&header, _body_bytes, handles, &mut req)?;
396                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
397                        Ok(ControlRequest::SetAutomatedNetstackVersion {
398                            version: req.version,
399
400                            responder: ControlSetAutomatedNetstackVersionResponder {
401                                control_handle: std::mem::ManuallyDrop::new(control_handle),
402                                tx_id: header.tx_id,
403                            },
404                        })
405                    }
406                    0x5ffd36d5fcea08b0 => {
407                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
408                        let mut req = fidl::new_empty!(
409                            ControlSetUserNetstackVersionRequest,
410                            fidl::encoding::DefaultFuchsiaResourceDialect
411                        );
412                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetUserNetstackVersionRequest>(&header, _body_bytes, handles, &mut req)?;
413                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
414                        Ok(ControlRequest::SetUserNetstackVersion {
415                            version: req.version,
416
417                            responder: ControlSetUserNetstackVersionResponder {
418                                control_handle: std::mem::ManuallyDrop::new(control_handle),
419                                tx_id: header.tx_id,
420                            },
421                        })
422                    }
423                    _ => Err(fidl::Error::UnknownOrdinal {
424                        ordinal: header.ordinal,
425                        protocol_name:
426                            <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
427                    }),
428                }))
429            },
430        )
431    }
432}
433
434/// Provides access to controlling netstack migration configuration.
435#[derive(Debug)]
436pub enum ControlRequest {
437    /// Sets the automated target network stack version.
438    ///
439    /// Takes effect on next boot.
440    ///
441    /// + request `version` requested network stack version. If unset, the
442    ///   automated version preference is cleared.
443    SetAutomatedNetstackVersion {
444        version: Option<Box<VersionSetting>>,
445        responder: ControlSetAutomatedNetstackVersionResponder,
446    },
447    /// Sets user selection target network stack version.
448    ///
449    /// Takes effect on next boot.
450    ///
451    /// If set, the user netstack version preference always takes precedence
452    /// over the automated version selection.
453    ///
454    /// + request `version` requested network stack version. If unset, the user
455    ///   version preference is cleared.
456    SetUserNetstackVersion {
457        version: Option<Box<VersionSetting>>,
458        responder: ControlSetUserNetstackVersionResponder,
459    },
460}
461
462impl ControlRequest {
463    #[allow(irrefutable_let_patterns)]
464    pub fn into_set_automated_netstack_version(
465        self,
466    ) -> Option<(Option<Box<VersionSetting>>, ControlSetAutomatedNetstackVersionResponder)> {
467        if let ControlRequest::SetAutomatedNetstackVersion { version, responder } = self {
468            Some((version, responder))
469        } else {
470            None
471        }
472    }
473
474    #[allow(irrefutable_let_patterns)]
475    pub fn into_set_user_netstack_version(
476        self,
477    ) -> Option<(Option<Box<VersionSetting>>, ControlSetUserNetstackVersionResponder)> {
478        if let ControlRequest::SetUserNetstackVersion { version, responder } = self {
479            Some((version, responder))
480        } else {
481            None
482        }
483    }
484
485    /// Name of the method defined in FIDL
486    pub fn method_name(&self) -> &'static str {
487        match *self {
488            ControlRequest::SetAutomatedNetstackVersion { .. } => "set_automated_netstack_version",
489            ControlRequest::SetUserNetstackVersion { .. } => "set_user_netstack_version",
490        }
491    }
492}
493
494#[derive(Debug, Clone)]
495pub struct ControlControlHandle {
496    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
497}
498
499impl fidl::endpoints::ControlHandle for ControlControlHandle {
500    fn shutdown(&self) {
501        self.inner.shutdown()
502    }
503    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
504        self.inner.shutdown_with_epitaph(status)
505    }
506
507    fn is_closed(&self) -> bool {
508        self.inner.channel().is_closed()
509    }
510    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
511        self.inner.channel().on_closed()
512    }
513
514    #[cfg(target_os = "fuchsia")]
515    fn signal_peer(
516        &self,
517        clear_mask: zx::Signals,
518        set_mask: zx::Signals,
519    ) -> Result<(), zx_status::Status> {
520        use fidl::Peered;
521        self.inner.channel().signal_peer(clear_mask, set_mask)
522    }
523}
524
525impl ControlControlHandle {}
526
527#[must_use = "FIDL methods require a response to be sent"]
528#[derive(Debug)]
529pub struct ControlSetAutomatedNetstackVersionResponder {
530    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
531    tx_id: u32,
532}
533
534/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
535/// if the responder is dropped without sending a response, so that the client
536/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
537impl std::ops::Drop for ControlSetAutomatedNetstackVersionResponder {
538    fn drop(&mut self) {
539        self.control_handle.shutdown();
540        // Safety: drops once, never accessed again
541        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
542    }
543}
544
545impl fidl::endpoints::Responder for ControlSetAutomatedNetstackVersionResponder {
546    type ControlHandle = ControlControlHandle;
547
548    fn control_handle(&self) -> &ControlControlHandle {
549        &self.control_handle
550    }
551
552    fn drop_without_shutdown(mut self) {
553        // Safety: drops once, never accessed again due to mem::forget
554        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
555        // Prevent Drop from running (which would shut down the channel)
556        std::mem::forget(self);
557    }
558}
559
560impl ControlSetAutomatedNetstackVersionResponder {
561    /// Sends a response to the FIDL transaction.
562    ///
563    /// Sets the channel to shutdown if an error occurs.
564    pub fn send(self) -> Result<(), fidl::Error> {
565        let _result = self.send_raw();
566        if _result.is_err() {
567            self.control_handle.shutdown();
568        }
569        self.drop_without_shutdown();
570        _result
571    }
572
573    /// Similar to "send" but does not shutdown the channel if an error occurs.
574    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
575        let _result = self.send_raw();
576        self.drop_without_shutdown();
577        _result
578    }
579
580    fn send_raw(&self) -> Result<(), fidl::Error> {
581        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
582            (),
583            self.tx_id,
584            0x643e4cfaf3bb5fea,
585            fidl::encoding::DynamicFlags::empty(),
586        )
587    }
588}
589
590#[must_use = "FIDL methods require a response to be sent"]
591#[derive(Debug)]
592pub struct ControlSetUserNetstackVersionResponder {
593    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
594    tx_id: u32,
595}
596
597/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
598/// if the responder is dropped without sending a response, so that the client
599/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
600impl std::ops::Drop for ControlSetUserNetstackVersionResponder {
601    fn drop(&mut self) {
602        self.control_handle.shutdown();
603        // Safety: drops once, never accessed again
604        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
605    }
606}
607
608impl fidl::endpoints::Responder for ControlSetUserNetstackVersionResponder {
609    type ControlHandle = ControlControlHandle;
610
611    fn control_handle(&self) -> &ControlControlHandle {
612        &self.control_handle
613    }
614
615    fn drop_without_shutdown(mut self) {
616        // Safety: drops once, never accessed again due to mem::forget
617        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
618        // Prevent Drop from running (which would shut down the channel)
619        std::mem::forget(self);
620    }
621}
622
623impl ControlSetUserNetstackVersionResponder {
624    /// Sends a response to the FIDL transaction.
625    ///
626    /// Sets the channel to shutdown if an error occurs.
627    pub fn send(self) -> Result<(), fidl::Error> {
628        let _result = self.send_raw();
629        if _result.is_err() {
630            self.control_handle.shutdown();
631        }
632        self.drop_without_shutdown();
633        _result
634    }
635
636    /// Similar to "send" but does not shutdown the channel if an error occurs.
637    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
638        let _result = self.send_raw();
639        self.drop_without_shutdown();
640        _result
641    }
642
643    fn send_raw(&self) -> Result<(), fidl::Error> {
644        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
645            (),
646            self.tx_id,
647            0x5ffd36d5fcea08b0,
648            fidl::encoding::DynamicFlags::empty(),
649        )
650    }
651}
652
653#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
654pub struct StateMarker;
655
656impl fidl::endpoints::ProtocolMarker for StateMarker {
657    type Proxy = StateProxy;
658    type RequestStream = StateRequestStream;
659    #[cfg(target_os = "fuchsia")]
660    type SynchronousProxy = StateSynchronousProxy;
661
662    const DEBUG_NAME: &'static str = "fuchsia.net.stackmigrationdeprecated.State";
663}
664impl fidl::endpoints::DiscoverableProtocolMarker for StateMarker {}
665
666pub trait StateProxyInterface: Send + Sync {
667    type GetNetstackVersionResponseFut: std::future::Future<Output = Result<InEffectVersion, fidl::Error>>
668        + Send;
669    fn r#get_netstack_version(&self) -> Self::GetNetstackVersionResponseFut;
670}
671#[derive(Debug)]
672#[cfg(target_os = "fuchsia")]
673pub struct StateSynchronousProxy {
674    client: fidl::client::sync::Client,
675}
676
677#[cfg(target_os = "fuchsia")]
678impl fidl::endpoints::SynchronousProxy for StateSynchronousProxy {
679    type Proxy = StateProxy;
680    type Protocol = StateMarker;
681
682    fn from_channel(inner: fidl::Channel) -> Self {
683        Self::new(inner)
684    }
685
686    fn into_channel(self) -> fidl::Channel {
687        self.client.into_channel()
688    }
689
690    fn as_channel(&self) -> &fidl::Channel {
691        self.client.as_channel()
692    }
693}
694
695#[cfg(target_os = "fuchsia")]
696impl StateSynchronousProxy {
697    pub fn new(channel: fidl::Channel) -> Self {
698        let protocol_name = <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
699        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
700    }
701
702    pub fn into_channel(self) -> fidl::Channel {
703        self.client.into_channel()
704    }
705
706    /// Waits until an event arrives and returns it. It is safe for other
707    /// threads to make concurrent requests while waiting for an event.
708    pub fn wait_for_event(
709        &self,
710        deadline: zx::MonotonicInstant,
711    ) -> Result<StateEvent, fidl::Error> {
712        StateEvent::decode(self.client.wait_for_event(deadline)?)
713    }
714
715    /// Gets the target network stack version.
716    ///
717    /// - response `in_effect_version` the configurations currently in effect.
718    pub fn r#get_netstack_version(
719        &self,
720        ___deadline: zx::MonotonicInstant,
721    ) -> Result<InEffectVersion, fidl::Error> {
722        let _response = self
723            .client
724            .send_query::<fidl::encoding::EmptyPayload, StateGetNetstackVersionResponse>(
725                (),
726                0x67053bfebb619ba1,
727                fidl::encoding::DynamicFlags::empty(),
728                ___deadline,
729            )?;
730        Ok(_response.in_effect_version)
731    }
732}
733
734#[cfg(target_os = "fuchsia")]
735impl From<StateSynchronousProxy> for zx::Handle {
736    fn from(value: StateSynchronousProxy) -> Self {
737        value.into_channel().into()
738    }
739}
740
741#[cfg(target_os = "fuchsia")]
742impl From<fidl::Channel> for StateSynchronousProxy {
743    fn from(value: fidl::Channel) -> Self {
744        Self::new(value)
745    }
746}
747
748#[derive(Debug, Clone)]
749pub struct StateProxy {
750    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
751}
752
753impl fidl::endpoints::Proxy for StateProxy {
754    type Protocol = StateMarker;
755
756    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
757        Self::new(inner)
758    }
759
760    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
761        self.client.into_channel().map_err(|client| Self { client })
762    }
763
764    fn as_channel(&self) -> &::fidl::AsyncChannel {
765        self.client.as_channel()
766    }
767}
768
769impl StateProxy {
770    /// Create a new Proxy for fuchsia.net.stackmigrationdeprecated/State.
771    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
772        let protocol_name = <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
773        Self { client: fidl::client::Client::new(channel, protocol_name) }
774    }
775
776    /// Get a Stream of events from the remote end of the protocol.
777    ///
778    /// # Panics
779    ///
780    /// Panics if the event stream was already taken.
781    pub fn take_event_stream(&self) -> StateEventStream {
782        StateEventStream { event_receiver: self.client.take_event_receiver() }
783    }
784
785    /// Gets the target network stack version.
786    ///
787    /// - response `in_effect_version` the configurations currently in effect.
788    pub fn r#get_netstack_version(
789        &self,
790    ) -> fidl::client::QueryResponseFut<
791        InEffectVersion,
792        fidl::encoding::DefaultFuchsiaResourceDialect,
793    > {
794        StateProxyInterface::r#get_netstack_version(self)
795    }
796}
797
798impl StateProxyInterface for StateProxy {
799    type GetNetstackVersionResponseFut = fidl::client::QueryResponseFut<
800        InEffectVersion,
801        fidl::encoding::DefaultFuchsiaResourceDialect,
802    >;
803    fn r#get_netstack_version(&self) -> Self::GetNetstackVersionResponseFut {
804        fn _decode(
805            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
806        ) -> Result<InEffectVersion, fidl::Error> {
807            let _response = fidl::client::decode_transaction_body::<
808                StateGetNetstackVersionResponse,
809                fidl::encoding::DefaultFuchsiaResourceDialect,
810                0x67053bfebb619ba1,
811            >(_buf?)?;
812            Ok(_response.in_effect_version)
813        }
814        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, InEffectVersion>(
815            (),
816            0x67053bfebb619ba1,
817            fidl::encoding::DynamicFlags::empty(),
818            _decode,
819        )
820    }
821}
822
823pub struct StateEventStream {
824    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
825}
826
827impl std::marker::Unpin for StateEventStream {}
828
829impl futures::stream::FusedStream for StateEventStream {
830    fn is_terminated(&self) -> bool {
831        self.event_receiver.is_terminated()
832    }
833}
834
835impl futures::Stream for StateEventStream {
836    type Item = Result<StateEvent, fidl::Error>;
837
838    fn poll_next(
839        mut self: std::pin::Pin<&mut Self>,
840        cx: &mut std::task::Context<'_>,
841    ) -> std::task::Poll<Option<Self::Item>> {
842        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
843            &mut self.event_receiver,
844            cx
845        )?) {
846            Some(buf) => std::task::Poll::Ready(Some(StateEvent::decode(buf))),
847            None => std::task::Poll::Ready(None),
848        }
849    }
850}
851
852#[derive(Debug)]
853pub enum StateEvent {}
854
855impl StateEvent {
856    /// Decodes a message buffer as a [`StateEvent`].
857    fn decode(
858        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
859    ) -> Result<StateEvent, fidl::Error> {
860        let (bytes, _handles) = buf.split_mut();
861        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
862        debug_assert_eq!(tx_header.tx_id, 0);
863        match tx_header.ordinal {
864            _ => Err(fidl::Error::UnknownOrdinal {
865                ordinal: tx_header.ordinal,
866                protocol_name: <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
867            }),
868        }
869    }
870}
871
872/// A Stream of incoming requests for fuchsia.net.stackmigrationdeprecated/State.
873pub struct StateRequestStream {
874    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
875    is_terminated: bool,
876}
877
878impl std::marker::Unpin for StateRequestStream {}
879
880impl futures::stream::FusedStream for StateRequestStream {
881    fn is_terminated(&self) -> bool {
882        self.is_terminated
883    }
884}
885
886impl fidl::endpoints::RequestStream for StateRequestStream {
887    type Protocol = StateMarker;
888    type ControlHandle = StateControlHandle;
889
890    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
891        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
892    }
893
894    fn control_handle(&self) -> Self::ControlHandle {
895        StateControlHandle { inner: self.inner.clone() }
896    }
897
898    fn into_inner(
899        self,
900    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
901    {
902        (self.inner, self.is_terminated)
903    }
904
905    fn from_inner(
906        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
907        is_terminated: bool,
908    ) -> Self {
909        Self { inner, is_terminated }
910    }
911}
912
913impl futures::Stream for StateRequestStream {
914    type Item = Result<StateRequest, fidl::Error>;
915
916    fn poll_next(
917        mut self: std::pin::Pin<&mut Self>,
918        cx: &mut std::task::Context<'_>,
919    ) -> std::task::Poll<Option<Self::Item>> {
920        let this = &mut *self;
921        if this.inner.check_shutdown(cx) {
922            this.is_terminated = true;
923            return std::task::Poll::Ready(None);
924        }
925        if this.is_terminated {
926            panic!("polled StateRequestStream after completion");
927        }
928        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
929            |bytes, handles| {
930                match this.inner.channel().read_etc(cx, bytes, handles) {
931                    std::task::Poll::Ready(Ok(())) => {}
932                    std::task::Poll::Pending => return std::task::Poll::Pending,
933                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
934                        this.is_terminated = true;
935                        return std::task::Poll::Ready(None);
936                    }
937                    std::task::Poll::Ready(Err(e)) => {
938                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
939                            e.into(),
940                        ))))
941                    }
942                }
943
944                // A message has been received from the channel
945                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
946
947                std::task::Poll::Ready(Some(match header.ordinal {
948                    0x67053bfebb619ba1 => {
949                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
950                        let mut req = fidl::new_empty!(
951                            fidl::encoding::EmptyPayload,
952                            fidl::encoding::DefaultFuchsiaResourceDialect
953                        );
954                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
955                        let control_handle = StateControlHandle { inner: this.inner.clone() };
956                        Ok(StateRequest::GetNetstackVersion {
957                            responder: StateGetNetstackVersionResponder {
958                                control_handle: std::mem::ManuallyDrop::new(control_handle),
959                                tx_id: header.tx_id,
960                            },
961                        })
962                    }
963                    _ => Err(fidl::Error::UnknownOrdinal {
964                        ordinal: header.ordinal,
965                        protocol_name: <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
966                    }),
967                }))
968            },
969        )
970    }
971}
972
973/// Provides access to reading netstack migration configuration.
974#[derive(Debug)]
975pub enum StateRequest {
976    /// Gets the target network stack version.
977    ///
978    /// - response `in_effect_version` the configurations currently in effect.
979    GetNetstackVersion { responder: StateGetNetstackVersionResponder },
980}
981
982impl StateRequest {
983    #[allow(irrefutable_let_patterns)]
984    pub fn into_get_netstack_version(self) -> Option<(StateGetNetstackVersionResponder)> {
985        if let StateRequest::GetNetstackVersion { responder } = self {
986            Some((responder))
987        } else {
988            None
989        }
990    }
991
992    /// Name of the method defined in FIDL
993    pub fn method_name(&self) -> &'static str {
994        match *self {
995            StateRequest::GetNetstackVersion { .. } => "get_netstack_version",
996        }
997    }
998}
999
1000#[derive(Debug, Clone)]
1001pub struct StateControlHandle {
1002    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1003}
1004
1005impl fidl::endpoints::ControlHandle for StateControlHandle {
1006    fn shutdown(&self) {
1007        self.inner.shutdown()
1008    }
1009    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1010        self.inner.shutdown_with_epitaph(status)
1011    }
1012
1013    fn is_closed(&self) -> bool {
1014        self.inner.channel().is_closed()
1015    }
1016    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1017        self.inner.channel().on_closed()
1018    }
1019
1020    #[cfg(target_os = "fuchsia")]
1021    fn signal_peer(
1022        &self,
1023        clear_mask: zx::Signals,
1024        set_mask: zx::Signals,
1025    ) -> Result<(), zx_status::Status> {
1026        use fidl::Peered;
1027        self.inner.channel().signal_peer(clear_mask, set_mask)
1028    }
1029}
1030
1031impl StateControlHandle {}
1032
1033#[must_use = "FIDL methods require a response to be sent"]
1034#[derive(Debug)]
1035pub struct StateGetNetstackVersionResponder {
1036    control_handle: std::mem::ManuallyDrop<StateControlHandle>,
1037    tx_id: u32,
1038}
1039
1040/// Set the the channel to be shutdown (see [`StateControlHandle::shutdown`])
1041/// if the responder is dropped without sending a response, so that the client
1042/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1043impl std::ops::Drop for StateGetNetstackVersionResponder {
1044    fn drop(&mut self) {
1045        self.control_handle.shutdown();
1046        // Safety: drops once, never accessed again
1047        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1048    }
1049}
1050
1051impl fidl::endpoints::Responder for StateGetNetstackVersionResponder {
1052    type ControlHandle = StateControlHandle;
1053
1054    fn control_handle(&self) -> &StateControlHandle {
1055        &self.control_handle
1056    }
1057
1058    fn drop_without_shutdown(mut self) {
1059        // Safety: drops once, never accessed again due to mem::forget
1060        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1061        // Prevent Drop from running (which would shut down the channel)
1062        std::mem::forget(self);
1063    }
1064}
1065
1066impl StateGetNetstackVersionResponder {
1067    /// Sends a response to the FIDL transaction.
1068    ///
1069    /// Sets the channel to shutdown if an error occurs.
1070    pub fn send(self, mut in_effect_version: &InEffectVersion) -> Result<(), fidl::Error> {
1071        let _result = self.send_raw(in_effect_version);
1072        if _result.is_err() {
1073            self.control_handle.shutdown();
1074        }
1075        self.drop_without_shutdown();
1076        _result
1077    }
1078
1079    /// Similar to "send" but does not shutdown the channel if an error occurs.
1080    pub fn send_no_shutdown_on_err(
1081        self,
1082        mut in_effect_version: &InEffectVersion,
1083    ) -> Result<(), fidl::Error> {
1084        let _result = self.send_raw(in_effect_version);
1085        self.drop_without_shutdown();
1086        _result
1087    }
1088
1089    fn send_raw(&self, mut in_effect_version: &InEffectVersion) -> Result<(), fidl::Error> {
1090        self.control_handle.inner.send::<StateGetNetstackVersionResponse>(
1091            (in_effect_version,),
1092            self.tx_id,
1093            0x67053bfebb619ba1,
1094            fidl::encoding::DynamicFlags::empty(),
1095        )
1096    }
1097}
1098
1099mod internal {
1100    use super::*;
1101}