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