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