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::NullableHandle {
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
384    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
385        self.inner.shutdown_with_epitaph(status)
386    }
387
388    fn is_closed(&self) -> bool {
389        self.inner.channel().is_closed()
390    }
391    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
392        self.inner.channel().on_closed()
393    }
394
395    #[cfg(target_os = "fuchsia")]
396    fn signal_peer(
397        &self,
398        clear_mask: zx::Signals,
399        set_mask: zx::Signals,
400    ) -> Result<(), zx_status::Status> {
401        use fidl::Peered;
402        self.inner.channel().signal_peer(clear_mask, set_mask)
403    }
404}
405
406impl FactoryResetCountdownControlHandle {}
407
408#[must_use = "FIDL methods require a response to be sent"]
409#[derive(Debug)]
410pub struct FactoryResetCountdownWatchResponder {
411    control_handle: std::mem::ManuallyDrop<FactoryResetCountdownControlHandle>,
412    tx_id: u32,
413}
414
415/// Set the the channel to be shutdown (see [`FactoryResetCountdownControlHandle::shutdown`])
416/// if the responder is dropped without sending a response, so that the client
417/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
418impl std::ops::Drop for FactoryResetCountdownWatchResponder {
419    fn drop(&mut self) {
420        self.control_handle.shutdown();
421        // Safety: drops once, never accessed again
422        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
423    }
424}
425
426impl fidl::endpoints::Responder for FactoryResetCountdownWatchResponder {
427    type ControlHandle = FactoryResetCountdownControlHandle;
428
429    fn control_handle(&self) -> &FactoryResetCountdownControlHandle {
430        &self.control_handle
431    }
432
433    fn drop_without_shutdown(mut self) {
434        // Safety: drops once, never accessed again due to mem::forget
435        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
436        // Prevent Drop from running (which would shut down the channel)
437        std::mem::forget(self);
438    }
439}
440
441impl FactoryResetCountdownWatchResponder {
442    /// Sends a response to the FIDL transaction.
443    ///
444    /// Sets the channel to shutdown if an error occurs.
445    pub fn send(self, mut state: &FactoryResetCountdownState) -> Result<(), fidl::Error> {
446        let _result = self.send_raw(state);
447        if _result.is_err() {
448            self.control_handle.shutdown();
449        }
450        self.drop_without_shutdown();
451        _result
452    }
453
454    /// Similar to "send" but does not shutdown the channel if an error occurs.
455    pub fn send_no_shutdown_on_err(
456        self,
457        mut state: &FactoryResetCountdownState,
458    ) -> Result<(), fidl::Error> {
459        let _result = self.send_raw(state);
460        self.drop_without_shutdown();
461        _result
462    }
463
464    fn send_raw(&self, mut state: &FactoryResetCountdownState) -> Result<(), fidl::Error> {
465        self.control_handle.inner.send::<FactoryResetCountdownWatchResponse>(
466            (state,),
467            self.tx_id,
468            0x1d486a7889bc943a,
469            fidl::encoding::DynamicFlags::empty(),
470        )
471    }
472}
473
474#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
475pub struct ProgressRendererMarker;
476
477impl fidl::endpoints::ProtocolMarker for ProgressRendererMarker {
478    type Proxy = ProgressRendererProxy;
479    type RequestStream = ProgressRendererRequestStream;
480    #[cfg(target_os = "fuchsia")]
481    type SynchronousProxy = ProgressRendererSynchronousProxy;
482
483    const DEBUG_NAME: &'static str = "fuchsia.recovery.ui.ProgressRenderer";
484}
485impl fidl::endpoints::DiscoverableProtocolMarker for ProgressRendererMarker {}
486
487pub trait ProgressRendererProxyInterface: Send + Sync {
488    type RenderResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
489    fn r#render(&self, status: Status, percent_complete: f32) -> Self::RenderResponseFut;
490    type Render2ResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
491    fn r#render2(&self, payload: &ProgressRendererRender2Request) -> Self::Render2ResponseFut;
492}
493#[derive(Debug)]
494#[cfg(target_os = "fuchsia")]
495pub struct ProgressRendererSynchronousProxy {
496    client: fidl::client::sync::Client,
497}
498
499#[cfg(target_os = "fuchsia")]
500impl fidl::endpoints::SynchronousProxy for ProgressRendererSynchronousProxy {
501    type Proxy = ProgressRendererProxy;
502    type Protocol = ProgressRendererMarker;
503
504    fn from_channel(inner: fidl::Channel) -> Self {
505        Self::new(inner)
506    }
507
508    fn into_channel(self) -> fidl::Channel {
509        self.client.into_channel()
510    }
511
512    fn as_channel(&self) -> &fidl::Channel {
513        self.client.as_channel()
514    }
515}
516
517#[cfg(target_os = "fuchsia")]
518impl ProgressRendererSynchronousProxy {
519    pub fn new(channel: fidl::Channel) -> Self {
520        let protocol_name = <ProgressRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
521        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
522    }
523
524    pub fn into_channel(self) -> fidl::Channel {
525        self.client.into_channel()
526    }
527
528    /// Waits until an event arrives and returns it. It is safe for other
529    /// threads to make concurrent requests while waiting for an event.
530    pub fn wait_for_event(
531        &self,
532        deadline: zx::MonotonicInstant,
533    ) -> Result<ProgressRendererEvent, fidl::Error> {
534        ProgressRendererEvent::decode(self.client.wait_for_event(deadline)?)
535    }
536
537    /// Called to send progress updates to the renderer.
538    ///
539    /// The return value is used for flow control, and implementers should acknowledge receipt of
540    /// each message in order to continue receiving future messages.
541    pub fn r#render(
542        &self,
543        mut status: Status,
544        mut percent_complete: f32,
545        ___deadline: zx::MonotonicInstant,
546    ) -> Result<(), fidl::Error> {
547        let _response =
548            self.client.send_query::<ProgressRendererRenderRequest, fidl::encoding::EmptyPayload>(
549                (status, percent_complete),
550                0x68f03b362c8c1a54,
551                fidl::encoding::DynamicFlags::empty(),
552                ___deadline,
553            )?;
554        Ok(_response)
555    }
556
557    /// Called to send progress updates to the renderer.
558    ///
559    /// This call optionally contains timing or speed information for the progress bar to move
560    /// slowly to percent_complete
561    ///
562    /// The return value is used for flow control, and implementers should acknowledge receipt of
563    /// each message in order to continue receiving future messages.
564    pub fn r#render2(
565        &self,
566        mut payload: &ProgressRendererRender2Request,
567        ___deadline: zx::MonotonicInstant,
568    ) -> Result<(), fidl::Error> {
569        let _response = self
570            .client
571            .send_query::<ProgressRendererRender2Request, fidl::encoding::EmptyPayload>(
572                payload,
573                0x218acc9beba72126,
574                fidl::encoding::DynamicFlags::empty(),
575                ___deadline,
576            )?;
577        Ok(_response)
578    }
579}
580
581#[cfg(target_os = "fuchsia")]
582impl From<ProgressRendererSynchronousProxy> for zx::NullableHandle {
583    fn from(value: ProgressRendererSynchronousProxy) -> Self {
584        value.into_channel().into()
585    }
586}
587
588#[cfg(target_os = "fuchsia")]
589impl From<fidl::Channel> for ProgressRendererSynchronousProxy {
590    fn from(value: fidl::Channel) -> Self {
591        Self::new(value)
592    }
593}
594
595#[cfg(target_os = "fuchsia")]
596impl fidl::endpoints::FromClient for ProgressRendererSynchronousProxy {
597    type Protocol = ProgressRendererMarker;
598
599    fn from_client(value: fidl::endpoints::ClientEnd<ProgressRendererMarker>) -> Self {
600        Self::new(value.into_channel())
601    }
602}
603
604#[derive(Debug, Clone)]
605pub struct ProgressRendererProxy {
606    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
607}
608
609impl fidl::endpoints::Proxy for ProgressRendererProxy {
610    type Protocol = ProgressRendererMarker;
611
612    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
613        Self::new(inner)
614    }
615
616    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
617        self.client.into_channel().map_err(|client| Self { client })
618    }
619
620    fn as_channel(&self) -> &::fidl::AsyncChannel {
621        self.client.as_channel()
622    }
623}
624
625impl ProgressRendererProxy {
626    /// Create a new Proxy for fuchsia.recovery.ui/ProgressRenderer.
627    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
628        let protocol_name = <ProgressRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
629        Self { client: fidl::client::Client::new(channel, protocol_name) }
630    }
631
632    /// Get a Stream of events from the remote end of the protocol.
633    ///
634    /// # Panics
635    ///
636    /// Panics if the event stream was already taken.
637    pub fn take_event_stream(&self) -> ProgressRendererEventStream {
638        ProgressRendererEventStream { event_receiver: self.client.take_event_receiver() }
639    }
640
641    /// Called to send progress updates to the renderer.
642    ///
643    /// The return value is used for flow control, and implementers should acknowledge receipt of
644    /// each message in order to continue receiving future messages.
645    pub fn r#render(
646        &self,
647        mut status: Status,
648        mut percent_complete: f32,
649    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
650        ProgressRendererProxyInterface::r#render(self, status, percent_complete)
651    }
652
653    /// Called to send progress updates to the renderer.
654    ///
655    /// This call optionally contains timing or speed information for the progress bar to move
656    /// slowly to percent_complete
657    ///
658    /// The return value is used for flow control, and implementers should acknowledge receipt of
659    /// each message in order to continue receiving future messages.
660    pub fn r#render2(
661        &self,
662        mut payload: &ProgressRendererRender2Request,
663    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
664        ProgressRendererProxyInterface::r#render2(self, payload)
665    }
666}
667
668impl ProgressRendererProxyInterface for ProgressRendererProxy {
669    type RenderResponseFut =
670        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
671    fn r#render(&self, mut status: Status, mut percent_complete: f32) -> Self::RenderResponseFut {
672        fn _decode(
673            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
674        ) -> Result<(), fidl::Error> {
675            let _response = fidl::client::decode_transaction_body::<
676                fidl::encoding::EmptyPayload,
677                fidl::encoding::DefaultFuchsiaResourceDialect,
678                0x68f03b362c8c1a54,
679            >(_buf?)?;
680            Ok(_response)
681        }
682        self.client.send_query_and_decode::<ProgressRendererRenderRequest, ()>(
683            (status, percent_complete),
684            0x68f03b362c8c1a54,
685            fidl::encoding::DynamicFlags::empty(),
686            _decode,
687        )
688    }
689
690    type Render2ResponseFut =
691        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
692    fn r#render2(&self, mut payload: &ProgressRendererRender2Request) -> Self::Render2ResponseFut {
693        fn _decode(
694            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
695        ) -> Result<(), fidl::Error> {
696            let _response = fidl::client::decode_transaction_body::<
697                fidl::encoding::EmptyPayload,
698                fidl::encoding::DefaultFuchsiaResourceDialect,
699                0x218acc9beba72126,
700            >(_buf?)?;
701            Ok(_response)
702        }
703        self.client.send_query_and_decode::<ProgressRendererRender2Request, ()>(
704            payload,
705            0x218acc9beba72126,
706            fidl::encoding::DynamicFlags::empty(),
707            _decode,
708        )
709    }
710}
711
712pub struct ProgressRendererEventStream {
713    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
714}
715
716impl std::marker::Unpin for ProgressRendererEventStream {}
717
718impl futures::stream::FusedStream for ProgressRendererEventStream {
719    fn is_terminated(&self) -> bool {
720        self.event_receiver.is_terminated()
721    }
722}
723
724impl futures::Stream for ProgressRendererEventStream {
725    type Item = Result<ProgressRendererEvent, fidl::Error>;
726
727    fn poll_next(
728        mut self: std::pin::Pin<&mut Self>,
729        cx: &mut std::task::Context<'_>,
730    ) -> std::task::Poll<Option<Self::Item>> {
731        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
732            &mut self.event_receiver,
733            cx
734        )?) {
735            Some(buf) => std::task::Poll::Ready(Some(ProgressRendererEvent::decode(buf))),
736            None => std::task::Poll::Ready(None),
737        }
738    }
739}
740
741#[derive(Debug)]
742pub enum ProgressRendererEvent {}
743
744impl ProgressRendererEvent {
745    /// Decodes a message buffer as a [`ProgressRendererEvent`].
746    fn decode(
747        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
748    ) -> Result<ProgressRendererEvent, fidl::Error> {
749        let (bytes, _handles) = buf.split_mut();
750        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
751        debug_assert_eq!(tx_header.tx_id, 0);
752        match tx_header.ordinal {
753            _ => Err(fidl::Error::UnknownOrdinal {
754                ordinal: tx_header.ordinal,
755                protocol_name:
756                    <ProgressRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
757            }),
758        }
759    }
760}
761
762/// A Stream of incoming requests for fuchsia.recovery.ui/ProgressRenderer.
763pub struct ProgressRendererRequestStream {
764    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
765    is_terminated: bool,
766}
767
768impl std::marker::Unpin for ProgressRendererRequestStream {}
769
770impl futures::stream::FusedStream for ProgressRendererRequestStream {
771    fn is_terminated(&self) -> bool {
772        self.is_terminated
773    }
774}
775
776impl fidl::endpoints::RequestStream for ProgressRendererRequestStream {
777    type Protocol = ProgressRendererMarker;
778    type ControlHandle = ProgressRendererControlHandle;
779
780    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
781        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
782    }
783
784    fn control_handle(&self) -> Self::ControlHandle {
785        ProgressRendererControlHandle { inner: self.inner.clone() }
786    }
787
788    fn into_inner(
789        self,
790    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
791    {
792        (self.inner, self.is_terminated)
793    }
794
795    fn from_inner(
796        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
797        is_terminated: bool,
798    ) -> Self {
799        Self { inner, is_terminated }
800    }
801}
802
803impl futures::Stream for ProgressRendererRequestStream {
804    type Item = Result<ProgressRendererRequest, fidl::Error>;
805
806    fn poll_next(
807        mut self: std::pin::Pin<&mut Self>,
808        cx: &mut std::task::Context<'_>,
809    ) -> std::task::Poll<Option<Self::Item>> {
810        let this = &mut *self;
811        if this.inner.check_shutdown(cx) {
812            this.is_terminated = true;
813            return std::task::Poll::Ready(None);
814        }
815        if this.is_terminated {
816            panic!("polled ProgressRendererRequestStream after completion");
817        }
818        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
819            |bytes, handles| {
820                match this.inner.channel().read_etc(cx, bytes, handles) {
821                    std::task::Poll::Ready(Ok(())) => {}
822                    std::task::Poll::Pending => return std::task::Poll::Pending,
823                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
824                        this.is_terminated = true;
825                        return std::task::Poll::Ready(None);
826                    }
827                    std::task::Poll::Ready(Err(e)) => {
828                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
829                            e.into(),
830                        ))));
831                    }
832                }
833
834                // A message has been received from the channel
835                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
836
837                std::task::Poll::Ready(Some(match header.ordinal {
838                    0x68f03b362c8c1a54 => {
839                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
840                        let mut req = fidl::new_empty!(
841                            ProgressRendererRenderRequest,
842                            fidl::encoding::DefaultFuchsiaResourceDialect
843                        );
844                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProgressRendererRenderRequest>(&header, _body_bytes, handles, &mut req)?;
845                        let control_handle =
846                            ProgressRendererControlHandle { inner: this.inner.clone() };
847                        Ok(ProgressRendererRequest::Render {
848                            status: req.status,
849                            percent_complete: req.percent_complete,
850
851                            responder: ProgressRendererRenderResponder {
852                                control_handle: std::mem::ManuallyDrop::new(control_handle),
853                                tx_id: header.tx_id,
854                            },
855                        })
856                    }
857                    0x218acc9beba72126 => {
858                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
859                        let mut req = fidl::new_empty!(
860                            ProgressRendererRender2Request,
861                            fidl::encoding::DefaultFuchsiaResourceDialect
862                        );
863                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProgressRendererRender2Request>(&header, _body_bytes, handles, &mut req)?;
864                        let control_handle =
865                            ProgressRendererControlHandle { inner: this.inner.clone() };
866                        Ok(ProgressRendererRequest::Render2 {
867                            payload: req,
868                            responder: ProgressRendererRender2Responder {
869                                control_handle: std::mem::ManuallyDrop::new(control_handle),
870                                tx_id: header.tx_id,
871                            },
872                        })
873                    }
874                    _ => Err(fidl::Error::UnknownOrdinal {
875                        ordinal: header.ordinal,
876                        protocol_name:
877                            <ProgressRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
878                    }),
879                }))
880            },
881        )
882    }
883}
884
885/// Protocol to receive progress updates to display a carnelian based progress bar UI.
886#[derive(Debug)]
887pub enum ProgressRendererRequest {
888    /// Called to send progress updates to the renderer.
889    ///
890    /// The return value is used for flow control, and implementers should acknowledge receipt of
891    /// each message in order to continue receiving future messages.
892    Render { status: Status, percent_complete: f32, responder: ProgressRendererRenderResponder },
893    /// Called to send progress updates to the renderer.
894    ///
895    /// This call optionally contains timing or speed information for the progress bar to move
896    /// slowly to percent_complete
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    Render2 { payload: ProgressRendererRender2Request, responder: ProgressRendererRender2Responder },
901}
902
903impl ProgressRendererRequest {
904    #[allow(irrefutable_let_patterns)]
905    pub fn into_render(self) -> Option<(Status, f32, ProgressRendererRenderResponder)> {
906        if let ProgressRendererRequest::Render { status, percent_complete, responder } = self {
907            Some((status, percent_complete, responder))
908        } else {
909            None
910        }
911    }
912
913    #[allow(irrefutable_let_patterns)]
914    pub fn into_render2(
915        self,
916    ) -> Option<(ProgressRendererRender2Request, ProgressRendererRender2Responder)> {
917        if let ProgressRendererRequest::Render2 { payload, responder } = self {
918            Some((payload, responder))
919        } else {
920            None
921        }
922    }
923
924    /// Name of the method defined in FIDL
925    pub fn method_name(&self) -> &'static str {
926        match *self {
927            ProgressRendererRequest::Render { .. } => "render",
928            ProgressRendererRequest::Render2 { .. } => "render2",
929        }
930    }
931}
932
933#[derive(Debug, Clone)]
934pub struct ProgressRendererControlHandle {
935    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
936}
937
938impl fidl::endpoints::ControlHandle for ProgressRendererControlHandle {
939    fn shutdown(&self) {
940        self.inner.shutdown()
941    }
942
943    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
944        self.inner.shutdown_with_epitaph(status)
945    }
946
947    fn is_closed(&self) -> bool {
948        self.inner.channel().is_closed()
949    }
950    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
951        self.inner.channel().on_closed()
952    }
953
954    #[cfg(target_os = "fuchsia")]
955    fn signal_peer(
956        &self,
957        clear_mask: zx::Signals,
958        set_mask: zx::Signals,
959    ) -> Result<(), zx_status::Status> {
960        use fidl::Peered;
961        self.inner.channel().signal_peer(clear_mask, set_mask)
962    }
963}
964
965impl ProgressRendererControlHandle {}
966
967#[must_use = "FIDL methods require a response to be sent"]
968#[derive(Debug)]
969pub struct ProgressRendererRenderResponder {
970    control_handle: std::mem::ManuallyDrop<ProgressRendererControlHandle>,
971    tx_id: u32,
972}
973
974/// Set the the channel to be shutdown (see [`ProgressRendererControlHandle::shutdown`])
975/// if the responder is dropped without sending a response, so that the client
976/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
977impl std::ops::Drop for ProgressRendererRenderResponder {
978    fn drop(&mut self) {
979        self.control_handle.shutdown();
980        // Safety: drops once, never accessed again
981        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
982    }
983}
984
985impl fidl::endpoints::Responder for ProgressRendererRenderResponder {
986    type ControlHandle = ProgressRendererControlHandle;
987
988    fn control_handle(&self) -> &ProgressRendererControlHandle {
989        &self.control_handle
990    }
991
992    fn drop_without_shutdown(mut self) {
993        // Safety: drops once, never accessed again due to mem::forget
994        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
995        // Prevent Drop from running (which would shut down the channel)
996        std::mem::forget(self);
997    }
998}
999
1000impl ProgressRendererRenderResponder {
1001    /// Sends a response to the FIDL transaction.
1002    ///
1003    /// Sets the channel to shutdown if an error occurs.
1004    pub fn send(self) -> Result<(), fidl::Error> {
1005        let _result = self.send_raw();
1006        if _result.is_err() {
1007            self.control_handle.shutdown();
1008        }
1009        self.drop_without_shutdown();
1010        _result
1011    }
1012
1013    /// Similar to "send" but does not shutdown the channel if an error occurs.
1014    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1015        let _result = self.send_raw();
1016        self.drop_without_shutdown();
1017        _result
1018    }
1019
1020    fn send_raw(&self) -> Result<(), fidl::Error> {
1021        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1022            (),
1023            self.tx_id,
1024            0x68f03b362c8c1a54,
1025            fidl::encoding::DynamicFlags::empty(),
1026        )
1027    }
1028}
1029
1030#[must_use = "FIDL methods require a response to be sent"]
1031#[derive(Debug)]
1032pub struct ProgressRendererRender2Responder {
1033    control_handle: std::mem::ManuallyDrop<ProgressRendererControlHandle>,
1034    tx_id: u32,
1035}
1036
1037/// Set the the channel to be shutdown (see [`ProgressRendererControlHandle::shutdown`])
1038/// if the responder is dropped without sending a response, so that the client
1039/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1040impl std::ops::Drop for ProgressRendererRender2Responder {
1041    fn drop(&mut self) {
1042        self.control_handle.shutdown();
1043        // Safety: drops once, never accessed again
1044        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1045    }
1046}
1047
1048impl fidl::endpoints::Responder for ProgressRendererRender2Responder {
1049    type ControlHandle = ProgressRendererControlHandle;
1050
1051    fn control_handle(&self) -> &ProgressRendererControlHandle {
1052        &self.control_handle
1053    }
1054
1055    fn drop_without_shutdown(mut self) {
1056        // Safety: drops once, never accessed again due to mem::forget
1057        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1058        // Prevent Drop from running (which would shut down the channel)
1059        std::mem::forget(self);
1060    }
1061}
1062
1063impl ProgressRendererRender2Responder {
1064    /// Sends a response to the FIDL transaction.
1065    ///
1066    /// Sets the channel to shutdown if an error occurs.
1067    pub fn send(self) -> Result<(), fidl::Error> {
1068        let _result = self.send_raw();
1069        if _result.is_err() {
1070            self.control_handle.shutdown();
1071        }
1072        self.drop_without_shutdown();
1073        _result
1074    }
1075
1076    /// Similar to "send" but does not shutdown the channel if an error occurs.
1077    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1078        let _result = self.send_raw();
1079        self.drop_without_shutdown();
1080        _result
1081    }
1082
1083    fn send_raw(&self) -> Result<(), fidl::Error> {
1084        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1085            (),
1086            self.tx_id,
1087            0x218acc9beba72126,
1088            fidl::encoding::DynamicFlags::empty(),
1089        )
1090    }
1091}
1092
1093mod internal {
1094    use super::*;
1095}