Skip to main content

fdomain_fuchsia_net_stackmigrationdeprecated/
fdomain_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 fdomain_client::fidl::{ControlHandle as _, FDomainFlexibleIntoResult as _, Responder as _};
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9pub use fidl_fuchsia_net_stackmigrationdeprecated_common::*;
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
14pub struct ControlMarker;
15
16impl fdomain_client::fidl::ProtocolMarker for ControlMarker {
17    type Proxy = ControlProxy;
18    type RequestStream = ControlRequestStream;
19
20    const DEBUG_NAME: &'static str = "fuchsia.net.stackmigrationdeprecated.Control";
21}
22impl fdomain_client::fidl::DiscoverableProtocolMarker for ControlMarker {}
23
24pub trait ControlProxyInterface: Send + Sync {
25    type SetAutomatedNetstackVersionResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
26        + Send;
27    fn r#set_automated_netstack_version(
28        &self,
29        version: Option<&VersionSetting>,
30    ) -> Self::SetAutomatedNetstackVersionResponseFut;
31    type SetUserNetstackVersionResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
32        + Send;
33    fn r#set_user_netstack_version(
34        &self,
35        version: Option<&VersionSetting>,
36    ) -> Self::SetUserNetstackVersionResponseFut;
37}
38
39#[derive(Debug, Clone)]
40pub struct ControlProxy {
41    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
42}
43
44impl fdomain_client::fidl::Proxy for ControlProxy {
45    type Protocol = ControlMarker;
46
47    fn from_channel(inner: fdomain_client::Channel) -> Self {
48        Self::new(inner)
49    }
50
51    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
52        self.client.into_channel().map_err(|client| Self { client })
53    }
54
55    fn as_channel(&self) -> &fdomain_client::Channel {
56        self.client.as_channel()
57    }
58}
59
60impl ControlProxy {
61    /// Create a new Proxy for fuchsia.net.stackmigrationdeprecated/Control.
62    pub fn new(channel: fdomain_client::Channel) -> Self {
63        let protocol_name = <ControlMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
64        Self { client: fidl::client::Client::new(channel, protocol_name) }
65    }
66
67    /// Get a Stream of events from the remote end of the protocol.
68    ///
69    /// # Panics
70    ///
71    /// Panics if the event stream was already taken.
72    pub fn take_event_stream(&self) -> ControlEventStream {
73        ControlEventStream { event_receiver: self.client.take_event_receiver() }
74    }
75
76    /// Sets the automated target network stack version.
77    ///
78    /// Takes effect on next boot.
79    ///
80    /// + request `version` requested network stack version. If unset, the
81    ///   automated version preference is cleared.
82    pub fn r#set_automated_netstack_version(
83        &self,
84        mut version: Option<&VersionSetting>,
85    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
86        ControlProxyInterface::r#set_automated_netstack_version(self, version)
87    }
88
89    /// Sets user selection target network stack version.
90    ///
91    /// Takes effect on next boot.
92    ///
93    /// If set, the user netstack version preference always takes precedence
94    /// over the automated version selection.
95    ///
96    /// + request `version` requested network stack version. If unset, the user
97    ///   version preference is cleared.
98    pub fn r#set_user_netstack_version(
99        &self,
100        mut version: Option<&VersionSetting>,
101    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
102        ControlProxyInterface::r#set_user_netstack_version(self, version)
103    }
104}
105
106impl ControlProxyInterface for ControlProxy {
107    type SetAutomatedNetstackVersionResponseFut =
108        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
109    fn r#set_automated_netstack_version(
110        &self,
111        mut version: Option<&VersionSetting>,
112    ) -> Self::SetAutomatedNetstackVersionResponseFut {
113        fn _decode(
114            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
115        ) -> Result<(), fidl::Error> {
116            let _response = fidl::client::decode_transaction_body::<
117                fidl::encoding::EmptyPayload,
118                fdomain_client::fidl::FDomainResourceDialect,
119                0x643e4cfaf3bb5fea,
120            >(_buf?)?;
121            Ok(_response)
122        }
123        self.client.send_query_and_decode::<ControlSetAutomatedNetstackVersionRequest, ()>(
124            (version,),
125            0x643e4cfaf3bb5fea,
126            fidl::encoding::DynamicFlags::empty(),
127            _decode,
128        )
129    }
130
131    type SetUserNetstackVersionResponseFut =
132        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
133    fn r#set_user_netstack_version(
134        &self,
135        mut version: Option<&VersionSetting>,
136    ) -> Self::SetUserNetstackVersionResponseFut {
137        fn _decode(
138            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
139        ) -> Result<(), fidl::Error> {
140            let _response = fidl::client::decode_transaction_body::<
141                fidl::encoding::EmptyPayload,
142                fdomain_client::fidl::FDomainResourceDialect,
143                0x5ffd36d5fcea08b0,
144            >(_buf?)?;
145            Ok(_response)
146        }
147        self.client.send_query_and_decode::<ControlSetUserNetstackVersionRequest, ()>(
148            (version,),
149            0x5ffd36d5fcea08b0,
150            fidl::encoding::DynamicFlags::empty(),
151            _decode,
152        )
153    }
154}
155
156pub struct ControlEventStream {
157    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
158}
159
160impl std::marker::Unpin for ControlEventStream {}
161
162impl futures::stream::FusedStream for ControlEventStream {
163    fn is_terminated(&self) -> bool {
164        self.event_receiver.is_terminated()
165    }
166}
167
168impl futures::Stream for ControlEventStream {
169    type Item = Result<ControlEvent, fidl::Error>;
170
171    fn poll_next(
172        mut self: std::pin::Pin<&mut Self>,
173        cx: &mut std::task::Context<'_>,
174    ) -> std::task::Poll<Option<Self::Item>> {
175        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
176            &mut self.event_receiver,
177            cx
178        )?) {
179            Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
180            None => std::task::Poll::Ready(None),
181        }
182    }
183}
184
185#[derive(Debug)]
186pub enum ControlEvent {}
187
188impl ControlEvent {
189    /// Decodes a message buffer as a [`ControlEvent`].
190    fn decode(
191        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
192    ) -> Result<ControlEvent, fidl::Error> {
193        let (bytes, _handles) = buf.split_mut();
194        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
195        debug_assert_eq!(tx_header.tx_id, 0);
196        match tx_header.ordinal {
197            _ => Err(fidl::Error::UnknownOrdinal {
198                ordinal: tx_header.ordinal,
199                protocol_name: <ControlMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
200            }),
201        }
202    }
203}
204
205/// A Stream of incoming requests for fuchsia.net.stackmigrationdeprecated/Control.
206pub struct ControlRequestStream {
207    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
208    is_terminated: bool,
209}
210
211impl std::marker::Unpin for ControlRequestStream {}
212
213impl futures::stream::FusedStream for ControlRequestStream {
214    fn is_terminated(&self) -> bool {
215        self.is_terminated
216    }
217}
218
219impl fdomain_client::fidl::RequestStream for ControlRequestStream {
220    type Protocol = ControlMarker;
221    type ControlHandle = ControlControlHandle;
222
223    fn from_channel(channel: fdomain_client::Channel) -> Self {
224        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
225    }
226
227    fn control_handle(&self) -> Self::ControlHandle {
228        ControlControlHandle { inner: self.inner.clone() }
229    }
230
231    fn into_inner(
232        self,
233    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
234    {
235        (self.inner, self.is_terminated)
236    }
237
238    fn from_inner(
239        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
240        is_terminated: bool,
241    ) -> Self {
242        Self { inner, is_terminated }
243    }
244}
245
246impl futures::Stream for ControlRequestStream {
247    type Item = Result<ControlRequest, fidl::Error>;
248
249    fn poll_next(
250        mut self: std::pin::Pin<&mut Self>,
251        cx: &mut std::task::Context<'_>,
252    ) -> std::task::Poll<Option<Self::Item>> {
253        let this = &mut *self;
254        if this.inner.check_shutdown(cx) {
255            this.is_terminated = true;
256            return std::task::Poll::Ready(None);
257        }
258        if this.is_terminated {
259            panic!("polled ControlRequestStream after completion");
260        }
261        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
262            |bytes, handles| {
263                match this.inner.channel().read_etc(cx, bytes, handles) {
264                    std::task::Poll::Ready(Ok(())) => {}
265                    std::task::Poll::Pending => return std::task::Poll::Pending,
266                    std::task::Poll::Ready(Err(None)) => {
267                        this.is_terminated = true;
268                        return std::task::Poll::Ready(None);
269                    }
270                    std::task::Poll::Ready(Err(Some(e))) => {
271                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
272                            e.into(),
273                        ))));
274                    }
275                }
276
277                // A message has been received from the channel
278                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
279
280                std::task::Poll::Ready(Some(match header.ordinal {
281                    0x643e4cfaf3bb5fea => {
282                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
283                        let mut req = fidl::new_empty!(
284                            ControlSetAutomatedNetstackVersionRequest,
285                            fdomain_client::fidl::FDomainResourceDialect
286                        );
287                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ControlSetAutomatedNetstackVersionRequest>(&header, _body_bytes, handles, &mut req)?;
288                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
289                        Ok(ControlRequest::SetAutomatedNetstackVersion {
290                            version: req.version,
291
292                            responder: ControlSetAutomatedNetstackVersionResponder {
293                                control_handle: std::mem::ManuallyDrop::new(control_handle),
294                                tx_id: header.tx_id,
295                            },
296                        })
297                    }
298                    0x5ffd36d5fcea08b0 => {
299                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
300                        let mut req = fidl::new_empty!(
301                            ControlSetUserNetstackVersionRequest,
302                            fdomain_client::fidl::FDomainResourceDialect
303                        );
304                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ControlSetUserNetstackVersionRequest>(&header, _body_bytes, handles, &mut req)?;
305                        let control_handle = ControlControlHandle { inner: this.inner.clone() };
306                        Ok(ControlRequest::SetUserNetstackVersion {
307                            version: req.version,
308
309                            responder: ControlSetUserNetstackVersionResponder {
310                                control_handle: std::mem::ManuallyDrop::new(control_handle),
311                                tx_id: header.tx_id,
312                            },
313                        })
314                    }
315                    _ => Err(fidl::Error::UnknownOrdinal {
316                        ordinal: header.ordinal,
317                        protocol_name:
318                            <ControlMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
319                    }),
320                }))
321            },
322        )
323    }
324}
325
326/// Provides access to controlling netstack migration configuration.
327#[derive(Debug)]
328pub enum ControlRequest {
329    /// Sets the automated target network stack version.
330    ///
331    /// Takes effect on next boot.
332    ///
333    /// + request `version` requested network stack version. If unset, the
334    ///   automated version preference is cleared.
335    SetAutomatedNetstackVersion {
336        version: Option<Box<VersionSetting>>,
337        responder: ControlSetAutomatedNetstackVersionResponder,
338    },
339    /// Sets user selection target network stack version.
340    ///
341    /// Takes effect on next boot.
342    ///
343    /// If set, the user netstack version preference always takes precedence
344    /// over the automated version selection.
345    ///
346    /// + request `version` requested network stack version. If unset, the user
347    ///   version preference is cleared.
348    SetUserNetstackVersion {
349        version: Option<Box<VersionSetting>>,
350        responder: ControlSetUserNetstackVersionResponder,
351    },
352}
353
354impl ControlRequest {
355    #[allow(irrefutable_let_patterns)]
356    pub fn into_set_automated_netstack_version(
357        self,
358    ) -> Option<(Option<Box<VersionSetting>>, ControlSetAutomatedNetstackVersionResponder)> {
359        if let ControlRequest::SetAutomatedNetstackVersion { version, responder } = self {
360            Some((version, responder))
361        } else {
362            None
363        }
364    }
365
366    #[allow(irrefutable_let_patterns)]
367    pub fn into_set_user_netstack_version(
368        self,
369    ) -> Option<(Option<Box<VersionSetting>>, ControlSetUserNetstackVersionResponder)> {
370        if let ControlRequest::SetUserNetstackVersion { version, responder } = self {
371            Some((version, responder))
372        } else {
373            None
374        }
375    }
376
377    /// Name of the method defined in FIDL
378    pub fn method_name(&self) -> &'static str {
379        match *self {
380            ControlRequest::SetAutomatedNetstackVersion { .. } => "set_automated_netstack_version",
381            ControlRequest::SetUserNetstackVersion { .. } => "set_user_netstack_version",
382        }
383    }
384}
385
386#[derive(Debug, Clone)]
387pub struct ControlControlHandle {
388    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
389}
390
391impl ControlControlHandle {
392    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
393        self.inner.shutdown_with_epitaph(status.into())
394    }
395}
396
397impl fdomain_client::fidl::ControlHandle for ControlControlHandle {
398    fn shutdown(&self) {
399        self.inner.shutdown()
400    }
401
402    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
403        self.inner.shutdown_with_epitaph(status)
404    }
405
406    fn is_closed(&self) -> bool {
407        self.inner.channel().is_closed()
408    }
409    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
410        self.inner.channel().on_closed()
411    }
412}
413
414impl ControlControlHandle {}
415
416#[must_use = "FIDL methods require a response to be sent"]
417#[derive(Debug)]
418pub struct ControlSetAutomatedNetstackVersionResponder {
419    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
420    tx_id: u32,
421}
422
423/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
424/// if the responder is dropped without sending a response, so that the client
425/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
426impl std::ops::Drop for ControlSetAutomatedNetstackVersionResponder {
427    fn drop(&mut self) {
428        self.control_handle.shutdown();
429        // Safety: drops once, never accessed again
430        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
431    }
432}
433
434impl fdomain_client::fidl::Responder for ControlSetAutomatedNetstackVersionResponder {
435    type ControlHandle = ControlControlHandle;
436
437    fn control_handle(&self) -> &ControlControlHandle {
438        &self.control_handle
439    }
440
441    fn drop_without_shutdown(mut self) {
442        // Safety: drops once, never accessed again due to mem::forget
443        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
444        // Prevent Drop from running (which would shut down the channel)
445        std::mem::forget(self);
446    }
447}
448
449impl ControlSetAutomatedNetstackVersionResponder {
450    /// Sends a response to the FIDL transaction.
451    ///
452    /// Sets the channel to shutdown if an error occurs.
453    pub fn send(self) -> Result<(), fidl::Error> {
454        let _result = self.send_raw();
455        if _result.is_err() {
456            self.control_handle.shutdown();
457        }
458        self.drop_without_shutdown();
459        _result
460    }
461
462    /// Similar to "send" but does not shutdown the channel if an error occurs.
463    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
464        let _result = self.send_raw();
465        self.drop_without_shutdown();
466        _result
467    }
468
469    fn send_raw(&self) -> Result<(), fidl::Error> {
470        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
471            (),
472            self.tx_id,
473            0x643e4cfaf3bb5fea,
474            fidl::encoding::DynamicFlags::empty(),
475        )
476    }
477}
478
479#[must_use = "FIDL methods require a response to be sent"]
480#[derive(Debug)]
481pub struct ControlSetUserNetstackVersionResponder {
482    control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
483    tx_id: u32,
484}
485
486/// Set the the channel to be shutdown (see [`ControlControlHandle::shutdown`])
487/// if the responder is dropped without sending a response, so that the client
488/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
489impl std::ops::Drop for ControlSetUserNetstackVersionResponder {
490    fn drop(&mut self) {
491        self.control_handle.shutdown();
492        // Safety: drops once, never accessed again
493        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
494    }
495}
496
497impl fdomain_client::fidl::Responder for ControlSetUserNetstackVersionResponder {
498    type ControlHandle = ControlControlHandle;
499
500    fn control_handle(&self) -> &ControlControlHandle {
501        &self.control_handle
502    }
503
504    fn drop_without_shutdown(mut self) {
505        // Safety: drops once, never accessed again due to mem::forget
506        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
507        // Prevent Drop from running (which would shut down the channel)
508        std::mem::forget(self);
509    }
510}
511
512impl ControlSetUserNetstackVersionResponder {
513    /// Sends a response to the FIDL transaction.
514    ///
515    /// Sets the channel to shutdown if an error occurs.
516    pub fn send(self) -> Result<(), fidl::Error> {
517        let _result = self.send_raw();
518        if _result.is_err() {
519            self.control_handle.shutdown();
520        }
521        self.drop_without_shutdown();
522        _result
523    }
524
525    /// Similar to "send" but does not shutdown the channel if an error occurs.
526    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
527        let _result = self.send_raw();
528        self.drop_without_shutdown();
529        _result
530    }
531
532    fn send_raw(&self) -> Result<(), fidl::Error> {
533        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
534            (),
535            self.tx_id,
536            0x5ffd36d5fcea08b0,
537            fidl::encoding::DynamicFlags::empty(),
538        )
539    }
540}
541
542#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
543pub struct StateMarker;
544
545impl fdomain_client::fidl::ProtocolMarker for StateMarker {
546    type Proxy = StateProxy;
547    type RequestStream = StateRequestStream;
548
549    const DEBUG_NAME: &'static str = "fuchsia.net.stackmigrationdeprecated.State";
550}
551impl fdomain_client::fidl::DiscoverableProtocolMarker for StateMarker {}
552
553pub trait StateProxyInterface: Send + Sync {
554    type GetNetstackVersionResponseFut: std::future::Future<Output = Result<InEffectVersion, fidl::Error>>
555        + Send;
556    fn r#get_netstack_version(&self) -> Self::GetNetstackVersionResponseFut;
557}
558
559#[derive(Debug, Clone)]
560pub struct StateProxy {
561    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
562}
563
564impl fdomain_client::fidl::Proxy for StateProxy {
565    type Protocol = StateMarker;
566
567    fn from_channel(inner: fdomain_client::Channel) -> Self {
568        Self::new(inner)
569    }
570
571    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
572        self.client.into_channel().map_err(|client| Self { client })
573    }
574
575    fn as_channel(&self) -> &fdomain_client::Channel {
576        self.client.as_channel()
577    }
578}
579
580impl StateProxy {
581    /// Create a new Proxy for fuchsia.net.stackmigrationdeprecated/State.
582    pub fn new(channel: fdomain_client::Channel) -> Self {
583        let protocol_name = <StateMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
584        Self { client: fidl::client::Client::new(channel, protocol_name) }
585    }
586
587    /// Get a Stream of events from the remote end of the protocol.
588    ///
589    /// # Panics
590    ///
591    /// Panics if the event stream was already taken.
592    pub fn take_event_stream(&self) -> StateEventStream {
593        StateEventStream { event_receiver: self.client.take_event_receiver() }
594    }
595
596    /// Gets the target network stack version.
597    ///
598    /// - response `in_effect_version` the configurations currently in effect.
599    pub fn r#get_netstack_version(
600        &self,
601    ) -> fidl::client::QueryResponseFut<InEffectVersion, fdomain_client::fidl::FDomainResourceDialect>
602    {
603        StateProxyInterface::r#get_netstack_version(self)
604    }
605}
606
607impl StateProxyInterface for StateProxy {
608    type GetNetstackVersionResponseFut = fidl::client::QueryResponseFut<
609        InEffectVersion,
610        fdomain_client::fidl::FDomainResourceDialect,
611    >;
612    fn r#get_netstack_version(&self) -> Self::GetNetstackVersionResponseFut {
613        fn _decode(
614            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
615        ) -> Result<InEffectVersion, fidl::Error> {
616            let _response = fidl::client::decode_transaction_body::<
617                StateGetNetstackVersionResponse,
618                fdomain_client::fidl::FDomainResourceDialect,
619                0x67053bfebb619ba1,
620            >(_buf?)?;
621            Ok(_response.in_effect_version)
622        }
623        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, InEffectVersion>(
624            (),
625            0x67053bfebb619ba1,
626            fidl::encoding::DynamicFlags::empty(),
627            _decode,
628        )
629    }
630}
631
632pub struct StateEventStream {
633    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
634}
635
636impl std::marker::Unpin for StateEventStream {}
637
638impl futures::stream::FusedStream for StateEventStream {
639    fn is_terminated(&self) -> bool {
640        self.event_receiver.is_terminated()
641    }
642}
643
644impl futures::Stream for StateEventStream {
645    type Item = Result<StateEvent, fidl::Error>;
646
647    fn poll_next(
648        mut self: std::pin::Pin<&mut Self>,
649        cx: &mut std::task::Context<'_>,
650    ) -> std::task::Poll<Option<Self::Item>> {
651        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
652            &mut self.event_receiver,
653            cx
654        )?) {
655            Some(buf) => std::task::Poll::Ready(Some(StateEvent::decode(buf))),
656            None => std::task::Poll::Ready(None),
657        }
658    }
659}
660
661#[derive(Debug)]
662pub enum StateEvent {}
663
664impl StateEvent {
665    /// Decodes a message buffer as a [`StateEvent`].
666    fn decode(
667        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
668    ) -> Result<StateEvent, fidl::Error> {
669        let (bytes, _handles) = buf.split_mut();
670        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
671        debug_assert_eq!(tx_header.tx_id, 0);
672        match tx_header.ordinal {
673            _ => Err(fidl::Error::UnknownOrdinal {
674                ordinal: tx_header.ordinal,
675                protocol_name: <StateMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
676            }),
677        }
678    }
679}
680
681/// A Stream of incoming requests for fuchsia.net.stackmigrationdeprecated/State.
682pub struct StateRequestStream {
683    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
684    is_terminated: bool,
685}
686
687impl std::marker::Unpin for StateRequestStream {}
688
689impl futures::stream::FusedStream for StateRequestStream {
690    fn is_terminated(&self) -> bool {
691        self.is_terminated
692    }
693}
694
695impl fdomain_client::fidl::RequestStream for StateRequestStream {
696    type Protocol = StateMarker;
697    type ControlHandle = StateControlHandle;
698
699    fn from_channel(channel: fdomain_client::Channel) -> Self {
700        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
701    }
702
703    fn control_handle(&self) -> Self::ControlHandle {
704        StateControlHandle { inner: self.inner.clone() }
705    }
706
707    fn into_inner(
708        self,
709    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
710    {
711        (self.inner, self.is_terminated)
712    }
713
714    fn from_inner(
715        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
716        is_terminated: bool,
717    ) -> Self {
718        Self { inner, is_terminated }
719    }
720}
721
722impl futures::Stream for StateRequestStream {
723    type Item = Result<StateRequest, fidl::Error>;
724
725    fn poll_next(
726        mut self: std::pin::Pin<&mut Self>,
727        cx: &mut std::task::Context<'_>,
728    ) -> std::task::Poll<Option<Self::Item>> {
729        let this = &mut *self;
730        if this.inner.check_shutdown(cx) {
731            this.is_terminated = true;
732            return std::task::Poll::Ready(None);
733        }
734        if this.is_terminated {
735            panic!("polled StateRequestStream after completion");
736        }
737        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
738            |bytes, handles| {
739                match this.inner.channel().read_etc(cx, bytes, handles) {
740                    std::task::Poll::Ready(Ok(())) => {}
741                    std::task::Poll::Pending => return std::task::Poll::Pending,
742                    std::task::Poll::Ready(Err(None)) => {
743                        this.is_terminated = true;
744                        return std::task::Poll::Ready(None);
745                    }
746                    std::task::Poll::Ready(Err(Some(e))) => {
747                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
748                            e.into(),
749                        ))));
750                    }
751                }
752
753                // A message has been received from the channel
754                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
755
756                std::task::Poll::Ready(Some(match header.ordinal {
757                    0x67053bfebb619ba1 => {
758                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
759                        let mut req = fidl::new_empty!(
760                            fidl::encoding::EmptyPayload,
761                            fdomain_client::fidl::FDomainResourceDialect
762                        );
763                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
764                        let control_handle = StateControlHandle { inner: this.inner.clone() };
765                        Ok(StateRequest::GetNetstackVersion {
766                            responder: StateGetNetstackVersionResponder {
767                                control_handle: std::mem::ManuallyDrop::new(control_handle),
768                                tx_id: header.tx_id,
769                            },
770                        })
771                    }
772                    _ => Err(fidl::Error::UnknownOrdinal {
773                        ordinal: header.ordinal,
774                        protocol_name:
775                            <StateMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
776                    }),
777                }))
778            },
779        )
780    }
781}
782
783/// Provides access to reading netstack migration configuration.
784#[derive(Debug)]
785pub enum StateRequest {
786    /// Gets the target network stack version.
787    ///
788    /// - response `in_effect_version` the configurations currently in effect.
789    GetNetstackVersion { responder: StateGetNetstackVersionResponder },
790}
791
792impl StateRequest {
793    #[allow(irrefutable_let_patterns)]
794    pub fn into_get_netstack_version(self) -> Option<(StateGetNetstackVersionResponder)> {
795        if let StateRequest::GetNetstackVersion { responder } = self {
796            Some((responder))
797        } else {
798            None
799        }
800    }
801
802    /// Name of the method defined in FIDL
803    pub fn method_name(&self) -> &'static str {
804        match *self {
805            StateRequest::GetNetstackVersion { .. } => "get_netstack_version",
806        }
807    }
808}
809
810#[derive(Debug, Clone)]
811pub struct StateControlHandle {
812    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
813}
814
815impl StateControlHandle {
816    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
817        self.inner.shutdown_with_epitaph(status.into())
818    }
819}
820
821impl fdomain_client::fidl::ControlHandle for StateControlHandle {
822    fn shutdown(&self) {
823        self.inner.shutdown()
824    }
825
826    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
827        self.inner.shutdown_with_epitaph(status)
828    }
829
830    fn is_closed(&self) -> bool {
831        self.inner.channel().is_closed()
832    }
833    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
834        self.inner.channel().on_closed()
835    }
836}
837
838impl StateControlHandle {}
839
840#[must_use = "FIDL methods require a response to be sent"]
841#[derive(Debug)]
842pub struct StateGetNetstackVersionResponder {
843    control_handle: std::mem::ManuallyDrop<StateControlHandle>,
844    tx_id: u32,
845}
846
847/// Set the the channel to be shutdown (see [`StateControlHandle::shutdown`])
848/// if the responder is dropped without sending a response, so that the client
849/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
850impl std::ops::Drop for StateGetNetstackVersionResponder {
851    fn drop(&mut self) {
852        self.control_handle.shutdown();
853        // Safety: drops once, never accessed again
854        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
855    }
856}
857
858impl fdomain_client::fidl::Responder for StateGetNetstackVersionResponder {
859    type ControlHandle = StateControlHandle;
860
861    fn control_handle(&self) -> &StateControlHandle {
862        &self.control_handle
863    }
864
865    fn drop_without_shutdown(mut self) {
866        // Safety: drops once, never accessed again due to mem::forget
867        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
868        // Prevent Drop from running (which would shut down the channel)
869        std::mem::forget(self);
870    }
871}
872
873impl StateGetNetstackVersionResponder {
874    /// Sends a response to the FIDL transaction.
875    ///
876    /// Sets the channel to shutdown if an error occurs.
877    pub fn send(self, mut in_effect_version: &InEffectVersion) -> Result<(), fidl::Error> {
878        let _result = self.send_raw(in_effect_version);
879        if _result.is_err() {
880            self.control_handle.shutdown();
881        }
882        self.drop_without_shutdown();
883        _result
884    }
885
886    /// Similar to "send" but does not shutdown the channel if an error occurs.
887    pub fn send_no_shutdown_on_err(
888        self,
889        mut in_effect_version: &InEffectVersion,
890    ) -> Result<(), fidl::Error> {
891        let _result = self.send_raw(in_effect_version);
892        self.drop_without_shutdown();
893        _result
894    }
895
896    fn send_raw(&self, mut in_effect_version: &InEffectVersion) -> Result<(), fidl::Error> {
897        self.control_handle.inner.send::<StateGetNetstackVersionResponse>(
898            (in_effect_version,),
899            self.tx_id,
900            0x67053bfebb619ba1,
901            fidl::encoding::DynamicFlags::empty(),
902        )
903    }
904}
905
906mod internal {
907    use super::*;
908}