Skip to main content

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