fidl_fuchsia_update_installer/
fidl_fuchsia_update_installer.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_installer__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct InstallerMonitorUpdateRequest {
16    pub attempt_id: Option<String>,
17    pub monitor: fidl::endpoints::ClientEnd<MonitorMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for InstallerMonitorUpdateRequest
22{
23}
24
25#[derive(Debug, PartialEq)]
26pub struct InstallerStartUpdateRequest {
27    pub url: fidl_fuchsia_pkg::PackageUrl,
28    pub options: Options,
29    pub monitor: fidl::endpoints::ClientEnd<MonitorMarker>,
30    pub reboot_controller: Option<fidl::endpoints::ServerEnd<RebootControllerMarker>>,
31    pub signature: Option<Vec<u8>>,
32}
33
34impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
35    for InstallerStartUpdateRequest
36{
37}
38
39#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
40pub struct InstallerMarker;
41
42impl fidl::endpoints::ProtocolMarker for InstallerMarker {
43    type Proxy = InstallerProxy;
44    type RequestStream = InstallerRequestStream;
45    #[cfg(target_os = "fuchsia")]
46    type SynchronousProxy = InstallerSynchronousProxy;
47
48    const DEBUG_NAME: &'static str = "fuchsia.update.installer.Installer";
49}
50impl fidl::endpoints::DiscoverableProtocolMarker for InstallerMarker {}
51pub type InstallerStartUpdateResult = Result<String, UpdateNotStartedReason>;
52pub type InstallerSuspendUpdateResult = Result<(), SuspendError>;
53pub type InstallerResumeUpdateResult = Result<(), ResumeError>;
54pub type InstallerCancelUpdateResult = Result<(), CancelError>;
55
56pub trait InstallerProxyInterface: Send + Sync {
57    type StartUpdateResponseFut: std::future::Future<Output = Result<InstallerStartUpdateResult, fidl::Error>>
58        + Send;
59    fn r#start_update(
60        &self,
61        url: &fidl_fuchsia_pkg::PackageUrl,
62        options: &Options,
63        monitor: fidl::endpoints::ClientEnd<MonitorMarker>,
64        reboot_controller: Option<fidl::endpoints::ServerEnd<RebootControllerMarker>>,
65        signature: Option<&[u8]>,
66    ) -> Self::StartUpdateResponseFut;
67    type MonitorUpdateResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
68    fn r#monitor_update(
69        &self,
70        attempt_id: Option<&str>,
71        monitor: fidl::endpoints::ClientEnd<MonitorMarker>,
72    ) -> Self::MonitorUpdateResponseFut;
73    type SuspendUpdateResponseFut: std::future::Future<Output = Result<InstallerSuspendUpdateResult, fidl::Error>>
74        + Send;
75    fn r#suspend_update(&self, attempt_id: Option<&str>) -> Self::SuspendUpdateResponseFut;
76    type ResumeUpdateResponseFut: std::future::Future<Output = Result<InstallerResumeUpdateResult, fidl::Error>>
77        + Send;
78    fn r#resume_update(&self, attempt_id: Option<&str>) -> Self::ResumeUpdateResponseFut;
79    type CancelUpdateResponseFut: std::future::Future<Output = Result<InstallerCancelUpdateResult, fidl::Error>>
80        + Send;
81    fn r#cancel_update(&self, attempt_id: Option<&str>) -> Self::CancelUpdateResponseFut;
82}
83#[derive(Debug)]
84#[cfg(target_os = "fuchsia")]
85pub struct InstallerSynchronousProxy {
86    client: fidl::client::sync::Client,
87}
88
89#[cfg(target_os = "fuchsia")]
90impl fidl::endpoints::SynchronousProxy for InstallerSynchronousProxy {
91    type Proxy = InstallerProxy;
92    type Protocol = InstallerMarker;
93
94    fn from_channel(inner: fidl::Channel) -> Self {
95        Self::new(inner)
96    }
97
98    fn into_channel(self) -> fidl::Channel {
99        self.client.into_channel()
100    }
101
102    fn as_channel(&self) -> &fidl::Channel {
103        self.client.as_channel()
104    }
105}
106
107#[cfg(target_os = "fuchsia")]
108impl InstallerSynchronousProxy {
109    pub fn new(channel: fidl::Channel) -> Self {
110        let protocol_name = <InstallerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
111        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
112    }
113
114    pub fn into_channel(self) -> fidl::Channel {
115        self.client.into_channel()
116    }
117
118    /// Waits until an event arrives and returns it. It is safe for other
119    /// threads to make concurrent requests while waiting for an event.
120    pub fn wait_for_event(
121        &self,
122        deadline: zx::MonotonicInstant,
123    ) -> Result<InstallerEvent, fidl::Error> {
124        InstallerEvent::decode(self.client.wait_for_event(deadline)?)
125    }
126
127    /// Start an update if one is not running, or attach to a pending update
128    /// attempt if one is running and
129    /// [`Options.allow_attach_to_existing_attempt`] is true. If an update
130    /// attempt is started or attached to, provide status updates through
131    /// `monitor`.
132    ///
133    /// + request `url` The fuchsia-pkg URL of the update package to update to.
134    /// + request `options` Configuration options for this update attempt.
135    ///     Ignored or merged with the existing `options` if an update attempt
136    ///     is already in progress.
137    /// + request `monitor` A protocol on which to receive progress updates.
138    /// + request `reboot_controller` An optional protocol to control the timing
139    ///     of the reboot into the update system. If not provided, the update
140    ///     attempt will initiate the reboot as soon as it is ready.
141    /// + request `signature` The Ed25519 signature used to verify the manifest.
142    ///     Required for packageless updates. Disallowed for package-based updates.
143    ///
144    /// - response `attempt_id` UUID identifying this update attempt. For
145    ///     updates that require a reboot, components may use this identifier to
146    ///     disambiguate the completion of this update attempt from new update
147    ///     attempts that start post-reboot.
148    pub fn r#start_update(
149        &self,
150        mut url: &fidl_fuchsia_pkg::PackageUrl,
151        mut options: &Options,
152        mut monitor: fidl::endpoints::ClientEnd<MonitorMarker>,
153        mut reboot_controller: Option<fidl::endpoints::ServerEnd<RebootControllerMarker>>,
154        mut signature: Option<&[u8]>,
155        ___deadline: zx::MonotonicInstant,
156    ) -> Result<InstallerStartUpdateResult, fidl::Error> {
157        let _response =
158            self.client.send_query::<InstallerStartUpdateRequest, fidl::encoding::ResultType<
159                InstallerStartUpdateResponse,
160                UpdateNotStartedReason,
161            >>(
162                (url, options, monitor, reboot_controller, signature),
163                0x2b1c5ba9167c320b,
164                fidl::encoding::DynamicFlags::empty(),
165                ___deadline,
166            )?;
167        Ok(_response.map(|x| x.attempt_id))
168    }
169
170    /// Attempt to monitor a specific update attempt, if it exists. This request
171    /// will not start an update if one is not already running.
172    ///
173    /// + request `attempt_id` UUID identifying the requested update attempt. If
174    ///     not given, monitor any active update attempt.
175    /// + request `monitor` A protocol on which to receive progress updates.
176    ///
177    /// - response `attached` Whether or not the provided monitor was attached
178    ///     to an in-progress update attempt. If false, monitor will be closed
179    ///     by the server.
180    pub fn r#monitor_update(
181        &self,
182        mut attempt_id: Option<&str>,
183        mut monitor: fidl::endpoints::ClientEnd<MonitorMarker>,
184        ___deadline: zx::MonotonicInstant,
185    ) -> Result<bool, fidl::Error> {
186        let _response = self
187            .client
188            .send_query::<InstallerMonitorUpdateRequest, InstallerMonitorUpdateResponse>(
189                (attempt_id, monitor),
190                0x21d54aa1fd825a32,
191                fidl::encoding::DynamicFlags::empty(),
192                ___deadline,
193            )?;
194        Ok(_response.attached)
195    }
196
197    /// Suspend a specific update attempt, if it exists.
198    ///
199    /// + request `attempt_id` UUID identifying the requested update attempt. If
200    ///     not given, suspend any active update attempt.
201    pub fn r#suspend_update(
202        &self,
203        mut attempt_id: Option<&str>,
204        ___deadline: zx::MonotonicInstant,
205    ) -> Result<InstallerSuspendUpdateResult, fidl::Error> {
206        let _response = self.client.send_query::<
207            InstallerSuspendUpdateRequest,
208            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, SuspendError>,
209        >(
210            (attempt_id,),
211            0x788de328461f9950,
212            fidl::encoding::DynamicFlags::empty(),
213            ___deadline,
214        )?;
215        Ok(_response.map(|x| x))
216    }
217
218    /// Resume a specific update attempt, if it exists.
219    ///
220    /// + request `attempt_id` UUID identifying the requested update attempt. If
221    ///     not given, resume any active update attempt.
222    pub fn r#resume_update(
223        &self,
224        mut attempt_id: Option<&str>,
225        ___deadline: zx::MonotonicInstant,
226    ) -> Result<InstallerResumeUpdateResult, fidl::Error> {
227        let _response = self.client.send_query::<
228            InstallerResumeUpdateRequest,
229            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ResumeError>,
230        >(
231            (attempt_id,),
232            0x7479e805fec33dd3,
233            fidl::encoding::DynamicFlags::empty(),
234            ___deadline,
235        )?;
236        Ok(_response.map(|x| x))
237    }
238
239    /// Cancel a specific update attempt, if it exists.
240    ///
241    /// + request `attempt_id` UUID identifying the requested update attempt. If
242    ///     not given, cancel any active update attempt.
243    pub fn r#cancel_update(
244        &self,
245        mut attempt_id: Option<&str>,
246        ___deadline: zx::MonotonicInstant,
247    ) -> Result<InstallerCancelUpdateResult, fidl::Error> {
248        let _response = self.client.send_query::<
249            InstallerCancelUpdateRequest,
250            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, CancelError>,
251        >(
252            (attempt_id,),
253            0x472dec9160a1d0f,
254            fidl::encoding::DynamicFlags::empty(),
255            ___deadline,
256        )?;
257        Ok(_response.map(|x| x))
258    }
259}
260
261#[cfg(target_os = "fuchsia")]
262impl From<InstallerSynchronousProxy> for zx::NullableHandle {
263    fn from(value: InstallerSynchronousProxy) -> Self {
264        value.into_channel().into()
265    }
266}
267
268#[cfg(target_os = "fuchsia")]
269impl From<fidl::Channel> for InstallerSynchronousProxy {
270    fn from(value: fidl::Channel) -> Self {
271        Self::new(value)
272    }
273}
274
275#[cfg(target_os = "fuchsia")]
276impl fidl::endpoints::FromClient for InstallerSynchronousProxy {
277    type Protocol = InstallerMarker;
278
279    fn from_client(value: fidl::endpoints::ClientEnd<InstallerMarker>) -> Self {
280        Self::new(value.into_channel())
281    }
282}
283
284#[derive(Debug, Clone)]
285pub struct InstallerProxy {
286    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
287}
288
289impl fidl::endpoints::Proxy for InstallerProxy {
290    type Protocol = InstallerMarker;
291
292    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
293        Self::new(inner)
294    }
295
296    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
297        self.client.into_channel().map_err(|client| Self { client })
298    }
299
300    fn as_channel(&self) -> &::fidl::AsyncChannel {
301        self.client.as_channel()
302    }
303}
304
305impl InstallerProxy {
306    /// Create a new Proxy for fuchsia.update.installer/Installer.
307    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
308        let protocol_name = <InstallerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
309        Self { client: fidl::client::Client::new(channel, protocol_name) }
310    }
311
312    /// Get a Stream of events from the remote end of the protocol.
313    ///
314    /// # Panics
315    ///
316    /// Panics if the event stream was already taken.
317    pub fn take_event_stream(&self) -> InstallerEventStream {
318        InstallerEventStream { event_receiver: self.client.take_event_receiver() }
319    }
320
321    /// Start an update if one is not running, or attach to a pending update
322    /// attempt if one is running and
323    /// [`Options.allow_attach_to_existing_attempt`] is true. If an update
324    /// attempt is started or attached to, provide status updates through
325    /// `monitor`.
326    ///
327    /// + request `url` The fuchsia-pkg URL of the update package to update to.
328    /// + request `options` Configuration options for this update attempt.
329    ///     Ignored or merged with the existing `options` if an update attempt
330    ///     is already in progress.
331    /// + request `monitor` A protocol on which to receive progress updates.
332    /// + request `reboot_controller` An optional protocol to control the timing
333    ///     of the reboot into the update system. If not provided, the update
334    ///     attempt will initiate the reboot as soon as it is ready.
335    /// + request `signature` The Ed25519 signature used to verify the manifest.
336    ///     Required for packageless updates. Disallowed for package-based updates.
337    ///
338    /// - response `attempt_id` UUID identifying this update attempt. For
339    ///     updates that require a reboot, components may use this identifier to
340    ///     disambiguate the completion of this update attempt from new update
341    ///     attempts that start post-reboot.
342    pub fn r#start_update(
343        &self,
344        mut url: &fidl_fuchsia_pkg::PackageUrl,
345        mut options: &Options,
346        mut monitor: fidl::endpoints::ClientEnd<MonitorMarker>,
347        mut reboot_controller: Option<fidl::endpoints::ServerEnd<RebootControllerMarker>>,
348        mut signature: Option<&[u8]>,
349    ) -> fidl::client::QueryResponseFut<
350        InstallerStartUpdateResult,
351        fidl::encoding::DefaultFuchsiaResourceDialect,
352    > {
353        InstallerProxyInterface::r#start_update(
354            self,
355            url,
356            options,
357            monitor,
358            reboot_controller,
359            signature,
360        )
361    }
362
363    /// Attempt to monitor a specific update attempt, if it exists. This request
364    /// will not start an update if one is not already running.
365    ///
366    /// + request `attempt_id` UUID identifying the requested update attempt. If
367    ///     not given, monitor any active update attempt.
368    /// + request `monitor` A protocol on which to receive progress updates.
369    ///
370    /// - response `attached` Whether or not the provided monitor was attached
371    ///     to an in-progress update attempt. If false, monitor will be closed
372    ///     by the server.
373    pub fn r#monitor_update(
374        &self,
375        mut attempt_id: Option<&str>,
376        mut monitor: fidl::endpoints::ClientEnd<MonitorMarker>,
377    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
378        InstallerProxyInterface::r#monitor_update(self, attempt_id, monitor)
379    }
380
381    /// Suspend a specific update attempt, if it exists.
382    ///
383    /// + request `attempt_id` UUID identifying the requested update attempt. If
384    ///     not given, suspend any active update attempt.
385    pub fn r#suspend_update(
386        &self,
387        mut attempt_id: Option<&str>,
388    ) -> fidl::client::QueryResponseFut<
389        InstallerSuspendUpdateResult,
390        fidl::encoding::DefaultFuchsiaResourceDialect,
391    > {
392        InstallerProxyInterface::r#suspend_update(self, attempt_id)
393    }
394
395    /// Resume a specific update attempt, if it exists.
396    ///
397    /// + request `attempt_id` UUID identifying the requested update attempt. If
398    ///     not given, resume any active update attempt.
399    pub fn r#resume_update(
400        &self,
401        mut attempt_id: Option<&str>,
402    ) -> fidl::client::QueryResponseFut<
403        InstallerResumeUpdateResult,
404        fidl::encoding::DefaultFuchsiaResourceDialect,
405    > {
406        InstallerProxyInterface::r#resume_update(self, attempt_id)
407    }
408
409    /// Cancel a specific update attempt, if it exists.
410    ///
411    /// + request `attempt_id` UUID identifying the requested update attempt. If
412    ///     not given, cancel any active update attempt.
413    pub fn r#cancel_update(
414        &self,
415        mut attempt_id: Option<&str>,
416    ) -> fidl::client::QueryResponseFut<
417        InstallerCancelUpdateResult,
418        fidl::encoding::DefaultFuchsiaResourceDialect,
419    > {
420        InstallerProxyInterface::r#cancel_update(self, attempt_id)
421    }
422}
423
424impl InstallerProxyInterface for InstallerProxy {
425    type StartUpdateResponseFut = fidl::client::QueryResponseFut<
426        InstallerStartUpdateResult,
427        fidl::encoding::DefaultFuchsiaResourceDialect,
428    >;
429    fn r#start_update(
430        &self,
431        mut url: &fidl_fuchsia_pkg::PackageUrl,
432        mut options: &Options,
433        mut monitor: fidl::endpoints::ClientEnd<MonitorMarker>,
434        mut reboot_controller: Option<fidl::endpoints::ServerEnd<RebootControllerMarker>>,
435        mut signature: Option<&[u8]>,
436    ) -> Self::StartUpdateResponseFut {
437        fn _decode(
438            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
439        ) -> Result<InstallerStartUpdateResult, fidl::Error> {
440            let _response = fidl::client::decode_transaction_body::<
441                fidl::encoding::ResultType<InstallerStartUpdateResponse, UpdateNotStartedReason>,
442                fidl::encoding::DefaultFuchsiaResourceDialect,
443                0x2b1c5ba9167c320b,
444            >(_buf?)?;
445            Ok(_response.map(|x| x.attempt_id))
446        }
447        self.client
448            .send_query_and_decode::<InstallerStartUpdateRequest, InstallerStartUpdateResult>(
449                (url, options, monitor, reboot_controller, signature),
450                0x2b1c5ba9167c320b,
451                fidl::encoding::DynamicFlags::empty(),
452                _decode,
453            )
454    }
455
456    type MonitorUpdateResponseFut =
457        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
458    fn r#monitor_update(
459        &self,
460        mut attempt_id: Option<&str>,
461        mut monitor: fidl::endpoints::ClientEnd<MonitorMarker>,
462    ) -> Self::MonitorUpdateResponseFut {
463        fn _decode(
464            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
465        ) -> Result<bool, fidl::Error> {
466            let _response = fidl::client::decode_transaction_body::<
467                InstallerMonitorUpdateResponse,
468                fidl::encoding::DefaultFuchsiaResourceDialect,
469                0x21d54aa1fd825a32,
470            >(_buf?)?;
471            Ok(_response.attached)
472        }
473        self.client.send_query_and_decode::<InstallerMonitorUpdateRequest, bool>(
474            (attempt_id, monitor),
475            0x21d54aa1fd825a32,
476            fidl::encoding::DynamicFlags::empty(),
477            _decode,
478        )
479    }
480
481    type SuspendUpdateResponseFut = fidl::client::QueryResponseFut<
482        InstallerSuspendUpdateResult,
483        fidl::encoding::DefaultFuchsiaResourceDialect,
484    >;
485    fn r#suspend_update(&self, mut attempt_id: Option<&str>) -> Self::SuspendUpdateResponseFut {
486        fn _decode(
487            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
488        ) -> Result<InstallerSuspendUpdateResult, fidl::Error> {
489            let _response = fidl::client::decode_transaction_body::<
490                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, SuspendError>,
491                fidl::encoding::DefaultFuchsiaResourceDialect,
492                0x788de328461f9950,
493            >(_buf?)?;
494            Ok(_response.map(|x| x))
495        }
496        self.client
497            .send_query_and_decode::<InstallerSuspendUpdateRequest, InstallerSuspendUpdateResult>(
498                (attempt_id,),
499                0x788de328461f9950,
500                fidl::encoding::DynamicFlags::empty(),
501                _decode,
502            )
503    }
504
505    type ResumeUpdateResponseFut = fidl::client::QueryResponseFut<
506        InstallerResumeUpdateResult,
507        fidl::encoding::DefaultFuchsiaResourceDialect,
508    >;
509    fn r#resume_update(&self, mut attempt_id: Option<&str>) -> Self::ResumeUpdateResponseFut {
510        fn _decode(
511            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
512        ) -> Result<InstallerResumeUpdateResult, fidl::Error> {
513            let _response = fidl::client::decode_transaction_body::<
514                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ResumeError>,
515                fidl::encoding::DefaultFuchsiaResourceDialect,
516                0x7479e805fec33dd3,
517            >(_buf?)?;
518            Ok(_response.map(|x| x))
519        }
520        self.client
521            .send_query_and_decode::<InstallerResumeUpdateRequest, InstallerResumeUpdateResult>(
522                (attempt_id,),
523                0x7479e805fec33dd3,
524                fidl::encoding::DynamicFlags::empty(),
525                _decode,
526            )
527    }
528
529    type CancelUpdateResponseFut = fidl::client::QueryResponseFut<
530        InstallerCancelUpdateResult,
531        fidl::encoding::DefaultFuchsiaResourceDialect,
532    >;
533    fn r#cancel_update(&self, mut attempt_id: Option<&str>) -> Self::CancelUpdateResponseFut {
534        fn _decode(
535            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
536        ) -> Result<InstallerCancelUpdateResult, fidl::Error> {
537            let _response = fidl::client::decode_transaction_body::<
538                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, CancelError>,
539                fidl::encoding::DefaultFuchsiaResourceDialect,
540                0x472dec9160a1d0f,
541            >(_buf?)?;
542            Ok(_response.map(|x| x))
543        }
544        self.client
545            .send_query_and_decode::<InstallerCancelUpdateRequest, InstallerCancelUpdateResult>(
546                (attempt_id,),
547                0x472dec9160a1d0f,
548                fidl::encoding::DynamicFlags::empty(),
549                _decode,
550            )
551    }
552}
553
554pub struct InstallerEventStream {
555    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
556}
557
558impl std::marker::Unpin for InstallerEventStream {}
559
560impl futures::stream::FusedStream for InstallerEventStream {
561    fn is_terminated(&self) -> bool {
562        self.event_receiver.is_terminated()
563    }
564}
565
566impl futures::Stream for InstallerEventStream {
567    type Item = Result<InstallerEvent, fidl::Error>;
568
569    fn poll_next(
570        mut self: std::pin::Pin<&mut Self>,
571        cx: &mut std::task::Context<'_>,
572    ) -> std::task::Poll<Option<Self::Item>> {
573        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
574            &mut self.event_receiver,
575            cx
576        )?) {
577            Some(buf) => std::task::Poll::Ready(Some(InstallerEvent::decode(buf))),
578            None => std::task::Poll::Ready(None),
579        }
580    }
581}
582
583#[derive(Debug)]
584pub enum InstallerEvent {}
585
586impl InstallerEvent {
587    /// Decodes a message buffer as a [`InstallerEvent`].
588    fn decode(
589        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
590    ) -> Result<InstallerEvent, fidl::Error> {
591        let (bytes, _handles) = buf.split_mut();
592        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
593        debug_assert_eq!(tx_header.tx_id, 0);
594        match tx_header.ordinal {
595            _ => Err(fidl::Error::UnknownOrdinal {
596                ordinal: tx_header.ordinal,
597                protocol_name: <InstallerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
598            }),
599        }
600    }
601}
602
603/// A Stream of incoming requests for fuchsia.update.installer/Installer.
604pub struct InstallerRequestStream {
605    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
606    is_terminated: bool,
607}
608
609impl std::marker::Unpin for InstallerRequestStream {}
610
611impl futures::stream::FusedStream for InstallerRequestStream {
612    fn is_terminated(&self) -> bool {
613        self.is_terminated
614    }
615}
616
617impl fidl::endpoints::RequestStream for InstallerRequestStream {
618    type Protocol = InstallerMarker;
619    type ControlHandle = InstallerControlHandle;
620
621    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
622        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
623    }
624
625    fn control_handle(&self) -> Self::ControlHandle {
626        InstallerControlHandle { inner: self.inner.clone() }
627    }
628
629    fn into_inner(
630        self,
631    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
632    {
633        (self.inner, self.is_terminated)
634    }
635
636    fn from_inner(
637        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
638        is_terminated: bool,
639    ) -> Self {
640        Self { inner, is_terminated }
641    }
642}
643
644impl futures::Stream for InstallerRequestStream {
645    type Item = Result<InstallerRequest, fidl::Error>;
646
647    fn poll_next(
648        mut self: std::pin::Pin<&mut Self>,
649        cx: &mut std::task::Context<'_>,
650    ) -> std::task::Poll<Option<Self::Item>> {
651        let this = &mut *self;
652        if this.inner.check_shutdown(cx) {
653            this.is_terminated = true;
654            return std::task::Poll::Ready(None);
655        }
656        if this.is_terminated {
657            panic!("polled InstallerRequestStream after completion");
658        }
659        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
660            |bytes, handles| {
661                match this.inner.channel().read_etc(cx, bytes, handles) {
662                    std::task::Poll::Ready(Ok(())) => {}
663                    std::task::Poll::Pending => return std::task::Poll::Pending,
664                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
665                        this.is_terminated = true;
666                        return std::task::Poll::Ready(None);
667                    }
668                    std::task::Poll::Ready(Err(e)) => {
669                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
670                            e.into(),
671                        ))));
672                    }
673                }
674
675                // A message has been received from the channel
676                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
677
678                std::task::Poll::Ready(Some(match header.ordinal {
679                    0x2b1c5ba9167c320b => {
680                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
681                        let mut req = fidl::new_empty!(
682                            InstallerStartUpdateRequest,
683                            fidl::encoding::DefaultFuchsiaResourceDialect
684                        );
685                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InstallerStartUpdateRequest>(&header, _body_bytes, handles, &mut req)?;
686                        let control_handle = InstallerControlHandle { inner: this.inner.clone() };
687                        Ok(InstallerRequest::StartUpdate {
688                            url: req.url,
689                            options: req.options,
690                            monitor: req.monitor,
691                            reboot_controller: req.reboot_controller,
692                            signature: req.signature,
693
694                            responder: InstallerStartUpdateResponder {
695                                control_handle: std::mem::ManuallyDrop::new(control_handle),
696                                tx_id: header.tx_id,
697                            },
698                        })
699                    }
700                    0x21d54aa1fd825a32 => {
701                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
702                        let mut req = fidl::new_empty!(
703                            InstallerMonitorUpdateRequest,
704                            fidl::encoding::DefaultFuchsiaResourceDialect
705                        );
706                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InstallerMonitorUpdateRequest>(&header, _body_bytes, handles, &mut req)?;
707                        let control_handle = InstallerControlHandle { inner: this.inner.clone() };
708                        Ok(InstallerRequest::MonitorUpdate {
709                            attempt_id: req.attempt_id,
710                            monitor: req.monitor,
711
712                            responder: InstallerMonitorUpdateResponder {
713                                control_handle: std::mem::ManuallyDrop::new(control_handle),
714                                tx_id: header.tx_id,
715                            },
716                        })
717                    }
718                    0x788de328461f9950 => {
719                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
720                        let mut req = fidl::new_empty!(
721                            InstallerSuspendUpdateRequest,
722                            fidl::encoding::DefaultFuchsiaResourceDialect
723                        );
724                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InstallerSuspendUpdateRequest>(&header, _body_bytes, handles, &mut req)?;
725                        let control_handle = InstallerControlHandle { inner: this.inner.clone() };
726                        Ok(InstallerRequest::SuspendUpdate {
727                            attempt_id: req.attempt_id,
728
729                            responder: InstallerSuspendUpdateResponder {
730                                control_handle: std::mem::ManuallyDrop::new(control_handle),
731                                tx_id: header.tx_id,
732                            },
733                        })
734                    }
735                    0x7479e805fec33dd3 => {
736                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
737                        let mut req = fidl::new_empty!(
738                            InstallerResumeUpdateRequest,
739                            fidl::encoding::DefaultFuchsiaResourceDialect
740                        );
741                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InstallerResumeUpdateRequest>(&header, _body_bytes, handles, &mut req)?;
742                        let control_handle = InstallerControlHandle { inner: this.inner.clone() };
743                        Ok(InstallerRequest::ResumeUpdate {
744                            attempt_id: req.attempt_id,
745
746                            responder: InstallerResumeUpdateResponder {
747                                control_handle: std::mem::ManuallyDrop::new(control_handle),
748                                tx_id: header.tx_id,
749                            },
750                        })
751                    }
752                    0x472dec9160a1d0f => {
753                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
754                        let mut req = fidl::new_empty!(
755                            InstallerCancelUpdateRequest,
756                            fidl::encoding::DefaultFuchsiaResourceDialect
757                        );
758                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<InstallerCancelUpdateRequest>(&header, _body_bytes, handles, &mut req)?;
759                        let control_handle = InstallerControlHandle { inner: this.inner.clone() };
760                        Ok(InstallerRequest::CancelUpdate {
761                            attempt_id: req.attempt_id,
762
763                            responder: InstallerCancelUpdateResponder {
764                                control_handle: std::mem::ManuallyDrop::new(control_handle),
765                                tx_id: header.tx_id,
766                            },
767                        })
768                    }
769                    _ => Err(fidl::Error::UnknownOrdinal {
770                        ordinal: header.ordinal,
771                        protocol_name:
772                            <InstallerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
773                    }),
774                }))
775            },
776        )
777    }
778}
779
780/// Updates the system.
781///
782/// This protocol is intended to be consumed by a component capable of
783/// discovering when to update and what version of the system to install.
784#[derive(Debug)]
785pub enum InstallerRequest {
786    /// Start an update if one is not running, or attach to a pending update
787    /// attempt if one is running and
788    /// [`Options.allow_attach_to_existing_attempt`] is true. If an update
789    /// attempt is started or attached to, provide status updates through
790    /// `monitor`.
791    ///
792    /// + request `url` The fuchsia-pkg URL of the update package to update to.
793    /// + request `options` Configuration options for this update attempt.
794    ///     Ignored or merged with the existing `options` if an update attempt
795    ///     is already in progress.
796    /// + request `monitor` A protocol on which to receive progress updates.
797    /// + request `reboot_controller` An optional protocol to control the timing
798    ///     of the reboot into the update system. If not provided, the update
799    ///     attempt will initiate the reboot as soon as it is ready.
800    /// + request `signature` The Ed25519 signature used to verify the manifest.
801    ///     Required for packageless updates. Disallowed for package-based updates.
802    ///
803    /// - response `attempt_id` UUID identifying this update attempt. For
804    ///     updates that require a reboot, components may use this identifier to
805    ///     disambiguate the completion of this update attempt from new update
806    ///     attempts that start post-reboot.
807    StartUpdate {
808        url: fidl_fuchsia_pkg::PackageUrl,
809        options: Options,
810        monitor: fidl::endpoints::ClientEnd<MonitorMarker>,
811        reboot_controller: Option<fidl::endpoints::ServerEnd<RebootControllerMarker>>,
812        signature: Option<Vec<u8>>,
813        responder: InstallerStartUpdateResponder,
814    },
815    /// Attempt to monitor a specific update attempt, if it exists. This request
816    /// will not start an update if one is not already running.
817    ///
818    /// + request `attempt_id` UUID identifying the requested update attempt. If
819    ///     not given, monitor any active update attempt.
820    /// + request `monitor` A protocol on which to receive progress updates.
821    ///
822    /// - response `attached` Whether or not the provided monitor was attached
823    ///     to an in-progress update attempt. If false, monitor will be closed
824    ///     by the server.
825    MonitorUpdate {
826        attempt_id: Option<String>,
827        monitor: fidl::endpoints::ClientEnd<MonitorMarker>,
828        responder: InstallerMonitorUpdateResponder,
829    },
830    /// Suspend a specific update attempt, if it exists.
831    ///
832    /// + request `attempt_id` UUID identifying the requested update attempt. If
833    ///     not given, suspend any active update attempt.
834    SuspendUpdate { attempt_id: Option<String>, responder: InstallerSuspendUpdateResponder },
835    /// Resume a specific update attempt, if it exists.
836    ///
837    /// + request `attempt_id` UUID identifying the requested update attempt. If
838    ///     not given, resume any active update attempt.
839    ResumeUpdate { attempt_id: Option<String>, responder: InstallerResumeUpdateResponder },
840    /// Cancel a specific update attempt, if it exists.
841    ///
842    /// + request `attempt_id` UUID identifying the requested update attempt. If
843    ///     not given, cancel any active update attempt.
844    CancelUpdate { attempt_id: Option<String>, responder: InstallerCancelUpdateResponder },
845}
846
847impl InstallerRequest {
848    #[allow(irrefutable_let_patterns)]
849    pub fn into_start_update(
850        self,
851    ) -> Option<(
852        fidl_fuchsia_pkg::PackageUrl,
853        Options,
854        fidl::endpoints::ClientEnd<MonitorMarker>,
855        Option<fidl::endpoints::ServerEnd<RebootControllerMarker>>,
856        Option<Vec<u8>>,
857        InstallerStartUpdateResponder,
858    )> {
859        if let InstallerRequest::StartUpdate {
860            url,
861            options,
862            monitor,
863            reboot_controller,
864            signature,
865            responder,
866        } = self
867        {
868            Some((url, options, monitor, reboot_controller, signature, responder))
869        } else {
870            None
871        }
872    }
873
874    #[allow(irrefutable_let_patterns)]
875    pub fn into_monitor_update(
876        self,
877    ) -> Option<(
878        Option<String>,
879        fidl::endpoints::ClientEnd<MonitorMarker>,
880        InstallerMonitorUpdateResponder,
881    )> {
882        if let InstallerRequest::MonitorUpdate { attempt_id, monitor, responder } = self {
883            Some((attempt_id, monitor, responder))
884        } else {
885            None
886        }
887    }
888
889    #[allow(irrefutable_let_patterns)]
890    pub fn into_suspend_update(self) -> Option<(Option<String>, InstallerSuspendUpdateResponder)> {
891        if let InstallerRequest::SuspendUpdate { attempt_id, responder } = self {
892            Some((attempt_id, responder))
893        } else {
894            None
895        }
896    }
897
898    #[allow(irrefutable_let_patterns)]
899    pub fn into_resume_update(self) -> Option<(Option<String>, InstallerResumeUpdateResponder)> {
900        if let InstallerRequest::ResumeUpdate { attempt_id, responder } = self {
901            Some((attempt_id, responder))
902        } else {
903            None
904        }
905    }
906
907    #[allow(irrefutable_let_patterns)]
908    pub fn into_cancel_update(self) -> Option<(Option<String>, InstallerCancelUpdateResponder)> {
909        if let InstallerRequest::CancelUpdate { attempt_id, responder } = self {
910            Some((attempt_id, responder))
911        } else {
912            None
913        }
914    }
915
916    /// Name of the method defined in FIDL
917    pub fn method_name(&self) -> &'static str {
918        match *self {
919            InstallerRequest::StartUpdate { .. } => "start_update",
920            InstallerRequest::MonitorUpdate { .. } => "monitor_update",
921            InstallerRequest::SuspendUpdate { .. } => "suspend_update",
922            InstallerRequest::ResumeUpdate { .. } => "resume_update",
923            InstallerRequest::CancelUpdate { .. } => "cancel_update",
924        }
925    }
926}
927
928#[derive(Debug, Clone)]
929pub struct InstallerControlHandle {
930    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
931}
932
933impl fidl::endpoints::ControlHandle for InstallerControlHandle {
934    fn shutdown(&self) {
935        self.inner.shutdown()
936    }
937
938    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
939        self.inner.shutdown_with_epitaph(status)
940    }
941
942    fn is_closed(&self) -> bool {
943        self.inner.channel().is_closed()
944    }
945    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
946        self.inner.channel().on_closed()
947    }
948
949    #[cfg(target_os = "fuchsia")]
950    fn signal_peer(
951        &self,
952        clear_mask: zx::Signals,
953        set_mask: zx::Signals,
954    ) -> Result<(), zx_status::Status> {
955        use fidl::Peered;
956        self.inner.channel().signal_peer(clear_mask, set_mask)
957    }
958}
959
960impl InstallerControlHandle {}
961
962#[must_use = "FIDL methods require a response to be sent"]
963#[derive(Debug)]
964pub struct InstallerStartUpdateResponder {
965    control_handle: std::mem::ManuallyDrop<InstallerControlHandle>,
966    tx_id: u32,
967}
968
969/// Set the the channel to be shutdown (see [`InstallerControlHandle::shutdown`])
970/// if the responder is dropped without sending a response, so that the client
971/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
972impl std::ops::Drop for InstallerStartUpdateResponder {
973    fn drop(&mut self) {
974        self.control_handle.shutdown();
975        // Safety: drops once, never accessed again
976        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
977    }
978}
979
980impl fidl::endpoints::Responder for InstallerStartUpdateResponder {
981    type ControlHandle = InstallerControlHandle;
982
983    fn control_handle(&self) -> &InstallerControlHandle {
984        &self.control_handle
985    }
986
987    fn drop_without_shutdown(mut self) {
988        // Safety: drops once, never accessed again due to mem::forget
989        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
990        // Prevent Drop from running (which would shut down the channel)
991        std::mem::forget(self);
992    }
993}
994
995impl InstallerStartUpdateResponder {
996    /// Sends a response to the FIDL transaction.
997    ///
998    /// Sets the channel to shutdown if an error occurs.
999    pub fn send(self, mut result: Result<&str, UpdateNotStartedReason>) -> Result<(), fidl::Error> {
1000        let _result = self.send_raw(result);
1001        if _result.is_err() {
1002            self.control_handle.shutdown();
1003        }
1004        self.drop_without_shutdown();
1005        _result
1006    }
1007
1008    /// Similar to "send" but does not shutdown the channel if an error occurs.
1009    pub fn send_no_shutdown_on_err(
1010        self,
1011        mut result: Result<&str, UpdateNotStartedReason>,
1012    ) -> Result<(), fidl::Error> {
1013        let _result = self.send_raw(result);
1014        self.drop_without_shutdown();
1015        _result
1016    }
1017
1018    fn send_raw(
1019        &self,
1020        mut result: Result<&str, UpdateNotStartedReason>,
1021    ) -> Result<(), fidl::Error> {
1022        self.control_handle.inner.send::<fidl::encoding::ResultType<
1023            InstallerStartUpdateResponse,
1024            UpdateNotStartedReason,
1025        >>(
1026            result.map(|attempt_id| (attempt_id,)),
1027            self.tx_id,
1028            0x2b1c5ba9167c320b,
1029            fidl::encoding::DynamicFlags::empty(),
1030        )
1031    }
1032}
1033
1034#[must_use = "FIDL methods require a response to be sent"]
1035#[derive(Debug)]
1036pub struct InstallerMonitorUpdateResponder {
1037    control_handle: std::mem::ManuallyDrop<InstallerControlHandle>,
1038    tx_id: u32,
1039}
1040
1041/// Set the the channel to be shutdown (see [`InstallerControlHandle::shutdown`])
1042/// if the responder is dropped without sending a response, so that the client
1043/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1044impl std::ops::Drop for InstallerMonitorUpdateResponder {
1045    fn drop(&mut self) {
1046        self.control_handle.shutdown();
1047        // Safety: drops once, never accessed again
1048        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1049    }
1050}
1051
1052impl fidl::endpoints::Responder for InstallerMonitorUpdateResponder {
1053    type ControlHandle = InstallerControlHandle;
1054
1055    fn control_handle(&self) -> &InstallerControlHandle {
1056        &self.control_handle
1057    }
1058
1059    fn drop_without_shutdown(mut self) {
1060        // Safety: drops once, never accessed again due to mem::forget
1061        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1062        // Prevent Drop from running (which would shut down the channel)
1063        std::mem::forget(self);
1064    }
1065}
1066
1067impl InstallerMonitorUpdateResponder {
1068    /// Sends a response to the FIDL transaction.
1069    ///
1070    /// Sets the channel to shutdown if an error occurs.
1071    pub fn send(self, mut attached: bool) -> Result<(), fidl::Error> {
1072        let _result = self.send_raw(attached);
1073        if _result.is_err() {
1074            self.control_handle.shutdown();
1075        }
1076        self.drop_without_shutdown();
1077        _result
1078    }
1079
1080    /// Similar to "send" but does not shutdown the channel if an error occurs.
1081    pub fn send_no_shutdown_on_err(self, mut attached: bool) -> Result<(), fidl::Error> {
1082        let _result = self.send_raw(attached);
1083        self.drop_without_shutdown();
1084        _result
1085    }
1086
1087    fn send_raw(&self, mut attached: bool) -> Result<(), fidl::Error> {
1088        self.control_handle.inner.send::<InstallerMonitorUpdateResponse>(
1089            (attached,),
1090            self.tx_id,
1091            0x21d54aa1fd825a32,
1092            fidl::encoding::DynamicFlags::empty(),
1093        )
1094    }
1095}
1096
1097#[must_use = "FIDL methods require a response to be sent"]
1098#[derive(Debug)]
1099pub struct InstallerSuspendUpdateResponder {
1100    control_handle: std::mem::ManuallyDrop<InstallerControlHandle>,
1101    tx_id: u32,
1102}
1103
1104/// Set the the channel to be shutdown (see [`InstallerControlHandle::shutdown`])
1105/// if the responder is dropped without sending a response, so that the client
1106/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1107impl std::ops::Drop for InstallerSuspendUpdateResponder {
1108    fn drop(&mut self) {
1109        self.control_handle.shutdown();
1110        // Safety: drops once, never accessed again
1111        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1112    }
1113}
1114
1115impl fidl::endpoints::Responder for InstallerSuspendUpdateResponder {
1116    type ControlHandle = InstallerControlHandle;
1117
1118    fn control_handle(&self) -> &InstallerControlHandle {
1119        &self.control_handle
1120    }
1121
1122    fn drop_without_shutdown(mut self) {
1123        // Safety: drops once, never accessed again due to mem::forget
1124        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1125        // Prevent Drop from running (which would shut down the channel)
1126        std::mem::forget(self);
1127    }
1128}
1129
1130impl InstallerSuspendUpdateResponder {
1131    /// Sends a response to the FIDL transaction.
1132    ///
1133    /// Sets the channel to shutdown if an error occurs.
1134    pub fn send(self, mut result: Result<(), SuspendError>) -> Result<(), fidl::Error> {
1135        let _result = self.send_raw(result);
1136        if _result.is_err() {
1137            self.control_handle.shutdown();
1138        }
1139        self.drop_without_shutdown();
1140        _result
1141    }
1142
1143    /// Similar to "send" but does not shutdown the channel if an error occurs.
1144    pub fn send_no_shutdown_on_err(
1145        self,
1146        mut result: Result<(), SuspendError>,
1147    ) -> Result<(), fidl::Error> {
1148        let _result = self.send_raw(result);
1149        self.drop_without_shutdown();
1150        _result
1151    }
1152
1153    fn send_raw(&self, mut result: Result<(), SuspendError>) -> Result<(), fidl::Error> {
1154        self.control_handle.inner.send::<fidl::encoding::ResultType<
1155            fidl::encoding::EmptyStruct,
1156            SuspendError,
1157        >>(
1158            result,
1159            self.tx_id,
1160            0x788de328461f9950,
1161            fidl::encoding::DynamicFlags::empty(),
1162        )
1163    }
1164}
1165
1166#[must_use = "FIDL methods require a response to be sent"]
1167#[derive(Debug)]
1168pub struct InstallerResumeUpdateResponder {
1169    control_handle: std::mem::ManuallyDrop<InstallerControlHandle>,
1170    tx_id: u32,
1171}
1172
1173/// Set the the channel to be shutdown (see [`InstallerControlHandle::shutdown`])
1174/// if the responder is dropped without sending a response, so that the client
1175/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1176impl std::ops::Drop for InstallerResumeUpdateResponder {
1177    fn drop(&mut self) {
1178        self.control_handle.shutdown();
1179        // Safety: drops once, never accessed again
1180        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1181    }
1182}
1183
1184impl fidl::endpoints::Responder for InstallerResumeUpdateResponder {
1185    type ControlHandle = InstallerControlHandle;
1186
1187    fn control_handle(&self) -> &InstallerControlHandle {
1188        &self.control_handle
1189    }
1190
1191    fn drop_without_shutdown(mut self) {
1192        // Safety: drops once, never accessed again due to mem::forget
1193        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1194        // Prevent Drop from running (which would shut down the channel)
1195        std::mem::forget(self);
1196    }
1197}
1198
1199impl InstallerResumeUpdateResponder {
1200    /// Sends a response to the FIDL transaction.
1201    ///
1202    /// Sets the channel to shutdown if an error occurs.
1203    pub fn send(self, mut result: Result<(), ResumeError>) -> Result<(), fidl::Error> {
1204        let _result = self.send_raw(result);
1205        if _result.is_err() {
1206            self.control_handle.shutdown();
1207        }
1208        self.drop_without_shutdown();
1209        _result
1210    }
1211
1212    /// Similar to "send" but does not shutdown the channel if an error occurs.
1213    pub fn send_no_shutdown_on_err(
1214        self,
1215        mut result: Result<(), ResumeError>,
1216    ) -> Result<(), fidl::Error> {
1217        let _result = self.send_raw(result);
1218        self.drop_without_shutdown();
1219        _result
1220    }
1221
1222    fn send_raw(&self, mut result: Result<(), ResumeError>) -> Result<(), fidl::Error> {
1223        self.control_handle.inner.send::<fidl::encoding::ResultType<
1224            fidl::encoding::EmptyStruct,
1225            ResumeError,
1226        >>(
1227            result,
1228            self.tx_id,
1229            0x7479e805fec33dd3,
1230            fidl::encoding::DynamicFlags::empty(),
1231        )
1232    }
1233}
1234
1235#[must_use = "FIDL methods require a response to be sent"]
1236#[derive(Debug)]
1237pub struct InstallerCancelUpdateResponder {
1238    control_handle: std::mem::ManuallyDrop<InstallerControlHandle>,
1239    tx_id: u32,
1240}
1241
1242/// Set the the channel to be shutdown (see [`InstallerControlHandle::shutdown`])
1243/// if the responder is dropped without sending a response, so that the client
1244/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1245impl std::ops::Drop for InstallerCancelUpdateResponder {
1246    fn drop(&mut self) {
1247        self.control_handle.shutdown();
1248        // Safety: drops once, never accessed again
1249        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1250    }
1251}
1252
1253impl fidl::endpoints::Responder for InstallerCancelUpdateResponder {
1254    type ControlHandle = InstallerControlHandle;
1255
1256    fn control_handle(&self) -> &InstallerControlHandle {
1257        &self.control_handle
1258    }
1259
1260    fn drop_without_shutdown(mut self) {
1261        // Safety: drops once, never accessed again due to mem::forget
1262        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1263        // Prevent Drop from running (which would shut down the channel)
1264        std::mem::forget(self);
1265    }
1266}
1267
1268impl InstallerCancelUpdateResponder {
1269    /// Sends a response to the FIDL transaction.
1270    ///
1271    /// Sets the channel to shutdown if an error occurs.
1272    pub fn send(self, mut result: Result<(), CancelError>) -> Result<(), fidl::Error> {
1273        let _result = self.send_raw(result);
1274        if _result.is_err() {
1275            self.control_handle.shutdown();
1276        }
1277        self.drop_without_shutdown();
1278        _result
1279    }
1280
1281    /// Similar to "send" but does not shutdown the channel if an error occurs.
1282    pub fn send_no_shutdown_on_err(
1283        self,
1284        mut result: Result<(), CancelError>,
1285    ) -> Result<(), fidl::Error> {
1286        let _result = self.send_raw(result);
1287        self.drop_without_shutdown();
1288        _result
1289    }
1290
1291    fn send_raw(&self, mut result: Result<(), CancelError>) -> Result<(), fidl::Error> {
1292        self.control_handle.inner.send::<fidl::encoding::ResultType<
1293            fidl::encoding::EmptyStruct,
1294            CancelError,
1295        >>(
1296            result,
1297            self.tx_id,
1298            0x472dec9160a1d0f,
1299            fidl::encoding::DynamicFlags::empty(),
1300        )
1301    }
1302}
1303
1304#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1305pub struct MonitorMarker;
1306
1307impl fidl::endpoints::ProtocolMarker for MonitorMarker {
1308    type Proxy = MonitorProxy;
1309    type RequestStream = MonitorRequestStream;
1310    #[cfg(target_os = "fuchsia")]
1311    type SynchronousProxy = MonitorSynchronousProxy;
1312
1313    const DEBUG_NAME: &'static str = "(anonymous) Monitor";
1314}
1315
1316pub trait MonitorProxyInterface: Send + Sync {
1317    type OnStateResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1318    fn r#on_state(&self, state: &State) -> Self::OnStateResponseFut;
1319}
1320#[derive(Debug)]
1321#[cfg(target_os = "fuchsia")]
1322pub struct MonitorSynchronousProxy {
1323    client: fidl::client::sync::Client,
1324}
1325
1326#[cfg(target_os = "fuchsia")]
1327impl fidl::endpoints::SynchronousProxy for MonitorSynchronousProxy {
1328    type Proxy = MonitorProxy;
1329    type Protocol = MonitorMarker;
1330
1331    fn from_channel(inner: fidl::Channel) -> Self {
1332        Self::new(inner)
1333    }
1334
1335    fn into_channel(self) -> fidl::Channel {
1336        self.client.into_channel()
1337    }
1338
1339    fn as_channel(&self) -> &fidl::Channel {
1340        self.client.as_channel()
1341    }
1342}
1343
1344#[cfg(target_os = "fuchsia")]
1345impl MonitorSynchronousProxy {
1346    pub fn new(channel: fidl::Channel) -> Self {
1347        let protocol_name = <MonitorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1348        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1349    }
1350
1351    pub fn into_channel(self) -> fidl::Channel {
1352        self.client.into_channel()
1353    }
1354
1355    /// Waits until an event arrives and returns it. It is safe for other
1356    /// threads to make concurrent requests while waiting for an event.
1357    pub fn wait_for_event(
1358        &self,
1359        deadline: zx::MonotonicInstant,
1360    ) -> Result<MonitorEvent, fidl::Error> {
1361        MonitorEvent::decode(self.client.wait_for_event(deadline)?)
1362    }
1363
1364    /// Receives a status update for this installation attempt.
1365    ///
1366    /// This request will be called for all state changes, skipping none.
1367    /// However, message delivery is throttled by the rate at which the
1368    /// implementation acknowledges the messages.
1369    ///
1370    /// The throttled delivery doesn't impact the underlying state of the
1371    /// [`Installer`].  It does not wait for any acknowledgements before it
1372    /// moves on to the next state in its state machine.  The [`Installer`] will
1373    /// simply queue up the states for the [`Monitor`] implementor to receive.
1374    ///
1375    /// During states with data that changes as the updage progress, the
1376    /// [`Installer`] may, at its discretion, collapse redundant information
1377    /// like the fraction completed, in the event that the [`Monitor`]
1378    /// implementation is not responding to the `OnState()` requests in a timely
1379    /// manner.
1380    ///
1381    /// + request `state` The new state of the update installation attempt.
1382    /// - response        The implementation is ready to receive the next
1383    ///                   [`State`] from the [`Installer`].
1384    pub fn r#on_state(
1385        &self,
1386        mut state: &State,
1387        ___deadline: zx::MonotonicInstant,
1388    ) -> Result<(), fidl::Error> {
1389        let _response =
1390            self.client.send_query::<MonitorOnStateRequest, fidl::encoding::EmptyPayload>(
1391                (state,),
1392                0x574105820d16cf26,
1393                fidl::encoding::DynamicFlags::empty(),
1394                ___deadline,
1395            )?;
1396        Ok(_response)
1397    }
1398}
1399
1400#[cfg(target_os = "fuchsia")]
1401impl From<MonitorSynchronousProxy> for zx::NullableHandle {
1402    fn from(value: MonitorSynchronousProxy) -> Self {
1403        value.into_channel().into()
1404    }
1405}
1406
1407#[cfg(target_os = "fuchsia")]
1408impl From<fidl::Channel> for MonitorSynchronousProxy {
1409    fn from(value: fidl::Channel) -> Self {
1410        Self::new(value)
1411    }
1412}
1413
1414#[cfg(target_os = "fuchsia")]
1415impl fidl::endpoints::FromClient for MonitorSynchronousProxy {
1416    type Protocol = MonitorMarker;
1417
1418    fn from_client(value: fidl::endpoints::ClientEnd<MonitorMarker>) -> Self {
1419        Self::new(value.into_channel())
1420    }
1421}
1422
1423#[derive(Debug, Clone)]
1424pub struct MonitorProxy {
1425    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1426}
1427
1428impl fidl::endpoints::Proxy for MonitorProxy {
1429    type Protocol = MonitorMarker;
1430
1431    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1432        Self::new(inner)
1433    }
1434
1435    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1436        self.client.into_channel().map_err(|client| Self { client })
1437    }
1438
1439    fn as_channel(&self) -> &::fidl::AsyncChannel {
1440        self.client.as_channel()
1441    }
1442}
1443
1444impl MonitorProxy {
1445    /// Create a new Proxy for fuchsia.update.installer/Monitor.
1446    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1447        let protocol_name = <MonitorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1448        Self { client: fidl::client::Client::new(channel, protocol_name) }
1449    }
1450
1451    /// Get a Stream of events from the remote end of the protocol.
1452    ///
1453    /// # Panics
1454    ///
1455    /// Panics if the event stream was already taken.
1456    pub fn take_event_stream(&self) -> MonitorEventStream {
1457        MonitorEventStream { event_receiver: self.client.take_event_receiver() }
1458    }
1459
1460    /// Receives a status update for this installation attempt.
1461    ///
1462    /// This request will be called for all state changes, skipping none.
1463    /// However, message delivery is throttled by the rate at which the
1464    /// implementation acknowledges the messages.
1465    ///
1466    /// The throttled delivery doesn't impact the underlying state of the
1467    /// [`Installer`].  It does not wait for any acknowledgements before it
1468    /// moves on to the next state in its state machine.  The [`Installer`] will
1469    /// simply queue up the states for the [`Monitor`] implementor to receive.
1470    ///
1471    /// During states with data that changes as the updage progress, the
1472    /// [`Installer`] may, at its discretion, collapse redundant information
1473    /// like the fraction completed, in the event that the [`Monitor`]
1474    /// implementation is not responding to the `OnState()` requests in a timely
1475    /// manner.
1476    ///
1477    /// + request `state` The new state of the update installation attempt.
1478    /// - response        The implementation is ready to receive the next
1479    ///                   [`State`] from the [`Installer`].
1480    pub fn r#on_state(
1481        &self,
1482        mut state: &State,
1483    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1484        MonitorProxyInterface::r#on_state(self, state)
1485    }
1486}
1487
1488impl MonitorProxyInterface for MonitorProxy {
1489    type OnStateResponseFut =
1490        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1491    fn r#on_state(&self, mut state: &State) -> Self::OnStateResponseFut {
1492        fn _decode(
1493            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1494        ) -> Result<(), fidl::Error> {
1495            let _response = fidl::client::decode_transaction_body::<
1496                fidl::encoding::EmptyPayload,
1497                fidl::encoding::DefaultFuchsiaResourceDialect,
1498                0x574105820d16cf26,
1499            >(_buf?)?;
1500            Ok(_response)
1501        }
1502        self.client.send_query_and_decode::<MonitorOnStateRequest, ()>(
1503            (state,),
1504            0x574105820d16cf26,
1505            fidl::encoding::DynamicFlags::empty(),
1506            _decode,
1507        )
1508    }
1509}
1510
1511pub struct MonitorEventStream {
1512    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1513}
1514
1515impl std::marker::Unpin for MonitorEventStream {}
1516
1517impl futures::stream::FusedStream for MonitorEventStream {
1518    fn is_terminated(&self) -> bool {
1519        self.event_receiver.is_terminated()
1520    }
1521}
1522
1523impl futures::Stream for MonitorEventStream {
1524    type Item = Result<MonitorEvent, fidl::Error>;
1525
1526    fn poll_next(
1527        mut self: std::pin::Pin<&mut Self>,
1528        cx: &mut std::task::Context<'_>,
1529    ) -> std::task::Poll<Option<Self::Item>> {
1530        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1531            &mut self.event_receiver,
1532            cx
1533        )?) {
1534            Some(buf) => std::task::Poll::Ready(Some(MonitorEvent::decode(buf))),
1535            None => std::task::Poll::Ready(None),
1536        }
1537    }
1538}
1539
1540#[derive(Debug)]
1541pub enum MonitorEvent {}
1542
1543impl MonitorEvent {
1544    /// Decodes a message buffer as a [`MonitorEvent`].
1545    fn decode(
1546        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1547    ) -> Result<MonitorEvent, fidl::Error> {
1548        let (bytes, _handles) = buf.split_mut();
1549        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1550        debug_assert_eq!(tx_header.tx_id, 0);
1551        match tx_header.ordinal {
1552            _ => Err(fidl::Error::UnknownOrdinal {
1553                ordinal: tx_header.ordinal,
1554                protocol_name: <MonitorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1555            }),
1556        }
1557    }
1558}
1559
1560/// A Stream of incoming requests for fuchsia.update.installer/Monitor.
1561pub struct MonitorRequestStream {
1562    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1563    is_terminated: bool,
1564}
1565
1566impl std::marker::Unpin for MonitorRequestStream {}
1567
1568impl futures::stream::FusedStream for MonitorRequestStream {
1569    fn is_terminated(&self) -> bool {
1570        self.is_terminated
1571    }
1572}
1573
1574impl fidl::endpoints::RequestStream for MonitorRequestStream {
1575    type Protocol = MonitorMarker;
1576    type ControlHandle = MonitorControlHandle;
1577
1578    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1579        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1580    }
1581
1582    fn control_handle(&self) -> Self::ControlHandle {
1583        MonitorControlHandle { inner: self.inner.clone() }
1584    }
1585
1586    fn into_inner(
1587        self,
1588    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1589    {
1590        (self.inner, self.is_terminated)
1591    }
1592
1593    fn from_inner(
1594        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1595        is_terminated: bool,
1596    ) -> Self {
1597        Self { inner, is_terminated }
1598    }
1599}
1600
1601impl futures::Stream for MonitorRequestStream {
1602    type Item = Result<MonitorRequest, fidl::Error>;
1603
1604    fn poll_next(
1605        mut self: std::pin::Pin<&mut Self>,
1606        cx: &mut std::task::Context<'_>,
1607    ) -> std::task::Poll<Option<Self::Item>> {
1608        let this = &mut *self;
1609        if this.inner.check_shutdown(cx) {
1610            this.is_terminated = true;
1611            return std::task::Poll::Ready(None);
1612        }
1613        if this.is_terminated {
1614            panic!("polled MonitorRequestStream after completion");
1615        }
1616        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1617            |bytes, handles| {
1618                match this.inner.channel().read_etc(cx, bytes, handles) {
1619                    std::task::Poll::Ready(Ok(())) => {}
1620                    std::task::Poll::Pending => return std::task::Poll::Pending,
1621                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1622                        this.is_terminated = true;
1623                        return std::task::Poll::Ready(None);
1624                    }
1625                    std::task::Poll::Ready(Err(e)) => {
1626                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1627                            e.into(),
1628                        ))));
1629                    }
1630                }
1631
1632                // A message has been received from the channel
1633                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1634
1635                std::task::Poll::Ready(Some(match header.ordinal {
1636                    0x574105820d16cf26 => {
1637                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1638                        let mut req = fidl::new_empty!(
1639                            MonitorOnStateRequest,
1640                            fidl::encoding::DefaultFuchsiaResourceDialect
1641                        );
1642                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MonitorOnStateRequest>(&header, _body_bytes, handles, &mut req)?;
1643                        let control_handle = MonitorControlHandle { inner: this.inner.clone() };
1644                        Ok(MonitorRequest::OnState {
1645                            state: req.state,
1646
1647                            responder: MonitorOnStateResponder {
1648                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1649                                tx_id: header.tx_id,
1650                            },
1651                        })
1652                    }
1653                    _ => Err(fidl::Error::UnknownOrdinal {
1654                        ordinal: header.ordinal,
1655                        protocol_name:
1656                            <MonitorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1657                    }),
1658                }))
1659            },
1660        )
1661    }
1662}
1663
1664/// Monitors a single update installation attempt.
1665///
1666/// Clients interested in receiving progress information for an update attempt
1667/// should implement this protocol and provide the client end to
1668/// [`Installer.StartUpdate`] or [`Installer.MonitorUpdate`].
1669#[derive(Debug)]
1670pub enum MonitorRequest {
1671    /// Receives a status update for this installation attempt.
1672    ///
1673    /// This request will be called for all state changes, skipping none.
1674    /// However, message delivery is throttled by the rate at which the
1675    /// implementation acknowledges the messages.
1676    ///
1677    /// The throttled delivery doesn't impact the underlying state of the
1678    /// [`Installer`].  It does not wait for any acknowledgements before it
1679    /// moves on to the next state in its state machine.  The [`Installer`] will
1680    /// simply queue up the states for the [`Monitor`] implementor to receive.
1681    ///
1682    /// During states with data that changes as the updage progress, the
1683    /// [`Installer`] may, at its discretion, collapse redundant information
1684    /// like the fraction completed, in the event that the [`Monitor`]
1685    /// implementation is not responding to the `OnState()` requests in a timely
1686    /// manner.
1687    ///
1688    /// + request `state` The new state of the update installation attempt.
1689    /// - response        The implementation is ready to receive the next
1690    ///                   [`State`] from the [`Installer`].
1691    OnState { state: State, responder: MonitorOnStateResponder },
1692}
1693
1694impl MonitorRequest {
1695    #[allow(irrefutable_let_patterns)]
1696    pub fn into_on_state(self) -> Option<(State, MonitorOnStateResponder)> {
1697        if let MonitorRequest::OnState { state, responder } = self {
1698            Some((state, responder))
1699        } else {
1700            None
1701        }
1702    }
1703
1704    /// Name of the method defined in FIDL
1705    pub fn method_name(&self) -> &'static str {
1706        match *self {
1707            MonitorRequest::OnState { .. } => "on_state",
1708        }
1709    }
1710}
1711
1712#[derive(Debug, Clone)]
1713pub struct MonitorControlHandle {
1714    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1715}
1716
1717impl fidl::endpoints::ControlHandle for MonitorControlHandle {
1718    fn shutdown(&self) {
1719        self.inner.shutdown()
1720    }
1721
1722    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1723        self.inner.shutdown_with_epitaph(status)
1724    }
1725
1726    fn is_closed(&self) -> bool {
1727        self.inner.channel().is_closed()
1728    }
1729    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1730        self.inner.channel().on_closed()
1731    }
1732
1733    #[cfg(target_os = "fuchsia")]
1734    fn signal_peer(
1735        &self,
1736        clear_mask: zx::Signals,
1737        set_mask: zx::Signals,
1738    ) -> Result<(), zx_status::Status> {
1739        use fidl::Peered;
1740        self.inner.channel().signal_peer(clear_mask, set_mask)
1741    }
1742}
1743
1744impl MonitorControlHandle {}
1745
1746#[must_use = "FIDL methods require a response to be sent"]
1747#[derive(Debug)]
1748pub struct MonitorOnStateResponder {
1749    control_handle: std::mem::ManuallyDrop<MonitorControlHandle>,
1750    tx_id: u32,
1751}
1752
1753/// Set the the channel to be shutdown (see [`MonitorControlHandle::shutdown`])
1754/// if the responder is dropped without sending a response, so that the client
1755/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1756impl std::ops::Drop for MonitorOnStateResponder {
1757    fn drop(&mut self) {
1758        self.control_handle.shutdown();
1759        // Safety: drops once, never accessed again
1760        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1761    }
1762}
1763
1764impl fidl::endpoints::Responder for MonitorOnStateResponder {
1765    type ControlHandle = MonitorControlHandle;
1766
1767    fn control_handle(&self) -> &MonitorControlHandle {
1768        &self.control_handle
1769    }
1770
1771    fn drop_without_shutdown(mut self) {
1772        // Safety: drops once, never accessed again due to mem::forget
1773        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1774        // Prevent Drop from running (which would shut down the channel)
1775        std::mem::forget(self);
1776    }
1777}
1778
1779impl MonitorOnStateResponder {
1780    /// Sends a response to the FIDL transaction.
1781    ///
1782    /// Sets the channel to shutdown if an error occurs.
1783    pub fn send(self) -> Result<(), fidl::Error> {
1784        let _result = self.send_raw();
1785        if _result.is_err() {
1786            self.control_handle.shutdown();
1787        }
1788        self.drop_without_shutdown();
1789        _result
1790    }
1791
1792    /// Similar to "send" but does not shutdown the channel if an error occurs.
1793    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1794        let _result = self.send_raw();
1795        self.drop_without_shutdown();
1796        _result
1797    }
1798
1799    fn send_raw(&self) -> Result<(), fidl::Error> {
1800        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1801            (),
1802            self.tx_id,
1803            0x574105820d16cf26,
1804            fidl::encoding::DynamicFlags::empty(),
1805        )
1806    }
1807}
1808
1809#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1810pub struct RebootControllerMarker;
1811
1812impl fidl::endpoints::ProtocolMarker for RebootControllerMarker {
1813    type Proxy = RebootControllerProxy;
1814    type RequestStream = RebootControllerRequestStream;
1815    #[cfg(target_os = "fuchsia")]
1816    type SynchronousProxy = RebootControllerSynchronousProxy;
1817
1818    const DEBUG_NAME: &'static str = "(anonymous) RebootController";
1819}
1820
1821pub trait RebootControllerProxyInterface: Send + Sync {
1822    fn r#unblock(&self) -> Result<(), fidl::Error>;
1823    fn r#detach(&self) -> Result<(), fidl::Error>;
1824}
1825#[derive(Debug)]
1826#[cfg(target_os = "fuchsia")]
1827pub struct RebootControllerSynchronousProxy {
1828    client: fidl::client::sync::Client,
1829}
1830
1831#[cfg(target_os = "fuchsia")]
1832impl fidl::endpoints::SynchronousProxy for RebootControllerSynchronousProxy {
1833    type Proxy = RebootControllerProxy;
1834    type Protocol = RebootControllerMarker;
1835
1836    fn from_channel(inner: fidl::Channel) -> Self {
1837        Self::new(inner)
1838    }
1839
1840    fn into_channel(self) -> fidl::Channel {
1841        self.client.into_channel()
1842    }
1843
1844    fn as_channel(&self) -> &fidl::Channel {
1845        self.client.as_channel()
1846    }
1847}
1848
1849#[cfg(target_os = "fuchsia")]
1850impl RebootControllerSynchronousProxy {
1851    pub fn new(channel: fidl::Channel) -> Self {
1852        let protocol_name = <RebootControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1853        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1854    }
1855
1856    pub fn into_channel(self) -> fidl::Channel {
1857        self.client.into_channel()
1858    }
1859
1860    /// Waits until an event arrives and returns it. It is safe for other
1861    /// threads to make concurrent requests while waiting for an event.
1862    pub fn wait_for_event(
1863        &self,
1864        deadline: zx::MonotonicInstant,
1865    ) -> Result<RebootControllerEvent, fidl::Error> {
1866        RebootControllerEvent::decode(self.client.wait_for_event(deadline)?)
1867    }
1868
1869    /// Informs the update attempt that it may reboot when ready, unblocking a
1870    /// pending reboot if it is already ready to reboot.
1871    ///
1872    /// If a controller is dropped without sending this request or
1873    /// [`RebootController.Detach`], the update attempt reclaims control of the
1874    /// timing of the reboot, behaving as if the update attempt was not given a
1875    /// [`RebootController`] at all.
1876    pub fn r#unblock(&self) -> Result<(), fidl::Error> {
1877        self.client.send::<fidl::encoding::EmptyPayload>(
1878            (),
1879            0x5705625395e3d520,
1880            fidl::encoding::DynamicFlags::empty(),
1881        )
1882    }
1883
1884    /// Informs the update attempt that it should wait to reboot indefinitely,
1885    /// even if this [`RebootController`] connection is dropped.
1886    pub fn r#detach(&self) -> Result<(), fidl::Error> {
1887        self.client.send::<fidl::encoding::EmptyPayload>(
1888            (),
1889            0x1daa560411955f16,
1890            fidl::encoding::DynamicFlags::empty(),
1891        )
1892    }
1893}
1894
1895#[cfg(target_os = "fuchsia")]
1896impl From<RebootControllerSynchronousProxy> for zx::NullableHandle {
1897    fn from(value: RebootControllerSynchronousProxy) -> Self {
1898        value.into_channel().into()
1899    }
1900}
1901
1902#[cfg(target_os = "fuchsia")]
1903impl From<fidl::Channel> for RebootControllerSynchronousProxy {
1904    fn from(value: fidl::Channel) -> Self {
1905        Self::new(value)
1906    }
1907}
1908
1909#[cfg(target_os = "fuchsia")]
1910impl fidl::endpoints::FromClient for RebootControllerSynchronousProxy {
1911    type Protocol = RebootControllerMarker;
1912
1913    fn from_client(value: fidl::endpoints::ClientEnd<RebootControllerMarker>) -> Self {
1914        Self::new(value.into_channel())
1915    }
1916}
1917
1918#[derive(Debug, Clone)]
1919pub struct RebootControllerProxy {
1920    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1921}
1922
1923impl fidl::endpoints::Proxy for RebootControllerProxy {
1924    type Protocol = RebootControllerMarker;
1925
1926    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1927        Self::new(inner)
1928    }
1929
1930    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1931        self.client.into_channel().map_err(|client| Self { client })
1932    }
1933
1934    fn as_channel(&self) -> &::fidl::AsyncChannel {
1935        self.client.as_channel()
1936    }
1937}
1938
1939impl RebootControllerProxy {
1940    /// Create a new Proxy for fuchsia.update.installer/RebootController.
1941    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1942        let protocol_name = <RebootControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1943        Self { client: fidl::client::Client::new(channel, protocol_name) }
1944    }
1945
1946    /// Get a Stream of events from the remote end of the protocol.
1947    ///
1948    /// # Panics
1949    ///
1950    /// Panics if the event stream was already taken.
1951    pub fn take_event_stream(&self) -> RebootControllerEventStream {
1952        RebootControllerEventStream { event_receiver: self.client.take_event_receiver() }
1953    }
1954
1955    /// Informs the update attempt that it may reboot when ready, unblocking a
1956    /// pending reboot if it is already ready to reboot.
1957    ///
1958    /// If a controller is dropped without sending this request or
1959    /// [`RebootController.Detach`], the update attempt reclaims control of the
1960    /// timing of the reboot, behaving as if the update attempt was not given a
1961    /// [`RebootController`] at all.
1962    pub fn r#unblock(&self) -> Result<(), fidl::Error> {
1963        RebootControllerProxyInterface::r#unblock(self)
1964    }
1965
1966    /// Informs the update attempt that it should wait to reboot indefinitely,
1967    /// even if this [`RebootController`] connection is dropped.
1968    pub fn r#detach(&self) -> Result<(), fidl::Error> {
1969        RebootControllerProxyInterface::r#detach(self)
1970    }
1971}
1972
1973impl RebootControllerProxyInterface for RebootControllerProxy {
1974    fn r#unblock(&self) -> Result<(), fidl::Error> {
1975        self.client.send::<fidl::encoding::EmptyPayload>(
1976            (),
1977            0x5705625395e3d520,
1978            fidl::encoding::DynamicFlags::empty(),
1979        )
1980    }
1981
1982    fn r#detach(&self) -> Result<(), fidl::Error> {
1983        self.client.send::<fidl::encoding::EmptyPayload>(
1984            (),
1985            0x1daa560411955f16,
1986            fidl::encoding::DynamicFlags::empty(),
1987        )
1988    }
1989}
1990
1991pub struct RebootControllerEventStream {
1992    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1993}
1994
1995impl std::marker::Unpin for RebootControllerEventStream {}
1996
1997impl futures::stream::FusedStream for RebootControllerEventStream {
1998    fn is_terminated(&self) -> bool {
1999        self.event_receiver.is_terminated()
2000    }
2001}
2002
2003impl futures::Stream for RebootControllerEventStream {
2004    type Item = Result<RebootControllerEvent, fidl::Error>;
2005
2006    fn poll_next(
2007        mut self: std::pin::Pin<&mut Self>,
2008        cx: &mut std::task::Context<'_>,
2009    ) -> std::task::Poll<Option<Self::Item>> {
2010        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2011            &mut self.event_receiver,
2012            cx
2013        )?) {
2014            Some(buf) => std::task::Poll::Ready(Some(RebootControllerEvent::decode(buf))),
2015            None => std::task::Poll::Ready(None),
2016        }
2017    }
2018}
2019
2020#[derive(Debug)]
2021pub enum RebootControllerEvent {}
2022
2023impl RebootControllerEvent {
2024    /// Decodes a message buffer as a [`RebootControllerEvent`].
2025    fn decode(
2026        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2027    ) -> Result<RebootControllerEvent, fidl::Error> {
2028        let (bytes, _handles) = buf.split_mut();
2029        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2030        debug_assert_eq!(tx_header.tx_id, 0);
2031        match tx_header.ordinal {
2032            _ => Err(fidl::Error::UnknownOrdinal {
2033                ordinal: tx_header.ordinal,
2034                protocol_name:
2035                    <RebootControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2036            }),
2037        }
2038    }
2039}
2040
2041/// A Stream of incoming requests for fuchsia.update.installer/RebootController.
2042pub struct RebootControllerRequestStream {
2043    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2044    is_terminated: bool,
2045}
2046
2047impl std::marker::Unpin for RebootControllerRequestStream {}
2048
2049impl futures::stream::FusedStream for RebootControllerRequestStream {
2050    fn is_terminated(&self) -> bool {
2051        self.is_terminated
2052    }
2053}
2054
2055impl fidl::endpoints::RequestStream for RebootControllerRequestStream {
2056    type Protocol = RebootControllerMarker;
2057    type ControlHandle = RebootControllerControlHandle;
2058
2059    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2060        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2061    }
2062
2063    fn control_handle(&self) -> Self::ControlHandle {
2064        RebootControllerControlHandle { inner: self.inner.clone() }
2065    }
2066
2067    fn into_inner(
2068        self,
2069    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2070    {
2071        (self.inner, self.is_terminated)
2072    }
2073
2074    fn from_inner(
2075        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2076        is_terminated: bool,
2077    ) -> Self {
2078        Self { inner, is_terminated }
2079    }
2080}
2081
2082impl futures::Stream for RebootControllerRequestStream {
2083    type Item = Result<RebootControllerRequest, fidl::Error>;
2084
2085    fn poll_next(
2086        mut self: std::pin::Pin<&mut Self>,
2087        cx: &mut std::task::Context<'_>,
2088    ) -> std::task::Poll<Option<Self::Item>> {
2089        let this = &mut *self;
2090        if this.inner.check_shutdown(cx) {
2091            this.is_terminated = true;
2092            return std::task::Poll::Ready(None);
2093        }
2094        if this.is_terminated {
2095            panic!("polled RebootControllerRequestStream after completion");
2096        }
2097        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2098            |bytes, handles| {
2099                match this.inner.channel().read_etc(cx, bytes, handles) {
2100                    std::task::Poll::Ready(Ok(())) => {}
2101                    std::task::Poll::Pending => return std::task::Poll::Pending,
2102                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2103                        this.is_terminated = true;
2104                        return std::task::Poll::Ready(None);
2105                    }
2106                    std::task::Poll::Ready(Err(e)) => {
2107                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2108                            e.into(),
2109                        ))));
2110                    }
2111                }
2112
2113                // A message has been received from the channel
2114                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2115
2116                std::task::Poll::Ready(Some(match header.ordinal {
2117                    0x5705625395e3d520 => {
2118                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2119                        let mut req = fidl::new_empty!(
2120                            fidl::encoding::EmptyPayload,
2121                            fidl::encoding::DefaultFuchsiaResourceDialect
2122                        );
2123                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2124                        let control_handle =
2125                            RebootControllerControlHandle { inner: this.inner.clone() };
2126                        Ok(RebootControllerRequest::Unblock { control_handle })
2127                    }
2128                    0x1daa560411955f16 => {
2129                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2130                        let mut req = fidl::new_empty!(
2131                            fidl::encoding::EmptyPayload,
2132                            fidl::encoding::DefaultFuchsiaResourceDialect
2133                        );
2134                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2135                        let control_handle =
2136                            RebootControllerControlHandle { inner: this.inner.clone() };
2137                        Ok(RebootControllerRequest::Detach { control_handle })
2138                    }
2139                    _ => Err(fidl::Error::UnknownOrdinal {
2140                        ordinal: header.ordinal,
2141                        protocol_name:
2142                            <RebootControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2143                    }),
2144                }))
2145            },
2146        )
2147    }
2148}
2149
2150/// Controls the timing of the reboot into the updated system.
2151///
2152/// If the client end of a [`RebootController`] is closed without calling
2153/// [`RebootController.Detach()`], the update attempt will fall back to the
2154/// default behavior of rebooting as soon as it is ready.
2155#[derive(Debug)]
2156pub enum RebootControllerRequest {
2157    /// Informs the update attempt that it may reboot when ready, unblocking a
2158    /// pending reboot if it is already ready to reboot.
2159    ///
2160    /// If a controller is dropped without sending this request or
2161    /// [`RebootController.Detach`], the update attempt reclaims control of the
2162    /// timing of the reboot, behaving as if the update attempt was not given a
2163    /// [`RebootController`] at all.
2164    Unblock { control_handle: RebootControllerControlHandle },
2165    /// Informs the update attempt that it should wait to reboot indefinitely,
2166    /// even if this [`RebootController`] connection is dropped.
2167    Detach { control_handle: RebootControllerControlHandle },
2168}
2169
2170impl RebootControllerRequest {
2171    #[allow(irrefutable_let_patterns)]
2172    pub fn into_unblock(self) -> Option<(RebootControllerControlHandle)> {
2173        if let RebootControllerRequest::Unblock { control_handle } = self {
2174            Some((control_handle))
2175        } else {
2176            None
2177        }
2178    }
2179
2180    #[allow(irrefutable_let_patterns)]
2181    pub fn into_detach(self) -> Option<(RebootControllerControlHandle)> {
2182        if let RebootControllerRequest::Detach { control_handle } = self {
2183            Some((control_handle))
2184        } else {
2185            None
2186        }
2187    }
2188
2189    /// Name of the method defined in FIDL
2190    pub fn method_name(&self) -> &'static str {
2191        match *self {
2192            RebootControllerRequest::Unblock { .. } => "unblock",
2193            RebootControllerRequest::Detach { .. } => "detach",
2194        }
2195    }
2196}
2197
2198#[derive(Debug, Clone)]
2199pub struct RebootControllerControlHandle {
2200    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2201}
2202
2203impl fidl::endpoints::ControlHandle for RebootControllerControlHandle {
2204    fn shutdown(&self) {
2205        self.inner.shutdown()
2206    }
2207
2208    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2209        self.inner.shutdown_with_epitaph(status)
2210    }
2211
2212    fn is_closed(&self) -> bool {
2213        self.inner.channel().is_closed()
2214    }
2215    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2216        self.inner.channel().on_closed()
2217    }
2218
2219    #[cfg(target_os = "fuchsia")]
2220    fn signal_peer(
2221        &self,
2222        clear_mask: zx::Signals,
2223        set_mask: zx::Signals,
2224    ) -> Result<(), zx_status::Status> {
2225        use fidl::Peered;
2226        self.inner.channel().signal_peer(clear_mask, set_mask)
2227    }
2228}
2229
2230impl RebootControllerControlHandle {}
2231
2232mod internal {
2233    use super::*;
2234
2235    impl fidl::encoding::ResourceTypeMarker for InstallerMonitorUpdateRequest {
2236        type Borrowed<'a> = &'a mut Self;
2237        fn take_or_borrow<'a>(
2238            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2239        ) -> Self::Borrowed<'a> {
2240            value
2241        }
2242    }
2243
2244    unsafe impl fidl::encoding::TypeMarker for InstallerMonitorUpdateRequest {
2245        type Owned = Self;
2246
2247        #[inline(always)]
2248        fn inline_align(_context: fidl::encoding::Context) -> usize {
2249            8
2250        }
2251
2252        #[inline(always)]
2253        fn inline_size(_context: fidl::encoding::Context) -> usize {
2254            24
2255        }
2256    }
2257
2258    unsafe impl
2259        fidl::encoding::Encode<
2260            InstallerMonitorUpdateRequest,
2261            fidl::encoding::DefaultFuchsiaResourceDialect,
2262        > for &mut InstallerMonitorUpdateRequest
2263    {
2264        #[inline]
2265        unsafe fn encode(
2266            self,
2267            encoder: &mut fidl::encoding::Encoder<
2268                '_,
2269                fidl::encoding::DefaultFuchsiaResourceDialect,
2270            >,
2271            offset: usize,
2272            _depth: fidl::encoding::Depth,
2273        ) -> fidl::Result<()> {
2274            encoder.debug_check_bounds::<InstallerMonitorUpdateRequest>(offset);
2275            // Delegate to tuple encoding.
2276            fidl::encoding::Encode::<InstallerMonitorUpdateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2277                (
2278                    <fidl::encoding::Optional<fidl::encoding::BoundedString<36>> as fidl::encoding::ValueTypeMarker>::borrow(&self.attempt_id),
2279                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<MonitorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.monitor),
2280                ),
2281                encoder, offset, _depth
2282            )
2283        }
2284    }
2285    unsafe impl<
2286        T0: fidl::encoding::Encode<
2287                fidl::encoding::Optional<fidl::encoding::BoundedString<36>>,
2288                fidl::encoding::DefaultFuchsiaResourceDialect,
2289            >,
2290        T1: fidl::encoding::Encode<
2291                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<MonitorMarker>>,
2292                fidl::encoding::DefaultFuchsiaResourceDialect,
2293            >,
2294    >
2295        fidl::encoding::Encode<
2296            InstallerMonitorUpdateRequest,
2297            fidl::encoding::DefaultFuchsiaResourceDialect,
2298        > for (T0, T1)
2299    {
2300        #[inline]
2301        unsafe fn encode(
2302            self,
2303            encoder: &mut fidl::encoding::Encoder<
2304                '_,
2305                fidl::encoding::DefaultFuchsiaResourceDialect,
2306            >,
2307            offset: usize,
2308            depth: fidl::encoding::Depth,
2309        ) -> fidl::Result<()> {
2310            encoder.debug_check_bounds::<InstallerMonitorUpdateRequest>(offset);
2311            // Zero out padding regions. There's no need to apply masks
2312            // because the unmasked parts will be overwritten by fields.
2313            unsafe {
2314                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
2315                (ptr as *mut u64).write_unaligned(0);
2316            }
2317            // Write the fields.
2318            self.0.encode(encoder, offset + 0, depth)?;
2319            self.1.encode(encoder, offset + 16, depth)?;
2320            Ok(())
2321        }
2322    }
2323
2324    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2325        for InstallerMonitorUpdateRequest
2326    {
2327        #[inline(always)]
2328        fn new_empty() -> Self {
2329            Self {
2330                attempt_id: fidl::new_empty!(
2331                    fidl::encoding::Optional<fidl::encoding::BoundedString<36>>,
2332                    fidl::encoding::DefaultFuchsiaResourceDialect
2333                ),
2334                monitor: fidl::new_empty!(
2335                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<MonitorMarker>>,
2336                    fidl::encoding::DefaultFuchsiaResourceDialect
2337                ),
2338            }
2339        }
2340
2341        #[inline]
2342        unsafe fn decode(
2343            &mut self,
2344            decoder: &mut fidl::encoding::Decoder<
2345                '_,
2346                fidl::encoding::DefaultFuchsiaResourceDialect,
2347            >,
2348            offset: usize,
2349            _depth: fidl::encoding::Depth,
2350        ) -> fidl::Result<()> {
2351            decoder.debug_check_bounds::<Self>(offset);
2352            // Verify that padding bytes are zero.
2353            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
2354            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2355            let mask = 0xffffffff00000000u64;
2356            let maskedval = padval & mask;
2357            if maskedval != 0 {
2358                return Err(fidl::Error::NonZeroPadding {
2359                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
2360                });
2361            }
2362            fidl::decode!(
2363                fidl::encoding::Optional<fidl::encoding::BoundedString<36>>,
2364                fidl::encoding::DefaultFuchsiaResourceDialect,
2365                &mut self.attempt_id,
2366                decoder,
2367                offset + 0,
2368                _depth
2369            )?;
2370            fidl::decode!(
2371                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<MonitorMarker>>,
2372                fidl::encoding::DefaultFuchsiaResourceDialect,
2373                &mut self.monitor,
2374                decoder,
2375                offset + 16,
2376                _depth
2377            )?;
2378            Ok(())
2379        }
2380    }
2381
2382    impl fidl::encoding::ResourceTypeMarker for InstallerStartUpdateRequest {
2383        type Borrowed<'a> = &'a mut Self;
2384        fn take_or_borrow<'a>(
2385            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2386        ) -> Self::Borrowed<'a> {
2387            value
2388        }
2389    }
2390
2391    unsafe impl fidl::encoding::TypeMarker for InstallerStartUpdateRequest {
2392        type Owned = Self;
2393
2394        #[inline(always)]
2395        fn inline_align(_context: fidl::encoding::Context) -> usize {
2396            8
2397        }
2398
2399        #[inline(always)]
2400        fn inline_size(_context: fidl::encoding::Context) -> usize {
2401            56
2402        }
2403    }
2404
2405    unsafe impl
2406        fidl::encoding::Encode<
2407            InstallerStartUpdateRequest,
2408            fidl::encoding::DefaultFuchsiaResourceDialect,
2409        > for &mut InstallerStartUpdateRequest
2410    {
2411        #[inline]
2412        unsafe fn encode(
2413            self,
2414            encoder: &mut fidl::encoding::Encoder<
2415                '_,
2416                fidl::encoding::DefaultFuchsiaResourceDialect,
2417            >,
2418            offset: usize,
2419            _depth: fidl::encoding::Depth,
2420        ) -> fidl::Result<()> {
2421            encoder.debug_check_bounds::<InstallerStartUpdateRequest>(offset);
2422            // Delegate to tuple encoding.
2423            fidl::encoding::Encode::<InstallerStartUpdateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2424                (
2425                    <fidl_fuchsia_pkg::PackageUrl as fidl::encoding::ValueTypeMarker>::borrow(&self.url),
2426                    <Options as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
2427                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<MonitorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.monitor),
2428                    <fidl::encoding::Optional<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RebootControllerMarker>>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.reboot_controller),
2429                    <fidl::encoding::Optional<fidl::encoding::Vector<u8, 64>> as fidl::encoding::ValueTypeMarker>::borrow(&self.signature),
2430                ),
2431                encoder, offset, _depth
2432            )
2433        }
2434    }
2435    unsafe impl<
2436        T0: fidl::encoding::Encode<
2437                fidl_fuchsia_pkg::PackageUrl,
2438                fidl::encoding::DefaultFuchsiaResourceDialect,
2439            >,
2440        T1: fidl::encoding::Encode<Options, fidl::encoding::DefaultFuchsiaResourceDialect>,
2441        T2: fidl::encoding::Encode<
2442                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<MonitorMarker>>,
2443                fidl::encoding::DefaultFuchsiaResourceDialect,
2444            >,
2445        T3: fidl::encoding::Encode<
2446                fidl::encoding::Optional<
2447                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RebootControllerMarker>>,
2448                >,
2449                fidl::encoding::DefaultFuchsiaResourceDialect,
2450            >,
2451        T4: fidl::encoding::Encode<
2452                fidl::encoding::Optional<fidl::encoding::Vector<u8, 64>>,
2453                fidl::encoding::DefaultFuchsiaResourceDialect,
2454            >,
2455    >
2456        fidl::encoding::Encode<
2457            InstallerStartUpdateRequest,
2458            fidl::encoding::DefaultFuchsiaResourceDialect,
2459        > for (T0, T1, T2, T3, T4)
2460    {
2461        #[inline]
2462        unsafe fn encode(
2463            self,
2464            encoder: &mut fidl::encoding::Encoder<
2465                '_,
2466                fidl::encoding::DefaultFuchsiaResourceDialect,
2467            >,
2468            offset: usize,
2469            depth: fidl::encoding::Depth,
2470        ) -> fidl::Result<()> {
2471            encoder.debug_check_bounds::<InstallerStartUpdateRequest>(offset);
2472            // Zero out padding regions. There's no need to apply masks
2473            // because the unmasked parts will be overwritten by fields.
2474            // Write the fields.
2475            self.0.encode(encoder, offset + 0, depth)?;
2476            self.1.encode(encoder, offset + 16, depth)?;
2477            self.2.encode(encoder, offset + 32, depth)?;
2478            self.3.encode(encoder, offset + 36, depth)?;
2479            self.4.encode(encoder, offset + 40, depth)?;
2480            Ok(())
2481        }
2482    }
2483
2484    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2485        for InstallerStartUpdateRequest
2486    {
2487        #[inline(always)]
2488        fn new_empty() -> Self {
2489            Self {
2490                url: fidl::new_empty!(
2491                    fidl_fuchsia_pkg::PackageUrl,
2492                    fidl::encoding::DefaultFuchsiaResourceDialect
2493                ),
2494                options: fidl::new_empty!(Options, fidl::encoding::DefaultFuchsiaResourceDialect),
2495                monitor: fidl::new_empty!(
2496                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<MonitorMarker>>,
2497                    fidl::encoding::DefaultFuchsiaResourceDialect
2498                ),
2499                reboot_controller: fidl::new_empty!(
2500                    fidl::encoding::Optional<
2501                        fidl::encoding::Endpoint<
2502                            fidl::endpoints::ServerEnd<RebootControllerMarker>,
2503                        >,
2504                    >,
2505                    fidl::encoding::DefaultFuchsiaResourceDialect
2506                ),
2507                signature: fidl::new_empty!(
2508                    fidl::encoding::Optional<fidl::encoding::Vector<u8, 64>>,
2509                    fidl::encoding::DefaultFuchsiaResourceDialect
2510                ),
2511            }
2512        }
2513
2514        #[inline]
2515        unsafe fn decode(
2516            &mut self,
2517            decoder: &mut fidl::encoding::Decoder<
2518                '_,
2519                fidl::encoding::DefaultFuchsiaResourceDialect,
2520            >,
2521            offset: usize,
2522            _depth: fidl::encoding::Depth,
2523        ) -> fidl::Result<()> {
2524            decoder.debug_check_bounds::<Self>(offset);
2525            // Verify that padding bytes are zero.
2526            fidl::decode!(
2527                fidl_fuchsia_pkg::PackageUrl,
2528                fidl::encoding::DefaultFuchsiaResourceDialect,
2529                &mut self.url,
2530                decoder,
2531                offset + 0,
2532                _depth
2533            )?;
2534            fidl::decode!(
2535                Options,
2536                fidl::encoding::DefaultFuchsiaResourceDialect,
2537                &mut self.options,
2538                decoder,
2539                offset + 16,
2540                _depth
2541            )?;
2542            fidl::decode!(
2543                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<MonitorMarker>>,
2544                fidl::encoding::DefaultFuchsiaResourceDialect,
2545                &mut self.monitor,
2546                decoder,
2547                offset + 32,
2548                _depth
2549            )?;
2550            fidl::decode!(
2551                fidl::encoding::Optional<
2552                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RebootControllerMarker>>,
2553                >,
2554                fidl::encoding::DefaultFuchsiaResourceDialect,
2555                &mut self.reboot_controller,
2556                decoder,
2557                offset + 36,
2558                _depth
2559            )?;
2560            fidl::decode!(
2561                fidl::encoding::Optional<fidl::encoding::Vector<u8, 64>>,
2562                fidl::encoding::DefaultFuchsiaResourceDialect,
2563                &mut self.signature,
2564                decoder,
2565                offset + 40,
2566                _depth
2567            )?;
2568            Ok(())
2569        }
2570    }
2571}