Skip to main content

fidl_fuchsia_update/
fidl_fuchsia_update.rs

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