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 _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
14#[repr(u32)]
15pub enum Status {
16    Active = 1,
17    Paused = 2,
18    Error = 3,
19    Cancelled = 4,
20    Complete = 5,
21}
22
23impl Status {
24    #[inline]
25    pub fn from_primitive(prim: u32) -> Option<Self> {
26        match prim {
27            1 => Some(Self::Active),
28            2 => Some(Self::Paused),
29            3 => Some(Self::Error),
30            4 => Some(Self::Cancelled),
31            5 => Some(Self::Complete),
32            _ => None,
33        }
34    }
35
36    #[inline]
37    pub const fn into_primitive(self) -> u32 {
38        self as u32
39    }
40
41    #[deprecated = "Strict enums should not use `is_unknown`"]
42    #[inline]
43    pub fn is_unknown(&self) -> bool {
44        false
45    }
46}
47
48#[derive(Clone, Debug, PartialEq)]
49pub struct FactoryResetCountdownWatchResponse {
50    pub state: FactoryResetCountdownState,
51}
52
53impl fidl::Persistable for FactoryResetCountdownWatchResponse {}
54
55#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
56pub struct ProgressRendererRenderRequest {
57    pub status: Status,
58    pub percent_complete: f32,
59}
60
61impl fidl::Persistable for ProgressRendererRenderRequest {}
62
63/// Information provided through the FactoryResetCountdown protocol on the
64/// current factory reset state.
65#[derive(Clone, Debug, Default, PartialEq)]
66pub struct FactoryResetCountdownState {
67    /// The time of when factory reset is scheduled to be triggered when a
68    /// countdown for factory reset is in progress with respect to the monotonic
69    /// clock. This field is left unpopulated if no reset is scheduled.
70    pub scheduled_reset_time: Option<i64>,
71    #[doc(hidden)]
72    pub __source_breaking: fidl::marker::SourceBreaking,
73}
74
75impl fidl::Persistable for FactoryResetCountdownState {}
76
77#[derive(Clone, Debug, Default, PartialEq)]
78pub struct ProgressRendererRender2Request {
79    pub status: Option<Status>,
80    /// Optional, only used with status ACTIVE
81    /// No value or an invalid value sets the progress bar to 0%
82    /// Values: [0.0 - 100.0]
83    pub percent_complete: Option<f32>,
84    /// Time to take to move slowly to percent_complete
85    /// Optional, only used with status ACTIVE
86    /// No value indicates an instant jump to percent_complete
87    pub elapsed_time: Option<i64>,
88    #[doc(hidden)]
89    pub __source_breaking: fidl::marker::SourceBreaking,
90}
91
92impl fidl::Persistable for ProgressRendererRender2Request {}
93
94#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
95pub struct FactoryResetCountdownMarker;
96
97impl fidl::endpoints::ProtocolMarker for FactoryResetCountdownMarker {
98    type Proxy = FactoryResetCountdownProxy;
99    type RequestStream = FactoryResetCountdownRequestStream;
100    #[cfg(target_os = "fuchsia")]
101    type SynchronousProxy = FactoryResetCountdownSynchronousProxy;
102
103    const DEBUG_NAME: &'static str = "fuchsia.recovery.ui.FactoryResetCountdown";
104}
105impl fidl::endpoints::DiscoverableProtocolMarker for FactoryResetCountdownMarker {}
106
107pub trait FactoryResetCountdownProxyInterface: Send + Sync {
108    type WatchResponseFut: std::future::Future<Output = Result<FactoryResetCountdownState, fidl::Error>>
109        + Send;
110    fn r#watch(&self) -> Self::WatchResponseFut;
111}
112#[derive(Debug)]
113#[cfg(target_os = "fuchsia")]
114pub struct FactoryResetCountdownSynchronousProxy {
115    client: fidl::client::sync::Client,
116}
117
118#[cfg(target_os = "fuchsia")]
119impl fidl::endpoints::SynchronousProxy for FactoryResetCountdownSynchronousProxy {
120    type Proxy = FactoryResetCountdownProxy;
121    type Protocol = FactoryResetCountdownMarker;
122
123    fn from_channel(inner: fidl::Channel) -> Self {
124        Self::new(inner)
125    }
126
127    fn into_channel(self) -> fidl::Channel {
128        self.client.into_channel()
129    }
130
131    fn as_channel(&self) -> &fidl::Channel {
132        self.client.as_channel()
133    }
134}
135
136#[cfg(target_os = "fuchsia")]
137impl FactoryResetCountdownSynchronousProxy {
138    pub fn new(channel: fidl::Channel) -> Self {
139        let protocol_name =
140            <FactoryResetCountdownMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
141        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
142    }
143
144    pub fn into_channel(self) -> fidl::Channel {
145        self.client.into_channel()
146    }
147
148    /// Waits until an event arrives and returns it. It is safe for other
149    /// threads to make concurrent requests while waiting for an event.
150    pub fn wait_for_event(
151        &self,
152        deadline: zx::MonotonicInstant,
153    ) -> Result<FactoryResetCountdownEvent, fidl::Error> {
154        FactoryResetCountdownEvent::decode(self.client.wait_for_event(deadline)?)
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        ___deadline: zx::MonotonicInstant,
163    ) -> Result<FactoryResetCountdownState, fidl::Error> {
164        let _response = self
165            .client
166            .send_query::<fidl::encoding::EmptyPayload, FactoryResetCountdownWatchResponse>(
167                (),
168                0x1d486a7889bc943a,
169                fidl::encoding::DynamicFlags::empty(),
170                ___deadline,
171            )?;
172        Ok(_response.state)
173    }
174}
175
176#[derive(Debug, Clone)]
177pub struct FactoryResetCountdownProxy {
178    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
179}
180
181impl fidl::endpoints::Proxy for FactoryResetCountdownProxy {
182    type Protocol = FactoryResetCountdownMarker;
183
184    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
185        Self::new(inner)
186    }
187
188    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
189        self.client.into_channel().map_err(|client| Self { client })
190    }
191
192    fn as_channel(&self) -> &::fidl::AsyncChannel {
193        self.client.as_channel()
194    }
195}
196
197impl FactoryResetCountdownProxy {
198    /// Create a new Proxy for fuchsia.recovery.ui/FactoryResetCountdown.
199    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
200        let protocol_name =
201            <FactoryResetCountdownMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
202        Self { client: fidl::client::Client::new(channel, protocol_name) }
203    }
204
205    /// Get a Stream of events from the remote end of the protocol.
206    ///
207    /// # Panics
208    ///
209    /// Panics if the event stream was already taken.
210    pub fn take_event_stream(&self) -> FactoryResetCountdownEventStream {
211        FactoryResetCountdownEventStream { event_receiver: self.client.take_event_receiver() }
212    }
213
214    /// Hanging get that returns when a factory reset is scheduled or a
215    /// scheduled factory reset is cancelled. Will return immediately on first
216    /// call per connection and then on change after that.
217    pub fn r#watch(
218        &self,
219    ) -> fidl::client::QueryResponseFut<
220        FactoryResetCountdownState,
221        fidl::encoding::DefaultFuchsiaResourceDialect,
222    > {
223        FactoryResetCountdownProxyInterface::r#watch(self)
224    }
225}
226
227impl FactoryResetCountdownProxyInterface for FactoryResetCountdownProxy {
228    type WatchResponseFut = fidl::client::QueryResponseFut<
229        FactoryResetCountdownState,
230        fidl::encoding::DefaultFuchsiaResourceDialect,
231    >;
232    fn r#watch(&self) -> Self::WatchResponseFut {
233        fn _decode(
234            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
235        ) -> Result<FactoryResetCountdownState, fidl::Error> {
236            let _response = fidl::client::decode_transaction_body::<
237                FactoryResetCountdownWatchResponse,
238                fidl::encoding::DefaultFuchsiaResourceDialect,
239                0x1d486a7889bc943a,
240            >(_buf?)?;
241            Ok(_response.state)
242        }
243        self.client
244            .send_query_and_decode::<fidl::encoding::EmptyPayload, FactoryResetCountdownState>(
245                (),
246                0x1d486a7889bc943a,
247                fidl::encoding::DynamicFlags::empty(),
248                _decode,
249            )
250    }
251}
252
253pub struct FactoryResetCountdownEventStream {
254    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
255}
256
257impl std::marker::Unpin for FactoryResetCountdownEventStream {}
258
259impl futures::stream::FusedStream for FactoryResetCountdownEventStream {
260    fn is_terminated(&self) -> bool {
261        self.event_receiver.is_terminated()
262    }
263}
264
265impl futures::Stream for FactoryResetCountdownEventStream {
266    type Item = Result<FactoryResetCountdownEvent, fidl::Error>;
267
268    fn poll_next(
269        mut self: std::pin::Pin<&mut Self>,
270        cx: &mut std::task::Context<'_>,
271    ) -> std::task::Poll<Option<Self::Item>> {
272        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
273            &mut self.event_receiver,
274            cx
275        )?) {
276            Some(buf) => std::task::Poll::Ready(Some(FactoryResetCountdownEvent::decode(buf))),
277            None => std::task::Poll::Ready(None),
278        }
279    }
280}
281
282#[derive(Debug)]
283pub enum FactoryResetCountdownEvent {}
284
285impl FactoryResetCountdownEvent {
286    /// Decodes a message buffer as a [`FactoryResetCountdownEvent`].
287    fn decode(
288        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
289    ) -> Result<FactoryResetCountdownEvent, fidl::Error> {
290        let (bytes, _handles) = buf.split_mut();
291        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
292        debug_assert_eq!(tx_header.tx_id, 0);
293        match tx_header.ordinal {
294            _ => Err(fidl::Error::UnknownOrdinal {
295                ordinal: tx_header.ordinal,
296                protocol_name:
297                    <FactoryResetCountdownMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
298            }),
299        }
300    }
301}
302
303/// A Stream of incoming requests for fuchsia.recovery.ui/FactoryResetCountdown.
304pub struct FactoryResetCountdownRequestStream {
305    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
306    is_terminated: bool,
307}
308
309impl std::marker::Unpin for FactoryResetCountdownRequestStream {}
310
311impl futures::stream::FusedStream for FactoryResetCountdownRequestStream {
312    fn is_terminated(&self) -> bool {
313        self.is_terminated
314    }
315}
316
317impl fidl::endpoints::RequestStream for FactoryResetCountdownRequestStream {
318    type Protocol = FactoryResetCountdownMarker;
319    type ControlHandle = FactoryResetCountdownControlHandle;
320
321    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
322        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
323    }
324
325    fn control_handle(&self) -> Self::ControlHandle {
326        FactoryResetCountdownControlHandle { inner: self.inner.clone() }
327    }
328
329    fn into_inner(
330        self,
331    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
332    {
333        (self.inner, self.is_terminated)
334    }
335
336    fn from_inner(
337        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
338        is_terminated: bool,
339    ) -> Self {
340        Self { inner, is_terminated }
341    }
342}
343
344impl futures::Stream for FactoryResetCountdownRequestStream {
345    type Item = Result<FactoryResetCountdownRequest, fidl::Error>;
346
347    fn poll_next(
348        mut self: std::pin::Pin<&mut Self>,
349        cx: &mut std::task::Context<'_>,
350    ) -> std::task::Poll<Option<Self::Item>> {
351        let this = &mut *self;
352        if this.inner.check_shutdown(cx) {
353            this.is_terminated = true;
354            return std::task::Poll::Ready(None);
355        }
356        if this.is_terminated {
357            panic!("polled FactoryResetCountdownRequestStream after completion");
358        }
359        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
360            |bytes, handles| {
361                match this.inner.channel().read_etc(cx, bytes, handles) {
362                    std::task::Poll::Ready(Ok(())) => {}
363                    std::task::Poll::Pending => return std::task::Poll::Pending,
364                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
365                        this.is_terminated = true;
366                        return std::task::Poll::Ready(None);
367                    }
368                    std::task::Poll::Ready(Err(e)) => {
369                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
370                            e.into(),
371                        ))))
372                    }
373                }
374
375                // A message has been received from the channel
376                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
377
378                std::task::Poll::Ready(Some(match header.ordinal {
379                0x1d486a7889bc943a => {
380                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
381                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
382                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
383                    let control_handle = FactoryResetCountdownControlHandle {
384                        inner: this.inner.clone(),
385                    };
386                    Ok(FactoryResetCountdownRequest::Watch {
387                        responder: FactoryResetCountdownWatchResponder {
388                            control_handle: std::mem::ManuallyDrop::new(control_handle),
389                            tx_id: header.tx_id,
390                        },
391                    })
392                }
393                _ => Err(fidl::Error::UnknownOrdinal {
394                    ordinal: header.ordinal,
395                    protocol_name: <FactoryResetCountdownMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
396                }),
397            }))
398            },
399        )
400    }
401}
402
403/// Protocol to watch for changes when a factory reset countdown is started or
404/// cancelled. An immediate factory reset does not start a countdown.
405#[derive(Debug)]
406pub enum FactoryResetCountdownRequest {
407    /// Hanging get that returns when a factory reset is scheduled or a
408    /// scheduled factory reset is cancelled. Will return immediately on first
409    /// call per connection and then on change after that.
410    Watch { responder: FactoryResetCountdownWatchResponder },
411}
412
413impl FactoryResetCountdownRequest {
414    #[allow(irrefutable_let_patterns)]
415    pub fn into_watch(self) -> Option<(FactoryResetCountdownWatchResponder)> {
416        if let FactoryResetCountdownRequest::Watch { responder } = self {
417            Some((responder))
418        } else {
419            None
420        }
421    }
422
423    /// Name of the method defined in FIDL
424    pub fn method_name(&self) -> &'static str {
425        match *self {
426            FactoryResetCountdownRequest::Watch { .. } => "watch",
427        }
428    }
429}
430
431#[derive(Debug, Clone)]
432pub struct FactoryResetCountdownControlHandle {
433    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
434}
435
436impl fidl::endpoints::ControlHandle for FactoryResetCountdownControlHandle {
437    fn shutdown(&self) {
438        self.inner.shutdown()
439    }
440    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
441        self.inner.shutdown_with_epitaph(status)
442    }
443
444    fn is_closed(&self) -> bool {
445        self.inner.channel().is_closed()
446    }
447    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
448        self.inner.channel().on_closed()
449    }
450
451    #[cfg(target_os = "fuchsia")]
452    fn signal_peer(
453        &self,
454        clear_mask: zx::Signals,
455        set_mask: zx::Signals,
456    ) -> Result<(), zx_status::Status> {
457        use fidl::Peered;
458        self.inner.channel().signal_peer(clear_mask, set_mask)
459    }
460}
461
462impl FactoryResetCountdownControlHandle {}
463
464#[must_use = "FIDL methods require a response to be sent"]
465#[derive(Debug)]
466pub struct FactoryResetCountdownWatchResponder {
467    control_handle: std::mem::ManuallyDrop<FactoryResetCountdownControlHandle>,
468    tx_id: u32,
469}
470
471/// Set the the channel to be shutdown (see [`FactoryResetCountdownControlHandle::shutdown`])
472/// if the responder is dropped without sending a response, so that the client
473/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
474impl std::ops::Drop for FactoryResetCountdownWatchResponder {
475    fn drop(&mut self) {
476        self.control_handle.shutdown();
477        // Safety: drops once, never accessed again
478        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
479    }
480}
481
482impl fidl::endpoints::Responder for FactoryResetCountdownWatchResponder {
483    type ControlHandle = FactoryResetCountdownControlHandle;
484
485    fn control_handle(&self) -> &FactoryResetCountdownControlHandle {
486        &self.control_handle
487    }
488
489    fn drop_without_shutdown(mut self) {
490        // Safety: drops once, never accessed again due to mem::forget
491        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
492        // Prevent Drop from running (which would shut down the channel)
493        std::mem::forget(self);
494    }
495}
496
497impl FactoryResetCountdownWatchResponder {
498    /// Sends a response to the FIDL transaction.
499    ///
500    /// Sets the channel to shutdown if an error occurs.
501    pub fn send(self, mut state: &FactoryResetCountdownState) -> Result<(), fidl::Error> {
502        let _result = self.send_raw(state);
503        if _result.is_err() {
504            self.control_handle.shutdown();
505        }
506        self.drop_without_shutdown();
507        _result
508    }
509
510    /// Similar to "send" but does not shutdown the channel if an error occurs.
511    pub fn send_no_shutdown_on_err(
512        self,
513        mut state: &FactoryResetCountdownState,
514    ) -> Result<(), fidl::Error> {
515        let _result = self.send_raw(state);
516        self.drop_without_shutdown();
517        _result
518    }
519
520    fn send_raw(&self, mut state: &FactoryResetCountdownState) -> Result<(), fidl::Error> {
521        self.control_handle.inner.send::<FactoryResetCountdownWatchResponse>(
522            (state,),
523            self.tx_id,
524            0x1d486a7889bc943a,
525            fidl::encoding::DynamicFlags::empty(),
526        )
527    }
528}
529
530#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
531pub struct ProgressRendererMarker;
532
533impl fidl::endpoints::ProtocolMarker for ProgressRendererMarker {
534    type Proxy = ProgressRendererProxy;
535    type RequestStream = ProgressRendererRequestStream;
536    #[cfg(target_os = "fuchsia")]
537    type SynchronousProxy = ProgressRendererSynchronousProxy;
538
539    const DEBUG_NAME: &'static str = "fuchsia.recovery.ui.ProgressRenderer";
540}
541impl fidl::endpoints::DiscoverableProtocolMarker for ProgressRendererMarker {}
542
543pub trait ProgressRendererProxyInterface: Send + Sync {
544    type RenderResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
545    fn r#render(&self, status: Status, percent_complete: f32) -> Self::RenderResponseFut;
546    type Render2ResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
547    fn r#render2(&self, payload: &ProgressRendererRender2Request) -> Self::Render2ResponseFut;
548}
549#[derive(Debug)]
550#[cfg(target_os = "fuchsia")]
551pub struct ProgressRendererSynchronousProxy {
552    client: fidl::client::sync::Client,
553}
554
555#[cfg(target_os = "fuchsia")]
556impl fidl::endpoints::SynchronousProxy for ProgressRendererSynchronousProxy {
557    type Proxy = ProgressRendererProxy;
558    type Protocol = ProgressRendererMarker;
559
560    fn from_channel(inner: fidl::Channel) -> Self {
561        Self::new(inner)
562    }
563
564    fn into_channel(self) -> fidl::Channel {
565        self.client.into_channel()
566    }
567
568    fn as_channel(&self) -> &fidl::Channel {
569        self.client.as_channel()
570    }
571}
572
573#[cfg(target_os = "fuchsia")]
574impl ProgressRendererSynchronousProxy {
575    pub fn new(channel: fidl::Channel) -> Self {
576        let protocol_name = <ProgressRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
577        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
578    }
579
580    pub fn into_channel(self) -> fidl::Channel {
581        self.client.into_channel()
582    }
583
584    /// Waits until an event arrives and returns it. It is safe for other
585    /// threads to make concurrent requests while waiting for an event.
586    pub fn wait_for_event(
587        &self,
588        deadline: zx::MonotonicInstant,
589    ) -> Result<ProgressRendererEvent, fidl::Error> {
590        ProgressRendererEvent::decode(self.client.wait_for_event(deadline)?)
591    }
592
593    /// Called to send progress updates to the renderer.
594    ///
595    /// The return value is used for flow control, and implementers should acknowledge receipt of
596    /// each message in order to continue receiving future messages.
597    pub fn r#render(
598        &self,
599        mut status: Status,
600        mut percent_complete: f32,
601        ___deadline: zx::MonotonicInstant,
602    ) -> Result<(), fidl::Error> {
603        let _response =
604            self.client.send_query::<ProgressRendererRenderRequest, fidl::encoding::EmptyPayload>(
605                (status, percent_complete),
606                0x68f03b362c8c1a54,
607                fidl::encoding::DynamicFlags::empty(),
608                ___deadline,
609            )?;
610        Ok(_response)
611    }
612
613    /// Called to send progress updates to the renderer.
614    ///
615    /// This call optionally contains timing or speed information for the progress bar to move
616    /// slowly to percent_complete
617    ///
618    /// The return value is used for flow control, and implementers should acknowledge receipt of
619    /// each message in order to continue receiving future messages.
620    pub fn r#render2(
621        &self,
622        mut payload: &ProgressRendererRender2Request,
623        ___deadline: zx::MonotonicInstant,
624    ) -> Result<(), fidl::Error> {
625        let _response = self
626            .client
627            .send_query::<ProgressRendererRender2Request, fidl::encoding::EmptyPayload>(
628                payload,
629                0x218acc9beba72126,
630                fidl::encoding::DynamicFlags::empty(),
631                ___deadline,
632            )?;
633        Ok(_response)
634    }
635}
636
637#[derive(Debug, Clone)]
638pub struct ProgressRendererProxy {
639    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
640}
641
642impl fidl::endpoints::Proxy for ProgressRendererProxy {
643    type Protocol = ProgressRendererMarker;
644
645    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
646        Self::new(inner)
647    }
648
649    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
650        self.client.into_channel().map_err(|client| Self { client })
651    }
652
653    fn as_channel(&self) -> &::fidl::AsyncChannel {
654        self.client.as_channel()
655    }
656}
657
658impl ProgressRendererProxy {
659    /// Create a new Proxy for fuchsia.recovery.ui/ProgressRenderer.
660    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
661        let protocol_name = <ProgressRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
662        Self { client: fidl::client::Client::new(channel, protocol_name) }
663    }
664
665    /// Get a Stream of events from the remote end of the protocol.
666    ///
667    /// # Panics
668    ///
669    /// Panics if the event stream was already taken.
670    pub fn take_event_stream(&self) -> ProgressRendererEventStream {
671        ProgressRendererEventStream { event_receiver: self.client.take_event_receiver() }
672    }
673
674    /// Called to send progress updates to the renderer.
675    ///
676    /// The return value is used for flow control, and implementers should acknowledge receipt of
677    /// each message in order to continue receiving future messages.
678    pub fn r#render(
679        &self,
680        mut status: Status,
681        mut percent_complete: f32,
682    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
683        ProgressRendererProxyInterface::r#render(self, status, percent_complete)
684    }
685
686    /// Called to send progress updates to the renderer.
687    ///
688    /// This call optionally contains timing or speed information for the progress bar to move
689    /// slowly to percent_complete
690    ///
691    /// The return value is used for flow control, and implementers should acknowledge receipt of
692    /// each message in order to continue receiving future messages.
693    pub fn r#render2(
694        &self,
695        mut payload: &ProgressRendererRender2Request,
696    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
697        ProgressRendererProxyInterface::r#render2(self, payload)
698    }
699}
700
701impl ProgressRendererProxyInterface for ProgressRendererProxy {
702    type RenderResponseFut =
703        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
704    fn r#render(&self, mut status: Status, mut percent_complete: f32) -> Self::RenderResponseFut {
705        fn _decode(
706            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
707        ) -> Result<(), fidl::Error> {
708            let _response = fidl::client::decode_transaction_body::<
709                fidl::encoding::EmptyPayload,
710                fidl::encoding::DefaultFuchsiaResourceDialect,
711                0x68f03b362c8c1a54,
712            >(_buf?)?;
713            Ok(_response)
714        }
715        self.client.send_query_and_decode::<ProgressRendererRenderRequest, ()>(
716            (status, percent_complete),
717            0x68f03b362c8c1a54,
718            fidl::encoding::DynamicFlags::empty(),
719            _decode,
720        )
721    }
722
723    type Render2ResponseFut =
724        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
725    fn r#render2(&self, mut payload: &ProgressRendererRender2Request) -> Self::Render2ResponseFut {
726        fn _decode(
727            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
728        ) -> Result<(), fidl::Error> {
729            let _response = fidl::client::decode_transaction_body::<
730                fidl::encoding::EmptyPayload,
731                fidl::encoding::DefaultFuchsiaResourceDialect,
732                0x218acc9beba72126,
733            >(_buf?)?;
734            Ok(_response)
735        }
736        self.client.send_query_and_decode::<ProgressRendererRender2Request, ()>(
737            payload,
738            0x218acc9beba72126,
739            fidl::encoding::DynamicFlags::empty(),
740            _decode,
741        )
742    }
743}
744
745pub struct ProgressRendererEventStream {
746    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
747}
748
749impl std::marker::Unpin for ProgressRendererEventStream {}
750
751impl futures::stream::FusedStream for ProgressRendererEventStream {
752    fn is_terminated(&self) -> bool {
753        self.event_receiver.is_terminated()
754    }
755}
756
757impl futures::Stream for ProgressRendererEventStream {
758    type Item = Result<ProgressRendererEvent, fidl::Error>;
759
760    fn poll_next(
761        mut self: std::pin::Pin<&mut Self>,
762        cx: &mut std::task::Context<'_>,
763    ) -> std::task::Poll<Option<Self::Item>> {
764        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
765            &mut self.event_receiver,
766            cx
767        )?) {
768            Some(buf) => std::task::Poll::Ready(Some(ProgressRendererEvent::decode(buf))),
769            None => std::task::Poll::Ready(None),
770        }
771    }
772}
773
774#[derive(Debug)]
775pub enum ProgressRendererEvent {}
776
777impl ProgressRendererEvent {
778    /// Decodes a message buffer as a [`ProgressRendererEvent`].
779    fn decode(
780        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
781    ) -> Result<ProgressRendererEvent, fidl::Error> {
782        let (bytes, _handles) = buf.split_mut();
783        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
784        debug_assert_eq!(tx_header.tx_id, 0);
785        match tx_header.ordinal {
786            _ => Err(fidl::Error::UnknownOrdinal {
787                ordinal: tx_header.ordinal,
788                protocol_name:
789                    <ProgressRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
790            }),
791        }
792    }
793}
794
795/// A Stream of incoming requests for fuchsia.recovery.ui/ProgressRenderer.
796pub struct ProgressRendererRequestStream {
797    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
798    is_terminated: bool,
799}
800
801impl std::marker::Unpin for ProgressRendererRequestStream {}
802
803impl futures::stream::FusedStream for ProgressRendererRequestStream {
804    fn is_terminated(&self) -> bool {
805        self.is_terminated
806    }
807}
808
809impl fidl::endpoints::RequestStream for ProgressRendererRequestStream {
810    type Protocol = ProgressRendererMarker;
811    type ControlHandle = ProgressRendererControlHandle;
812
813    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
814        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
815    }
816
817    fn control_handle(&self) -> Self::ControlHandle {
818        ProgressRendererControlHandle { inner: self.inner.clone() }
819    }
820
821    fn into_inner(
822        self,
823    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
824    {
825        (self.inner, self.is_terminated)
826    }
827
828    fn from_inner(
829        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
830        is_terminated: bool,
831    ) -> Self {
832        Self { inner, is_terminated }
833    }
834}
835
836impl futures::Stream for ProgressRendererRequestStream {
837    type Item = Result<ProgressRendererRequest, fidl::Error>;
838
839    fn poll_next(
840        mut self: std::pin::Pin<&mut Self>,
841        cx: &mut std::task::Context<'_>,
842    ) -> std::task::Poll<Option<Self::Item>> {
843        let this = &mut *self;
844        if this.inner.check_shutdown(cx) {
845            this.is_terminated = true;
846            return std::task::Poll::Ready(None);
847        }
848        if this.is_terminated {
849            panic!("polled ProgressRendererRequestStream after completion");
850        }
851        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
852            |bytes, handles| {
853                match this.inner.channel().read_etc(cx, bytes, handles) {
854                    std::task::Poll::Ready(Ok(())) => {}
855                    std::task::Poll::Pending => return std::task::Poll::Pending,
856                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
857                        this.is_terminated = true;
858                        return std::task::Poll::Ready(None);
859                    }
860                    std::task::Poll::Ready(Err(e)) => {
861                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
862                            e.into(),
863                        ))))
864                    }
865                }
866
867                // A message has been received from the channel
868                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
869
870                std::task::Poll::Ready(Some(match header.ordinal {
871                    0x68f03b362c8c1a54 => {
872                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
873                        let mut req = fidl::new_empty!(
874                            ProgressRendererRenderRequest,
875                            fidl::encoding::DefaultFuchsiaResourceDialect
876                        );
877                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProgressRendererRenderRequest>(&header, _body_bytes, handles, &mut req)?;
878                        let control_handle =
879                            ProgressRendererControlHandle { inner: this.inner.clone() };
880                        Ok(ProgressRendererRequest::Render {
881                            status: req.status,
882                            percent_complete: req.percent_complete,
883
884                            responder: ProgressRendererRenderResponder {
885                                control_handle: std::mem::ManuallyDrop::new(control_handle),
886                                tx_id: header.tx_id,
887                            },
888                        })
889                    }
890                    0x218acc9beba72126 => {
891                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
892                        let mut req = fidl::new_empty!(
893                            ProgressRendererRender2Request,
894                            fidl::encoding::DefaultFuchsiaResourceDialect
895                        );
896                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProgressRendererRender2Request>(&header, _body_bytes, handles, &mut req)?;
897                        let control_handle =
898                            ProgressRendererControlHandle { inner: this.inner.clone() };
899                        Ok(ProgressRendererRequest::Render2 {
900                            payload: req,
901                            responder: ProgressRendererRender2Responder {
902                                control_handle: std::mem::ManuallyDrop::new(control_handle),
903                                tx_id: header.tx_id,
904                            },
905                        })
906                    }
907                    _ => Err(fidl::Error::UnknownOrdinal {
908                        ordinal: header.ordinal,
909                        protocol_name:
910                            <ProgressRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
911                    }),
912                }))
913            },
914        )
915    }
916}
917
918/// Protocol to receive progress updates to display a carnelian based progress bar UI.
919#[derive(Debug)]
920pub enum ProgressRendererRequest {
921    /// Called to send progress updates to the renderer.
922    ///
923    /// The return value is used for flow control, and implementers should acknowledge receipt of
924    /// each message in order to continue receiving future messages.
925    Render { status: Status, percent_complete: f32, responder: ProgressRendererRenderResponder },
926    /// Called to send progress updates to the renderer.
927    ///
928    /// This call optionally contains timing or speed information for the progress bar to move
929    /// slowly to percent_complete
930    ///
931    /// The return value is used for flow control, and implementers should acknowledge receipt of
932    /// each message in order to continue receiving future messages.
933    Render2 { payload: ProgressRendererRender2Request, responder: ProgressRendererRender2Responder },
934}
935
936impl ProgressRendererRequest {
937    #[allow(irrefutable_let_patterns)]
938    pub fn into_render(self) -> Option<(Status, f32, ProgressRendererRenderResponder)> {
939        if let ProgressRendererRequest::Render { status, percent_complete, responder } = self {
940            Some((status, percent_complete, responder))
941        } else {
942            None
943        }
944    }
945
946    #[allow(irrefutable_let_patterns)]
947    pub fn into_render2(
948        self,
949    ) -> Option<(ProgressRendererRender2Request, ProgressRendererRender2Responder)> {
950        if let ProgressRendererRequest::Render2 { payload, responder } = self {
951            Some((payload, responder))
952        } else {
953            None
954        }
955    }
956
957    /// Name of the method defined in FIDL
958    pub fn method_name(&self) -> &'static str {
959        match *self {
960            ProgressRendererRequest::Render { .. } => "render",
961            ProgressRendererRequest::Render2 { .. } => "render2",
962        }
963    }
964}
965
966#[derive(Debug, Clone)]
967pub struct ProgressRendererControlHandle {
968    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
969}
970
971impl fidl::endpoints::ControlHandle for ProgressRendererControlHandle {
972    fn shutdown(&self) {
973        self.inner.shutdown()
974    }
975    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
976        self.inner.shutdown_with_epitaph(status)
977    }
978
979    fn is_closed(&self) -> bool {
980        self.inner.channel().is_closed()
981    }
982    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
983        self.inner.channel().on_closed()
984    }
985
986    #[cfg(target_os = "fuchsia")]
987    fn signal_peer(
988        &self,
989        clear_mask: zx::Signals,
990        set_mask: zx::Signals,
991    ) -> Result<(), zx_status::Status> {
992        use fidl::Peered;
993        self.inner.channel().signal_peer(clear_mask, set_mask)
994    }
995}
996
997impl ProgressRendererControlHandle {}
998
999#[must_use = "FIDL methods require a response to be sent"]
1000#[derive(Debug)]
1001pub struct ProgressRendererRenderResponder {
1002    control_handle: std::mem::ManuallyDrop<ProgressRendererControlHandle>,
1003    tx_id: u32,
1004}
1005
1006/// Set the the channel to be shutdown (see [`ProgressRendererControlHandle::shutdown`])
1007/// if the responder is dropped without sending a response, so that the client
1008/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1009impl std::ops::Drop for ProgressRendererRenderResponder {
1010    fn drop(&mut self) {
1011        self.control_handle.shutdown();
1012        // Safety: drops once, never accessed again
1013        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1014    }
1015}
1016
1017impl fidl::endpoints::Responder for ProgressRendererRenderResponder {
1018    type ControlHandle = ProgressRendererControlHandle;
1019
1020    fn control_handle(&self) -> &ProgressRendererControlHandle {
1021        &self.control_handle
1022    }
1023
1024    fn drop_without_shutdown(mut self) {
1025        // Safety: drops once, never accessed again due to mem::forget
1026        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1027        // Prevent Drop from running (which would shut down the channel)
1028        std::mem::forget(self);
1029    }
1030}
1031
1032impl ProgressRendererRenderResponder {
1033    /// Sends a response to the FIDL transaction.
1034    ///
1035    /// Sets the channel to shutdown if an error occurs.
1036    pub fn send(self) -> Result<(), fidl::Error> {
1037        let _result = self.send_raw();
1038        if _result.is_err() {
1039            self.control_handle.shutdown();
1040        }
1041        self.drop_without_shutdown();
1042        _result
1043    }
1044
1045    /// Similar to "send" but does not shutdown the channel if an error occurs.
1046    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1047        let _result = self.send_raw();
1048        self.drop_without_shutdown();
1049        _result
1050    }
1051
1052    fn send_raw(&self) -> Result<(), fidl::Error> {
1053        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1054            (),
1055            self.tx_id,
1056            0x68f03b362c8c1a54,
1057            fidl::encoding::DynamicFlags::empty(),
1058        )
1059    }
1060}
1061
1062#[must_use = "FIDL methods require a response to be sent"]
1063#[derive(Debug)]
1064pub struct ProgressRendererRender2Responder {
1065    control_handle: std::mem::ManuallyDrop<ProgressRendererControlHandle>,
1066    tx_id: u32,
1067}
1068
1069/// Set the the channel to be shutdown (see [`ProgressRendererControlHandle::shutdown`])
1070/// if the responder is dropped without sending a response, so that the client
1071/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1072impl std::ops::Drop for ProgressRendererRender2Responder {
1073    fn drop(&mut self) {
1074        self.control_handle.shutdown();
1075        // Safety: drops once, never accessed again
1076        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1077    }
1078}
1079
1080impl fidl::endpoints::Responder for ProgressRendererRender2Responder {
1081    type ControlHandle = ProgressRendererControlHandle;
1082
1083    fn control_handle(&self) -> &ProgressRendererControlHandle {
1084        &self.control_handle
1085    }
1086
1087    fn drop_without_shutdown(mut self) {
1088        // Safety: drops once, never accessed again due to mem::forget
1089        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1090        // Prevent Drop from running (which would shut down the channel)
1091        std::mem::forget(self);
1092    }
1093}
1094
1095impl ProgressRendererRender2Responder {
1096    /// Sends a response to the FIDL transaction.
1097    ///
1098    /// Sets the channel to shutdown if an error occurs.
1099    pub fn send(self) -> Result<(), fidl::Error> {
1100        let _result = self.send_raw();
1101        if _result.is_err() {
1102            self.control_handle.shutdown();
1103        }
1104        self.drop_without_shutdown();
1105        _result
1106    }
1107
1108    /// Similar to "send" but does not shutdown the channel if an error occurs.
1109    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1110        let _result = self.send_raw();
1111        self.drop_without_shutdown();
1112        _result
1113    }
1114
1115    fn send_raw(&self) -> Result<(), fidl::Error> {
1116        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1117            (),
1118            self.tx_id,
1119            0x218acc9beba72126,
1120            fidl::encoding::DynamicFlags::empty(),
1121        )
1122    }
1123}
1124
1125mod internal {
1126    use super::*;
1127    unsafe impl fidl::encoding::TypeMarker for Status {
1128        type Owned = Self;
1129
1130        #[inline(always)]
1131        fn inline_align(_context: fidl::encoding::Context) -> usize {
1132            std::mem::align_of::<u32>()
1133        }
1134
1135        #[inline(always)]
1136        fn inline_size(_context: fidl::encoding::Context) -> usize {
1137            std::mem::size_of::<u32>()
1138        }
1139
1140        #[inline(always)]
1141        fn encode_is_copy() -> bool {
1142            true
1143        }
1144
1145        #[inline(always)]
1146        fn decode_is_copy() -> bool {
1147            false
1148        }
1149    }
1150
1151    impl fidl::encoding::ValueTypeMarker for Status {
1152        type Borrowed<'a> = Self;
1153        #[inline(always)]
1154        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1155            *value
1156        }
1157    }
1158
1159    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Status {
1160        #[inline]
1161        unsafe fn encode(
1162            self,
1163            encoder: &mut fidl::encoding::Encoder<'_, D>,
1164            offset: usize,
1165            _depth: fidl::encoding::Depth,
1166        ) -> fidl::Result<()> {
1167            encoder.debug_check_bounds::<Self>(offset);
1168            encoder.write_num(self.into_primitive(), offset);
1169            Ok(())
1170        }
1171    }
1172
1173    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Status {
1174        #[inline(always)]
1175        fn new_empty() -> Self {
1176            Self::Active
1177        }
1178
1179        #[inline]
1180        unsafe fn decode(
1181            &mut self,
1182            decoder: &mut fidl::encoding::Decoder<'_, D>,
1183            offset: usize,
1184            _depth: fidl::encoding::Depth,
1185        ) -> fidl::Result<()> {
1186            decoder.debug_check_bounds::<Self>(offset);
1187            let prim = decoder.read_num::<u32>(offset);
1188
1189            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1190            Ok(())
1191        }
1192    }
1193
1194    impl fidl::encoding::ValueTypeMarker for FactoryResetCountdownWatchResponse {
1195        type Borrowed<'a> = &'a Self;
1196        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1197            value
1198        }
1199    }
1200
1201    unsafe impl fidl::encoding::TypeMarker for FactoryResetCountdownWatchResponse {
1202        type Owned = Self;
1203
1204        #[inline(always)]
1205        fn inline_align(_context: fidl::encoding::Context) -> usize {
1206            8
1207        }
1208
1209        #[inline(always)]
1210        fn inline_size(_context: fidl::encoding::Context) -> usize {
1211            16
1212        }
1213    }
1214
1215    unsafe impl<D: fidl::encoding::ResourceDialect>
1216        fidl::encoding::Encode<FactoryResetCountdownWatchResponse, D>
1217        for &FactoryResetCountdownWatchResponse
1218    {
1219        #[inline]
1220        unsafe fn encode(
1221            self,
1222            encoder: &mut fidl::encoding::Encoder<'_, D>,
1223            offset: usize,
1224            _depth: fidl::encoding::Depth,
1225        ) -> fidl::Result<()> {
1226            encoder.debug_check_bounds::<FactoryResetCountdownWatchResponse>(offset);
1227            // Delegate to tuple encoding.
1228            fidl::encoding::Encode::<FactoryResetCountdownWatchResponse, D>::encode(
1229                (<FactoryResetCountdownState as fidl::encoding::ValueTypeMarker>::borrow(
1230                    &self.state,
1231                ),),
1232                encoder,
1233                offset,
1234                _depth,
1235            )
1236        }
1237    }
1238    unsafe impl<
1239            D: fidl::encoding::ResourceDialect,
1240            T0: fidl::encoding::Encode<FactoryResetCountdownState, D>,
1241        > fidl::encoding::Encode<FactoryResetCountdownWatchResponse, D> for (T0,)
1242    {
1243        #[inline]
1244        unsafe fn encode(
1245            self,
1246            encoder: &mut fidl::encoding::Encoder<'_, D>,
1247            offset: usize,
1248            depth: fidl::encoding::Depth,
1249        ) -> fidl::Result<()> {
1250            encoder.debug_check_bounds::<FactoryResetCountdownWatchResponse>(offset);
1251            // Zero out padding regions. There's no need to apply masks
1252            // because the unmasked parts will be overwritten by fields.
1253            // Write the fields.
1254            self.0.encode(encoder, offset + 0, depth)?;
1255            Ok(())
1256        }
1257    }
1258
1259    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1260        for FactoryResetCountdownWatchResponse
1261    {
1262        #[inline(always)]
1263        fn new_empty() -> Self {
1264            Self { state: fidl::new_empty!(FactoryResetCountdownState, D) }
1265        }
1266
1267        #[inline]
1268        unsafe fn decode(
1269            &mut self,
1270            decoder: &mut fidl::encoding::Decoder<'_, D>,
1271            offset: usize,
1272            _depth: fidl::encoding::Depth,
1273        ) -> fidl::Result<()> {
1274            decoder.debug_check_bounds::<Self>(offset);
1275            // Verify that padding bytes are zero.
1276            fidl::decode!(
1277                FactoryResetCountdownState,
1278                D,
1279                &mut self.state,
1280                decoder,
1281                offset + 0,
1282                _depth
1283            )?;
1284            Ok(())
1285        }
1286    }
1287
1288    impl fidl::encoding::ValueTypeMarker for ProgressRendererRenderRequest {
1289        type Borrowed<'a> = &'a Self;
1290        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1291            value
1292        }
1293    }
1294
1295    unsafe impl fidl::encoding::TypeMarker for ProgressRendererRenderRequest {
1296        type Owned = Self;
1297
1298        #[inline(always)]
1299        fn inline_align(_context: fidl::encoding::Context) -> usize {
1300            4
1301        }
1302
1303        #[inline(always)]
1304        fn inline_size(_context: fidl::encoding::Context) -> usize {
1305            8
1306        }
1307    }
1308
1309    unsafe impl<D: fidl::encoding::ResourceDialect>
1310        fidl::encoding::Encode<ProgressRendererRenderRequest, D>
1311        for &ProgressRendererRenderRequest
1312    {
1313        #[inline]
1314        unsafe fn encode(
1315            self,
1316            encoder: &mut fidl::encoding::Encoder<'_, D>,
1317            offset: usize,
1318            _depth: fidl::encoding::Depth,
1319        ) -> fidl::Result<()> {
1320            encoder.debug_check_bounds::<ProgressRendererRenderRequest>(offset);
1321            // Delegate to tuple encoding.
1322            fidl::encoding::Encode::<ProgressRendererRenderRequest, D>::encode(
1323                (
1324                    <Status as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
1325                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.percent_complete),
1326                ),
1327                encoder,
1328                offset,
1329                _depth,
1330            )
1331        }
1332    }
1333    unsafe impl<
1334            D: fidl::encoding::ResourceDialect,
1335            T0: fidl::encoding::Encode<Status, D>,
1336            T1: fidl::encoding::Encode<f32, D>,
1337        > fidl::encoding::Encode<ProgressRendererRenderRequest, D> for (T0, T1)
1338    {
1339        #[inline]
1340        unsafe fn encode(
1341            self,
1342            encoder: &mut fidl::encoding::Encoder<'_, D>,
1343            offset: usize,
1344            depth: fidl::encoding::Depth,
1345        ) -> fidl::Result<()> {
1346            encoder.debug_check_bounds::<ProgressRendererRenderRequest>(offset);
1347            // Zero out padding regions. There's no need to apply masks
1348            // because the unmasked parts will be overwritten by fields.
1349            // Write the fields.
1350            self.0.encode(encoder, offset + 0, depth)?;
1351            self.1.encode(encoder, offset + 4, depth)?;
1352            Ok(())
1353        }
1354    }
1355
1356    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1357        for ProgressRendererRenderRequest
1358    {
1359        #[inline(always)]
1360        fn new_empty() -> Self {
1361            Self { status: fidl::new_empty!(Status, D), percent_complete: fidl::new_empty!(f32, D) }
1362        }
1363
1364        #[inline]
1365        unsafe fn decode(
1366            &mut self,
1367            decoder: &mut fidl::encoding::Decoder<'_, D>,
1368            offset: usize,
1369            _depth: fidl::encoding::Depth,
1370        ) -> fidl::Result<()> {
1371            decoder.debug_check_bounds::<Self>(offset);
1372            // Verify that padding bytes are zero.
1373            fidl::decode!(Status, D, &mut self.status, decoder, offset + 0, _depth)?;
1374            fidl::decode!(f32, D, &mut self.percent_complete, decoder, offset + 4, _depth)?;
1375            Ok(())
1376        }
1377    }
1378
1379    impl FactoryResetCountdownState {
1380        #[inline(always)]
1381        fn max_ordinal_present(&self) -> u64 {
1382            if let Some(_) = self.scheduled_reset_time {
1383                return 1;
1384            }
1385            0
1386        }
1387    }
1388
1389    impl fidl::encoding::ValueTypeMarker for FactoryResetCountdownState {
1390        type Borrowed<'a> = &'a Self;
1391        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1392            value
1393        }
1394    }
1395
1396    unsafe impl fidl::encoding::TypeMarker for FactoryResetCountdownState {
1397        type Owned = Self;
1398
1399        #[inline(always)]
1400        fn inline_align(_context: fidl::encoding::Context) -> usize {
1401            8
1402        }
1403
1404        #[inline(always)]
1405        fn inline_size(_context: fidl::encoding::Context) -> usize {
1406            16
1407        }
1408    }
1409
1410    unsafe impl<D: fidl::encoding::ResourceDialect>
1411        fidl::encoding::Encode<FactoryResetCountdownState, D> for &FactoryResetCountdownState
1412    {
1413        unsafe fn encode(
1414            self,
1415            encoder: &mut fidl::encoding::Encoder<'_, D>,
1416            offset: usize,
1417            mut depth: fidl::encoding::Depth,
1418        ) -> fidl::Result<()> {
1419            encoder.debug_check_bounds::<FactoryResetCountdownState>(offset);
1420            // Vector header
1421            let max_ordinal: u64 = self.max_ordinal_present();
1422            encoder.write_num(max_ordinal, offset);
1423            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1424            // Calling encoder.out_of_line_offset(0) is not allowed.
1425            if max_ordinal == 0 {
1426                return Ok(());
1427            }
1428            depth.increment()?;
1429            let envelope_size = 8;
1430            let bytes_len = max_ordinal as usize * envelope_size;
1431            #[allow(unused_variables)]
1432            let offset = encoder.out_of_line_offset(bytes_len);
1433            let mut _prev_end_offset: usize = 0;
1434            if 1 > max_ordinal {
1435                return Ok(());
1436            }
1437
1438            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1439            // are envelope_size bytes.
1440            let cur_offset: usize = (1 - 1) * envelope_size;
1441
1442            // Zero reserved fields.
1443            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1444
1445            // Safety:
1446            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1447            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1448            //   envelope_size bytes, there is always sufficient room.
1449            fidl::encoding::encode_in_envelope_optional::<i64, D>(
1450                self.scheduled_reset_time
1451                    .as_ref()
1452                    .map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1453                encoder,
1454                offset + cur_offset,
1455                depth,
1456            )?;
1457
1458            _prev_end_offset = cur_offset + envelope_size;
1459
1460            Ok(())
1461        }
1462    }
1463
1464    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1465        for FactoryResetCountdownState
1466    {
1467        #[inline(always)]
1468        fn new_empty() -> Self {
1469            Self::default()
1470        }
1471
1472        unsafe fn decode(
1473            &mut self,
1474            decoder: &mut fidl::encoding::Decoder<'_, D>,
1475            offset: usize,
1476            mut depth: fidl::encoding::Depth,
1477        ) -> fidl::Result<()> {
1478            decoder.debug_check_bounds::<Self>(offset);
1479            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1480                None => return Err(fidl::Error::NotNullable),
1481                Some(len) => len,
1482            };
1483            // Calling decoder.out_of_line_offset(0) is not allowed.
1484            if len == 0 {
1485                return Ok(());
1486            };
1487            depth.increment()?;
1488            let envelope_size = 8;
1489            let bytes_len = len * envelope_size;
1490            let offset = decoder.out_of_line_offset(bytes_len)?;
1491            // Decode the envelope for each type.
1492            let mut _next_ordinal_to_read = 0;
1493            let mut next_offset = offset;
1494            let end_offset = offset + bytes_len;
1495            _next_ordinal_to_read += 1;
1496            if next_offset >= end_offset {
1497                return Ok(());
1498            }
1499
1500            // Decode unknown envelopes for gaps in ordinals.
1501            while _next_ordinal_to_read < 1 {
1502                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1503                _next_ordinal_to_read += 1;
1504                next_offset += envelope_size;
1505            }
1506
1507            let next_out_of_line = decoder.next_out_of_line();
1508            let handles_before = decoder.remaining_handles();
1509            if let Some((inlined, num_bytes, num_handles)) =
1510                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1511            {
1512                let member_inline_size =
1513                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1514                if inlined != (member_inline_size <= 4) {
1515                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1516                }
1517                let inner_offset;
1518                let mut inner_depth = depth.clone();
1519                if inlined {
1520                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1521                    inner_offset = next_offset;
1522                } else {
1523                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1524                    inner_depth.increment()?;
1525                }
1526                let val_ref =
1527                    self.scheduled_reset_time.get_or_insert_with(|| fidl::new_empty!(i64, D));
1528                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
1529                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1530                {
1531                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1532                }
1533                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1534                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1535                }
1536            }
1537
1538            next_offset += envelope_size;
1539
1540            // Decode the remaining unknown envelopes.
1541            while next_offset < end_offset {
1542                _next_ordinal_to_read += 1;
1543                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1544                next_offset += envelope_size;
1545            }
1546
1547            Ok(())
1548        }
1549    }
1550
1551    impl ProgressRendererRender2Request {
1552        #[inline(always)]
1553        fn max_ordinal_present(&self) -> u64 {
1554            if let Some(_) = self.elapsed_time {
1555                return 3;
1556            }
1557            if let Some(_) = self.percent_complete {
1558                return 2;
1559            }
1560            if let Some(_) = self.status {
1561                return 1;
1562            }
1563            0
1564        }
1565    }
1566
1567    impl fidl::encoding::ValueTypeMarker for ProgressRendererRender2Request {
1568        type Borrowed<'a> = &'a Self;
1569        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1570            value
1571        }
1572    }
1573
1574    unsafe impl fidl::encoding::TypeMarker for ProgressRendererRender2Request {
1575        type Owned = Self;
1576
1577        #[inline(always)]
1578        fn inline_align(_context: fidl::encoding::Context) -> usize {
1579            8
1580        }
1581
1582        #[inline(always)]
1583        fn inline_size(_context: fidl::encoding::Context) -> usize {
1584            16
1585        }
1586    }
1587
1588    unsafe impl<D: fidl::encoding::ResourceDialect>
1589        fidl::encoding::Encode<ProgressRendererRender2Request, D>
1590        for &ProgressRendererRender2Request
1591    {
1592        unsafe fn encode(
1593            self,
1594            encoder: &mut fidl::encoding::Encoder<'_, D>,
1595            offset: usize,
1596            mut depth: fidl::encoding::Depth,
1597        ) -> fidl::Result<()> {
1598            encoder.debug_check_bounds::<ProgressRendererRender2Request>(offset);
1599            // Vector header
1600            let max_ordinal: u64 = self.max_ordinal_present();
1601            encoder.write_num(max_ordinal, offset);
1602            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1603            // Calling encoder.out_of_line_offset(0) is not allowed.
1604            if max_ordinal == 0 {
1605                return Ok(());
1606            }
1607            depth.increment()?;
1608            let envelope_size = 8;
1609            let bytes_len = max_ordinal as usize * envelope_size;
1610            #[allow(unused_variables)]
1611            let offset = encoder.out_of_line_offset(bytes_len);
1612            let mut _prev_end_offset: usize = 0;
1613            if 1 > max_ordinal {
1614                return Ok(());
1615            }
1616
1617            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1618            // are envelope_size bytes.
1619            let cur_offset: usize = (1 - 1) * envelope_size;
1620
1621            // Zero reserved fields.
1622            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1623
1624            // Safety:
1625            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1626            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1627            //   envelope_size bytes, there is always sufficient room.
1628            fidl::encoding::encode_in_envelope_optional::<Status, D>(
1629                self.status.as_ref().map(<Status as fidl::encoding::ValueTypeMarker>::borrow),
1630                encoder,
1631                offset + cur_offset,
1632                depth,
1633            )?;
1634
1635            _prev_end_offset = cur_offset + envelope_size;
1636            if 2 > max_ordinal {
1637                return Ok(());
1638            }
1639
1640            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1641            // are envelope_size bytes.
1642            let cur_offset: usize = (2 - 1) * envelope_size;
1643
1644            // Zero reserved fields.
1645            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1646
1647            // Safety:
1648            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1649            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1650            //   envelope_size bytes, there is always sufficient room.
1651            fidl::encoding::encode_in_envelope_optional::<f32, D>(
1652                self.percent_complete
1653                    .as_ref()
1654                    .map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
1655                encoder,
1656                offset + cur_offset,
1657                depth,
1658            )?;
1659
1660            _prev_end_offset = cur_offset + envelope_size;
1661            if 3 > max_ordinal {
1662                return Ok(());
1663            }
1664
1665            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1666            // are envelope_size bytes.
1667            let cur_offset: usize = (3 - 1) * envelope_size;
1668
1669            // Zero reserved fields.
1670            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1671
1672            // Safety:
1673            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1674            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1675            //   envelope_size bytes, there is always sufficient room.
1676            fidl::encoding::encode_in_envelope_optional::<i64, D>(
1677                self.elapsed_time.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1678                encoder,
1679                offset + cur_offset,
1680                depth,
1681            )?;
1682
1683            _prev_end_offset = cur_offset + envelope_size;
1684
1685            Ok(())
1686        }
1687    }
1688
1689    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1690        for ProgressRendererRender2Request
1691    {
1692        #[inline(always)]
1693        fn new_empty() -> Self {
1694            Self::default()
1695        }
1696
1697        unsafe fn decode(
1698            &mut self,
1699            decoder: &mut fidl::encoding::Decoder<'_, D>,
1700            offset: usize,
1701            mut depth: fidl::encoding::Depth,
1702        ) -> fidl::Result<()> {
1703            decoder.debug_check_bounds::<Self>(offset);
1704            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1705                None => return Err(fidl::Error::NotNullable),
1706                Some(len) => len,
1707            };
1708            // Calling decoder.out_of_line_offset(0) is not allowed.
1709            if len == 0 {
1710                return Ok(());
1711            };
1712            depth.increment()?;
1713            let envelope_size = 8;
1714            let bytes_len = len * envelope_size;
1715            let offset = decoder.out_of_line_offset(bytes_len)?;
1716            // Decode the envelope for each type.
1717            let mut _next_ordinal_to_read = 0;
1718            let mut next_offset = offset;
1719            let end_offset = offset + bytes_len;
1720            _next_ordinal_to_read += 1;
1721            if next_offset >= end_offset {
1722                return Ok(());
1723            }
1724
1725            // Decode unknown envelopes for gaps in ordinals.
1726            while _next_ordinal_to_read < 1 {
1727                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1728                _next_ordinal_to_read += 1;
1729                next_offset += envelope_size;
1730            }
1731
1732            let next_out_of_line = decoder.next_out_of_line();
1733            let handles_before = decoder.remaining_handles();
1734            if let Some((inlined, num_bytes, num_handles)) =
1735                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1736            {
1737                let member_inline_size =
1738                    <Status as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1739                if inlined != (member_inline_size <= 4) {
1740                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1741                }
1742                let inner_offset;
1743                let mut inner_depth = depth.clone();
1744                if inlined {
1745                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1746                    inner_offset = next_offset;
1747                } else {
1748                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1749                    inner_depth.increment()?;
1750                }
1751                let val_ref = self.status.get_or_insert_with(|| fidl::new_empty!(Status, D));
1752                fidl::decode!(Status, D, val_ref, decoder, inner_offset, inner_depth)?;
1753                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1754                {
1755                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1756                }
1757                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1758                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1759                }
1760            }
1761
1762            next_offset += envelope_size;
1763            _next_ordinal_to_read += 1;
1764            if next_offset >= end_offset {
1765                return Ok(());
1766            }
1767
1768            // Decode unknown envelopes for gaps in ordinals.
1769            while _next_ordinal_to_read < 2 {
1770                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1771                _next_ordinal_to_read += 1;
1772                next_offset += envelope_size;
1773            }
1774
1775            let next_out_of_line = decoder.next_out_of_line();
1776            let handles_before = decoder.remaining_handles();
1777            if let Some((inlined, num_bytes, num_handles)) =
1778                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1779            {
1780                let member_inline_size =
1781                    <f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1782                if inlined != (member_inline_size <= 4) {
1783                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1784                }
1785                let inner_offset;
1786                let mut inner_depth = depth.clone();
1787                if inlined {
1788                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1789                    inner_offset = next_offset;
1790                } else {
1791                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1792                    inner_depth.increment()?;
1793                }
1794                let val_ref = self.percent_complete.get_or_insert_with(|| fidl::new_empty!(f32, D));
1795                fidl::decode!(f32, D, val_ref, decoder, inner_offset, inner_depth)?;
1796                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1797                {
1798                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1799                }
1800                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1801                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1802                }
1803            }
1804
1805            next_offset += envelope_size;
1806            _next_ordinal_to_read += 1;
1807            if next_offset >= end_offset {
1808                return Ok(());
1809            }
1810
1811            // Decode unknown envelopes for gaps in ordinals.
1812            while _next_ordinal_to_read < 3 {
1813                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1814                _next_ordinal_to_read += 1;
1815                next_offset += envelope_size;
1816            }
1817
1818            let next_out_of_line = decoder.next_out_of_line();
1819            let handles_before = decoder.remaining_handles();
1820            if let Some((inlined, num_bytes, num_handles)) =
1821                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1822            {
1823                let member_inline_size =
1824                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1825                if inlined != (member_inline_size <= 4) {
1826                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1827                }
1828                let inner_offset;
1829                let mut inner_depth = depth.clone();
1830                if inlined {
1831                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1832                    inner_offset = next_offset;
1833                } else {
1834                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1835                    inner_depth.increment()?;
1836                }
1837                let val_ref = self.elapsed_time.get_or_insert_with(|| fidl::new_empty!(i64, D));
1838                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
1839                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1840                {
1841                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1842                }
1843                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1844                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1845                }
1846            }
1847
1848            next_offset += envelope_size;
1849
1850            // Decode the remaining unknown envelopes.
1851            while next_offset < end_offset {
1852                _next_ordinal_to_read += 1;
1853                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1854                next_offset += envelope_size;
1855            }
1856
1857            Ok(())
1858        }
1859    }
1860}