Skip to main content

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