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::NullableHandle {
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    /// Create a new Proxy for fuchsia.net.stackmigrationdeprecated/Control.
179    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    /// Get a Stream of events from the remote end of the protocol.
185    ///
186    /// # Panics
187    ///
188    /// Panics if the event stream was already taken.
189    pub fn take_event_stream(&self) -> ControlEventStream {
190        ControlEventStream { event_receiver: self.client.take_event_receiver() }
191    }
192
193    /// Sets the automated target network stack version.
194    ///
195    /// Takes effect on next boot.
196    ///
197    /// + request `version` requested network stack version. If unset, the
198    ///   automated version preference is cleared.
199    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    /// Sets user selection target network stack version.
207    ///
208    /// Takes effect on next boot.
209    ///
210    /// If set, the user netstack version preference always takes precedence
211    /// over the automated version selection.
212    ///
213    /// + request `version` requested network stack version. If unset, the user
214    ///   version preference is cleared.
215    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    /// Decodes a message buffer as a [`ControlEvent`].
307    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
322/// A Stream of incoming requests for fuchsia.net.stackmigrationdeprecated/Control.
323pub 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                // A message has been received from the channel
395                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/// Provides access to controlling netstack migration configuration.
444#[derive(Debug)]
445pub enum ControlRequest {
446    /// Sets the automated target network stack version.
447    ///
448    /// Takes effect on next boot.
449    ///
450    /// + request `version` requested network stack version. If unset, the
451    ///   automated version preference is cleared.
452    SetAutomatedNetstackVersion {
453        version: Option<Box<VersionSetting>>,
454        responder: ControlSetAutomatedNetstackVersionResponder,
455    },
456    /// Sets user selection target network stack version.
457    ///
458    /// Takes effect on next boot.
459    ///
460    /// If set, the user netstack version preference always takes precedence
461    /// over the automated version selection.
462    ///
463    /// + request `version` requested network stack version. If unset, the user
464    ///   version preference is cleared.
465    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    /// Name of the method defined in FIDL
495    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
513    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
514        self.inner.shutdown_with_epitaph(status)
515    }
516
517    fn is_closed(&self) -> bool {
518        self.inner.channel().is_closed()
519    }
520    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
521        self.inner.channel().on_closed()
522    }
523
524    #[cfg(target_os = "fuchsia")]
525    fn signal_peer(
526        &self,
527        clear_mask: zx::Signals,
528        set_mask: zx::Signals,
529    ) -> Result<(), zx_status::Status> {
530        use fidl::Peered;
531        self.inner.channel().signal_peer(clear_mask, set_mask)
532    }
533}
534
535impl ControlControlHandle {}
536
537#[must_use = "FIDL methods require a response to be sent"]
538#[derive(Debug)]
539pub struct ControlSetAutomatedNetstackVersionResponder {
540    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
541    tx_id: u32,
542}
543
544/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
545/// if the responder is dropped without sending a response, so that the client
546/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
547impl std::ops::Drop for ControlSetAutomatedNetstackVersionResponder {
548    fn drop(&mut self) {
549        self.control_handle.shutdown();
550        // Safety: drops once, never accessed again
551        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
552    }
553}
554
555impl fidl::endpoints::Responder for ControlSetAutomatedNetstackVersionResponder {
556    type ControlHandle = ControlControlHandle;
557
558    fn control_handle(&self) -> &ControlControlHandle {
559        &self.control_handle
560    }
561
562    fn drop_without_shutdown(mut self) {
563        // Safety: drops once, never accessed again due to mem::forget
564        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
565        // Prevent Drop from running (which would shut down the channel)
566        std::mem::forget(self);
567    }
568}
569
570impl ControlSetAutomatedNetstackVersionResponder {
571    /// Sends a response to the FIDL transaction.
572    ///
573    /// Sets the channel to shutdown if an error occurs.
574    pub fn send(self) -> Result<(), fidl::Error> {
575        let _result = self.send_raw();
576        if _result.is_err() {
577            self.control_handle.shutdown();
578        }
579        self.drop_without_shutdown();
580        _result
581    }
582
583    /// Similar to "send" but does not shutdown the channel if an error occurs.
584    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
585        let _result = self.send_raw();
586        self.drop_without_shutdown();
587        _result
588    }
589
590    fn send_raw(&self) -> Result<(), fidl::Error> {
591        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
592            (),
593            self.tx_id,
594            0x643e4cfaf3bb5fea,
595            fidl::encoding::DynamicFlags::empty(),
596        )
597    }
598}
599
600#[must_use = "FIDL methods require a response to be sent"]
601#[derive(Debug)]
602pub struct ControlSetUserNetstackVersionResponder {
603    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
604    tx_id: u32,
605}
606
607/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
608/// if the responder is dropped without sending a response, so that the client
609/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
610impl std::ops::Drop for ControlSetUserNetstackVersionResponder {
611    fn drop(&mut self) {
612        self.control_handle.shutdown();
613        // Safety: drops once, never accessed again
614        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
615    }
616}
617
618impl fidl::endpoints::Responder for ControlSetUserNetstackVersionResponder {
619    type ControlHandle = ControlControlHandle;
620
621    fn control_handle(&self) -> &ControlControlHandle {
622        &self.control_handle
623    }
624
625    fn drop_without_shutdown(mut self) {
626        // Safety: drops once, never accessed again due to mem::forget
627        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
628        // Prevent Drop from running (which would shut down the channel)
629        std::mem::forget(self);
630    }
631}
632
633impl ControlSetUserNetstackVersionResponder {
634    /// Sends a response to the FIDL transaction.
635    ///
636    /// Sets the channel to shutdown if an error occurs.
637    pub fn send(self) -> Result<(), fidl::Error> {
638        let _result = self.send_raw();
639        if _result.is_err() {
640            self.control_handle.shutdown();
641        }
642        self.drop_without_shutdown();
643        _result
644    }
645
646    /// Similar to "send" but does not shutdown the channel if an error occurs.
647    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
648        let _result = self.send_raw();
649        self.drop_without_shutdown();
650        _result
651    }
652
653    fn send_raw(&self) -> Result<(), fidl::Error> {
654        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
655            (),
656            self.tx_id,
657            0x5ffd36d5fcea08b0,
658            fidl::encoding::DynamicFlags::empty(),
659        )
660    }
661}
662
663#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
664pub struct StateMarker;
665
666impl fidl::endpoints::ProtocolMarker for StateMarker {
667    type Proxy = StateProxy;
668    type RequestStream = StateRequestStream;
669    #[cfg(target_os = "fuchsia")]
670    type SynchronousProxy = StateSynchronousProxy;
671
672    const DEBUG_NAME: &'static str = "fuchsia.net.stackmigrationdeprecated.State";
673}
674impl fidl::endpoints::DiscoverableProtocolMarker for StateMarker {}
675
676pub trait StateProxyInterface: Send + Sync {
677    type GetNetstackVersionResponseFut: std::future::Future<Output = Result<InEffectVersion, fidl::Error>>
678        + Send;
679    fn r#get_netstack_version(&self) -> Self::GetNetstackVersionResponseFut;
680}
681#[derive(Debug)]
682#[cfg(target_os = "fuchsia")]
683pub struct StateSynchronousProxy {
684    client: fidl::client::sync::Client,
685}
686
687#[cfg(target_os = "fuchsia")]
688impl fidl::endpoints::SynchronousProxy for StateSynchronousProxy {
689    type Proxy = StateProxy;
690    type Protocol = StateMarker;
691
692    fn from_channel(inner: fidl::Channel) -> Self {
693        Self::new(inner)
694    }
695
696    fn into_channel(self) -> fidl::Channel {
697        self.client.into_channel()
698    }
699
700    fn as_channel(&self) -> &fidl::Channel {
701        self.client.as_channel()
702    }
703}
704
705#[cfg(target_os = "fuchsia")]
706impl StateSynchronousProxy {
707    pub fn new(channel: fidl::Channel) -> Self {
708        let protocol_name = <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
709        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
710    }
711
712    pub fn into_channel(self) -> fidl::Channel {
713        self.client.into_channel()
714    }
715
716    /// Waits until an event arrives and returns it. It is safe for other
717    /// threads to make concurrent requests while waiting for an event.
718    pub fn wait_for_event(
719        &self,
720        deadline: zx::MonotonicInstant,
721    ) -> Result<StateEvent, fidl::Error> {
722        StateEvent::decode(self.client.wait_for_event(deadline)?)
723    }
724
725    /// Gets the target network stack version.
726    ///
727    /// - response `in_effect_version` the configurations currently in effect.
728    pub fn r#get_netstack_version(
729        &self,
730        ___deadline: zx::MonotonicInstant,
731    ) -> Result<InEffectVersion, fidl::Error> {
732        let _response = self
733            .client
734            .send_query::<fidl::encoding::EmptyPayload, StateGetNetstackVersionResponse>(
735                (),
736                0x67053bfebb619ba1,
737                fidl::encoding::DynamicFlags::empty(),
738                ___deadline,
739            )?;
740        Ok(_response.in_effect_version)
741    }
742}
743
744#[cfg(target_os = "fuchsia")]
745impl From<StateSynchronousProxy> for zx::NullableHandle {
746    fn from(value: StateSynchronousProxy) -> Self {
747        value.into_channel().into()
748    }
749}
750
751#[cfg(target_os = "fuchsia")]
752impl From<fidl::Channel> for StateSynchronousProxy {
753    fn from(value: fidl::Channel) -> Self {
754        Self::new(value)
755    }
756}
757
758#[cfg(target_os = "fuchsia")]
759impl fidl::endpoints::FromClient for StateSynchronousProxy {
760    type Protocol = StateMarker;
761
762    fn from_client(value: fidl::endpoints::ClientEnd<StateMarker>) -> Self {
763        Self::new(value.into_channel())
764    }
765}
766
767#[derive(Debug, Clone)]
768pub struct StateProxy {
769    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
770}
771
772impl fidl::endpoints::Proxy for StateProxy {
773    type Protocol = StateMarker;
774
775    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
776        Self::new(inner)
777    }
778
779    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
780        self.client.into_channel().map_err(|client| Self { client })
781    }
782
783    fn as_channel(&self) -> &::fidl::AsyncChannel {
784        self.client.as_channel()
785    }
786}
787
788impl StateProxy {
789    /// Create a new Proxy for fuchsia.net.stackmigrationdeprecated/State.
790    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
791        let protocol_name = <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
792        Self { client: fidl::client::Client::new(channel, protocol_name) }
793    }
794
795    /// Get a Stream of events from the remote end of the protocol.
796    ///
797    /// # Panics
798    ///
799    /// Panics if the event stream was already taken.
800    pub fn take_event_stream(&self) -> StateEventStream {
801        StateEventStream { event_receiver: self.client.take_event_receiver() }
802    }
803
804    /// Gets the target network stack version.
805    ///
806    /// - response `in_effect_version` the configurations currently in effect.
807    pub fn r#get_netstack_version(
808        &self,
809    ) -> fidl::client::QueryResponseFut<
810        InEffectVersion,
811        fidl::encoding::DefaultFuchsiaResourceDialect,
812    > {
813        StateProxyInterface::r#get_netstack_version(self)
814    }
815}
816
817impl StateProxyInterface for StateProxy {
818    type GetNetstackVersionResponseFut = fidl::client::QueryResponseFut<
819        InEffectVersion,
820        fidl::encoding::DefaultFuchsiaResourceDialect,
821    >;
822    fn r#get_netstack_version(&self) -> Self::GetNetstackVersionResponseFut {
823        fn _decode(
824            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
825        ) -> Result<InEffectVersion, fidl::Error> {
826            let _response = fidl::client::decode_transaction_body::<
827                StateGetNetstackVersionResponse,
828                fidl::encoding::DefaultFuchsiaResourceDialect,
829                0x67053bfebb619ba1,
830            >(_buf?)?;
831            Ok(_response.in_effect_version)
832        }
833        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, InEffectVersion>(
834            (),
835            0x67053bfebb619ba1,
836            fidl::encoding::DynamicFlags::empty(),
837            _decode,
838        )
839    }
840}
841
842pub struct StateEventStream {
843    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
844}
845
846impl std::marker::Unpin for StateEventStream {}
847
848impl futures::stream::FusedStream for StateEventStream {
849    fn is_terminated(&self) -> bool {
850        self.event_receiver.is_terminated()
851    }
852}
853
854impl futures::Stream for StateEventStream {
855    type Item = Result<StateEvent, fidl::Error>;
856
857    fn poll_next(
858        mut self: std::pin::Pin<&mut Self>,
859        cx: &mut std::task::Context<'_>,
860    ) -> std::task::Poll<Option<Self::Item>> {
861        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
862            &mut self.event_receiver,
863            cx
864        )?) {
865            Some(buf) => std::task::Poll::Ready(Some(StateEvent::decode(buf))),
866            None => std::task::Poll::Ready(None),
867        }
868    }
869}
870
871#[derive(Debug)]
872pub enum StateEvent {}
873
874impl StateEvent {
875    /// Decodes a message buffer as a [`StateEvent`].
876    fn decode(
877        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
878    ) -> Result<StateEvent, fidl::Error> {
879        let (bytes, _handles) = buf.split_mut();
880        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
881        debug_assert_eq!(tx_header.tx_id, 0);
882        match tx_header.ordinal {
883            _ => Err(fidl::Error::UnknownOrdinal {
884                ordinal: tx_header.ordinal,
885                protocol_name: <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
886            }),
887        }
888    }
889}
890
891/// A Stream of incoming requests for fuchsia.net.stackmigrationdeprecated/State.
892pub struct StateRequestStream {
893    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
894    is_terminated: bool,
895}
896
897impl std::marker::Unpin for StateRequestStream {}
898
899impl futures::stream::FusedStream for StateRequestStream {
900    fn is_terminated(&self) -> bool {
901        self.is_terminated
902    }
903}
904
905impl fidl::endpoints::RequestStream for StateRequestStream {
906    type Protocol = StateMarker;
907    type ControlHandle = StateControlHandle;
908
909    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
910        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
911    }
912
913    fn control_handle(&self) -> Self::ControlHandle {
914        StateControlHandle { inner: self.inner.clone() }
915    }
916
917    fn into_inner(
918        self,
919    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
920    {
921        (self.inner, self.is_terminated)
922    }
923
924    fn from_inner(
925        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
926        is_terminated: bool,
927    ) -> Self {
928        Self { inner, is_terminated }
929    }
930}
931
932impl futures::Stream for StateRequestStream {
933    type Item = Result<StateRequest, fidl::Error>;
934
935    fn poll_next(
936        mut self: std::pin::Pin<&mut Self>,
937        cx: &mut std::task::Context<'_>,
938    ) -> std::task::Poll<Option<Self::Item>> {
939        let this = &mut *self;
940        if this.inner.check_shutdown(cx) {
941            this.is_terminated = true;
942            return std::task::Poll::Ready(None);
943        }
944        if this.is_terminated {
945            panic!("polled StateRequestStream after completion");
946        }
947        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
948            |bytes, handles| {
949                match this.inner.channel().read_etc(cx, bytes, handles) {
950                    std::task::Poll::Ready(Ok(())) => {}
951                    std::task::Poll::Pending => return std::task::Poll::Pending,
952                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
953                        this.is_terminated = true;
954                        return std::task::Poll::Ready(None);
955                    }
956                    std::task::Poll::Ready(Err(e)) => {
957                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
958                            e.into(),
959                        ))));
960                    }
961                }
962
963                // A message has been received from the channel
964                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
965
966                std::task::Poll::Ready(Some(match header.ordinal {
967                    0x67053bfebb619ba1 => {
968                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
969                        let mut req = fidl::new_empty!(
970                            fidl::encoding::EmptyPayload,
971                            fidl::encoding::DefaultFuchsiaResourceDialect
972                        );
973                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
974                        let control_handle = StateControlHandle { inner: this.inner.clone() };
975                        Ok(StateRequest::GetNetstackVersion {
976                            responder: StateGetNetstackVersionResponder {
977                                control_handle: std::mem::ManuallyDrop::new(control_handle),
978                                tx_id: header.tx_id,
979                            },
980                        })
981                    }
982                    _ => Err(fidl::Error::UnknownOrdinal {
983                        ordinal: header.ordinal,
984                        protocol_name: <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
985                    }),
986                }))
987            },
988        )
989    }
990}
991
992/// Provides access to reading netstack migration configuration.
993#[derive(Debug)]
994pub enum StateRequest {
995    /// Gets the target network stack version.
996    ///
997    /// - response `in_effect_version` the configurations currently in effect.
998    GetNetstackVersion { responder: StateGetNetstackVersionResponder },
999}
1000
1001impl StateRequest {
1002    #[allow(irrefutable_let_patterns)]
1003    pub fn into_get_netstack_version(self) -> Option<(StateGetNetstackVersionResponder)> {
1004        if let StateRequest::GetNetstackVersion { responder } = self {
1005            Some((responder))
1006        } else {
1007            None
1008        }
1009    }
1010
1011    /// Name of the method defined in FIDL
1012    pub fn method_name(&self) -> &'static str {
1013        match *self {
1014            StateRequest::GetNetstackVersion { .. } => "get_netstack_version",
1015        }
1016    }
1017}
1018
1019#[derive(Debug, Clone)]
1020pub struct StateControlHandle {
1021    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1022}
1023
1024impl fidl::endpoints::ControlHandle for StateControlHandle {
1025    fn shutdown(&self) {
1026        self.inner.shutdown()
1027    }
1028
1029    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1030        self.inner.shutdown_with_epitaph(status)
1031    }
1032
1033    fn is_closed(&self) -> bool {
1034        self.inner.channel().is_closed()
1035    }
1036    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1037        self.inner.channel().on_closed()
1038    }
1039
1040    #[cfg(target_os = "fuchsia")]
1041    fn signal_peer(
1042        &self,
1043        clear_mask: zx::Signals,
1044        set_mask: zx::Signals,
1045    ) -> Result<(), zx_status::Status> {
1046        use fidl::Peered;
1047        self.inner.channel().signal_peer(clear_mask, set_mask)
1048    }
1049}
1050
1051impl StateControlHandle {}
1052
1053#[must_use = "FIDL methods require a response to be sent"]
1054#[derive(Debug)]
1055pub struct StateGetNetstackVersionResponder {
1056    control_handle: std::mem::ManuallyDrop<StateControlHandle>,
1057    tx_id: u32,
1058}
1059
1060/// Set the the channel to be shutdown (see [`StateControlHandle::shutdown`])
1061/// if the responder is dropped without sending a response, so that the client
1062/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1063impl std::ops::Drop for StateGetNetstackVersionResponder {
1064    fn drop(&mut self) {
1065        self.control_handle.shutdown();
1066        // Safety: drops once, never accessed again
1067        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1068    }
1069}
1070
1071impl fidl::endpoints::Responder for StateGetNetstackVersionResponder {
1072    type ControlHandle = StateControlHandle;
1073
1074    fn control_handle(&self) -> &StateControlHandle {
1075        &self.control_handle
1076    }
1077
1078    fn drop_without_shutdown(mut self) {
1079        // Safety: drops once, never accessed again due to mem::forget
1080        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1081        // Prevent Drop from running (which would shut down the channel)
1082        std::mem::forget(self);
1083    }
1084}
1085
1086impl StateGetNetstackVersionResponder {
1087    /// Sends a response to the FIDL transaction.
1088    ///
1089    /// Sets the channel to shutdown if an error occurs.
1090    pub fn send(self, mut in_effect_version: &InEffectVersion) -> Result<(), fidl::Error> {
1091        let _result = self.send_raw(in_effect_version);
1092        if _result.is_err() {
1093            self.control_handle.shutdown();
1094        }
1095        self.drop_without_shutdown();
1096        _result
1097    }
1098
1099    /// Similar to "send" but does not shutdown the channel if an error occurs.
1100    pub fn send_no_shutdown_on_err(
1101        self,
1102        mut in_effect_version: &InEffectVersion,
1103    ) -> Result<(), fidl::Error> {
1104        let _result = self.send_raw(in_effect_version);
1105        self.drop_without_shutdown();
1106        _result
1107    }
1108
1109    fn send_raw(&self, mut in_effect_version: &InEffectVersion) -> Result<(), fidl::Error> {
1110        self.control_handle.inner.send::<StateGetNetstackVersionResponse>(
1111            (in_effect_version,),
1112            self.tx_id,
1113            0x67053bfebb619ba1,
1114            fidl::encoding::DynamicFlags::empty(),
1115        )
1116    }
1117}
1118
1119mod internal {
1120    use super::*;
1121}