Skip to main content

fidl_fuchsia_update/
fidl_fuchsia_update.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_update_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct AttemptsMonitorOnStartRequest {
16    pub options: AttemptOptions,
17    pub monitor: fidl::endpoints::ServerEnd<MonitorMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for AttemptsMonitorOnStartRequest
22{
23}
24
25#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct CommitStatusProviderIsCurrentSystemCommittedResponse {
27    pub event: fidl::EventPair,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for CommitStatusProviderIsCurrentSystemCommittedResponse
32{
33}
34
35#[derive(Debug, PartialEq)]
36pub struct ManagerCheckNowRequest {
37    pub options: CheckOptions,
38    pub monitor: Option<fidl::endpoints::ClientEnd<MonitorMarker>>,
39}
40
41impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ManagerCheckNowRequest {}
42
43#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
44pub struct ManagerMonitorAllUpdateChecksRequest {
45    pub attempts_monitor: fidl::endpoints::ClientEnd<AttemptsMonitorMarker>,
46}
47
48impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
49    for ManagerMonitorAllUpdateChecksRequest
50{
51}
52
53#[derive(Debug, Default, PartialEq)]
54pub struct ListenerNotifyOnFirstUpdateCheckRequest {
55    /// Entity notified after post-boot check. This is a required field.
56    pub notifier: Option<fidl::endpoints::ClientEnd<NotifierMarker>>,
57    #[doc(hidden)]
58    pub __source_breaking: fidl::marker::SourceBreaking,
59}
60
61impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
62    for ListenerNotifyOnFirstUpdateCheckRequest
63{
64}
65
66#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
67pub struct AttemptsMonitorMarker;
68
69impl fidl::endpoints::ProtocolMarker for AttemptsMonitorMarker {
70    type Proxy = AttemptsMonitorProxy;
71    type RequestStream = AttemptsMonitorRequestStream;
72    #[cfg(target_os = "fuchsia")]
73    type SynchronousProxy = AttemptsMonitorSynchronousProxy;
74
75    const DEBUG_NAME: &'static str = "(anonymous) AttemptsMonitor";
76}
77
78pub trait AttemptsMonitorProxyInterface: Send + Sync {
79    type OnStartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
80    fn r#on_start(
81        &self,
82        options: &AttemptOptions,
83        monitor: fidl::endpoints::ServerEnd<MonitorMarker>,
84    ) -> Self::OnStartResponseFut;
85}
86#[derive(Debug)]
87#[cfg(target_os = "fuchsia")]
88pub struct AttemptsMonitorSynchronousProxy {
89    client: fidl::client::sync::Client,
90}
91
92#[cfg(target_os = "fuchsia")]
93impl fidl::endpoints::SynchronousProxy for AttemptsMonitorSynchronousProxy {
94    type Proxy = AttemptsMonitorProxy;
95    type Protocol = AttemptsMonitorMarker;
96
97    fn from_channel(inner: fidl::Channel) -> Self {
98        Self::new(inner)
99    }
100
101    fn into_channel(self) -> fidl::Channel {
102        self.client.into_channel()
103    }
104
105    fn as_channel(&self) -> &fidl::Channel {
106        self.client.as_channel()
107    }
108}
109
110#[cfg(target_os = "fuchsia")]
111impl AttemptsMonitorSynchronousProxy {
112    pub fn new(channel: fidl::Channel) -> Self {
113        Self { client: fidl::client::sync::Client::new(channel) }
114    }
115
116    pub fn into_channel(self) -> fidl::Channel {
117        self.client.into_channel()
118    }
119
120    /// Waits until an event arrives and returns it. It is safe for other
121    /// threads to make concurrent requests while waiting for an event.
122    pub fn wait_for_event(
123        &self,
124        deadline: zx::MonotonicInstant,
125    ) -> Result<AttemptsMonitorEvent, fidl::Error> {
126        AttemptsMonitorEvent::decode(self.client.wait_for_event::<AttemptsMonitorMarker>(deadline)?)
127    }
128
129    /// Called when a new update attempt has started.
130    ///
131    /// Arguments:
132    /// * |options| Options for how this request should be performed.
133    /// * |monitor| A protocol on which to receive progress updates.
134    pub fn r#on_start(
135        &self,
136        mut options: &AttemptOptions,
137        mut monitor: fidl::endpoints::ServerEnd<MonitorMarker>,
138        ___deadline: zx::MonotonicInstant,
139    ) -> Result<(), fidl::Error> {
140        let _response = self.client.send_query::<
141            AttemptsMonitorOnStartRequest,
142            fidl::encoding::EmptyPayload,
143            AttemptsMonitorMarker,
144        >(
145            (options, monitor,),
146            0x75ea6bddd64d0714,
147            fidl::encoding::DynamicFlags::empty(),
148            ___deadline,
149        )?;
150        Ok(_response)
151    }
152}
153
154#[cfg(target_os = "fuchsia")]
155impl From<AttemptsMonitorSynchronousProxy> for zx::NullableHandle {
156    fn from(value: AttemptsMonitorSynchronousProxy) -> Self {
157        value.into_channel().into()
158    }
159}
160
161#[cfg(target_os = "fuchsia")]
162impl From<fidl::Channel> for AttemptsMonitorSynchronousProxy {
163    fn from(value: fidl::Channel) -> Self {
164        Self::new(value)
165    }
166}
167
168#[cfg(target_os = "fuchsia")]
169impl fidl::endpoints::FromClient for AttemptsMonitorSynchronousProxy {
170    type Protocol = AttemptsMonitorMarker;
171
172    fn from_client(value: fidl::endpoints::ClientEnd<AttemptsMonitorMarker>) -> Self {
173        Self::new(value.into_channel())
174    }
175}
176
177#[derive(Debug, Clone)]
178pub struct AttemptsMonitorProxy {
179    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
180}
181
182impl fidl::endpoints::Proxy for AttemptsMonitorProxy {
183    type Protocol = AttemptsMonitorMarker;
184
185    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
186        Self::new(inner)
187    }
188
189    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
190        self.client.into_channel().map_err(|client| Self { client })
191    }
192
193    fn as_channel(&self) -> &::fidl::AsyncChannel {
194        self.client.as_channel()
195    }
196}
197
198impl AttemptsMonitorProxy {
199    /// Create a new Proxy for fuchsia.update/AttemptsMonitor.
200    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
201        let protocol_name = <AttemptsMonitorMarker 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) -> AttemptsMonitorEventStream {
211        AttemptsMonitorEventStream { event_receiver: self.client.take_event_receiver() }
212    }
213
214    /// Called when a new update attempt has started.
215    ///
216    /// Arguments:
217    /// * |options| Options for how this request should be performed.
218    /// * |monitor| A protocol on which to receive progress updates.
219    pub fn r#on_start(
220        &self,
221        mut options: &AttemptOptions,
222        mut monitor: fidl::endpoints::ServerEnd<MonitorMarker>,
223    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
224        AttemptsMonitorProxyInterface::r#on_start(self, options, monitor)
225    }
226}
227
228impl AttemptsMonitorProxyInterface for AttemptsMonitorProxy {
229    type OnStartResponseFut =
230        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
231    fn r#on_start(
232        &self,
233        mut options: &AttemptOptions,
234        mut monitor: fidl::endpoints::ServerEnd<MonitorMarker>,
235    ) -> Self::OnStartResponseFut {
236        fn _decode(
237            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
238        ) -> Result<(), fidl::Error> {
239            let _response = fidl::client::decode_transaction_body::<
240                fidl::encoding::EmptyPayload,
241                fidl::encoding::DefaultFuchsiaResourceDialect,
242                0x75ea6bddd64d0714,
243            >(_buf?)?;
244            Ok(_response)
245        }
246        self.client.send_query_and_decode::<AttemptsMonitorOnStartRequest, ()>(
247            (options, monitor),
248            0x75ea6bddd64d0714,
249            fidl::encoding::DynamicFlags::empty(),
250            _decode,
251        )
252    }
253}
254
255pub struct AttemptsMonitorEventStream {
256    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
257}
258
259impl std::marker::Unpin for AttemptsMonitorEventStream {}
260
261impl futures::stream::FusedStream for AttemptsMonitorEventStream {
262    fn is_terminated(&self) -> bool {
263        self.event_receiver.is_terminated()
264    }
265}
266
267impl futures::Stream for AttemptsMonitorEventStream {
268    type Item = Result<AttemptsMonitorEvent, fidl::Error>;
269
270    fn poll_next(
271        mut self: std::pin::Pin<&mut Self>,
272        cx: &mut std::task::Context<'_>,
273    ) -> std::task::Poll<Option<Self::Item>> {
274        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
275            &mut self.event_receiver,
276            cx
277        )?) {
278            Some(buf) => std::task::Poll::Ready(Some(AttemptsMonitorEvent::decode(buf))),
279            None => std::task::Poll::Ready(None),
280        }
281    }
282}
283
284#[derive(Debug)]
285pub enum AttemptsMonitorEvent {}
286
287impl AttemptsMonitorEvent {
288    /// Decodes a message buffer as a [`AttemptsMonitorEvent`].
289    fn decode(
290        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
291    ) -> Result<AttemptsMonitorEvent, fidl::Error> {
292        let (bytes, _handles) = buf.split_mut();
293        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
294        debug_assert_eq!(tx_header.tx_id, 0);
295        match tx_header.ordinal {
296            _ => Err(fidl::Error::UnknownOrdinal {
297                ordinal: tx_header.ordinal,
298                protocol_name:
299                    <AttemptsMonitorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
300            }),
301        }
302    }
303}
304
305/// A Stream of incoming requests for fuchsia.update/AttemptsMonitor.
306pub struct AttemptsMonitorRequestStream {
307    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
308    is_terminated: bool,
309}
310
311impl std::marker::Unpin for AttemptsMonitorRequestStream {}
312
313impl futures::stream::FusedStream for AttemptsMonitorRequestStream {
314    fn is_terminated(&self) -> bool {
315        self.is_terminated
316    }
317}
318
319impl fidl::endpoints::RequestStream for AttemptsMonitorRequestStream {
320    type Protocol = AttemptsMonitorMarker;
321    type ControlHandle = AttemptsMonitorControlHandle;
322
323    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
324        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
325    }
326
327    fn control_handle(&self) -> Self::ControlHandle {
328        AttemptsMonitorControlHandle { inner: self.inner.clone() }
329    }
330
331    fn into_inner(
332        self,
333    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
334    {
335        (self.inner, self.is_terminated)
336    }
337
338    fn from_inner(
339        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
340        is_terminated: bool,
341    ) -> Self {
342        Self { inner, is_terminated }
343    }
344}
345
346impl futures::Stream for AttemptsMonitorRequestStream {
347    type Item = Result<AttemptsMonitorRequest, fidl::Error>;
348
349    fn poll_next(
350        mut self: std::pin::Pin<&mut Self>,
351        cx: &mut std::task::Context<'_>,
352    ) -> std::task::Poll<Option<Self::Item>> {
353        let this = &mut *self;
354        if this.inner.check_shutdown(cx) {
355            this.is_terminated = true;
356            return std::task::Poll::Ready(None);
357        }
358        if this.is_terminated {
359            panic!("polled AttemptsMonitorRequestStream after completion");
360        }
361        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
362            |bytes, handles| {
363                match this.inner.channel().read_etc(cx, bytes, handles) {
364                    std::task::Poll::Ready(Ok(())) => {}
365                    std::task::Poll::Pending => return std::task::Poll::Pending,
366                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
367                        this.is_terminated = true;
368                        return std::task::Poll::Ready(None);
369                    }
370                    std::task::Poll::Ready(Err(e)) => {
371                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
372                            e.into(),
373                        ))));
374                    }
375                }
376
377                // A message has been received from the channel
378                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
379
380                std::task::Poll::Ready(Some(match header.ordinal {
381                    0x75ea6bddd64d0714 => {
382                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
383                        let mut req = fidl::new_empty!(
384                            AttemptsMonitorOnStartRequest,
385                            fidl::encoding::DefaultFuchsiaResourceDialect
386                        );
387                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AttemptsMonitorOnStartRequest>(&header, _body_bytes, handles, &mut req)?;
388                        let control_handle =
389                            AttemptsMonitorControlHandle { inner: this.inner.clone() };
390                        Ok(AttemptsMonitorRequest::OnStart {
391                            options: req.options,
392                            monitor: req.monitor,
393
394                            responder: AttemptsMonitorOnStartResponder {
395                                control_handle: std::mem::ManuallyDrop::new(control_handle),
396                                tx_id: header.tx_id,
397                            },
398                        })
399                    }
400                    _ => Err(fidl::Error::UnknownOrdinal {
401                        ordinal: header.ordinal,
402                        protocol_name:
403                            <AttemptsMonitorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
404                    }),
405                }))
406            },
407        )
408    }
409}
410
411/// Monitors update attempts as they start.
412///
413/// Clients interested in receiving progress information for an update check
414/// should implement this protocol and provide the client end to
415/// [`Manager.MonitorAllUpdateChecks`].
416/// The Manager will close the client end of the AttemptsMonitor if there are
417/// more than 2 outstanding requests.
418#[derive(Debug)]
419pub enum AttemptsMonitorRequest {
420    /// Called when a new update attempt has started.
421    ///
422    /// Arguments:
423    /// * |options| Options for how this request should be performed.
424    /// * |monitor| A protocol on which to receive progress updates.
425    OnStart {
426        options: AttemptOptions,
427        monitor: fidl::endpoints::ServerEnd<MonitorMarker>,
428        responder: AttemptsMonitorOnStartResponder,
429    },
430}
431
432impl AttemptsMonitorRequest {
433    #[allow(irrefutable_let_patterns)]
434    pub fn into_on_start(
435        self,
436    ) -> Option<(
437        AttemptOptions,
438        fidl::endpoints::ServerEnd<MonitorMarker>,
439        AttemptsMonitorOnStartResponder,
440    )> {
441        if let AttemptsMonitorRequest::OnStart { options, monitor, responder } = self {
442            Some((options, monitor, responder))
443        } else {
444            None
445        }
446    }
447
448    /// Name of the method defined in FIDL
449    pub fn method_name(&self) -> &'static str {
450        match *self {
451            AttemptsMonitorRequest::OnStart { .. } => "on_start",
452        }
453    }
454}
455
456#[derive(Debug, Clone)]
457pub struct AttemptsMonitorControlHandle {
458    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
459}
460
461impl AttemptsMonitorControlHandle {
462    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
463        self.inner.shutdown_with_epitaph(status.into())
464    }
465}
466
467impl fidl::endpoints::ControlHandle for AttemptsMonitorControlHandle {
468    fn shutdown(&self) {
469        self.inner.shutdown()
470    }
471
472    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
473        self.inner.shutdown_with_epitaph(status)
474    }
475
476    fn is_closed(&self) -> bool {
477        self.inner.channel().is_closed()
478    }
479    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
480        self.inner.channel().on_closed()
481    }
482
483    #[cfg(target_os = "fuchsia")]
484    fn signal_peer(
485        &self,
486        clear_mask: zx::Signals,
487        set_mask: zx::Signals,
488    ) -> Result<(), zx_status::Status> {
489        use fidl::Peered;
490        self.inner.channel().signal_peer(clear_mask, set_mask)
491    }
492}
493
494impl AttemptsMonitorControlHandle {}
495
496#[must_use = "FIDL methods require a response to be sent"]
497#[derive(Debug)]
498pub struct AttemptsMonitorOnStartResponder {
499    control_handle: std::mem::ManuallyDrop<AttemptsMonitorControlHandle>,
500    tx_id: u32,
501}
502
503/// Set the the channel to be shutdown (see [`AttemptsMonitorControlHandle::shutdown`])
504/// if the responder is dropped without sending a response, so that the client
505/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
506impl std::ops::Drop for AttemptsMonitorOnStartResponder {
507    fn drop(&mut self) {
508        self.control_handle.shutdown();
509        // Safety: drops once, never accessed again
510        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
511    }
512}
513
514impl fidl::endpoints::Responder for AttemptsMonitorOnStartResponder {
515    type ControlHandle = AttemptsMonitorControlHandle;
516
517    fn control_handle(&self) -> &AttemptsMonitorControlHandle {
518        &self.control_handle
519    }
520
521    fn drop_without_shutdown(mut self) {
522        // Safety: drops once, never accessed again due to mem::forget
523        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
524        // Prevent Drop from running (which would shut down the channel)
525        std::mem::forget(self);
526    }
527}
528
529impl AttemptsMonitorOnStartResponder {
530    /// Sends a response to the FIDL transaction.
531    ///
532    /// Sets the channel to shutdown if an error occurs.
533    pub fn send(self) -> Result<(), fidl::Error> {
534        let _result = self.send_raw();
535        if _result.is_err() {
536            self.control_handle.shutdown();
537        }
538        self.drop_without_shutdown();
539        _result
540    }
541
542    /// Similar to "send" but does not shutdown the channel if an error occurs.
543    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
544        let _result = self.send_raw();
545        self.drop_without_shutdown();
546        _result
547    }
548
549    fn send_raw(&self) -> Result<(), fidl::Error> {
550        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
551            (),
552            self.tx_id,
553            0x75ea6bddd64d0714,
554            fidl::encoding::DynamicFlags::empty(),
555        )
556    }
557}
558
559#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
560pub struct CommitStatusProviderMarker;
561
562impl fidl::endpoints::ProtocolMarker for CommitStatusProviderMarker {
563    type Proxy = CommitStatusProviderProxy;
564    type RequestStream = CommitStatusProviderRequestStream;
565    #[cfg(target_os = "fuchsia")]
566    type SynchronousProxy = CommitStatusProviderSynchronousProxy;
567
568    const DEBUG_NAME: &'static str = "fuchsia.update.CommitStatusProvider";
569}
570impl fidl::endpoints::DiscoverableProtocolMarker for CommitStatusProviderMarker {}
571
572pub trait CommitStatusProviderProxyInterface: Send + Sync {
573    type IsCurrentSystemCommittedResponseFut: std::future::Future<Output = Result<fidl::EventPair, fidl::Error>>
574        + Send;
575    fn r#is_current_system_committed(&self) -> Self::IsCurrentSystemCommittedResponseFut;
576}
577#[derive(Debug)]
578#[cfg(target_os = "fuchsia")]
579pub struct CommitStatusProviderSynchronousProxy {
580    client: fidl::client::sync::Client,
581}
582
583#[cfg(target_os = "fuchsia")]
584impl fidl::endpoints::SynchronousProxy for CommitStatusProviderSynchronousProxy {
585    type Proxy = CommitStatusProviderProxy;
586    type Protocol = CommitStatusProviderMarker;
587
588    fn from_channel(inner: fidl::Channel) -> Self {
589        Self::new(inner)
590    }
591
592    fn into_channel(self) -> fidl::Channel {
593        self.client.into_channel()
594    }
595
596    fn as_channel(&self) -> &fidl::Channel {
597        self.client.as_channel()
598    }
599}
600
601#[cfg(target_os = "fuchsia")]
602impl CommitStatusProviderSynchronousProxy {
603    pub fn new(channel: fidl::Channel) -> Self {
604        Self { client: fidl::client::sync::Client::new(channel) }
605    }
606
607    pub fn into_channel(self) -> fidl::Channel {
608        self.client.into_channel()
609    }
610
611    /// Waits until an event arrives and returns it. It is safe for other
612    /// threads to make concurrent requests while waiting for an event.
613    pub fn wait_for_event(
614        &self,
615        deadline: zx::MonotonicInstant,
616    ) -> Result<CommitStatusProviderEvent, fidl::Error> {
617        CommitStatusProviderEvent::decode(
618            self.client.wait_for_event::<CommitStatusProviderMarker>(deadline)?,
619        )
620    }
621
622    /// Determines whether the currently booted system is committed, and immediately
623    /// returns an EventPair.
624    ///
625    /// * If the currently booted system is committed, the `ZX_USER_SIGNAL_0` signal
626    ///     is asserted on the EventPair, e.g. the signal is asserted before the
627    ///     EventPair is returned.
628    /// * If the commit is pending, no signals are asserted on the EventPair. When the
629    ///     system is committed, `ZX_USER_SIGNAL_0` is asserted on the EventPair.
630    /// * If the system fails to commit the currently booted version, the system
631    ///     will reboot and terminate the component serving [`CommitStatusProvider`],
632    ///     which will assert `ZX_EVENTPAIR_PEER_CLOSED`. At this point, any remaining
633    ///     EventPairs will observe the `ZX_EVENTPAIR_PEER_CLOSED` signal.
634    ///
635    /// - response `event` an EventPair with rights `ZX_RIGHTS_BASIC`.
636    pub fn r#is_current_system_committed(
637        &self,
638        ___deadline: zx::MonotonicInstant,
639    ) -> Result<fidl::EventPair, fidl::Error> {
640        let _response = self.client.send_query::<
641            fidl::encoding::EmptyPayload,
642            CommitStatusProviderIsCurrentSystemCommittedResponse,
643            CommitStatusProviderMarker,
644        >(
645            (),
646            0x4d49226840f25db1,
647            fidl::encoding::DynamicFlags::empty(),
648            ___deadline,
649        )?;
650        Ok(_response.event)
651    }
652}
653
654#[cfg(target_os = "fuchsia")]
655impl From<CommitStatusProviderSynchronousProxy> for zx::NullableHandle {
656    fn from(value: CommitStatusProviderSynchronousProxy) -> Self {
657        value.into_channel().into()
658    }
659}
660
661#[cfg(target_os = "fuchsia")]
662impl From<fidl::Channel> for CommitStatusProviderSynchronousProxy {
663    fn from(value: fidl::Channel) -> Self {
664        Self::new(value)
665    }
666}
667
668#[cfg(target_os = "fuchsia")]
669impl fidl::endpoints::FromClient for CommitStatusProviderSynchronousProxy {
670    type Protocol = CommitStatusProviderMarker;
671
672    fn from_client(value: fidl::endpoints::ClientEnd<CommitStatusProviderMarker>) -> Self {
673        Self::new(value.into_channel())
674    }
675}
676
677#[derive(Debug, Clone)]
678pub struct CommitStatusProviderProxy {
679    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
680}
681
682impl fidl::endpoints::Proxy for CommitStatusProviderProxy {
683    type Protocol = CommitStatusProviderMarker;
684
685    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
686        Self::new(inner)
687    }
688
689    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
690        self.client.into_channel().map_err(|client| Self { client })
691    }
692
693    fn as_channel(&self) -> &::fidl::AsyncChannel {
694        self.client.as_channel()
695    }
696}
697
698impl CommitStatusProviderProxy {
699    /// Create a new Proxy for fuchsia.update/CommitStatusProvider.
700    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
701        let protocol_name =
702            <CommitStatusProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
703        Self { client: fidl::client::Client::new(channel, protocol_name) }
704    }
705
706    /// Get a Stream of events from the remote end of the protocol.
707    ///
708    /// # Panics
709    ///
710    /// Panics if the event stream was already taken.
711    pub fn take_event_stream(&self) -> CommitStatusProviderEventStream {
712        CommitStatusProviderEventStream { event_receiver: self.client.take_event_receiver() }
713    }
714
715    /// Determines whether the currently booted system is committed, and immediately
716    /// returns an EventPair.
717    ///
718    /// * If the currently booted system is committed, the `ZX_USER_SIGNAL_0` signal
719    ///     is asserted on the EventPair, e.g. the signal is asserted before the
720    ///     EventPair is returned.
721    /// * If the commit is pending, no signals are asserted on the EventPair. When the
722    ///     system is committed, `ZX_USER_SIGNAL_0` is asserted on the EventPair.
723    /// * If the system fails to commit the currently booted version, the system
724    ///     will reboot and terminate the component serving [`CommitStatusProvider`],
725    ///     which will assert `ZX_EVENTPAIR_PEER_CLOSED`. At this point, any remaining
726    ///     EventPairs will observe the `ZX_EVENTPAIR_PEER_CLOSED` signal.
727    ///
728    /// - response `event` an EventPair with rights `ZX_RIGHTS_BASIC`.
729    pub fn r#is_current_system_committed(
730        &self,
731    ) -> fidl::client::QueryResponseFut<
732        fidl::EventPair,
733        fidl::encoding::DefaultFuchsiaResourceDialect,
734    > {
735        CommitStatusProviderProxyInterface::r#is_current_system_committed(self)
736    }
737}
738
739impl CommitStatusProviderProxyInterface for CommitStatusProviderProxy {
740    type IsCurrentSystemCommittedResponseFut = fidl::client::QueryResponseFut<
741        fidl::EventPair,
742        fidl::encoding::DefaultFuchsiaResourceDialect,
743    >;
744    fn r#is_current_system_committed(&self) -> Self::IsCurrentSystemCommittedResponseFut {
745        fn _decode(
746            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
747        ) -> Result<fidl::EventPair, fidl::Error> {
748            let _response = fidl::client::decode_transaction_body::<
749                CommitStatusProviderIsCurrentSystemCommittedResponse,
750                fidl::encoding::DefaultFuchsiaResourceDialect,
751                0x4d49226840f25db1,
752            >(_buf?)?;
753            Ok(_response.event)
754        }
755        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::EventPair>(
756            (),
757            0x4d49226840f25db1,
758            fidl::encoding::DynamicFlags::empty(),
759            _decode,
760        )
761    }
762}
763
764pub struct CommitStatusProviderEventStream {
765    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
766}
767
768impl std::marker::Unpin for CommitStatusProviderEventStream {}
769
770impl futures::stream::FusedStream for CommitStatusProviderEventStream {
771    fn is_terminated(&self) -> bool {
772        self.event_receiver.is_terminated()
773    }
774}
775
776impl futures::Stream for CommitStatusProviderEventStream {
777    type Item = Result<CommitStatusProviderEvent, fidl::Error>;
778
779    fn poll_next(
780        mut self: std::pin::Pin<&mut Self>,
781        cx: &mut std::task::Context<'_>,
782    ) -> std::task::Poll<Option<Self::Item>> {
783        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
784            &mut self.event_receiver,
785            cx
786        )?) {
787            Some(buf) => std::task::Poll::Ready(Some(CommitStatusProviderEvent::decode(buf))),
788            None => std::task::Poll::Ready(None),
789        }
790    }
791}
792
793#[derive(Debug)]
794pub enum CommitStatusProviderEvent {}
795
796impl CommitStatusProviderEvent {
797    /// Decodes a message buffer as a [`CommitStatusProviderEvent`].
798    fn decode(
799        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
800    ) -> Result<CommitStatusProviderEvent, fidl::Error> {
801        let (bytes, _handles) = buf.split_mut();
802        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
803        debug_assert_eq!(tx_header.tx_id, 0);
804        match tx_header.ordinal {
805            _ => Err(fidl::Error::UnknownOrdinal {
806                ordinal: tx_header.ordinal,
807                protocol_name:
808                    <CommitStatusProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
809            }),
810        }
811    }
812}
813
814/// A Stream of incoming requests for fuchsia.update/CommitStatusProvider.
815pub struct CommitStatusProviderRequestStream {
816    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
817    is_terminated: bool,
818}
819
820impl std::marker::Unpin for CommitStatusProviderRequestStream {}
821
822impl futures::stream::FusedStream for CommitStatusProviderRequestStream {
823    fn is_terminated(&self) -> bool {
824        self.is_terminated
825    }
826}
827
828impl fidl::endpoints::RequestStream for CommitStatusProviderRequestStream {
829    type Protocol = CommitStatusProviderMarker;
830    type ControlHandle = CommitStatusProviderControlHandle;
831
832    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
833        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
834    }
835
836    fn control_handle(&self) -> Self::ControlHandle {
837        CommitStatusProviderControlHandle { inner: self.inner.clone() }
838    }
839
840    fn into_inner(
841        self,
842    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
843    {
844        (self.inner, self.is_terminated)
845    }
846
847    fn from_inner(
848        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
849        is_terminated: bool,
850    ) -> Self {
851        Self { inner, is_terminated }
852    }
853}
854
855impl futures::Stream for CommitStatusProviderRequestStream {
856    type Item = Result<CommitStatusProviderRequest, fidl::Error>;
857
858    fn poll_next(
859        mut self: std::pin::Pin<&mut Self>,
860        cx: &mut std::task::Context<'_>,
861    ) -> std::task::Poll<Option<Self::Item>> {
862        let this = &mut *self;
863        if this.inner.check_shutdown(cx) {
864            this.is_terminated = true;
865            return std::task::Poll::Ready(None);
866        }
867        if this.is_terminated {
868            panic!("polled CommitStatusProviderRequestStream after completion");
869        }
870        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
871            |bytes, handles| {
872                match this.inner.channel().read_etc(cx, bytes, handles) {
873                    std::task::Poll::Ready(Ok(())) => {}
874                    std::task::Poll::Pending => return std::task::Poll::Pending,
875                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
876                        this.is_terminated = true;
877                        return std::task::Poll::Ready(None);
878                    }
879                    std::task::Poll::Ready(Err(e)) => {
880                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
881                            e.into(),
882                        ))));
883                    }
884                }
885
886                // A message has been received from the channel
887                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
888
889                std::task::Poll::Ready(Some(match header.ordinal {
890                0x4d49226840f25db1 => {
891                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
892                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
893                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
894                    let control_handle = CommitStatusProviderControlHandle {
895                        inner: this.inner.clone(),
896                    };
897                    Ok(CommitStatusProviderRequest::IsCurrentSystemCommitted {
898                        responder: CommitStatusProviderIsCurrentSystemCommittedResponder {
899                            control_handle: std::mem::ManuallyDrop::new(control_handle),
900                            tx_id: header.tx_id,
901                        },
902                    })
903                }
904                _ => Err(fidl::Error::UnknownOrdinal {
905                    ordinal: header.ordinal,
906                    protocol_name: <CommitStatusProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
907                }),
908            }))
909            },
910        )
911    }
912}
913
914/// A reporter for whether the currently booted system is committed. When an
915/// update is committed, this means:
916/// * The currently booted slot is marked as healthy (e.g. successfully booted).
917/// * The alternate slot (if present) is marked as unbootable.
918/// * The system will not roll back to the previous version of the OS on reboot.
919/// * The previous version of the OS may be garbage collected.
920///
921/// Until the update is committed, the system retains the prior version of the OS.
922/// That way, if we discover the newly written version is bad (e.g. it cannot itself
923/// update), then the system can fall back to the previous committed version.
924#[derive(Debug)]
925pub enum CommitStatusProviderRequest {
926    /// Determines whether the currently booted system is committed, and immediately
927    /// returns an EventPair.
928    ///
929    /// * If the currently booted system is committed, the `ZX_USER_SIGNAL_0` signal
930    ///     is asserted on the EventPair, e.g. the signal is asserted before the
931    ///     EventPair is returned.
932    /// * If the commit is pending, no signals are asserted on the EventPair. When the
933    ///     system is committed, `ZX_USER_SIGNAL_0` is asserted on the EventPair.
934    /// * If the system fails to commit the currently booted version, the system
935    ///     will reboot and terminate the component serving [`CommitStatusProvider`],
936    ///     which will assert `ZX_EVENTPAIR_PEER_CLOSED`. At this point, any remaining
937    ///     EventPairs will observe the `ZX_EVENTPAIR_PEER_CLOSED` signal.
938    ///
939    /// - response `event` an EventPair with rights `ZX_RIGHTS_BASIC`.
940    IsCurrentSystemCommitted { responder: CommitStatusProviderIsCurrentSystemCommittedResponder },
941}
942
943impl CommitStatusProviderRequest {
944    #[allow(irrefutable_let_patterns)]
945    pub fn into_is_current_system_committed(
946        self,
947    ) -> Option<(CommitStatusProviderIsCurrentSystemCommittedResponder)> {
948        if let CommitStatusProviderRequest::IsCurrentSystemCommitted { responder } = self {
949            Some((responder))
950        } else {
951            None
952        }
953    }
954
955    /// Name of the method defined in FIDL
956    pub fn method_name(&self) -> &'static str {
957        match *self {
958            CommitStatusProviderRequest::IsCurrentSystemCommitted { .. } => {
959                "is_current_system_committed"
960            }
961        }
962    }
963}
964
965#[derive(Debug, Clone)]
966pub struct CommitStatusProviderControlHandle {
967    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
968}
969
970impl CommitStatusProviderControlHandle {
971    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
972        self.inner.shutdown_with_epitaph(status.into())
973    }
974}
975
976impl fidl::endpoints::ControlHandle for CommitStatusProviderControlHandle {
977    fn shutdown(&self) {
978        self.inner.shutdown()
979    }
980
981    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
982        self.inner.shutdown_with_epitaph(status)
983    }
984
985    fn is_closed(&self) -> bool {
986        self.inner.channel().is_closed()
987    }
988    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
989        self.inner.channel().on_closed()
990    }
991
992    #[cfg(target_os = "fuchsia")]
993    fn signal_peer(
994        &self,
995        clear_mask: zx::Signals,
996        set_mask: zx::Signals,
997    ) -> Result<(), zx_status::Status> {
998        use fidl::Peered;
999        self.inner.channel().signal_peer(clear_mask, set_mask)
1000    }
1001}
1002
1003impl CommitStatusProviderControlHandle {}
1004
1005#[must_use = "FIDL methods require a response to be sent"]
1006#[derive(Debug)]
1007pub struct CommitStatusProviderIsCurrentSystemCommittedResponder {
1008    control_handle: std::mem::ManuallyDrop<CommitStatusProviderControlHandle>,
1009    tx_id: u32,
1010}
1011
1012/// Set the the channel to be shutdown (see [`CommitStatusProviderControlHandle::shutdown`])
1013/// if the responder is dropped without sending a response, so that the client
1014/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1015impl std::ops::Drop for CommitStatusProviderIsCurrentSystemCommittedResponder {
1016    fn drop(&mut self) {
1017        self.control_handle.shutdown();
1018        // Safety: drops once, never accessed again
1019        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1020    }
1021}
1022
1023impl fidl::endpoints::Responder for CommitStatusProviderIsCurrentSystemCommittedResponder {
1024    type ControlHandle = CommitStatusProviderControlHandle;
1025
1026    fn control_handle(&self) -> &CommitStatusProviderControlHandle {
1027        &self.control_handle
1028    }
1029
1030    fn drop_without_shutdown(mut self) {
1031        // Safety: drops once, never accessed again due to mem::forget
1032        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1033        // Prevent Drop from running (which would shut down the channel)
1034        std::mem::forget(self);
1035    }
1036}
1037
1038impl CommitStatusProviderIsCurrentSystemCommittedResponder {
1039    /// Sends a response to the FIDL transaction.
1040    ///
1041    /// Sets the channel to shutdown if an error occurs.
1042    pub fn send(self, mut event: fidl::EventPair) -> Result<(), fidl::Error> {
1043        let _result = self.send_raw(event);
1044        if _result.is_err() {
1045            self.control_handle.shutdown();
1046        }
1047        self.drop_without_shutdown();
1048        _result
1049    }
1050
1051    /// Similar to "send" but does not shutdown the channel if an error occurs.
1052    pub fn send_no_shutdown_on_err(self, mut event: fidl::EventPair) -> Result<(), fidl::Error> {
1053        let _result = self.send_raw(event);
1054        self.drop_without_shutdown();
1055        _result
1056    }
1057
1058    fn send_raw(&self, mut event: fidl::EventPair) -> Result<(), fidl::Error> {
1059        self.control_handle.inner.send::<CommitStatusProviderIsCurrentSystemCommittedResponse>(
1060            (event,),
1061            self.tx_id,
1062            0x4d49226840f25db1,
1063            fidl::encoding::DynamicFlags::empty(),
1064        )
1065    }
1066}
1067
1068#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1069pub struct ListenerMarker;
1070
1071impl fidl::endpoints::ProtocolMarker for ListenerMarker {
1072    type Proxy = ListenerProxy;
1073    type RequestStream = ListenerRequestStream;
1074    #[cfg(target_os = "fuchsia")]
1075    type SynchronousProxy = ListenerSynchronousProxy;
1076
1077    const DEBUG_NAME: &'static str = "fuchsia.update.Listener";
1078}
1079impl fidl::endpoints::DiscoverableProtocolMarker for ListenerMarker {}
1080
1081pub trait ListenerProxyInterface: Send + Sync {
1082    fn r#notify_on_first_update_check(
1083        &self,
1084        payload: ListenerNotifyOnFirstUpdateCheckRequest,
1085    ) -> Result<(), fidl::Error>;
1086}
1087#[derive(Debug)]
1088#[cfg(target_os = "fuchsia")]
1089pub struct ListenerSynchronousProxy {
1090    client: fidl::client::sync::Client,
1091}
1092
1093#[cfg(target_os = "fuchsia")]
1094impl fidl::endpoints::SynchronousProxy for ListenerSynchronousProxy {
1095    type Proxy = ListenerProxy;
1096    type Protocol = ListenerMarker;
1097
1098    fn from_channel(inner: fidl::Channel) -> Self {
1099        Self::new(inner)
1100    }
1101
1102    fn into_channel(self) -> fidl::Channel {
1103        self.client.into_channel()
1104    }
1105
1106    fn as_channel(&self) -> &fidl::Channel {
1107        self.client.as_channel()
1108    }
1109}
1110
1111#[cfg(target_os = "fuchsia")]
1112impl ListenerSynchronousProxy {
1113    pub fn new(channel: fidl::Channel) -> Self {
1114        Self { client: fidl::client::sync::Client::new(channel) }
1115    }
1116
1117    pub fn into_channel(self) -> fidl::Channel {
1118        self.client.into_channel()
1119    }
1120
1121    /// Waits until an event arrives and returns it. It is safe for other
1122    /// threads to make concurrent requests while waiting for an event.
1123    pub fn wait_for_event(
1124        &self,
1125        deadline: zx::MonotonicInstant,
1126    ) -> Result<ListenerEvent, fidl::Error> {
1127        ListenerEvent::decode(self.client.wait_for_event::<ListenerMarker>(deadline)?)
1128    }
1129
1130    /// Subscribe for a notification when the software update checker has
1131    /// completed its post-boot check (with or without error) and is not trying
1132    /// to reboot.
1133    /// If the update checker will never perform an update check, then it will close the connection
1134    /// with epitaph `ZX_ERR_NOT_SUPPORTED` and close the `notifier` connection without calling
1135    /// [`fuchsia.update/Notifier.Notify`].
1136    pub fn r#notify_on_first_update_check(
1137        &self,
1138        mut payload: ListenerNotifyOnFirstUpdateCheckRequest,
1139    ) -> Result<(), fidl::Error> {
1140        self.client.send::<ListenerNotifyOnFirstUpdateCheckRequest>(
1141            &mut payload,
1142            0x37c6c33b96f0cbbe,
1143            fidl::encoding::DynamicFlags::empty(),
1144        )
1145    }
1146}
1147
1148#[cfg(target_os = "fuchsia")]
1149impl From<ListenerSynchronousProxy> for zx::NullableHandle {
1150    fn from(value: ListenerSynchronousProxy) -> Self {
1151        value.into_channel().into()
1152    }
1153}
1154
1155#[cfg(target_os = "fuchsia")]
1156impl From<fidl::Channel> for ListenerSynchronousProxy {
1157    fn from(value: fidl::Channel) -> Self {
1158        Self::new(value)
1159    }
1160}
1161
1162#[cfg(target_os = "fuchsia")]
1163impl fidl::endpoints::FromClient for ListenerSynchronousProxy {
1164    type Protocol = ListenerMarker;
1165
1166    fn from_client(value: fidl::endpoints::ClientEnd<ListenerMarker>) -> Self {
1167        Self::new(value.into_channel())
1168    }
1169}
1170
1171#[derive(Debug, Clone)]
1172pub struct ListenerProxy {
1173    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1174}
1175
1176impl fidl::endpoints::Proxy for ListenerProxy {
1177    type Protocol = ListenerMarker;
1178
1179    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1180        Self::new(inner)
1181    }
1182
1183    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1184        self.client.into_channel().map_err(|client| Self { client })
1185    }
1186
1187    fn as_channel(&self) -> &::fidl::AsyncChannel {
1188        self.client.as_channel()
1189    }
1190}
1191
1192impl ListenerProxy {
1193    /// Create a new Proxy for fuchsia.update/Listener.
1194    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1195        let protocol_name = <ListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1196        Self { client: fidl::client::Client::new(channel, protocol_name) }
1197    }
1198
1199    /// Get a Stream of events from the remote end of the protocol.
1200    ///
1201    /// # Panics
1202    ///
1203    /// Panics if the event stream was already taken.
1204    pub fn take_event_stream(&self) -> ListenerEventStream {
1205        ListenerEventStream { event_receiver: self.client.take_event_receiver() }
1206    }
1207
1208    /// Subscribe for a notification when the software update checker has
1209    /// completed its post-boot check (with or without error) and is not trying
1210    /// to reboot.
1211    /// If the update checker will never perform an update check, then it will close the connection
1212    /// with epitaph `ZX_ERR_NOT_SUPPORTED` and close the `notifier` connection without calling
1213    /// [`fuchsia.update/Notifier.Notify`].
1214    pub fn r#notify_on_first_update_check(
1215        &self,
1216        mut payload: ListenerNotifyOnFirstUpdateCheckRequest,
1217    ) -> Result<(), fidl::Error> {
1218        ListenerProxyInterface::r#notify_on_first_update_check(self, payload)
1219    }
1220}
1221
1222impl ListenerProxyInterface for ListenerProxy {
1223    fn r#notify_on_first_update_check(
1224        &self,
1225        mut payload: ListenerNotifyOnFirstUpdateCheckRequest,
1226    ) -> Result<(), fidl::Error> {
1227        self.client.send::<ListenerNotifyOnFirstUpdateCheckRequest>(
1228            &mut payload,
1229            0x37c6c33b96f0cbbe,
1230            fidl::encoding::DynamicFlags::empty(),
1231        )
1232    }
1233}
1234
1235pub struct ListenerEventStream {
1236    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1237}
1238
1239impl std::marker::Unpin for ListenerEventStream {}
1240
1241impl futures::stream::FusedStream for ListenerEventStream {
1242    fn is_terminated(&self) -> bool {
1243        self.event_receiver.is_terminated()
1244    }
1245}
1246
1247impl futures::Stream for ListenerEventStream {
1248    type Item = Result<ListenerEvent, fidl::Error>;
1249
1250    fn poll_next(
1251        mut self: std::pin::Pin<&mut Self>,
1252        cx: &mut std::task::Context<'_>,
1253    ) -> std::task::Poll<Option<Self::Item>> {
1254        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1255            &mut self.event_receiver,
1256            cx
1257        )?) {
1258            Some(buf) => std::task::Poll::Ready(Some(ListenerEvent::decode(buf))),
1259            None => std::task::Poll::Ready(None),
1260        }
1261    }
1262}
1263
1264#[derive(Debug)]
1265pub enum ListenerEvent {
1266    #[non_exhaustive]
1267    _UnknownEvent {
1268        /// Ordinal of the event that was sent.
1269        ordinal: u64,
1270    },
1271}
1272
1273impl ListenerEvent {
1274    /// Decodes a message buffer as a [`ListenerEvent`].
1275    fn decode(
1276        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1277    ) -> Result<ListenerEvent, fidl::Error> {
1278        let (bytes, _handles) = buf.split_mut();
1279        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1280        debug_assert_eq!(tx_header.tx_id, 0);
1281        match tx_header.ordinal {
1282            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1283                Ok(ListenerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1284            }
1285            _ => Err(fidl::Error::UnknownOrdinal {
1286                ordinal: tx_header.ordinal,
1287                protocol_name: <ListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1288            }),
1289        }
1290    }
1291}
1292
1293/// A Stream of incoming requests for fuchsia.update/Listener.
1294pub struct ListenerRequestStream {
1295    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1296    is_terminated: bool,
1297}
1298
1299impl std::marker::Unpin for ListenerRequestStream {}
1300
1301impl futures::stream::FusedStream for ListenerRequestStream {
1302    fn is_terminated(&self) -> bool {
1303        self.is_terminated
1304    }
1305}
1306
1307impl fidl::endpoints::RequestStream for ListenerRequestStream {
1308    type Protocol = ListenerMarker;
1309    type ControlHandle = ListenerControlHandle;
1310
1311    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1312        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1313    }
1314
1315    fn control_handle(&self) -> Self::ControlHandle {
1316        ListenerControlHandle { inner: self.inner.clone() }
1317    }
1318
1319    fn into_inner(
1320        self,
1321    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1322    {
1323        (self.inner, self.is_terminated)
1324    }
1325
1326    fn from_inner(
1327        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1328        is_terminated: bool,
1329    ) -> Self {
1330        Self { inner, is_terminated }
1331    }
1332}
1333
1334impl futures::Stream for ListenerRequestStream {
1335    type Item = Result<ListenerRequest, fidl::Error>;
1336
1337    fn poll_next(
1338        mut self: std::pin::Pin<&mut Self>,
1339        cx: &mut std::task::Context<'_>,
1340    ) -> std::task::Poll<Option<Self::Item>> {
1341        let this = &mut *self;
1342        if this.inner.check_shutdown(cx) {
1343            this.is_terminated = true;
1344            return std::task::Poll::Ready(None);
1345        }
1346        if this.is_terminated {
1347            panic!("polled ListenerRequestStream after completion");
1348        }
1349        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1350            |bytes, handles| {
1351                match this.inner.channel().read_etc(cx, bytes, handles) {
1352                    std::task::Poll::Ready(Ok(())) => {}
1353                    std::task::Poll::Pending => return std::task::Poll::Pending,
1354                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1355                        this.is_terminated = true;
1356                        return std::task::Poll::Ready(None);
1357                    }
1358                    std::task::Poll::Ready(Err(e)) => {
1359                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1360                            e.into(),
1361                        ))));
1362                    }
1363                }
1364
1365                // A message has been received from the channel
1366                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1367
1368                std::task::Poll::Ready(Some(match header.ordinal {
1369                    0x37c6c33b96f0cbbe => {
1370                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1371                        let mut req = fidl::new_empty!(
1372                            ListenerNotifyOnFirstUpdateCheckRequest,
1373                            fidl::encoding::DefaultFuchsiaResourceDialect
1374                        );
1375                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ListenerNotifyOnFirstUpdateCheckRequest>(&header, _body_bytes, handles, &mut req)?;
1376                        let control_handle = ListenerControlHandle { inner: this.inner.clone() };
1377                        Ok(ListenerRequest::NotifyOnFirstUpdateCheck {
1378                            payload: req,
1379                            control_handle,
1380                        })
1381                    }
1382                    _ if header.tx_id == 0
1383                        && header
1384                            .dynamic_flags()
1385                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1386                    {
1387                        Ok(ListenerRequest::_UnknownMethod {
1388                            ordinal: header.ordinal,
1389                            control_handle: ListenerControlHandle { inner: this.inner.clone() },
1390                            method_type: fidl::MethodType::OneWay,
1391                        })
1392                    }
1393                    _ if header
1394                        .dynamic_flags()
1395                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1396                    {
1397                        this.inner.send_framework_err(
1398                            fidl::encoding::FrameworkErr::UnknownMethod,
1399                            header.tx_id,
1400                            header.ordinal,
1401                            header.dynamic_flags(),
1402                            (bytes, handles),
1403                        )?;
1404                        Ok(ListenerRequest::_UnknownMethod {
1405                            ordinal: header.ordinal,
1406                            control_handle: ListenerControlHandle { inner: this.inner.clone() },
1407                            method_type: fidl::MethodType::TwoWay,
1408                        })
1409                    }
1410                    _ => Err(fidl::Error::UnknownOrdinal {
1411                        ordinal: header.ordinal,
1412                        protocol_name:
1413                            <ListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1414                    }),
1415                }))
1416            },
1417        )
1418    }
1419}
1420
1421/// Used by components to wait for the first software update check to complete.
1422#[derive(Debug)]
1423pub enum ListenerRequest {
1424    /// Subscribe for a notification when the software update checker has
1425    /// completed its post-boot check (with or without error) and is not trying
1426    /// to reboot.
1427    /// If the update checker will never perform an update check, then it will close the connection
1428    /// with epitaph `ZX_ERR_NOT_SUPPORTED` and close the `notifier` connection without calling
1429    /// [`fuchsia.update/Notifier.Notify`].
1430    NotifyOnFirstUpdateCheck {
1431        payload: ListenerNotifyOnFirstUpdateCheckRequest,
1432        control_handle: ListenerControlHandle,
1433    },
1434    /// An interaction was received which does not match any known method.
1435    #[non_exhaustive]
1436    _UnknownMethod {
1437        /// Ordinal of the method that was called.
1438        ordinal: u64,
1439        control_handle: ListenerControlHandle,
1440        method_type: fidl::MethodType,
1441    },
1442}
1443
1444impl ListenerRequest {
1445    #[allow(irrefutable_let_patterns)]
1446    pub fn into_notify_on_first_update_check(
1447        self,
1448    ) -> Option<(ListenerNotifyOnFirstUpdateCheckRequest, ListenerControlHandle)> {
1449        if let ListenerRequest::NotifyOnFirstUpdateCheck { payload, control_handle } = self {
1450            Some((payload, control_handle))
1451        } else {
1452            None
1453        }
1454    }
1455
1456    /// Name of the method defined in FIDL
1457    pub fn method_name(&self) -> &'static str {
1458        match *self {
1459            ListenerRequest::NotifyOnFirstUpdateCheck { .. } => "notify_on_first_update_check",
1460            ListenerRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1461                "unknown one-way method"
1462            }
1463            ListenerRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1464                "unknown two-way method"
1465            }
1466        }
1467    }
1468}
1469
1470#[derive(Debug, Clone)]
1471pub struct ListenerControlHandle {
1472    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1473}
1474
1475impl ListenerControlHandle {
1476    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1477        self.inner.shutdown_with_epitaph(status.into())
1478    }
1479}
1480
1481impl fidl::endpoints::ControlHandle for ListenerControlHandle {
1482    fn shutdown(&self) {
1483        self.inner.shutdown()
1484    }
1485
1486    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1487        self.inner.shutdown_with_epitaph(status)
1488    }
1489
1490    fn is_closed(&self) -> bool {
1491        self.inner.channel().is_closed()
1492    }
1493    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1494        self.inner.channel().on_closed()
1495    }
1496
1497    #[cfg(target_os = "fuchsia")]
1498    fn signal_peer(
1499        &self,
1500        clear_mask: zx::Signals,
1501        set_mask: zx::Signals,
1502    ) -> Result<(), zx_status::Status> {
1503        use fidl::Peered;
1504        self.inner.channel().signal_peer(clear_mask, set_mask)
1505    }
1506}
1507
1508impl ListenerControlHandle {}
1509
1510#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1511pub struct ManagerMarker;
1512
1513impl fidl::endpoints::ProtocolMarker for ManagerMarker {
1514    type Proxy = ManagerProxy;
1515    type RequestStream = ManagerRequestStream;
1516    #[cfg(target_os = "fuchsia")]
1517    type SynchronousProxy = ManagerSynchronousProxy;
1518
1519    const DEBUG_NAME: &'static str = "fuchsia.update.Manager";
1520}
1521impl fidl::endpoints::DiscoverableProtocolMarker for ManagerMarker {}
1522pub type ManagerCheckNowResult = Result<(), CheckNotStartedReason>;
1523
1524pub trait ManagerProxyInterface: Send + Sync {
1525    type CheckNowResponseFut: std::future::Future<Output = Result<ManagerCheckNowResult, fidl::Error>>
1526        + Send;
1527    fn r#check_now(
1528        &self,
1529        options: &CheckOptions,
1530        monitor: Option<fidl::endpoints::ClientEnd<MonitorMarker>>,
1531    ) -> Self::CheckNowResponseFut;
1532    type PerformPendingRebootResponseFut: std::future::Future<Output = Result<bool, fidl::Error>>
1533        + Send;
1534    fn r#perform_pending_reboot(&self) -> Self::PerformPendingRebootResponseFut;
1535    fn r#monitor_all_update_checks(
1536        &self,
1537        attempts_monitor: fidl::endpoints::ClientEnd<AttemptsMonitorMarker>,
1538    ) -> Result<(), fidl::Error>;
1539}
1540#[derive(Debug)]
1541#[cfg(target_os = "fuchsia")]
1542pub struct ManagerSynchronousProxy {
1543    client: fidl::client::sync::Client,
1544}
1545
1546#[cfg(target_os = "fuchsia")]
1547impl fidl::endpoints::SynchronousProxy for ManagerSynchronousProxy {
1548    type Proxy = ManagerProxy;
1549    type Protocol = ManagerMarker;
1550
1551    fn from_channel(inner: fidl::Channel) -> Self {
1552        Self::new(inner)
1553    }
1554
1555    fn into_channel(self) -> fidl::Channel {
1556        self.client.into_channel()
1557    }
1558
1559    fn as_channel(&self) -> &fidl::Channel {
1560        self.client.as_channel()
1561    }
1562}
1563
1564#[cfg(target_os = "fuchsia")]
1565impl ManagerSynchronousProxy {
1566    pub fn new(channel: fidl::Channel) -> Self {
1567        Self { client: fidl::client::sync::Client::new(channel) }
1568    }
1569
1570    pub fn into_channel(self) -> fidl::Channel {
1571        self.client.into_channel()
1572    }
1573
1574    /// Waits until an event arrives and returns it. It is safe for other
1575    /// threads to make concurrent requests while waiting for an event.
1576    pub fn wait_for_event(
1577        &self,
1578        deadline: zx::MonotonicInstant,
1579    ) -> Result<ManagerEvent, fidl::Error> {
1580        ManagerEvent::decode(self.client.wait_for_event::<ManagerMarker>(deadline)?)
1581    }
1582
1583    /// Immediately check for an update, and optionally track the state and
1584    /// progress of that update check.
1585    ///
1586    /// + request `options` Options for how this request should be performed.
1587    ///                     E.g. What kind of entity initiated this request?
1588    ///                     E.g. Is monitoring an existing update check that
1589    ///                          is already in process an acceptable
1590    ///                          alternative?
1591    ///
1592    /// + request `monitor` An interface on which to receive the status events
1593    ///                     for this update check.  The monitor is only valid
1594    ///                     for this single update check, after that it will
1595    ///                     not receive any more notifications and will be
1596    ///                     closed.
1597    ///
1598    /// * error If an update check cannot be started, an error will be returned.
1599    ///         The [`Monitor`], if provided, will not receive any notifications.
1600    pub fn r#check_now(
1601        &self,
1602        mut options: &CheckOptions,
1603        mut monitor: Option<fidl::endpoints::ClientEnd<MonitorMarker>>,
1604        ___deadline: zx::MonotonicInstant,
1605    ) -> Result<ManagerCheckNowResult, fidl::Error> {
1606        let _response =
1607            self.client.send_query::<ManagerCheckNowRequest, fidl::encoding::ResultType<
1608                fidl::encoding::EmptyStruct,
1609                CheckNotStartedReason,
1610            >, ManagerMarker>(
1611                (options, monitor),
1612                0x4a5a2327156c3ba8,
1613                fidl::encoding::DynamicFlags::empty(),
1614                ___deadline,
1615            )?;
1616        Ok(_response.map(|x| x))
1617    }
1618
1619    /// Performs any pending reboot of the system into an updated OS, if an
1620    /// update has been staged for the next system startup.
1621    ///
1622    /// Replaced by
1623    /// `fuchsia.power/CollaborativeRebootInitiator.PerformPendingReboot`.
1624    pub fn r#perform_pending_reboot(
1625        &self,
1626        ___deadline: zx::MonotonicInstant,
1627    ) -> Result<bool, fidl::Error> {
1628        let _response = self.client.send_query::<
1629            fidl::encoding::EmptyPayload,
1630            ManagerPerformPendingRebootResponse,
1631            ManagerMarker,
1632        >(
1633            (),
1634            0x69b7d3c620b0879d,
1635            fidl::encoding::DynamicFlags::empty(),
1636            ___deadline,
1637        )?;
1638        Ok(_response.rebooting)
1639    }
1640
1641    /// Monitor all update attempts as they start, as well as an in-progress
1642    /// attempt, if there is one.
1643    ///
1644    /// Arguments:
1645    /// * |attempts_monitor| A protocol on which to receive |Monitor| instances
1646    /// as update attempts start.
1647    pub fn r#monitor_all_update_checks(
1648        &self,
1649        mut attempts_monitor: fidl::endpoints::ClientEnd<AttemptsMonitorMarker>,
1650    ) -> Result<(), fidl::Error> {
1651        self.client.send::<ManagerMonitorAllUpdateChecksRequest>(
1652            (attempts_monitor,),
1653            0x436bcf0efab3158b,
1654            fidl::encoding::DynamicFlags::empty(),
1655        )
1656    }
1657}
1658
1659#[cfg(target_os = "fuchsia")]
1660impl From<ManagerSynchronousProxy> for zx::NullableHandle {
1661    fn from(value: ManagerSynchronousProxy) -> Self {
1662        value.into_channel().into()
1663    }
1664}
1665
1666#[cfg(target_os = "fuchsia")]
1667impl From<fidl::Channel> for ManagerSynchronousProxy {
1668    fn from(value: fidl::Channel) -> Self {
1669        Self::new(value)
1670    }
1671}
1672
1673#[cfg(target_os = "fuchsia")]
1674impl fidl::endpoints::FromClient for ManagerSynchronousProxy {
1675    type Protocol = ManagerMarker;
1676
1677    fn from_client(value: fidl::endpoints::ClientEnd<ManagerMarker>) -> Self {
1678        Self::new(value.into_channel())
1679    }
1680}
1681
1682#[derive(Debug, Clone)]
1683pub struct ManagerProxy {
1684    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1685}
1686
1687impl fidl::endpoints::Proxy for ManagerProxy {
1688    type Protocol = ManagerMarker;
1689
1690    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1691        Self::new(inner)
1692    }
1693
1694    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1695        self.client.into_channel().map_err(|client| Self { client })
1696    }
1697
1698    fn as_channel(&self) -> &::fidl::AsyncChannel {
1699        self.client.as_channel()
1700    }
1701}
1702
1703impl ManagerProxy {
1704    /// Create a new Proxy for fuchsia.update/Manager.
1705    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1706        let protocol_name = <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1707        Self { client: fidl::client::Client::new(channel, protocol_name) }
1708    }
1709
1710    /// Get a Stream of events from the remote end of the protocol.
1711    ///
1712    /// # Panics
1713    ///
1714    /// Panics if the event stream was already taken.
1715    pub fn take_event_stream(&self) -> ManagerEventStream {
1716        ManagerEventStream { event_receiver: self.client.take_event_receiver() }
1717    }
1718
1719    /// Immediately check for an update, and optionally track the state and
1720    /// progress of that update check.
1721    ///
1722    /// + request `options` Options for how this request should be performed.
1723    ///                     E.g. What kind of entity initiated this request?
1724    ///                     E.g. Is monitoring an existing update check that
1725    ///                          is already in process an acceptable
1726    ///                          alternative?
1727    ///
1728    /// + request `monitor` An interface on which to receive the status events
1729    ///                     for this update check.  The monitor is only valid
1730    ///                     for this single update check, after that it will
1731    ///                     not receive any more notifications and will be
1732    ///                     closed.
1733    ///
1734    /// * error If an update check cannot be started, an error will be returned.
1735    ///         The [`Monitor`], if provided, will not receive any notifications.
1736    pub fn r#check_now(
1737        &self,
1738        mut options: &CheckOptions,
1739        mut monitor: Option<fidl::endpoints::ClientEnd<MonitorMarker>>,
1740    ) -> fidl::client::QueryResponseFut<
1741        ManagerCheckNowResult,
1742        fidl::encoding::DefaultFuchsiaResourceDialect,
1743    > {
1744        ManagerProxyInterface::r#check_now(self, options, monitor)
1745    }
1746
1747    /// Performs any pending reboot of the system into an updated OS, if an
1748    /// update has been staged for the next system startup.
1749    ///
1750    /// Replaced by
1751    /// `fuchsia.power/CollaborativeRebootInitiator.PerformPendingReboot`.
1752    pub fn r#perform_pending_reboot(
1753        &self,
1754    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
1755        ManagerProxyInterface::r#perform_pending_reboot(self)
1756    }
1757
1758    /// Monitor all update attempts as they start, as well as an in-progress
1759    /// attempt, if there is one.
1760    ///
1761    /// Arguments:
1762    /// * |attempts_monitor| A protocol on which to receive |Monitor| instances
1763    /// as update attempts start.
1764    pub fn r#monitor_all_update_checks(
1765        &self,
1766        mut attempts_monitor: fidl::endpoints::ClientEnd<AttemptsMonitorMarker>,
1767    ) -> Result<(), fidl::Error> {
1768        ManagerProxyInterface::r#monitor_all_update_checks(self, attempts_monitor)
1769    }
1770}
1771
1772impl ManagerProxyInterface for ManagerProxy {
1773    type CheckNowResponseFut = fidl::client::QueryResponseFut<
1774        ManagerCheckNowResult,
1775        fidl::encoding::DefaultFuchsiaResourceDialect,
1776    >;
1777    fn r#check_now(
1778        &self,
1779        mut options: &CheckOptions,
1780        mut monitor: Option<fidl::endpoints::ClientEnd<MonitorMarker>>,
1781    ) -> Self::CheckNowResponseFut {
1782        fn _decode(
1783            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1784        ) -> Result<ManagerCheckNowResult, fidl::Error> {
1785            let _response = fidl::client::decode_transaction_body::<
1786                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, CheckNotStartedReason>,
1787                fidl::encoding::DefaultFuchsiaResourceDialect,
1788                0x4a5a2327156c3ba8,
1789            >(_buf?)?;
1790            Ok(_response.map(|x| x))
1791        }
1792        self.client.send_query_and_decode::<ManagerCheckNowRequest, ManagerCheckNowResult>(
1793            (options, monitor),
1794            0x4a5a2327156c3ba8,
1795            fidl::encoding::DynamicFlags::empty(),
1796            _decode,
1797        )
1798    }
1799
1800    type PerformPendingRebootResponseFut =
1801        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
1802    fn r#perform_pending_reboot(&self) -> Self::PerformPendingRebootResponseFut {
1803        fn _decode(
1804            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1805        ) -> Result<bool, fidl::Error> {
1806            let _response = fidl::client::decode_transaction_body::<
1807                ManagerPerformPendingRebootResponse,
1808                fidl::encoding::DefaultFuchsiaResourceDialect,
1809                0x69b7d3c620b0879d,
1810            >(_buf?)?;
1811            Ok(_response.rebooting)
1812        }
1813        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
1814            (),
1815            0x69b7d3c620b0879d,
1816            fidl::encoding::DynamicFlags::empty(),
1817            _decode,
1818        )
1819    }
1820
1821    fn r#monitor_all_update_checks(
1822        &self,
1823        mut attempts_monitor: fidl::endpoints::ClientEnd<AttemptsMonitorMarker>,
1824    ) -> Result<(), fidl::Error> {
1825        self.client.send::<ManagerMonitorAllUpdateChecksRequest>(
1826            (attempts_monitor,),
1827            0x436bcf0efab3158b,
1828            fidl::encoding::DynamicFlags::empty(),
1829        )
1830    }
1831}
1832
1833pub struct ManagerEventStream {
1834    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1835}
1836
1837impl std::marker::Unpin for ManagerEventStream {}
1838
1839impl futures::stream::FusedStream for ManagerEventStream {
1840    fn is_terminated(&self) -> bool {
1841        self.event_receiver.is_terminated()
1842    }
1843}
1844
1845impl futures::Stream for ManagerEventStream {
1846    type Item = Result<ManagerEvent, fidl::Error>;
1847
1848    fn poll_next(
1849        mut self: std::pin::Pin<&mut Self>,
1850        cx: &mut std::task::Context<'_>,
1851    ) -> std::task::Poll<Option<Self::Item>> {
1852        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1853            &mut self.event_receiver,
1854            cx
1855        )?) {
1856            Some(buf) => std::task::Poll::Ready(Some(ManagerEvent::decode(buf))),
1857            None => std::task::Poll::Ready(None),
1858        }
1859    }
1860}
1861
1862#[derive(Debug)]
1863pub enum ManagerEvent {}
1864
1865impl ManagerEvent {
1866    /// Decodes a message buffer as a [`ManagerEvent`].
1867    fn decode(
1868        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1869    ) -> Result<ManagerEvent, fidl::Error> {
1870        let (bytes, _handles) = buf.split_mut();
1871        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1872        debug_assert_eq!(tx_header.tx_id, 0);
1873        match tx_header.ordinal {
1874            _ => Err(fidl::Error::UnknownOrdinal {
1875                ordinal: tx_header.ordinal,
1876                protocol_name: <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1877            }),
1878        }
1879    }
1880}
1881
1882/// A Stream of incoming requests for fuchsia.update/Manager.
1883pub struct ManagerRequestStream {
1884    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1885    is_terminated: bool,
1886}
1887
1888impl std::marker::Unpin for ManagerRequestStream {}
1889
1890impl futures::stream::FusedStream for ManagerRequestStream {
1891    fn is_terminated(&self) -> bool {
1892        self.is_terminated
1893    }
1894}
1895
1896impl fidl::endpoints::RequestStream for ManagerRequestStream {
1897    type Protocol = ManagerMarker;
1898    type ControlHandle = ManagerControlHandle;
1899
1900    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1901        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1902    }
1903
1904    fn control_handle(&self) -> Self::ControlHandle {
1905        ManagerControlHandle { inner: self.inner.clone() }
1906    }
1907
1908    fn into_inner(
1909        self,
1910    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1911    {
1912        (self.inner, self.is_terminated)
1913    }
1914
1915    fn from_inner(
1916        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1917        is_terminated: bool,
1918    ) -> Self {
1919        Self { inner, is_terminated }
1920    }
1921}
1922
1923impl futures::Stream for ManagerRequestStream {
1924    type Item = Result<ManagerRequest, fidl::Error>;
1925
1926    fn poll_next(
1927        mut self: std::pin::Pin<&mut Self>,
1928        cx: &mut std::task::Context<'_>,
1929    ) -> std::task::Poll<Option<Self::Item>> {
1930        let this = &mut *self;
1931        if this.inner.check_shutdown(cx) {
1932            this.is_terminated = true;
1933            return std::task::Poll::Ready(None);
1934        }
1935        if this.is_terminated {
1936            panic!("polled ManagerRequestStream after completion");
1937        }
1938        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1939            |bytes, handles| {
1940                match this.inner.channel().read_etc(cx, bytes, handles) {
1941                    std::task::Poll::Ready(Ok(())) => {}
1942                    std::task::Poll::Pending => return std::task::Poll::Pending,
1943                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1944                        this.is_terminated = true;
1945                        return std::task::Poll::Ready(None);
1946                    }
1947                    std::task::Poll::Ready(Err(e)) => {
1948                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1949                            e.into(),
1950                        ))));
1951                    }
1952                }
1953
1954                // A message has been received from the channel
1955                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1956
1957                std::task::Poll::Ready(Some(match header.ordinal {
1958                    0x4a5a2327156c3ba8 => {
1959                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1960                        let mut req = fidl::new_empty!(
1961                            ManagerCheckNowRequest,
1962                            fidl::encoding::DefaultFuchsiaResourceDialect
1963                        );
1964                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerCheckNowRequest>(&header, _body_bytes, handles, &mut req)?;
1965                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
1966                        Ok(ManagerRequest::CheckNow {
1967                            options: req.options,
1968                            monitor: req.monitor,
1969
1970                            responder: ManagerCheckNowResponder {
1971                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1972                                tx_id: header.tx_id,
1973                            },
1974                        })
1975                    }
1976                    0x69b7d3c620b0879d => {
1977                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1978                        let mut req = fidl::new_empty!(
1979                            fidl::encoding::EmptyPayload,
1980                            fidl::encoding::DefaultFuchsiaResourceDialect
1981                        );
1982                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1983                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
1984                        Ok(ManagerRequest::PerformPendingReboot {
1985                            responder: ManagerPerformPendingRebootResponder {
1986                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1987                                tx_id: header.tx_id,
1988                            },
1989                        })
1990                    }
1991                    0x436bcf0efab3158b => {
1992                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1993                        let mut req = fidl::new_empty!(
1994                            ManagerMonitorAllUpdateChecksRequest,
1995                            fidl::encoding::DefaultFuchsiaResourceDialect
1996                        );
1997                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerMonitorAllUpdateChecksRequest>(&header, _body_bytes, handles, &mut req)?;
1998                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
1999                        Ok(ManagerRequest::MonitorAllUpdateChecks {
2000                            attempts_monitor: req.attempts_monitor,
2001
2002                            control_handle,
2003                        })
2004                    }
2005                    _ => Err(fidl::Error::UnknownOrdinal {
2006                        ordinal: header.ordinal,
2007                        protocol_name:
2008                            <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2009                    }),
2010                }))
2011            },
2012        )
2013    }
2014}
2015
2016/// The Manager protocol is used by a client that wishes to either check for an
2017/// update, or follow the status of ongoing updates.
2018///
2019/// The Manager provides a mechanism for checking for updates via the
2020/// [`Manager.CheckNow`] message.
2021#[derive(Debug)]
2022pub enum ManagerRequest {
2023    /// Immediately check for an update, and optionally track the state and
2024    /// progress of that update check.
2025    ///
2026    /// + request `options` Options for how this request should be performed.
2027    ///                     E.g. What kind of entity initiated this request?
2028    ///                     E.g. Is monitoring an existing update check that
2029    ///                          is already in process an acceptable
2030    ///                          alternative?
2031    ///
2032    /// + request `monitor` An interface on which to receive the status events
2033    ///                     for this update check.  The monitor is only valid
2034    ///                     for this single update check, after that it will
2035    ///                     not receive any more notifications and will be
2036    ///                     closed.
2037    ///
2038    /// * error If an update check cannot be started, an error will be returned.
2039    ///         The [`Monitor`], if provided, will not receive any notifications.
2040    CheckNow {
2041        options: CheckOptions,
2042        monitor: Option<fidl::endpoints::ClientEnd<MonitorMarker>>,
2043        responder: ManagerCheckNowResponder,
2044    },
2045    /// Performs any pending reboot of the system into an updated OS, if an
2046    /// update has been staged for the next system startup.
2047    ///
2048    /// Replaced by
2049    /// `fuchsia.power/CollaborativeRebootInitiator.PerformPendingReboot`.
2050    PerformPendingReboot { responder: ManagerPerformPendingRebootResponder },
2051    /// Monitor all update attempts as they start, as well as an in-progress
2052    /// attempt, if there is one.
2053    ///
2054    /// Arguments:
2055    /// * |attempts_monitor| A protocol on which to receive |Monitor| instances
2056    /// as update attempts start.
2057    MonitorAllUpdateChecks {
2058        attempts_monitor: fidl::endpoints::ClientEnd<AttemptsMonitorMarker>,
2059        control_handle: ManagerControlHandle,
2060    },
2061}
2062
2063impl ManagerRequest {
2064    #[allow(irrefutable_let_patterns)]
2065    pub fn into_check_now(
2066        self,
2067    ) -> Option<(
2068        CheckOptions,
2069        Option<fidl::endpoints::ClientEnd<MonitorMarker>>,
2070        ManagerCheckNowResponder,
2071    )> {
2072        if let ManagerRequest::CheckNow { options, monitor, responder } = self {
2073            Some((options, monitor, responder))
2074        } else {
2075            None
2076        }
2077    }
2078
2079    #[allow(irrefutable_let_patterns)]
2080    pub fn into_perform_pending_reboot(self) -> Option<(ManagerPerformPendingRebootResponder)> {
2081        if let ManagerRequest::PerformPendingReboot { responder } = self {
2082            Some((responder))
2083        } else {
2084            None
2085        }
2086    }
2087
2088    #[allow(irrefutable_let_patterns)]
2089    pub fn into_monitor_all_update_checks(
2090        self,
2091    ) -> Option<(fidl::endpoints::ClientEnd<AttemptsMonitorMarker>, ManagerControlHandle)> {
2092        if let ManagerRequest::MonitorAllUpdateChecks { attempts_monitor, control_handle } = self {
2093            Some((attempts_monitor, control_handle))
2094        } else {
2095            None
2096        }
2097    }
2098
2099    /// Name of the method defined in FIDL
2100    pub fn method_name(&self) -> &'static str {
2101        match *self {
2102            ManagerRequest::CheckNow { .. } => "check_now",
2103            ManagerRequest::PerformPendingReboot { .. } => "perform_pending_reboot",
2104            ManagerRequest::MonitorAllUpdateChecks { .. } => "monitor_all_update_checks",
2105        }
2106    }
2107}
2108
2109#[derive(Debug, Clone)]
2110pub struct ManagerControlHandle {
2111    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2112}
2113
2114impl ManagerControlHandle {
2115    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2116        self.inner.shutdown_with_epitaph(status.into())
2117    }
2118}
2119
2120impl fidl::endpoints::ControlHandle for ManagerControlHandle {
2121    fn shutdown(&self) {
2122        self.inner.shutdown()
2123    }
2124
2125    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2126        self.inner.shutdown_with_epitaph(status)
2127    }
2128
2129    fn is_closed(&self) -> bool {
2130        self.inner.channel().is_closed()
2131    }
2132    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2133        self.inner.channel().on_closed()
2134    }
2135
2136    #[cfg(target_os = "fuchsia")]
2137    fn signal_peer(
2138        &self,
2139        clear_mask: zx::Signals,
2140        set_mask: zx::Signals,
2141    ) -> Result<(), zx_status::Status> {
2142        use fidl::Peered;
2143        self.inner.channel().signal_peer(clear_mask, set_mask)
2144    }
2145}
2146
2147impl ManagerControlHandle {}
2148
2149#[must_use = "FIDL methods require a response to be sent"]
2150#[derive(Debug)]
2151pub struct ManagerCheckNowResponder {
2152    control_handle: std::mem::ManuallyDrop<ManagerControlHandle>,
2153    tx_id: u32,
2154}
2155
2156/// Set the the channel to be shutdown (see [`ManagerControlHandle::shutdown`])
2157/// if the responder is dropped without sending a response, so that the client
2158/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2159impl std::ops::Drop for ManagerCheckNowResponder {
2160    fn drop(&mut self) {
2161        self.control_handle.shutdown();
2162        // Safety: drops once, never accessed again
2163        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2164    }
2165}
2166
2167impl fidl::endpoints::Responder for ManagerCheckNowResponder {
2168    type ControlHandle = ManagerControlHandle;
2169
2170    fn control_handle(&self) -> &ManagerControlHandle {
2171        &self.control_handle
2172    }
2173
2174    fn drop_without_shutdown(mut self) {
2175        // Safety: drops once, never accessed again due to mem::forget
2176        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2177        // Prevent Drop from running (which would shut down the channel)
2178        std::mem::forget(self);
2179    }
2180}
2181
2182impl ManagerCheckNowResponder {
2183    /// Sends a response to the FIDL transaction.
2184    ///
2185    /// Sets the channel to shutdown if an error occurs.
2186    pub fn send(self, mut result: Result<(), CheckNotStartedReason>) -> Result<(), fidl::Error> {
2187        let _result = self.send_raw(result);
2188        if _result.is_err() {
2189            self.control_handle.shutdown();
2190        }
2191        self.drop_without_shutdown();
2192        _result
2193    }
2194
2195    /// Similar to "send" but does not shutdown the channel if an error occurs.
2196    pub fn send_no_shutdown_on_err(
2197        self,
2198        mut result: Result<(), CheckNotStartedReason>,
2199    ) -> Result<(), fidl::Error> {
2200        let _result = self.send_raw(result);
2201        self.drop_without_shutdown();
2202        _result
2203    }
2204
2205    fn send_raw(&self, mut result: Result<(), CheckNotStartedReason>) -> Result<(), fidl::Error> {
2206        self.control_handle.inner.send::<fidl::encoding::ResultType<
2207            fidl::encoding::EmptyStruct,
2208            CheckNotStartedReason,
2209        >>(
2210            result,
2211            self.tx_id,
2212            0x4a5a2327156c3ba8,
2213            fidl::encoding::DynamicFlags::empty(),
2214        )
2215    }
2216}
2217
2218#[must_use = "FIDL methods require a response to be sent"]
2219#[derive(Debug)]
2220pub struct ManagerPerformPendingRebootResponder {
2221    control_handle: std::mem::ManuallyDrop<ManagerControlHandle>,
2222    tx_id: u32,
2223}
2224
2225/// Set the the channel to be shutdown (see [`ManagerControlHandle::shutdown`])
2226/// if the responder is dropped without sending a response, so that the client
2227/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2228impl std::ops::Drop for ManagerPerformPendingRebootResponder {
2229    fn drop(&mut self) {
2230        self.control_handle.shutdown();
2231        // Safety: drops once, never accessed again
2232        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2233    }
2234}
2235
2236impl fidl::endpoints::Responder for ManagerPerformPendingRebootResponder {
2237    type ControlHandle = ManagerControlHandle;
2238
2239    fn control_handle(&self) -> &ManagerControlHandle {
2240        &self.control_handle
2241    }
2242
2243    fn drop_without_shutdown(mut self) {
2244        // Safety: drops once, never accessed again due to mem::forget
2245        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2246        // Prevent Drop from running (which would shut down the channel)
2247        std::mem::forget(self);
2248    }
2249}
2250
2251impl ManagerPerformPendingRebootResponder {
2252    /// Sends a response to the FIDL transaction.
2253    ///
2254    /// Sets the channel to shutdown if an error occurs.
2255    pub fn send(self, mut rebooting: bool) -> Result<(), fidl::Error> {
2256        let _result = self.send_raw(rebooting);
2257        if _result.is_err() {
2258            self.control_handle.shutdown();
2259        }
2260        self.drop_without_shutdown();
2261        _result
2262    }
2263
2264    /// Similar to "send" but does not shutdown the channel if an error occurs.
2265    pub fn send_no_shutdown_on_err(self, mut rebooting: bool) -> Result<(), fidl::Error> {
2266        let _result = self.send_raw(rebooting);
2267        self.drop_without_shutdown();
2268        _result
2269    }
2270
2271    fn send_raw(&self, mut rebooting: bool) -> Result<(), fidl::Error> {
2272        self.control_handle.inner.send::<ManagerPerformPendingRebootResponse>(
2273            (rebooting,),
2274            self.tx_id,
2275            0x69b7d3c620b0879d,
2276            fidl::encoding::DynamicFlags::empty(),
2277        )
2278    }
2279}
2280
2281#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2282pub struct MonitorMarker;
2283
2284impl fidl::endpoints::ProtocolMarker for MonitorMarker {
2285    type Proxy = MonitorProxy;
2286    type RequestStream = MonitorRequestStream;
2287    #[cfg(target_os = "fuchsia")]
2288    type SynchronousProxy = MonitorSynchronousProxy;
2289
2290    const DEBUG_NAME: &'static str = "(anonymous) Monitor";
2291}
2292
2293pub trait MonitorProxyInterface: Send + Sync {
2294    type OnStateResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2295    fn r#on_state(&self, state: &State) -> Self::OnStateResponseFut;
2296}
2297#[derive(Debug)]
2298#[cfg(target_os = "fuchsia")]
2299pub struct MonitorSynchronousProxy {
2300    client: fidl::client::sync::Client,
2301}
2302
2303#[cfg(target_os = "fuchsia")]
2304impl fidl::endpoints::SynchronousProxy for MonitorSynchronousProxy {
2305    type Proxy = MonitorProxy;
2306    type Protocol = MonitorMarker;
2307
2308    fn from_channel(inner: fidl::Channel) -> Self {
2309        Self::new(inner)
2310    }
2311
2312    fn into_channel(self) -> fidl::Channel {
2313        self.client.into_channel()
2314    }
2315
2316    fn as_channel(&self) -> &fidl::Channel {
2317        self.client.as_channel()
2318    }
2319}
2320
2321#[cfg(target_os = "fuchsia")]
2322impl MonitorSynchronousProxy {
2323    pub fn new(channel: fidl::Channel) -> Self {
2324        Self { client: fidl::client::sync::Client::new(channel) }
2325    }
2326
2327    pub fn into_channel(self) -> fidl::Channel {
2328        self.client.into_channel()
2329    }
2330
2331    /// Waits until an event arrives and returns it. It is safe for other
2332    /// threads to make concurrent requests while waiting for an event.
2333    pub fn wait_for_event(
2334        &self,
2335        deadline: zx::MonotonicInstant,
2336    ) -> Result<MonitorEvent, fidl::Error> {
2337        MonitorEvent::decode(self.client.wait_for_event::<MonitorMarker>(deadline)?)
2338    }
2339
2340    /// Receives a status update for this update check.
2341    ///
2342    /// This request will be called for all state changes, skipping none.
2343    /// However, message delivery is throttled by the rate at which the
2344    /// implementation acknowledges the messages.
2345    ///
2346    /// The throttled delivery doesn't impact the underlying state of the
2347    /// [`Manager`].  It does not wait for any acknowledgements before it moves
2348    /// on to the next state in its state machine.  The [`Manager`] will simply
2349    /// queue up the states for the [`Monitor`] implementation to receive.
2350    ///
2351    /// During the installing_update state, the [`Manager`] may, at its
2352    /// discretion, collapse redundant information like the fraction completed,
2353    /// in the event that the [`Monitor`] implementation is not responding to
2354    /// the `OnState()` requests in a timely manner.
2355    ///
2356    /// + request `state` The new state of the update check.
2357    /// - response        The implementation is ready to receive the next
2358    ///                   [`State`] from the [`Manager`].
2359    pub fn r#on_state(
2360        &self,
2361        mut state: &State,
2362        ___deadline: zx::MonotonicInstant,
2363    ) -> Result<(), fidl::Error> {
2364        let _response = self
2365            .client
2366            .send_query::<MonitorOnStateRequest, fidl::encoding::EmptyPayload, MonitorMarker>(
2367                (state,),
2368                0x6d3cf4cbb1e41734,
2369                fidl::encoding::DynamicFlags::empty(),
2370                ___deadline,
2371            )?;
2372        Ok(_response)
2373    }
2374}
2375
2376#[cfg(target_os = "fuchsia")]
2377impl From<MonitorSynchronousProxy> for zx::NullableHandle {
2378    fn from(value: MonitorSynchronousProxy) -> Self {
2379        value.into_channel().into()
2380    }
2381}
2382
2383#[cfg(target_os = "fuchsia")]
2384impl From<fidl::Channel> for MonitorSynchronousProxy {
2385    fn from(value: fidl::Channel) -> Self {
2386        Self::new(value)
2387    }
2388}
2389
2390#[cfg(target_os = "fuchsia")]
2391impl fidl::endpoints::FromClient for MonitorSynchronousProxy {
2392    type Protocol = MonitorMarker;
2393
2394    fn from_client(value: fidl::endpoints::ClientEnd<MonitorMarker>) -> Self {
2395        Self::new(value.into_channel())
2396    }
2397}
2398
2399#[derive(Debug, Clone)]
2400pub struct MonitorProxy {
2401    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2402}
2403
2404impl fidl::endpoints::Proxy for MonitorProxy {
2405    type Protocol = MonitorMarker;
2406
2407    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2408        Self::new(inner)
2409    }
2410
2411    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2412        self.client.into_channel().map_err(|client| Self { client })
2413    }
2414
2415    fn as_channel(&self) -> &::fidl::AsyncChannel {
2416        self.client.as_channel()
2417    }
2418}
2419
2420impl MonitorProxy {
2421    /// Create a new Proxy for fuchsia.update/Monitor.
2422    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2423        let protocol_name = <MonitorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2424        Self { client: fidl::client::Client::new(channel, protocol_name) }
2425    }
2426
2427    /// Get a Stream of events from the remote end of the protocol.
2428    ///
2429    /// # Panics
2430    ///
2431    /// Panics if the event stream was already taken.
2432    pub fn take_event_stream(&self) -> MonitorEventStream {
2433        MonitorEventStream { event_receiver: self.client.take_event_receiver() }
2434    }
2435
2436    /// Receives a status update for this update check.
2437    ///
2438    /// This request will be called for all state changes, skipping none.
2439    /// However, message delivery is throttled by the rate at which the
2440    /// implementation acknowledges the messages.
2441    ///
2442    /// The throttled delivery doesn't impact the underlying state of the
2443    /// [`Manager`].  It does not wait for any acknowledgements before it moves
2444    /// on to the next state in its state machine.  The [`Manager`] will simply
2445    /// queue up the states for the [`Monitor`] implementation to receive.
2446    ///
2447    /// During the installing_update state, the [`Manager`] may, at its
2448    /// discretion, collapse redundant information like the fraction completed,
2449    /// in the event that the [`Monitor`] implementation is not responding to
2450    /// the `OnState()` requests in a timely manner.
2451    ///
2452    /// + request `state` The new state of the update check.
2453    /// - response        The implementation is ready to receive the next
2454    ///                   [`State`] from the [`Manager`].
2455    pub fn r#on_state(
2456        &self,
2457        mut state: &State,
2458    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2459        MonitorProxyInterface::r#on_state(self, state)
2460    }
2461}
2462
2463impl MonitorProxyInterface for MonitorProxy {
2464    type OnStateResponseFut =
2465        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2466    fn r#on_state(&self, mut state: &State) -> Self::OnStateResponseFut {
2467        fn _decode(
2468            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2469        ) -> Result<(), fidl::Error> {
2470            let _response = fidl::client::decode_transaction_body::<
2471                fidl::encoding::EmptyPayload,
2472                fidl::encoding::DefaultFuchsiaResourceDialect,
2473                0x6d3cf4cbb1e41734,
2474            >(_buf?)?;
2475            Ok(_response)
2476        }
2477        self.client.send_query_and_decode::<MonitorOnStateRequest, ()>(
2478            (state,),
2479            0x6d3cf4cbb1e41734,
2480            fidl::encoding::DynamicFlags::empty(),
2481            _decode,
2482        )
2483    }
2484}
2485
2486pub struct MonitorEventStream {
2487    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2488}
2489
2490impl std::marker::Unpin for MonitorEventStream {}
2491
2492impl futures::stream::FusedStream for MonitorEventStream {
2493    fn is_terminated(&self) -> bool {
2494        self.event_receiver.is_terminated()
2495    }
2496}
2497
2498impl futures::Stream for MonitorEventStream {
2499    type Item = Result<MonitorEvent, fidl::Error>;
2500
2501    fn poll_next(
2502        mut self: std::pin::Pin<&mut Self>,
2503        cx: &mut std::task::Context<'_>,
2504    ) -> std::task::Poll<Option<Self::Item>> {
2505        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2506            &mut self.event_receiver,
2507            cx
2508        )?) {
2509            Some(buf) => std::task::Poll::Ready(Some(MonitorEvent::decode(buf))),
2510            None => std::task::Poll::Ready(None),
2511        }
2512    }
2513}
2514
2515#[derive(Debug)]
2516pub enum MonitorEvent {}
2517
2518impl MonitorEvent {
2519    /// Decodes a message buffer as a [`MonitorEvent`].
2520    fn decode(
2521        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2522    ) -> Result<MonitorEvent, fidl::Error> {
2523        let (bytes, _handles) = buf.split_mut();
2524        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2525        debug_assert_eq!(tx_header.tx_id, 0);
2526        match tx_header.ordinal {
2527            _ => Err(fidl::Error::UnknownOrdinal {
2528                ordinal: tx_header.ordinal,
2529                protocol_name: <MonitorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2530            }),
2531        }
2532    }
2533}
2534
2535/// A Stream of incoming requests for fuchsia.update/Monitor.
2536pub struct MonitorRequestStream {
2537    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2538    is_terminated: bool,
2539}
2540
2541impl std::marker::Unpin for MonitorRequestStream {}
2542
2543impl futures::stream::FusedStream for MonitorRequestStream {
2544    fn is_terminated(&self) -> bool {
2545        self.is_terminated
2546    }
2547}
2548
2549impl fidl::endpoints::RequestStream for MonitorRequestStream {
2550    type Protocol = MonitorMarker;
2551    type ControlHandle = MonitorControlHandle;
2552
2553    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2554        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2555    }
2556
2557    fn control_handle(&self) -> Self::ControlHandle {
2558        MonitorControlHandle { inner: self.inner.clone() }
2559    }
2560
2561    fn into_inner(
2562        self,
2563    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2564    {
2565        (self.inner, self.is_terminated)
2566    }
2567
2568    fn from_inner(
2569        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2570        is_terminated: bool,
2571    ) -> Self {
2572        Self { inner, is_terminated }
2573    }
2574}
2575
2576impl futures::Stream for MonitorRequestStream {
2577    type Item = Result<MonitorRequest, fidl::Error>;
2578
2579    fn poll_next(
2580        mut self: std::pin::Pin<&mut Self>,
2581        cx: &mut std::task::Context<'_>,
2582    ) -> std::task::Poll<Option<Self::Item>> {
2583        let this = &mut *self;
2584        if this.inner.check_shutdown(cx) {
2585            this.is_terminated = true;
2586            return std::task::Poll::Ready(None);
2587        }
2588        if this.is_terminated {
2589            panic!("polled MonitorRequestStream after completion");
2590        }
2591        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2592            |bytes, handles| {
2593                match this.inner.channel().read_etc(cx, bytes, handles) {
2594                    std::task::Poll::Ready(Ok(())) => {}
2595                    std::task::Poll::Pending => return std::task::Poll::Pending,
2596                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2597                        this.is_terminated = true;
2598                        return std::task::Poll::Ready(None);
2599                    }
2600                    std::task::Poll::Ready(Err(e)) => {
2601                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2602                            e.into(),
2603                        ))));
2604                    }
2605                }
2606
2607                // A message has been received from the channel
2608                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2609
2610                std::task::Poll::Ready(Some(match header.ordinal {
2611                    0x6d3cf4cbb1e41734 => {
2612                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2613                        let mut req = fidl::new_empty!(
2614                            MonitorOnStateRequest,
2615                            fidl::encoding::DefaultFuchsiaResourceDialect
2616                        );
2617                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MonitorOnStateRequest>(&header, _body_bytes, handles, &mut req)?;
2618                        let control_handle = MonitorControlHandle { inner: this.inner.clone() };
2619                        Ok(MonitorRequest::OnState {
2620                            state: req.state,
2621
2622                            responder: MonitorOnStateResponder {
2623                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2624                                tx_id: header.tx_id,
2625                            },
2626                        })
2627                    }
2628                    _ => Err(fidl::Error::UnknownOrdinal {
2629                        ordinal: header.ordinal,
2630                        protocol_name:
2631                            <MonitorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2632                    }),
2633                }))
2634            },
2635        )
2636    }
2637}
2638
2639/// Monitors a single update check.
2640///
2641/// Clients interested in receiving progress information for an update check
2642/// should implement this protocol and provide the client end to
2643/// [`Manager.CheckNow`].
2644#[derive(Debug)]
2645pub enum MonitorRequest {
2646    /// Receives a status update for this update check.
2647    ///
2648    /// This request will be called for all state changes, skipping none.
2649    /// However, message delivery is throttled by the rate at which the
2650    /// implementation acknowledges the messages.
2651    ///
2652    /// The throttled delivery doesn't impact the underlying state of the
2653    /// [`Manager`].  It does not wait for any acknowledgements before it moves
2654    /// on to the next state in its state machine.  The [`Manager`] will simply
2655    /// queue up the states for the [`Monitor`] implementation to receive.
2656    ///
2657    /// During the installing_update state, the [`Manager`] may, at its
2658    /// discretion, collapse redundant information like the fraction completed,
2659    /// in the event that the [`Monitor`] implementation is not responding to
2660    /// the `OnState()` requests in a timely manner.
2661    ///
2662    /// + request `state` The new state of the update check.
2663    /// - response        The implementation is ready to receive the next
2664    ///                   [`State`] from the [`Manager`].
2665    OnState { state: State, responder: MonitorOnStateResponder },
2666}
2667
2668impl MonitorRequest {
2669    #[allow(irrefutable_let_patterns)]
2670    pub fn into_on_state(self) -> Option<(State, MonitorOnStateResponder)> {
2671        if let MonitorRequest::OnState { state, responder } = self {
2672            Some((state, responder))
2673        } else {
2674            None
2675        }
2676    }
2677
2678    /// Name of the method defined in FIDL
2679    pub fn method_name(&self) -> &'static str {
2680        match *self {
2681            MonitorRequest::OnState { .. } => "on_state",
2682        }
2683    }
2684}
2685
2686#[derive(Debug, Clone)]
2687pub struct MonitorControlHandle {
2688    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2689}
2690
2691impl MonitorControlHandle {
2692    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2693        self.inner.shutdown_with_epitaph(status.into())
2694    }
2695}
2696
2697impl fidl::endpoints::ControlHandle for MonitorControlHandle {
2698    fn shutdown(&self) {
2699        self.inner.shutdown()
2700    }
2701
2702    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2703        self.inner.shutdown_with_epitaph(status)
2704    }
2705
2706    fn is_closed(&self) -> bool {
2707        self.inner.channel().is_closed()
2708    }
2709    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2710        self.inner.channel().on_closed()
2711    }
2712
2713    #[cfg(target_os = "fuchsia")]
2714    fn signal_peer(
2715        &self,
2716        clear_mask: zx::Signals,
2717        set_mask: zx::Signals,
2718    ) -> Result<(), zx_status::Status> {
2719        use fidl::Peered;
2720        self.inner.channel().signal_peer(clear_mask, set_mask)
2721    }
2722}
2723
2724impl MonitorControlHandle {}
2725
2726#[must_use = "FIDL methods require a response to be sent"]
2727#[derive(Debug)]
2728pub struct MonitorOnStateResponder {
2729    control_handle: std::mem::ManuallyDrop<MonitorControlHandle>,
2730    tx_id: u32,
2731}
2732
2733/// Set the the channel to be shutdown (see [`MonitorControlHandle::shutdown`])
2734/// if the responder is dropped without sending a response, so that the client
2735/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2736impl std::ops::Drop for MonitorOnStateResponder {
2737    fn drop(&mut self) {
2738        self.control_handle.shutdown();
2739        // Safety: drops once, never accessed again
2740        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2741    }
2742}
2743
2744impl fidl::endpoints::Responder for MonitorOnStateResponder {
2745    type ControlHandle = MonitorControlHandle;
2746
2747    fn control_handle(&self) -> &MonitorControlHandle {
2748        &self.control_handle
2749    }
2750
2751    fn drop_without_shutdown(mut self) {
2752        // Safety: drops once, never accessed again due to mem::forget
2753        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2754        // Prevent Drop from running (which would shut down the channel)
2755        std::mem::forget(self);
2756    }
2757}
2758
2759impl MonitorOnStateResponder {
2760    /// Sends a response to the FIDL transaction.
2761    ///
2762    /// Sets the channel to shutdown if an error occurs.
2763    pub fn send(self) -> Result<(), fidl::Error> {
2764        let _result = self.send_raw();
2765        if _result.is_err() {
2766            self.control_handle.shutdown();
2767        }
2768        self.drop_without_shutdown();
2769        _result
2770    }
2771
2772    /// Similar to "send" but does not shutdown the channel if an error occurs.
2773    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2774        let _result = self.send_raw();
2775        self.drop_without_shutdown();
2776        _result
2777    }
2778
2779    fn send_raw(&self) -> Result<(), fidl::Error> {
2780        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2781            (),
2782            self.tx_id,
2783            0x6d3cf4cbb1e41734,
2784            fidl::encoding::DynamicFlags::empty(),
2785        )
2786    }
2787}
2788
2789#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2790pub struct NotifierMarker;
2791
2792impl fidl::endpoints::ProtocolMarker for NotifierMarker {
2793    type Proxy = NotifierProxy;
2794    type RequestStream = NotifierRequestStream;
2795    #[cfg(target_os = "fuchsia")]
2796    type SynchronousProxy = NotifierSynchronousProxy;
2797
2798    const DEBUG_NAME: &'static str = "fuchsia.update.Notifier";
2799}
2800impl fidl::endpoints::DiscoverableProtocolMarker for NotifierMarker {}
2801
2802pub trait NotifierProxyInterface: Send + Sync {
2803    fn r#notify(&self) -> Result<(), fidl::Error>;
2804}
2805#[derive(Debug)]
2806#[cfg(target_os = "fuchsia")]
2807pub struct NotifierSynchronousProxy {
2808    client: fidl::client::sync::Client,
2809}
2810
2811#[cfg(target_os = "fuchsia")]
2812impl fidl::endpoints::SynchronousProxy for NotifierSynchronousProxy {
2813    type Proxy = NotifierProxy;
2814    type Protocol = NotifierMarker;
2815
2816    fn from_channel(inner: fidl::Channel) -> Self {
2817        Self::new(inner)
2818    }
2819
2820    fn into_channel(self) -> fidl::Channel {
2821        self.client.into_channel()
2822    }
2823
2824    fn as_channel(&self) -> &fidl::Channel {
2825        self.client.as_channel()
2826    }
2827}
2828
2829#[cfg(target_os = "fuchsia")]
2830impl NotifierSynchronousProxy {
2831    pub fn new(channel: fidl::Channel) -> Self {
2832        Self { client: fidl::client::sync::Client::new(channel) }
2833    }
2834
2835    pub fn into_channel(self) -> fidl::Channel {
2836        self.client.into_channel()
2837    }
2838
2839    /// Waits until an event arrives and returns it. It is safe for other
2840    /// threads to make concurrent requests while waiting for an event.
2841    pub fn wait_for_event(
2842        &self,
2843        deadline: zx::MonotonicInstant,
2844    ) -> Result<NotifierEvent, fidl::Error> {
2845        NotifierEvent::decode(self.client.wait_for_event::<NotifierMarker>(deadline)?)
2846    }
2847
2848    /// Notify is called when the software update checker has completed its
2849    /// post-boot check (with or without error) and is not trying to reboot.
2850    pub fn r#notify(&self) -> Result<(), fidl::Error> {
2851        self.client.send::<fidl::encoding::EmptyPayload>(
2852            (),
2853            0x2506bf46404d3060,
2854            fidl::encoding::DynamicFlags::empty(),
2855        )
2856    }
2857}
2858
2859#[cfg(target_os = "fuchsia")]
2860impl From<NotifierSynchronousProxy> for zx::NullableHandle {
2861    fn from(value: NotifierSynchronousProxy) -> Self {
2862        value.into_channel().into()
2863    }
2864}
2865
2866#[cfg(target_os = "fuchsia")]
2867impl From<fidl::Channel> for NotifierSynchronousProxy {
2868    fn from(value: fidl::Channel) -> Self {
2869        Self::new(value)
2870    }
2871}
2872
2873#[cfg(target_os = "fuchsia")]
2874impl fidl::endpoints::FromClient for NotifierSynchronousProxy {
2875    type Protocol = NotifierMarker;
2876
2877    fn from_client(value: fidl::endpoints::ClientEnd<NotifierMarker>) -> Self {
2878        Self::new(value.into_channel())
2879    }
2880}
2881
2882#[derive(Debug, Clone)]
2883pub struct NotifierProxy {
2884    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2885}
2886
2887impl fidl::endpoints::Proxy for NotifierProxy {
2888    type Protocol = NotifierMarker;
2889
2890    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2891        Self::new(inner)
2892    }
2893
2894    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2895        self.client.into_channel().map_err(|client| Self { client })
2896    }
2897
2898    fn as_channel(&self) -> &::fidl::AsyncChannel {
2899        self.client.as_channel()
2900    }
2901}
2902
2903impl NotifierProxy {
2904    /// Create a new Proxy for fuchsia.update/Notifier.
2905    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2906        let protocol_name = <NotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2907        Self { client: fidl::client::Client::new(channel, protocol_name) }
2908    }
2909
2910    /// Get a Stream of events from the remote end of the protocol.
2911    ///
2912    /// # Panics
2913    ///
2914    /// Panics if the event stream was already taken.
2915    pub fn take_event_stream(&self) -> NotifierEventStream {
2916        NotifierEventStream { event_receiver: self.client.take_event_receiver() }
2917    }
2918
2919    /// Notify is called when the software update checker has completed its
2920    /// post-boot check (with or without error) and is not trying to reboot.
2921    pub fn r#notify(&self) -> Result<(), fidl::Error> {
2922        NotifierProxyInterface::r#notify(self)
2923    }
2924}
2925
2926impl NotifierProxyInterface for NotifierProxy {
2927    fn r#notify(&self) -> Result<(), fidl::Error> {
2928        self.client.send::<fidl::encoding::EmptyPayload>(
2929            (),
2930            0x2506bf46404d3060,
2931            fidl::encoding::DynamicFlags::empty(),
2932        )
2933    }
2934}
2935
2936pub struct NotifierEventStream {
2937    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2938}
2939
2940impl std::marker::Unpin for NotifierEventStream {}
2941
2942impl futures::stream::FusedStream for NotifierEventStream {
2943    fn is_terminated(&self) -> bool {
2944        self.event_receiver.is_terminated()
2945    }
2946}
2947
2948impl futures::Stream for NotifierEventStream {
2949    type Item = Result<NotifierEvent, fidl::Error>;
2950
2951    fn poll_next(
2952        mut self: std::pin::Pin<&mut Self>,
2953        cx: &mut std::task::Context<'_>,
2954    ) -> std::task::Poll<Option<Self::Item>> {
2955        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2956            &mut self.event_receiver,
2957            cx
2958        )?) {
2959            Some(buf) => std::task::Poll::Ready(Some(NotifierEvent::decode(buf))),
2960            None => std::task::Poll::Ready(None),
2961        }
2962    }
2963}
2964
2965#[derive(Debug)]
2966pub enum NotifierEvent {}
2967
2968impl NotifierEvent {
2969    /// Decodes a message buffer as a [`NotifierEvent`].
2970    fn decode(
2971        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2972    ) -> Result<NotifierEvent, fidl::Error> {
2973        let (bytes, _handles) = buf.split_mut();
2974        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2975        debug_assert_eq!(tx_header.tx_id, 0);
2976        match tx_header.ordinal {
2977            _ => Err(fidl::Error::UnknownOrdinal {
2978                ordinal: tx_header.ordinal,
2979                protocol_name: <NotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2980            }),
2981        }
2982    }
2983}
2984
2985/// A Stream of incoming requests for fuchsia.update/Notifier.
2986pub struct NotifierRequestStream {
2987    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2988    is_terminated: bool,
2989}
2990
2991impl std::marker::Unpin for NotifierRequestStream {}
2992
2993impl futures::stream::FusedStream for NotifierRequestStream {
2994    fn is_terminated(&self) -> bool {
2995        self.is_terminated
2996    }
2997}
2998
2999impl fidl::endpoints::RequestStream for NotifierRequestStream {
3000    type Protocol = NotifierMarker;
3001    type ControlHandle = NotifierControlHandle;
3002
3003    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3004        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3005    }
3006
3007    fn control_handle(&self) -> Self::ControlHandle {
3008        NotifierControlHandle { inner: self.inner.clone() }
3009    }
3010
3011    fn into_inner(
3012        self,
3013    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3014    {
3015        (self.inner, self.is_terminated)
3016    }
3017
3018    fn from_inner(
3019        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3020        is_terminated: bool,
3021    ) -> Self {
3022        Self { inner, is_terminated }
3023    }
3024}
3025
3026impl futures::Stream for NotifierRequestStream {
3027    type Item = Result<NotifierRequest, fidl::Error>;
3028
3029    fn poll_next(
3030        mut self: std::pin::Pin<&mut Self>,
3031        cx: &mut std::task::Context<'_>,
3032    ) -> std::task::Poll<Option<Self::Item>> {
3033        let this = &mut *self;
3034        if this.inner.check_shutdown(cx) {
3035            this.is_terminated = true;
3036            return std::task::Poll::Ready(None);
3037        }
3038        if this.is_terminated {
3039            panic!("polled NotifierRequestStream after completion");
3040        }
3041        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3042            |bytes, handles| {
3043                match this.inner.channel().read_etc(cx, bytes, handles) {
3044                    std::task::Poll::Ready(Ok(())) => {}
3045                    std::task::Poll::Pending => return std::task::Poll::Pending,
3046                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3047                        this.is_terminated = true;
3048                        return std::task::Poll::Ready(None);
3049                    }
3050                    std::task::Poll::Ready(Err(e)) => {
3051                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3052                            e.into(),
3053                        ))));
3054                    }
3055                }
3056
3057                // A message has been received from the channel
3058                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3059
3060                std::task::Poll::Ready(Some(match header.ordinal {
3061                    0x2506bf46404d3060 => {
3062                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3063                        let mut req = fidl::new_empty!(
3064                            fidl::encoding::EmptyPayload,
3065                            fidl::encoding::DefaultFuchsiaResourceDialect
3066                        );
3067                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3068                        let control_handle = NotifierControlHandle { inner: this.inner.clone() };
3069                        Ok(NotifierRequest::Notify { control_handle })
3070                    }
3071                    _ => Err(fidl::Error::UnknownOrdinal {
3072                        ordinal: header.ordinal,
3073                        protocol_name:
3074                            <NotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3075                    }),
3076                }))
3077            },
3078        )
3079    }
3080}
3081
3082/// Notifier for [`Listener`].
3083#[derive(Debug)]
3084pub enum NotifierRequest {
3085    /// Notify is called when the software update checker has completed its
3086    /// post-boot check (with or without error) and is not trying to reboot.
3087    Notify { control_handle: NotifierControlHandle },
3088}
3089
3090impl NotifierRequest {
3091    #[allow(irrefutable_let_patterns)]
3092    pub fn into_notify(self) -> Option<(NotifierControlHandle)> {
3093        if let NotifierRequest::Notify { control_handle } = self {
3094            Some((control_handle))
3095        } else {
3096            None
3097        }
3098    }
3099
3100    /// Name of the method defined in FIDL
3101    pub fn method_name(&self) -> &'static str {
3102        match *self {
3103            NotifierRequest::Notify { .. } => "notify",
3104        }
3105    }
3106}
3107
3108#[derive(Debug, Clone)]
3109pub struct NotifierControlHandle {
3110    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3111}
3112
3113impl NotifierControlHandle {
3114    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3115        self.inner.shutdown_with_epitaph(status.into())
3116    }
3117}
3118
3119impl fidl::endpoints::ControlHandle for NotifierControlHandle {
3120    fn shutdown(&self) {
3121        self.inner.shutdown()
3122    }
3123
3124    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3125        self.inner.shutdown_with_epitaph(status)
3126    }
3127
3128    fn is_closed(&self) -> bool {
3129        self.inner.channel().is_closed()
3130    }
3131    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3132        self.inner.channel().on_closed()
3133    }
3134
3135    #[cfg(target_os = "fuchsia")]
3136    fn signal_peer(
3137        &self,
3138        clear_mask: zx::Signals,
3139        set_mask: zx::Signals,
3140    ) -> Result<(), zx_status::Status> {
3141        use fidl::Peered;
3142        self.inner.channel().signal_peer(clear_mask, set_mask)
3143    }
3144}
3145
3146impl NotifierControlHandle {}
3147
3148mod internal {
3149    use super::*;
3150
3151    impl fidl::encoding::ResourceTypeMarker for AttemptsMonitorOnStartRequest {
3152        type Borrowed<'a> = &'a mut Self;
3153        fn take_or_borrow<'a>(
3154            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3155        ) -> Self::Borrowed<'a> {
3156            value
3157        }
3158    }
3159
3160    unsafe impl fidl::encoding::TypeMarker for AttemptsMonitorOnStartRequest {
3161        type Owned = Self;
3162
3163        #[inline(always)]
3164        fn inline_align(_context: fidl::encoding::Context) -> usize {
3165            8
3166        }
3167
3168        #[inline(always)]
3169        fn inline_size(_context: fidl::encoding::Context) -> usize {
3170            24
3171        }
3172    }
3173
3174    unsafe impl
3175        fidl::encoding::Encode<
3176            AttemptsMonitorOnStartRequest,
3177            fidl::encoding::DefaultFuchsiaResourceDialect,
3178        > for &mut AttemptsMonitorOnStartRequest
3179    {
3180        #[inline]
3181        unsafe fn encode(
3182            self,
3183            encoder: &mut fidl::encoding::Encoder<
3184                '_,
3185                fidl::encoding::DefaultFuchsiaResourceDialect,
3186            >,
3187            offset: usize,
3188            _depth: fidl::encoding::Depth,
3189        ) -> fidl::Result<()> {
3190            encoder.debug_check_bounds::<AttemptsMonitorOnStartRequest>(offset);
3191            // Delegate to tuple encoding.
3192            fidl::encoding::Encode::<AttemptsMonitorOnStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3193                (
3194                    <AttemptOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
3195                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MonitorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.monitor),
3196                ),
3197                encoder, offset, _depth
3198            )
3199        }
3200    }
3201    unsafe impl<
3202        T0: fidl::encoding::Encode<AttemptOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
3203        T1: fidl::encoding::Encode<
3204                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MonitorMarker>>,
3205                fidl::encoding::DefaultFuchsiaResourceDialect,
3206            >,
3207    >
3208        fidl::encoding::Encode<
3209            AttemptsMonitorOnStartRequest,
3210            fidl::encoding::DefaultFuchsiaResourceDialect,
3211        > for (T0, T1)
3212    {
3213        #[inline]
3214        unsafe fn encode(
3215            self,
3216            encoder: &mut fidl::encoding::Encoder<
3217                '_,
3218                fidl::encoding::DefaultFuchsiaResourceDialect,
3219            >,
3220            offset: usize,
3221            depth: fidl::encoding::Depth,
3222        ) -> fidl::Result<()> {
3223            encoder.debug_check_bounds::<AttemptsMonitorOnStartRequest>(offset);
3224            // Zero out padding regions. There's no need to apply masks
3225            // because the unmasked parts will be overwritten by fields.
3226            unsafe {
3227                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3228                (ptr as *mut u64).write_unaligned(0);
3229            }
3230            // Write the fields.
3231            self.0.encode(encoder, offset + 0, depth)?;
3232            self.1.encode(encoder, offset + 16, depth)?;
3233            Ok(())
3234        }
3235    }
3236
3237    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3238        for AttemptsMonitorOnStartRequest
3239    {
3240        #[inline(always)]
3241        fn new_empty() -> Self {
3242            Self {
3243                options: fidl::new_empty!(
3244                    AttemptOptions,
3245                    fidl::encoding::DefaultFuchsiaResourceDialect
3246                ),
3247                monitor: fidl::new_empty!(
3248                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MonitorMarker>>,
3249                    fidl::encoding::DefaultFuchsiaResourceDialect
3250                ),
3251            }
3252        }
3253
3254        #[inline]
3255        unsafe fn decode(
3256            &mut self,
3257            decoder: &mut fidl::encoding::Decoder<
3258                '_,
3259                fidl::encoding::DefaultFuchsiaResourceDialect,
3260            >,
3261            offset: usize,
3262            _depth: fidl::encoding::Depth,
3263        ) -> fidl::Result<()> {
3264            decoder.debug_check_bounds::<Self>(offset);
3265            // Verify that padding bytes are zero.
3266            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3267            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3268            let mask = 0xffffffff00000000u64;
3269            let maskedval = padval & mask;
3270            if maskedval != 0 {
3271                return Err(fidl::Error::NonZeroPadding {
3272                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3273                });
3274            }
3275            fidl::decode!(
3276                AttemptOptions,
3277                fidl::encoding::DefaultFuchsiaResourceDialect,
3278                &mut self.options,
3279                decoder,
3280                offset + 0,
3281                _depth
3282            )?;
3283            fidl::decode!(
3284                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MonitorMarker>>,
3285                fidl::encoding::DefaultFuchsiaResourceDialect,
3286                &mut self.monitor,
3287                decoder,
3288                offset + 16,
3289                _depth
3290            )?;
3291            Ok(())
3292        }
3293    }
3294
3295    impl fidl::encoding::ResourceTypeMarker for CommitStatusProviderIsCurrentSystemCommittedResponse {
3296        type Borrowed<'a> = &'a mut Self;
3297        fn take_or_borrow<'a>(
3298            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3299        ) -> Self::Borrowed<'a> {
3300            value
3301        }
3302    }
3303
3304    unsafe impl fidl::encoding::TypeMarker for CommitStatusProviderIsCurrentSystemCommittedResponse {
3305        type Owned = Self;
3306
3307        #[inline(always)]
3308        fn inline_align(_context: fidl::encoding::Context) -> usize {
3309            4
3310        }
3311
3312        #[inline(always)]
3313        fn inline_size(_context: fidl::encoding::Context) -> usize {
3314            4
3315        }
3316    }
3317
3318    unsafe impl
3319        fidl::encoding::Encode<
3320            CommitStatusProviderIsCurrentSystemCommittedResponse,
3321            fidl::encoding::DefaultFuchsiaResourceDialect,
3322        > for &mut CommitStatusProviderIsCurrentSystemCommittedResponse
3323    {
3324        #[inline]
3325        unsafe fn encode(
3326            self,
3327            encoder: &mut fidl::encoding::Encoder<
3328                '_,
3329                fidl::encoding::DefaultFuchsiaResourceDialect,
3330            >,
3331            offset: usize,
3332            _depth: fidl::encoding::Depth,
3333        ) -> fidl::Result<()> {
3334            encoder
3335                .debug_check_bounds::<CommitStatusProviderIsCurrentSystemCommittedResponse>(offset);
3336            // Delegate to tuple encoding.
3337            fidl::encoding::Encode::<
3338                CommitStatusProviderIsCurrentSystemCommittedResponse,
3339                fidl::encoding::DefaultFuchsiaResourceDialect,
3340            >::encode(
3341                (<fidl::encoding::HandleType<
3342                    fidl::EventPair,
3343                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3344                    2147483648,
3345                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3346                    &mut self.event
3347                ),),
3348                encoder,
3349                offset,
3350                _depth,
3351            )
3352        }
3353    }
3354    unsafe impl<
3355        T0: fidl::encoding::Encode<
3356                fidl::encoding::HandleType<
3357                    fidl::EventPair,
3358                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3359                    2147483648,
3360                >,
3361                fidl::encoding::DefaultFuchsiaResourceDialect,
3362            >,
3363    >
3364        fidl::encoding::Encode<
3365            CommitStatusProviderIsCurrentSystemCommittedResponse,
3366            fidl::encoding::DefaultFuchsiaResourceDialect,
3367        > for (T0,)
3368    {
3369        #[inline]
3370        unsafe fn encode(
3371            self,
3372            encoder: &mut fidl::encoding::Encoder<
3373                '_,
3374                fidl::encoding::DefaultFuchsiaResourceDialect,
3375            >,
3376            offset: usize,
3377            depth: fidl::encoding::Depth,
3378        ) -> fidl::Result<()> {
3379            encoder
3380                .debug_check_bounds::<CommitStatusProviderIsCurrentSystemCommittedResponse>(offset);
3381            // Zero out padding regions. There's no need to apply masks
3382            // because the unmasked parts will be overwritten by fields.
3383            // Write the fields.
3384            self.0.encode(encoder, offset + 0, depth)?;
3385            Ok(())
3386        }
3387    }
3388
3389    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3390        for CommitStatusProviderIsCurrentSystemCommittedResponse
3391    {
3392        #[inline(always)]
3393        fn new_empty() -> Self {
3394            Self {
3395                event: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3396            }
3397        }
3398
3399        #[inline]
3400        unsafe fn decode(
3401            &mut self,
3402            decoder: &mut fidl::encoding::Decoder<
3403                '_,
3404                fidl::encoding::DefaultFuchsiaResourceDialect,
3405            >,
3406            offset: usize,
3407            _depth: fidl::encoding::Depth,
3408        ) -> fidl::Result<()> {
3409            decoder.debug_check_bounds::<Self>(offset);
3410            // Verify that padding bytes are zero.
3411            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 0, _depth)?;
3412            Ok(())
3413        }
3414    }
3415
3416    impl fidl::encoding::ResourceTypeMarker for ManagerCheckNowRequest {
3417        type Borrowed<'a> = &'a mut Self;
3418        fn take_or_borrow<'a>(
3419            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3420        ) -> Self::Borrowed<'a> {
3421            value
3422        }
3423    }
3424
3425    unsafe impl fidl::encoding::TypeMarker for ManagerCheckNowRequest {
3426        type Owned = Self;
3427
3428        #[inline(always)]
3429        fn inline_align(_context: fidl::encoding::Context) -> usize {
3430            8
3431        }
3432
3433        #[inline(always)]
3434        fn inline_size(_context: fidl::encoding::Context) -> usize {
3435            24
3436        }
3437    }
3438
3439    unsafe impl
3440        fidl::encoding::Encode<
3441            ManagerCheckNowRequest,
3442            fidl::encoding::DefaultFuchsiaResourceDialect,
3443        > for &mut ManagerCheckNowRequest
3444    {
3445        #[inline]
3446        unsafe fn encode(
3447            self,
3448            encoder: &mut fidl::encoding::Encoder<
3449                '_,
3450                fidl::encoding::DefaultFuchsiaResourceDialect,
3451            >,
3452            offset: usize,
3453            _depth: fidl::encoding::Depth,
3454        ) -> fidl::Result<()> {
3455            encoder.debug_check_bounds::<ManagerCheckNowRequest>(offset);
3456            // Delegate to tuple encoding.
3457            fidl::encoding::Encode::<
3458                ManagerCheckNowRequest,
3459                fidl::encoding::DefaultFuchsiaResourceDialect,
3460            >::encode(
3461                (
3462                    <CheckOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
3463                    <fidl::encoding::Optional<
3464                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<MonitorMarker>>,
3465                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3466                        &mut self.monitor
3467                    ),
3468                ),
3469                encoder,
3470                offset,
3471                _depth,
3472            )
3473        }
3474    }
3475    unsafe impl<
3476        T0: fidl::encoding::Encode<CheckOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
3477        T1: fidl::encoding::Encode<
3478                fidl::encoding::Optional<
3479                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<MonitorMarker>>,
3480                >,
3481                fidl::encoding::DefaultFuchsiaResourceDialect,
3482            >,
3483    >
3484        fidl::encoding::Encode<
3485            ManagerCheckNowRequest,
3486            fidl::encoding::DefaultFuchsiaResourceDialect,
3487        > for (T0, T1)
3488    {
3489        #[inline]
3490        unsafe fn encode(
3491            self,
3492            encoder: &mut fidl::encoding::Encoder<
3493                '_,
3494                fidl::encoding::DefaultFuchsiaResourceDialect,
3495            >,
3496            offset: usize,
3497            depth: fidl::encoding::Depth,
3498        ) -> fidl::Result<()> {
3499            encoder.debug_check_bounds::<ManagerCheckNowRequest>(offset);
3500            // Zero out padding regions. There's no need to apply masks
3501            // because the unmasked parts will be overwritten by fields.
3502            unsafe {
3503                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3504                (ptr as *mut u64).write_unaligned(0);
3505            }
3506            // Write the fields.
3507            self.0.encode(encoder, offset + 0, depth)?;
3508            self.1.encode(encoder, offset + 16, depth)?;
3509            Ok(())
3510        }
3511    }
3512
3513    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3514        for ManagerCheckNowRequest
3515    {
3516        #[inline(always)]
3517        fn new_empty() -> Self {
3518            Self {
3519                options: fidl::new_empty!(
3520                    CheckOptions,
3521                    fidl::encoding::DefaultFuchsiaResourceDialect
3522                ),
3523                monitor: fidl::new_empty!(
3524                    fidl::encoding::Optional<
3525                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<MonitorMarker>>,
3526                    >,
3527                    fidl::encoding::DefaultFuchsiaResourceDialect
3528                ),
3529            }
3530        }
3531
3532        #[inline]
3533        unsafe fn decode(
3534            &mut self,
3535            decoder: &mut fidl::encoding::Decoder<
3536                '_,
3537                fidl::encoding::DefaultFuchsiaResourceDialect,
3538            >,
3539            offset: usize,
3540            _depth: fidl::encoding::Depth,
3541        ) -> fidl::Result<()> {
3542            decoder.debug_check_bounds::<Self>(offset);
3543            // Verify that padding bytes are zero.
3544            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3545            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3546            let mask = 0xffffffff00000000u64;
3547            let maskedval = padval & mask;
3548            if maskedval != 0 {
3549                return Err(fidl::Error::NonZeroPadding {
3550                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3551                });
3552            }
3553            fidl::decode!(
3554                CheckOptions,
3555                fidl::encoding::DefaultFuchsiaResourceDialect,
3556                &mut self.options,
3557                decoder,
3558                offset + 0,
3559                _depth
3560            )?;
3561            fidl::decode!(
3562                fidl::encoding::Optional<
3563                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<MonitorMarker>>,
3564                >,
3565                fidl::encoding::DefaultFuchsiaResourceDialect,
3566                &mut self.monitor,
3567                decoder,
3568                offset + 16,
3569                _depth
3570            )?;
3571            Ok(())
3572        }
3573    }
3574
3575    impl fidl::encoding::ResourceTypeMarker for ManagerMonitorAllUpdateChecksRequest {
3576        type Borrowed<'a> = &'a mut Self;
3577        fn take_or_borrow<'a>(
3578            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3579        ) -> Self::Borrowed<'a> {
3580            value
3581        }
3582    }
3583
3584    unsafe impl fidl::encoding::TypeMarker for ManagerMonitorAllUpdateChecksRequest {
3585        type Owned = Self;
3586
3587        #[inline(always)]
3588        fn inline_align(_context: fidl::encoding::Context) -> usize {
3589            4
3590        }
3591
3592        #[inline(always)]
3593        fn inline_size(_context: fidl::encoding::Context) -> usize {
3594            4
3595        }
3596    }
3597
3598    unsafe impl
3599        fidl::encoding::Encode<
3600            ManagerMonitorAllUpdateChecksRequest,
3601            fidl::encoding::DefaultFuchsiaResourceDialect,
3602        > for &mut ManagerMonitorAllUpdateChecksRequest
3603    {
3604        #[inline]
3605        unsafe fn encode(
3606            self,
3607            encoder: &mut fidl::encoding::Encoder<
3608                '_,
3609                fidl::encoding::DefaultFuchsiaResourceDialect,
3610            >,
3611            offset: usize,
3612            _depth: fidl::encoding::Depth,
3613        ) -> fidl::Result<()> {
3614            encoder.debug_check_bounds::<ManagerMonitorAllUpdateChecksRequest>(offset);
3615            // Delegate to tuple encoding.
3616            fidl::encoding::Encode::<ManagerMonitorAllUpdateChecksRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3617                (
3618                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AttemptsMonitorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.attempts_monitor),
3619                ),
3620                encoder, offset, _depth
3621            )
3622        }
3623    }
3624    unsafe impl<
3625        T0: fidl::encoding::Encode<
3626                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AttemptsMonitorMarker>>,
3627                fidl::encoding::DefaultFuchsiaResourceDialect,
3628            >,
3629    >
3630        fidl::encoding::Encode<
3631            ManagerMonitorAllUpdateChecksRequest,
3632            fidl::encoding::DefaultFuchsiaResourceDialect,
3633        > for (T0,)
3634    {
3635        #[inline]
3636        unsafe fn encode(
3637            self,
3638            encoder: &mut fidl::encoding::Encoder<
3639                '_,
3640                fidl::encoding::DefaultFuchsiaResourceDialect,
3641            >,
3642            offset: usize,
3643            depth: fidl::encoding::Depth,
3644        ) -> fidl::Result<()> {
3645            encoder.debug_check_bounds::<ManagerMonitorAllUpdateChecksRequest>(offset);
3646            // Zero out padding regions. There's no need to apply masks
3647            // because the unmasked parts will be overwritten by fields.
3648            // Write the fields.
3649            self.0.encode(encoder, offset + 0, depth)?;
3650            Ok(())
3651        }
3652    }
3653
3654    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3655        for ManagerMonitorAllUpdateChecksRequest
3656    {
3657        #[inline(always)]
3658        fn new_empty() -> Self {
3659            Self {
3660                attempts_monitor: fidl::new_empty!(
3661                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AttemptsMonitorMarker>>,
3662                    fidl::encoding::DefaultFuchsiaResourceDialect
3663                ),
3664            }
3665        }
3666
3667        #[inline]
3668        unsafe fn decode(
3669            &mut self,
3670            decoder: &mut fidl::encoding::Decoder<
3671                '_,
3672                fidl::encoding::DefaultFuchsiaResourceDialect,
3673            >,
3674            offset: usize,
3675            _depth: fidl::encoding::Depth,
3676        ) -> fidl::Result<()> {
3677            decoder.debug_check_bounds::<Self>(offset);
3678            // Verify that padding bytes are zero.
3679            fidl::decode!(
3680                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<AttemptsMonitorMarker>>,
3681                fidl::encoding::DefaultFuchsiaResourceDialect,
3682                &mut self.attempts_monitor,
3683                decoder,
3684                offset + 0,
3685                _depth
3686            )?;
3687            Ok(())
3688        }
3689    }
3690
3691    impl ListenerNotifyOnFirstUpdateCheckRequest {
3692        #[inline(always)]
3693        fn max_ordinal_present(&self) -> u64 {
3694            if let Some(_) = self.notifier {
3695                return 1;
3696            }
3697            0
3698        }
3699    }
3700
3701    impl fidl::encoding::ResourceTypeMarker for ListenerNotifyOnFirstUpdateCheckRequest {
3702        type Borrowed<'a> = &'a mut Self;
3703        fn take_or_borrow<'a>(
3704            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3705        ) -> Self::Borrowed<'a> {
3706            value
3707        }
3708    }
3709
3710    unsafe impl fidl::encoding::TypeMarker for ListenerNotifyOnFirstUpdateCheckRequest {
3711        type Owned = Self;
3712
3713        #[inline(always)]
3714        fn inline_align(_context: fidl::encoding::Context) -> usize {
3715            8
3716        }
3717
3718        #[inline(always)]
3719        fn inline_size(_context: fidl::encoding::Context) -> usize {
3720            16
3721        }
3722    }
3723
3724    unsafe impl
3725        fidl::encoding::Encode<
3726            ListenerNotifyOnFirstUpdateCheckRequest,
3727            fidl::encoding::DefaultFuchsiaResourceDialect,
3728        > for &mut ListenerNotifyOnFirstUpdateCheckRequest
3729    {
3730        unsafe fn encode(
3731            self,
3732            encoder: &mut fidl::encoding::Encoder<
3733                '_,
3734                fidl::encoding::DefaultFuchsiaResourceDialect,
3735            >,
3736            offset: usize,
3737            mut depth: fidl::encoding::Depth,
3738        ) -> fidl::Result<()> {
3739            encoder.debug_check_bounds::<ListenerNotifyOnFirstUpdateCheckRequest>(offset);
3740            // Vector header
3741            let max_ordinal: u64 = self.max_ordinal_present();
3742            encoder.write_num(max_ordinal, offset);
3743            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3744            // Calling encoder.out_of_line_offset(0) is not allowed.
3745            if max_ordinal == 0 {
3746                return Ok(());
3747            }
3748            depth.increment()?;
3749            let envelope_size = 8;
3750            let bytes_len = max_ordinal as usize * envelope_size;
3751            #[allow(unused_variables)]
3752            let offset = encoder.out_of_line_offset(bytes_len);
3753            let mut _prev_end_offset: usize = 0;
3754            if 1 > max_ordinal {
3755                return Ok(());
3756            }
3757
3758            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3759            // are envelope_size bytes.
3760            let cur_offset: usize = (1 - 1) * envelope_size;
3761
3762            // Zero reserved fields.
3763            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3764
3765            // Safety:
3766            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3767            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3768            //   envelope_size bytes, there is always sufficient room.
3769            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NotifierMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
3770            self.notifier.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NotifierMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
3771            encoder, offset + cur_offset, depth
3772        )?;
3773
3774            _prev_end_offset = cur_offset + envelope_size;
3775
3776            Ok(())
3777        }
3778    }
3779
3780    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3781        for ListenerNotifyOnFirstUpdateCheckRequest
3782    {
3783        #[inline(always)]
3784        fn new_empty() -> Self {
3785            Self::default()
3786        }
3787
3788        unsafe fn decode(
3789            &mut self,
3790            decoder: &mut fidl::encoding::Decoder<
3791                '_,
3792                fidl::encoding::DefaultFuchsiaResourceDialect,
3793            >,
3794            offset: usize,
3795            mut depth: fidl::encoding::Depth,
3796        ) -> fidl::Result<()> {
3797            decoder.debug_check_bounds::<Self>(offset);
3798            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3799                None => return Err(fidl::Error::NotNullable),
3800                Some(len) => len,
3801            };
3802            // Calling decoder.out_of_line_offset(0) is not allowed.
3803            if len == 0 {
3804                return Ok(());
3805            };
3806            depth.increment()?;
3807            let envelope_size = 8;
3808            let bytes_len = len * envelope_size;
3809            let offset = decoder.out_of_line_offset(bytes_len)?;
3810            // Decode the envelope for each type.
3811            let mut _next_ordinal_to_read = 0;
3812            let mut next_offset = offset;
3813            let end_offset = offset + bytes_len;
3814            _next_ordinal_to_read += 1;
3815            if next_offset >= end_offset {
3816                return Ok(());
3817            }
3818
3819            // Decode unknown envelopes for gaps in ordinals.
3820            while _next_ordinal_to_read < 1 {
3821                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3822                _next_ordinal_to_read += 1;
3823                next_offset += envelope_size;
3824            }
3825
3826            let next_out_of_line = decoder.next_out_of_line();
3827            let handles_before = decoder.remaining_handles();
3828            if let Some((inlined, num_bytes, num_handles)) =
3829                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3830            {
3831                let member_inline_size = <fidl::encoding::Endpoint<
3832                    fidl::endpoints::ClientEnd<NotifierMarker>,
3833                > as fidl::encoding::TypeMarker>::inline_size(
3834                    decoder.context
3835                );
3836                if inlined != (member_inline_size <= 4) {
3837                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3838                }
3839                let inner_offset;
3840                let mut inner_depth = depth.clone();
3841                if inlined {
3842                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3843                    inner_offset = next_offset;
3844                } else {
3845                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3846                    inner_depth.increment()?;
3847                }
3848                let val_ref = self.notifier.get_or_insert_with(|| {
3849                    fidl::new_empty!(
3850                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NotifierMarker>>,
3851                        fidl::encoding::DefaultFuchsiaResourceDialect
3852                    )
3853                });
3854                fidl::decode!(
3855                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NotifierMarker>>,
3856                    fidl::encoding::DefaultFuchsiaResourceDialect,
3857                    val_ref,
3858                    decoder,
3859                    inner_offset,
3860                    inner_depth
3861                )?;
3862                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3863                {
3864                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3865                }
3866                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3867                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3868                }
3869            }
3870
3871            next_offset += envelope_size;
3872
3873            // Decode the remaining unknown envelopes.
3874            while next_offset < end_offset {
3875                _next_ordinal_to_read += 1;
3876                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3877                next_offset += envelope_size;
3878            }
3879
3880            Ok(())
3881        }
3882    }
3883}