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