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