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