Skip to main content

fidl_fuchsia_update/
fidl_fuchsia_update.rs

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