Skip to main content

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