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