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