Skip to main content

fidl_fuchsia_fshost/
fidl_fuchsia_fshost.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_fshost_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct MountedSystemContainer {
16    /// Handle to a file where the new system image should be written to. Callers are
17    /// responsible for ensuring all data written to the file has been flushed to disk
18    /// before `mount_token` is dropped.
19    pub image_file: fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
20    /// Token used to maintain exclusive access to the system container. `image_file` is
21    /// only valid as long as this handle is kept alive. Must be dropped to install the new
22    /// blob volume via `fuchsia.fshost/Recovery.InstallBlobImage`.
23    pub mount_token: fidl::EventPair,
24}
25
26impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for MountedSystemContainer {}
27
28#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
29pub struct RecoveryMountSystemBlobVolumeRequest {
30    pub blob_exposed_dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
31}
32
33impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
34    for RecoveryMountSystemBlobVolumeRequest
35{
36}
37
38#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
39pub struct RecoveryWriteDataFileRequest {
40    pub filename: String,
41    pub payload: fidl::Vmo,
42}
43
44impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
45    for RecoveryWriteDataFileRequest
46{
47}
48
49#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
50pub struct StarnixVolumeProviderCheckRequest {
51    pub crypt: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
52}
53
54impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
55    for StarnixVolumeProviderCheckRequest
56{
57}
58
59#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
60pub struct StarnixVolumeProviderMountRequest {
61    pub crypt: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
62    pub mode: MountMode,
63    pub exposed_dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
64}
65
66impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
67    for StarnixVolumeProviderMountRequest
68{
69}
70
71#[derive(Debug, Default, PartialEq)]
72pub struct MountOptions {
73    pub read_only: Option<bool>,
74    /// [DEPRECATED] Metrics are always enabled now.
75    pub collect_metrics: Option<bool>,
76    pub verbose: Option<bool>,
77    pub write_compression_algorithm: Option<String>,
78    #[doc(hidden)]
79    pub __source_breaking: fidl::marker::SourceBreaking,
80}
81
82impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for MountOptions {}
83
84#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
85pub enum RecoveryGetBlobImageHandleResponse {
86    /// System container is unformatted and should be reprovisioned. This occurs when we do not
87    /// detect the filesystem type as what is expected for this device (e.g. we cannot find the
88    /// superblock), which suggests this device was never formatted.
89    Unformatted(Unformatted),
90    /// System container is mounted and ready for writing a new system image.
91    MountedSystemContainer(MountedSystemContainer),
92}
93
94impl RecoveryGetBlobImageHandleResponse {
95    #[inline]
96    pub fn ordinal(&self) -> u64 {
97        match *self {
98            Self::Unformatted(_) => 1,
99            Self::MountedSystemContainer(_) => 2,
100        }
101    }
102}
103
104impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
105    for RecoveryGetBlobImageHandleResponse
106{
107}
108
109#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
110pub struct AdminMarker;
111
112impl fidl::endpoints::ProtocolMarker for AdminMarker {
113    type Proxy = AdminProxy;
114    type RequestStream = AdminRequestStream;
115    #[cfg(target_os = "fuchsia")]
116    type SynchronousProxy = AdminSynchronousProxy;
117
118    const DEBUG_NAME: &'static str = "fuchsia.fshost.Admin";
119}
120impl fidl::endpoints::DiscoverableProtocolMarker for AdminMarker {}
121pub type AdminShredDataVolumeResult = Result<(), i32>;
122
123pub trait AdminProxyInterface: Send + Sync {
124    type ShredDataVolumeResponseFut: std::future::Future<Output = Result<AdminShredDataVolumeResult, fidl::Error>>
125        + Send;
126    fn r#shred_data_volume(&self) -> Self::ShredDataVolumeResponseFut;
127}
128#[derive(Debug)]
129#[cfg(target_os = "fuchsia")]
130pub struct AdminSynchronousProxy {
131    client: fidl::client::sync::Client,
132}
133
134#[cfg(target_os = "fuchsia")]
135impl fidl::endpoints::SynchronousProxy for AdminSynchronousProxy {
136    type Proxy = AdminProxy;
137    type Protocol = AdminMarker;
138
139    fn from_channel(inner: fidl::Channel) -> Self {
140        Self::new(inner)
141    }
142
143    fn into_channel(self) -> fidl::Channel {
144        self.client.into_channel()
145    }
146
147    fn as_channel(&self) -> &fidl::Channel {
148        self.client.as_channel()
149    }
150}
151
152#[cfg(target_os = "fuchsia")]
153impl AdminSynchronousProxy {
154    pub fn new(channel: fidl::Channel) -> Self {
155        Self { client: fidl::client::sync::Client::new(channel) }
156    }
157
158    pub fn into_channel(self) -> fidl::Channel {
159        self.client.into_channel()
160    }
161
162    /// Waits until an event arrives and returns it. It is safe for other
163    /// threads to make concurrent requests while waiting for an event.
164    pub fn wait_for_event(
165        &self,
166        deadline: zx::MonotonicInstant,
167    ) -> Result<AdminEvent, fidl::Error> {
168        AdminEvent::decode(self.client.wait_for_event::<AdminMarker>(deadline)?)
169    }
170
171    /// Wipes the data volume which will get reinitialised upon next boot.  This is not
172    /// cryptographically secure; the caller should take care to reset hardware keys.
173    pub fn r#shred_data_volume(
174        &self,
175        ___deadline: zx::MonotonicInstant,
176    ) -> Result<AdminShredDataVolumeResult, fidl::Error> {
177        let _response = self.client.send_query::<
178            fidl::encoding::EmptyPayload,
179            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
180            AdminMarker,
181        >(
182            (),
183            0xb0d6c2e95343a10,
184            fidl::encoding::DynamicFlags::empty(),
185            ___deadline,
186        )?;
187        Ok(_response.map(|x| x))
188    }
189}
190
191#[cfg(target_os = "fuchsia")]
192impl From<AdminSynchronousProxy> for zx::NullableHandle {
193    fn from(value: AdminSynchronousProxy) -> Self {
194        value.into_channel().into()
195    }
196}
197
198#[cfg(target_os = "fuchsia")]
199impl From<fidl::Channel> for AdminSynchronousProxy {
200    fn from(value: fidl::Channel) -> Self {
201        Self::new(value)
202    }
203}
204
205#[cfg(target_os = "fuchsia")]
206impl fidl::endpoints::FromClient for AdminSynchronousProxy {
207    type Protocol = AdminMarker;
208
209    fn from_client(value: fidl::endpoints::ClientEnd<AdminMarker>) -> Self {
210        Self::new(value.into_channel())
211    }
212}
213
214#[derive(Debug, Clone)]
215pub struct AdminProxy {
216    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
217}
218
219impl fidl::endpoints::Proxy for AdminProxy {
220    type Protocol = AdminMarker;
221
222    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
223        Self::new(inner)
224    }
225
226    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
227        self.client.into_channel().map_err(|client| Self { client })
228    }
229
230    fn as_channel(&self) -> &::fidl::AsyncChannel {
231        self.client.as_channel()
232    }
233}
234
235impl AdminProxy {
236    /// Create a new Proxy for fuchsia.fshost/Admin.
237    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
238        let protocol_name = <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
239        Self { client: fidl::client::Client::new(channel, protocol_name) }
240    }
241
242    /// Get a Stream of events from the remote end of the protocol.
243    ///
244    /// # Panics
245    ///
246    /// Panics if the event stream was already taken.
247    pub fn take_event_stream(&self) -> AdminEventStream {
248        AdminEventStream { event_receiver: self.client.take_event_receiver() }
249    }
250
251    /// Wipes the data volume which will get reinitialised upon next boot.  This is not
252    /// cryptographically secure; the caller should take care to reset hardware keys.
253    pub fn r#shred_data_volume(
254        &self,
255    ) -> fidl::client::QueryResponseFut<
256        AdminShredDataVolumeResult,
257        fidl::encoding::DefaultFuchsiaResourceDialect,
258    > {
259        AdminProxyInterface::r#shred_data_volume(self)
260    }
261}
262
263impl AdminProxyInterface for AdminProxy {
264    type ShredDataVolumeResponseFut = fidl::client::QueryResponseFut<
265        AdminShredDataVolumeResult,
266        fidl::encoding::DefaultFuchsiaResourceDialect,
267    >;
268    fn r#shred_data_volume(&self) -> Self::ShredDataVolumeResponseFut {
269        fn _decode(
270            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
271        ) -> Result<AdminShredDataVolumeResult, fidl::Error> {
272            let _response = fidl::client::decode_transaction_body::<
273                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
274                fidl::encoding::DefaultFuchsiaResourceDialect,
275                0xb0d6c2e95343a10,
276            >(_buf?)?;
277            Ok(_response.map(|x| x))
278        }
279        self.client
280            .send_query_and_decode::<fidl::encoding::EmptyPayload, AdminShredDataVolumeResult>(
281                (),
282                0xb0d6c2e95343a10,
283                fidl::encoding::DynamicFlags::empty(),
284                _decode,
285            )
286    }
287}
288
289pub struct AdminEventStream {
290    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
291}
292
293impl std::marker::Unpin for AdminEventStream {}
294
295impl futures::stream::FusedStream for AdminEventStream {
296    fn is_terminated(&self) -> bool {
297        self.event_receiver.is_terminated()
298    }
299}
300
301impl futures::Stream for AdminEventStream {
302    type Item = Result<AdminEvent, fidl::Error>;
303
304    fn poll_next(
305        mut self: std::pin::Pin<&mut Self>,
306        cx: &mut std::task::Context<'_>,
307    ) -> std::task::Poll<Option<Self::Item>> {
308        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
309            &mut self.event_receiver,
310            cx
311        )?) {
312            Some(buf) => std::task::Poll::Ready(Some(AdminEvent::decode(buf))),
313            None => std::task::Poll::Ready(None),
314        }
315    }
316}
317
318#[derive(Debug)]
319pub enum AdminEvent {}
320
321impl AdminEvent {
322    /// Decodes a message buffer as a [`AdminEvent`].
323    fn decode(
324        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
325    ) -> Result<AdminEvent, fidl::Error> {
326        let (bytes, _handles) = buf.split_mut();
327        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
328        debug_assert_eq!(tx_header.tx_id, 0);
329        match tx_header.ordinal {
330            _ => Err(fidl::Error::UnknownOrdinal {
331                ordinal: tx_header.ordinal,
332                protocol_name: <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
333            }),
334        }
335    }
336}
337
338/// A Stream of incoming requests for fuchsia.fshost/Admin.
339pub struct AdminRequestStream {
340    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
341    is_terminated: bool,
342}
343
344impl std::marker::Unpin for AdminRequestStream {}
345
346impl futures::stream::FusedStream for AdminRequestStream {
347    fn is_terminated(&self) -> bool {
348        self.is_terminated
349    }
350}
351
352impl fidl::endpoints::RequestStream for AdminRequestStream {
353    type Protocol = AdminMarker;
354    type ControlHandle = AdminControlHandle;
355
356    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
357        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
358    }
359
360    fn control_handle(&self) -> Self::ControlHandle {
361        AdminControlHandle { inner: self.inner.clone() }
362    }
363
364    fn into_inner(
365        self,
366    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
367    {
368        (self.inner, self.is_terminated)
369    }
370
371    fn from_inner(
372        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
373        is_terminated: bool,
374    ) -> Self {
375        Self { inner, is_terminated }
376    }
377}
378
379impl futures::Stream for AdminRequestStream {
380    type Item = Result<AdminRequest, fidl::Error>;
381
382    fn poll_next(
383        mut self: std::pin::Pin<&mut Self>,
384        cx: &mut std::task::Context<'_>,
385    ) -> std::task::Poll<Option<Self::Item>> {
386        let this = &mut *self;
387        if this.inner.check_shutdown(cx) {
388            this.is_terminated = true;
389            return std::task::Poll::Ready(None);
390        }
391        if this.is_terminated {
392            panic!("polled AdminRequestStream after completion");
393        }
394        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
395            |bytes, handles| {
396                match this.inner.channel().read_etc(cx, bytes, handles) {
397                    std::task::Poll::Ready(Ok(())) => {}
398                    std::task::Poll::Pending => return std::task::Poll::Pending,
399                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
400                        this.is_terminated = true;
401                        return std::task::Poll::Ready(None);
402                    }
403                    std::task::Poll::Ready(Err(e)) => {
404                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
405                            e.into(),
406                        ))));
407                    }
408                }
409
410                // A message has been received from the channel
411                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
412
413                std::task::Poll::Ready(Some(match header.ordinal {
414                    0xb0d6c2e95343a10 => {
415                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
416                        let mut req = fidl::new_empty!(
417                            fidl::encoding::EmptyPayload,
418                            fidl::encoding::DefaultFuchsiaResourceDialect
419                        );
420                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
421                        let control_handle = AdminControlHandle { inner: this.inner.clone() };
422                        Ok(AdminRequest::ShredDataVolume {
423                            responder: AdminShredDataVolumeResponder {
424                                control_handle: std::mem::ManuallyDrop::new(control_handle),
425                                tx_id: header.tx_id,
426                            },
427                        })
428                    }
429                    _ => Err(fidl::Error::UnknownOrdinal {
430                        ordinal: header.ordinal,
431                        protocol_name: <AdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
432                    }),
433                }))
434            },
435        )
436    }
437}
438
439/// Manages fshost lifecycle
440#[derive(Debug)]
441pub enum AdminRequest {
442    /// Wipes the data volume which will get reinitialised upon next boot.  This is not
443    /// cryptographically secure; the caller should take care to reset hardware keys.
444    ShredDataVolume { responder: AdminShredDataVolumeResponder },
445}
446
447impl AdminRequest {
448    #[allow(irrefutable_let_patterns)]
449    pub fn into_shred_data_volume(self) -> Option<(AdminShredDataVolumeResponder)> {
450        if let AdminRequest::ShredDataVolume { responder } = self {
451            Some((responder))
452        } else {
453            None
454        }
455    }
456
457    /// Name of the method defined in FIDL
458    pub fn method_name(&self) -> &'static str {
459        match *self {
460            AdminRequest::ShredDataVolume { .. } => "shred_data_volume",
461        }
462    }
463}
464
465#[derive(Debug, Clone)]
466pub struct AdminControlHandle {
467    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
468}
469
470impl fidl::endpoints::ControlHandle for AdminControlHandle {
471    fn shutdown(&self) {
472        self.inner.shutdown()
473    }
474
475    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
476        self.inner.shutdown_with_epitaph(status)
477    }
478
479    fn is_closed(&self) -> bool {
480        self.inner.channel().is_closed()
481    }
482    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
483        self.inner.channel().on_closed()
484    }
485
486    #[cfg(target_os = "fuchsia")]
487    fn signal_peer(
488        &self,
489        clear_mask: zx::Signals,
490        set_mask: zx::Signals,
491    ) -> Result<(), zx_status::Status> {
492        use fidl::Peered;
493        self.inner.channel().signal_peer(clear_mask, set_mask)
494    }
495}
496
497impl AdminControlHandle {}
498
499#[must_use = "FIDL methods require a response to be sent"]
500#[derive(Debug)]
501pub struct AdminShredDataVolumeResponder {
502    control_handle: std::mem::ManuallyDrop<AdminControlHandle>,
503    tx_id: u32,
504}
505
506/// Set the the channel to be shutdown (see [`AdminControlHandle::shutdown`])
507/// if the responder is dropped without sending a response, so that the client
508/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
509impl std::ops::Drop for AdminShredDataVolumeResponder {
510    fn drop(&mut self) {
511        self.control_handle.shutdown();
512        // Safety: drops once, never accessed again
513        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
514    }
515}
516
517impl fidl::endpoints::Responder for AdminShredDataVolumeResponder {
518    type ControlHandle = AdminControlHandle;
519
520    fn control_handle(&self) -> &AdminControlHandle {
521        &self.control_handle
522    }
523
524    fn drop_without_shutdown(mut self) {
525        // Safety: drops once, never accessed again due to mem::forget
526        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
527        // Prevent Drop from running (which would shut down the channel)
528        std::mem::forget(self);
529    }
530}
531
532impl AdminShredDataVolumeResponder {
533    /// Sends a response to the FIDL transaction.
534    ///
535    /// Sets the channel to shutdown if an error occurs.
536    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
537        let _result = self.send_raw(result);
538        if _result.is_err() {
539            self.control_handle.shutdown();
540        }
541        self.drop_without_shutdown();
542        _result
543    }
544
545    /// Similar to "send" but does not shutdown the channel if an error occurs.
546    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
547        let _result = self.send_raw(result);
548        self.drop_without_shutdown();
549        _result
550    }
551
552    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
553        self.control_handle
554            .inner
555            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
556                result,
557                self.tx_id,
558                0xb0d6c2e95343a10,
559                fidl::encoding::DynamicFlags::empty(),
560            )
561    }
562}
563
564#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
565pub struct RecoveryMarker;
566
567impl fidl::endpoints::ProtocolMarker for RecoveryMarker {
568    type Proxy = RecoveryProxy;
569    type RequestStream = RecoveryRequestStream;
570    #[cfg(target_os = "fuchsia")]
571    type SynchronousProxy = RecoverySynchronousProxy;
572
573    const DEBUG_NAME: &'static str = "fuchsia.fshost.Recovery";
574}
575impl fidl::endpoints::DiscoverableProtocolMarker for RecoveryMarker {}
576pub type RecoveryInitSystemPartitionTableResult = Result<(), i32>;
577pub type RecoveryWriteDataFileResult = Result<(), i32>;
578pub type RecoveryFormatSystemBlobVolumeResult = Result<(), i32>;
579pub type RecoveryMountSystemBlobVolumeResult = Result<(), i32>;
580pub type RecoveryGetBlobImageHandleResult = Result<RecoveryGetBlobImageHandleResponse, i32>;
581pub type RecoveryInstallBlobImageResult = Result<(), i32>;
582
583pub trait RecoveryProxyInterface: Send + Sync {
584    type InitSystemPartitionTableResponseFut: std::future::Future<Output = Result<RecoveryInitSystemPartitionTableResult, fidl::Error>>
585        + Send;
586    fn r#init_system_partition_table(
587        &self,
588        partitions: &[fidl_fuchsia_storage_partitions::PartitionInfo],
589    ) -> Self::InitSystemPartitionTableResponseFut;
590    type WriteDataFileResponseFut: std::future::Future<Output = Result<RecoveryWriteDataFileResult, fidl::Error>>
591        + Send;
592    fn r#write_data_file(
593        &self,
594        filename: &str,
595        payload: fidl::Vmo,
596    ) -> Self::WriteDataFileResponseFut;
597    type FormatSystemBlobVolumeResponseFut: std::future::Future<Output = Result<RecoveryFormatSystemBlobVolumeResult, fidl::Error>>
598        + Send;
599    fn r#format_system_blob_volume(&self) -> Self::FormatSystemBlobVolumeResponseFut;
600    type MountSystemBlobVolumeResponseFut: std::future::Future<Output = Result<RecoveryMountSystemBlobVolumeResult, fidl::Error>>
601        + Send;
602    fn r#mount_system_blob_volume(
603        &self,
604        blob_exposed_dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
605    ) -> Self::MountSystemBlobVolumeResponseFut;
606    type GetBlobImageHandleResponseFut: std::future::Future<Output = Result<RecoveryGetBlobImageHandleResult, fidl::Error>>
607        + Send;
608    fn r#get_blob_image_handle(&self) -> Self::GetBlobImageHandleResponseFut;
609    type InstallBlobImageResponseFut: std::future::Future<Output = Result<RecoveryInstallBlobImageResult, fidl::Error>>
610        + Send;
611    fn r#install_blob_image(&self) -> Self::InstallBlobImageResponseFut;
612}
613#[derive(Debug)]
614#[cfg(target_os = "fuchsia")]
615pub struct RecoverySynchronousProxy {
616    client: fidl::client::sync::Client,
617}
618
619#[cfg(target_os = "fuchsia")]
620impl fidl::endpoints::SynchronousProxy for RecoverySynchronousProxy {
621    type Proxy = RecoveryProxy;
622    type Protocol = RecoveryMarker;
623
624    fn from_channel(inner: fidl::Channel) -> Self {
625        Self::new(inner)
626    }
627
628    fn into_channel(self) -> fidl::Channel {
629        self.client.into_channel()
630    }
631
632    fn as_channel(&self) -> &fidl::Channel {
633        self.client.as_channel()
634    }
635}
636
637#[cfg(target_os = "fuchsia")]
638impl RecoverySynchronousProxy {
639    pub fn new(channel: fidl::Channel) -> Self {
640        Self { client: fidl::client::sync::Client::new(channel) }
641    }
642
643    pub fn into_channel(self) -> fidl::Channel {
644        self.client.into_channel()
645    }
646
647    /// Waits until an event arrives and returns it. It is safe for other
648    /// threads to make concurrent requests while waiting for an event.
649    pub fn wait_for_event(
650        &self,
651        deadline: zx::MonotonicInstant,
652    ) -> Result<RecoveryEvent, fidl::Error> {
653        RecoveryEvent::decode(self.client.wait_for_event::<RecoveryMarker>(deadline)?)
654    }
655
656    /// Wipes and re-initializes the system partition table.  This is a destructive operation!
657    pub fn r#init_system_partition_table(
658        &self,
659        mut partitions: &[fidl_fuchsia_storage_partitions::PartitionInfo],
660        ___deadline: zx::MonotonicInstant,
661    ) -> Result<RecoveryInitSystemPartitionTableResult, fidl::Error> {
662        let _response = self.client.send_query::<
663            RecoveryInitSystemPartitionTableRequest,
664            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
665            RecoveryMarker,
666        >(
667            (partitions,),
668            0x3dcadcbb75e2330b,
669            fidl::encoding::DynamicFlags::empty(),
670            ___deadline,
671        )?;
672        Ok(_response.map(|x| x))
673    }
674
675    /// Writes `filename` into the data partition with contents from `payload`, formatting the data
676    /// partition if it isn't already formatted.  Overwrites file if it already exists.
677    ///
678    /// This can only be called while the data partition isn't already mounted, which is typically
679    /// in recovery builds where fshost is running with the `ramdisk_image` flag set.
680    pub fn r#write_data_file(
681        &self,
682        mut filename: &str,
683        mut payload: fidl::Vmo,
684        ___deadline: zx::MonotonicInstant,
685    ) -> Result<RecoveryWriteDataFileResult, fidl::Error> {
686        let _response = self.client.send_query::<
687            RecoveryWriteDataFileRequest,
688            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
689            RecoveryMarker,
690        >(
691            (filename, payload,),
692            0xd6cf7b3f57b418d,
693            fidl::encoding::DynamicFlags::empty(),
694            ___deadline,
695        )?;
696        Ok(_response.map(|x| x))
697    }
698
699    /// Formats the blob volume in the system container. If the system container does not have a
700    /// blob volume, a new one will be created. All existing blobs will be deleted. If the system
701    /// container is corrupt or unmountable, this function will have no effect and will leave the
702    /// disk intact.
703    ///
704    /// **WARNING**: This can cause irreversible data loss and can render a device unbootable.
705    pub fn r#format_system_blob_volume(
706        &self,
707        ___deadline: zx::MonotonicInstant,
708    ) -> Result<RecoveryFormatSystemBlobVolumeResult, fidl::Error> {
709        let _response = self.client.send_query::<
710            fidl::encoding::EmptyPayload,
711            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
712            RecoveryMarker,
713        >(
714            (),
715            0x4e93f6b198f61f7d,
716            fidl::encoding::DynamicFlags::empty(),
717            ___deadline,
718        )?;
719        Ok(_response.map(|x| x))
720    }
721
722    /// Mounts the system container's blob volume, and returns a handle to the blob volume's
723    /// exposed directory to facilitate writing a new system. The system container will remain
724    /// mounted as long as `blob_exposed_dir` is kept open. Only the blob volume will be mounted.
725    pub fn r#mount_system_blob_volume(
726        &self,
727        mut blob_exposed_dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
728        ___deadline: zx::MonotonicInstant,
729    ) -> Result<RecoveryMountSystemBlobVolumeResult, fidl::Error> {
730        let _response = self.client.send_query::<
731            RecoveryMountSystemBlobVolumeRequest,
732            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
733            RecoveryMarker,
734        >(
735            (blob_exposed_dir,),
736            0x63ddff4240e908c0,
737            fidl::encoding::DynamicFlags::empty(),
738            ___deadline,
739        )?;
740        Ok(_response.map(|x| x))
741    }
742
743    /// Obtains a handle to a file where a new system blob volume can be written. The contents of
744    /// the file must be a valid fxfs partition image containing a blob volume. The existing blob
745    /// volume will remain unmodified until the system is rebooted, or `InstallBlobImage` is
746    /// called. The system container will remain mounted as long as `mount_token` is kept open.
747    /// *NOTE*: This method will delete any existing image data cached on disk. Callers are
748    /// responsible for keeping the returned `image_file` and `mount_token` alive until the system
749    /// image has been fully written and flushed to disk.
750    ///
751    /// # Errors
752    ///
753    /// * `ZX_ERR_IO_DATA_INTEGRITY`: An existing filesystem was found on the device, but it could
754    ///   not be mounted. This indicates that the filesystem is possibly corrupt, or has a newer
755    ///   on-disk version than the recovery image. To avoid unintended data loss, the user should
756    ///   explicitly initiate any remedial action, such as wiping the device or using a newer image.
757    /// * `ZX_ERR_INTERNAL`: An internal error occured; see fshost logs for more context.
758    pub fn r#get_blob_image_handle(
759        &self,
760        ___deadline: zx::MonotonicInstant,
761    ) -> Result<RecoveryGetBlobImageHandleResult, fidl::Error> {
762        let _response = self.client.send_query::<
763            fidl::encoding::EmptyPayload,
764            fidl::encoding::ResultType<RecoveryGetBlobImageHandleResponse, i32>,
765            RecoveryMarker,
766        >(
767            (),
768            0x5cc0f6646bdb5e57,
769            fidl::encoding::DynamicFlags::empty(),
770            ___deadline,
771        )?;
772        Ok(_response.map(|x| x))
773    }
774
775    /// Installs the blob volume previously written via `GetBlobImageHandle`, replacing the
776    /// existing blob volume in the system container. On failure, the existing blob volume will
777    /// remain intact, and the written image will be deleted to free space. A new blob image can
778    /// then be written and the installation process restarted. If no blob volume has been written,
779    /// this will have no effect. This function will block until the system container is unmounted.
780    pub fn r#install_blob_image(
781        &self,
782        ___deadline: zx::MonotonicInstant,
783    ) -> Result<RecoveryInstallBlobImageResult, fidl::Error> {
784        let _response = self.client.send_query::<
785            fidl::encoding::EmptyPayload,
786            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
787            RecoveryMarker,
788        >(
789            (),
790            0x323375398af8a29,
791            fidl::encoding::DynamicFlags::empty(),
792            ___deadline,
793        )?;
794        Ok(_response.map(|x| x))
795    }
796}
797
798#[cfg(target_os = "fuchsia")]
799impl From<RecoverySynchronousProxy> for zx::NullableHandle {
800    fn from(value: RecoverySynchronousProxy) -> Self {
801        value.into_channel().into()
802    }
803}
804
805#[cfg(target_os = "fuchsia")]
806impl From<fidl::Channel> for RecoverySynchronousProxy {
807    fn from(value: fidl::Channel) -> Self {
808        Self::new(value)
809    }
810}
811
812#[cfg(target_os = "fuchsia")]
813impl fidl::endpoints::FromClient for RecoverySynchronousProxy {
814    type Protocol = RecoveryMarker;
815
816    fn from_client(value: fidl::endpoints::ClientEnd<RecoveryMarker>) -> Self {
817        Self::new(value.into_channel())
818    }
819}
820
821#[derive(Debug, Clone)]
822pub struct RecoveryProxy {
823    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
824}
825
826impl fidl::endpoints::Proxy for RecoveryProxy {
827    type Protocol = RecoveryMarker;
828
829    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
830        Self::new(inner)
831    }
832
833    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
834        self.client.into_channel().map_err(|client| Self { client })
835    }
836
837    fn as_channel(&self) -> &::fidl::AsyncChannel {
838        self.client.as_channel()
839    }
840}
841
842impl RecoveryProxy {
843    /// Create a new Proxy for fuchsia.fshost/Recovery.
844    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
845        let protocol_name = <RecoveryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
846        Self { client: fidl::client::Client::new(channel, protocol_name) }
847    }
848
849    /// Get a Stream of events from the remote end of the protocol.
850    ///
851    /// # Panics
852    ///
853    /// Panics if the event stream was already taken.
854    pub fn take_event_stream(&self) -> RecoveryEventStream {
855        RecoveryEventStream { event_receiver: self.client.take_event_receiver() }
856    }
857
858    /// Wipes and re-initializes the system partition table.  This is a destructive operation!
859    pub fn r#init_system_partition_table(
860        &self,
861        mut partitions: &[fidl_fuchsia_storage_partitions::PartitionInfo],
862    ) -> fidl::client::QueryResponseFut<
863        RecoveryInitSystemPartitionTableResult,
864        fidl::encoding::DefaultFuchsiaResourceDialect,
865    > {
866        RecoveryProxyInterface::r#init_system_partition_table(self, partitions)
867    }
868
869    /// Writes `filename` into the data partition with contents from `payload`, formatting the data
870    /// partition if it isn't already formatted.  Overwrites file if it already exists.
871    ///
872    /// This can only be called while the data partition isn't already mounted, which is typically
873    /// in recovery builds where fshost is running with the `ramdisk_image` flag set.
874    pub fn r#write_data_file(
875        &self,
876        mut filename: &str,
877        mut payload: fidl::Vmo,
878    ) -> fidl::client::QueryResponseFut<
879        RecoveryWriteDataFileResult,
880        fidl::encoding::DefaultFuchsiaResourceDialect,
881    > {
882        RecoveryProxyInterface::r#write_data_file(self, filename, payload)
883    }
884
885    /// Formats the blob volume in the system container. If the system container does not have a
886    /// blob volume, a new one will be created. All existing blobs will be deleted. If the system
887    /// container is corrupt or unmountable, this function will have no effect and will leave the
888    /// disk intact.
889    ///
890    /// **WARNING**: This can cause irreversible data loss and can render a device unbootable.
891    pub fn r#format_system_blob_volume(
892        &self,
893    ) -> fidl::client::QueryResponseFut<
894        RecoveryFormatSystemBlobVolumeResult,
895        fidl::encoding::DefaultFuchsiaResourceDialect,
896    > {
897        RecoveryProxyInterface::r#format_system_blob_volume(self)
898    }
899
900    /// Mounts the system container's blob volume, and returns a handle to the blob volume's
901    /// exposed directory to facilitate writing a new system. The system container will remain
902    /// mounted as long as `blob_exposed_dir` is kept open. Only the blob volume will be mounted.
903    pub fn r#mount_system_blob_volume(
904        &self,
905        mut blob_exposed_dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
906    ) -> fidl::client::QueryResponseFut<
907        RecoveryMountSystemBlobVolumeResult,
908        fidl::encoding::DefaultFuchsiaResourceDialect,
909    > {
910        RecoveryProxyInterface::r#mount_system_blob_volume(self, blob_exposed_dir)
911    }
912
913    /// Obtains a handle to a file where a new system blob volume can be written. The contents of
914    /// the file must be a valid fxfs partition image containing a blob volume. The existing blob
915    /// volume will remain unmodified until the system is rebooted, or `InstallBlobImage` is
916    /// called. The system container will remain mounted as long as `mount_token` is kept open.
917    /// *NOTE*: This method will delete any existing image data cached on disk. Callers are
918    /// responsible for keeping the returned `image_file` and `mount_token` alive until the system
919    /// image has been fully written and flushed to disk.
920    ///
921    /// # Errors
922    ///
923    /// * `ZX_ERR_IO_DATA_INTEGRITY`: An existing filesystem was found on the device, but it could
924    ///   not be mounted. This indicates that the filesystem is possibly corrupt, or has a newer
925    ///   on-disk version than the recovery image. To avoid unintended data loss, the user should
926    ///   explicitly initiate any remedial action, such as wiping the device or using a newer image.
927    /// * `ZX_ERR_INTERNAL`: An internal error occured; see fshost logs for more context.
928    pub fn r#get_blob_image_handle(
929        &self,
930    ) -> fidl::client::QueryResponseFut<
931        RecoveryGetBlobImageHandleResult,
932        fidl::encoding::DefaultFuchsiaResourceDialect,
933    > {
934        RecoveryProxyInterface::r#get_blob_image_handle(self)
935    }
936
937    /// Installs the blob volume previously written via `GetBlobImageHandle`, replacing the
938    /// existing blob volume in the system container. On failure, the existing blob volume will
939    /// remain intact, and the written image will be deleted to free space. A new blob image can
940    /// then be written and the installation process restarted. If no blob volume has been written,
941    /// this will have no effect. This function will block until the system container is unmounted.
942    pub fn r#install_blob_image(
943        &self,
944    ) -> fidl::client::QueryResponseFut<
945        RecoveryInstallBlobImageResult,
946        fidl::encoding::DefaultFuchsiaResourceDialect,
947    > {
948        RecoveryProxyInterface::r#install_blob_image(self)
949    }
950}
951
952impl RecoveryProxyInterface for RecoveryProxy {
953    type InitSystemPartitionTableResponseFut = fidl::client::QueryResponseFut<
954        RecoveryInitSystemPartitionTableResult,
955        fidl::encoding::DefaultFuchsiaResourceDialect,
956    >;
957    fn r#init_system_partition_table(
958        &self,
959        mut partitions: &[fidl_fuchsia_storage_partitions::PartitionInfo],
960    ) -> Self::InitSystemPartitionTableResponseFut {
961        fn _decode(
962            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
963        ) -> Result<RecoveryInitSystemPartitionTableResult, fidl::Error> {
964            let _response = fidl::client::decode_transaction_body::<
965                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
966                fidl::encoding::DefaultFuchsiaResourceDialect,
967                0x3dcadcbb75e2330b,
968            >(_buf?)?;
969            Ok(_response.map(|x| x))
970        }
971        self.client.send_query_and_decode::<
972            RecoveryInitSystemPartitionTableRequest,
973            RecoveryInitSystemPartitionTableResult,
974        >(
975            (partitions,),
976            0x3dcadcbb75e2330b,
977            fidl::encoding::DynamicFlags::empty(),
978            _decode,
979        )
980    }
981
982    type WriteDataFileResponseFut = fidl::client::QueryResponseFut<
983        RecoveryWriteDataFileResult,
984        fidl::encoding::DefaultFuchsiaResourceDialect,
985    >;
986    fn r#write_data_file(
987        &self,
988        mut filename: &str,
989        mut payload: fidl::Vmo,
990    ) -> Self::WriteDataFileResponseFut {
991        fn _decode(
992            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
993        ) -> Result<RecoveryWriteDataFileResult, fidl::Error> {
994            let _response = fidl::client::decode_transaction_body::<
995                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
996                fidl::encoding::DefaultFuchsiaResourceDialect,
997                0xd6cf7b3f57b418d,
998            >(_buf?)?;
999            Ok(_response.map(|x| x))
1000        }
1001        self.client
1002            .send_query_and_decode::<RecoveryWriteDataFileRequest, RecoveryWriteDataFileResult>(
1003                (filename, payload),
1004                0xd6cf7b3f57b418d,
1005                fidl::encoding::DynamicFlags::empty(),
1006                _decode,
1007            )
1008    }
1009
1010    type FormatSystemBlobVolumeResponseFut = fidl::client::QueryResponseFut<
1011        RecoveryFormatSystemBlobVolumeResult,
1012        fidl::encoding::DefaultFuchsiaResourceDialect,
1013    >;
1014    fn r#format_system_blob_volume(&self) -> Self::FormatSystemBlobVolumeResponseFut {
1015        fn _decode(
1016            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1017        ) -> Result<RecoveryFormatSystemBlobVolumeResult, fidl::Error> {
1018            let _response = fidl::client::decode_transaction_body::<
1019                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1020                fidl::encoding::DefaultFuchsiaResourceDialect,
1021                0x4e93f6b198f61f7d,
1022            >(_buf?)?;
1023            Ok(_response.map(|x| x))
1024        }
1025        self.client.send_query_and_decode::<
1026            fidl::encoding::EmptyPayload,
1027            RecoveryFormatSystemBlobVolumeResult,
1028        >(
1029            (),
1030            0x4e93f6b198f61f7d,
1031            fidl::encoding::DynamicFlags::empty(),
1032            _decode,
1033        )
1034    }
1035
1036    type MountSystemBlobVolumeResponseFut = fidl::client::QueryResponseFut<
1037        RecoveryMountSystemBlobVolumeResult,
1038        fidl::encoding::DefaultFuchsiaResourceDialect,
1039    >;
1040    fn r#mount_system_blob_volume(
1041        &self,
1042        mut blob_exposed_dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1043    ) -> Self::MountSystemBlobVolumeResponseFut {
1044        fn _decode(
1045            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1046        ) -> Result<RecoveryMountSystemBlobVolumeResult, fidl::Error> {
1047            let _response = fidl::client::decode_transaction_body::<
1048                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1049                fidl::encoding::DefaultFuchsiaResourceDialect,
1050                0x63ddff4240e908c0,
1051            >(_buf?)?;
1052            Ok(_response.map(|x| x))
1053        }
1054        self.client.send_query_and_decode::<
1055            RecoveryMountSystemBlobVolumeRequest,
1056            RecoveryMountSystemBlobVolumeResult,
1057        >(
1058            (blob_exposed_dir,),
1059            0x63ddff4240e908c0,
1060            fidl::encoding::DynamicFlags::empty(),
1061            _decode,
1062        )
1063    }
1064
1065    type GetBlobImageHandleResponseFut = fidl::client::QueryResponseFut<
1066        RecoveryGetBlobImageHandleResult,
1067        fidl::encoding::DefaultFuchsiaResourceDialect,
1068    >;
1069    fn r#get_blob_image_handle(&self) -> Self::GetBlobImageHandleResponseFut {
1070        fn _decode(
1071            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1072        ) -> Result<RecoveryGetBlobImageHandleResult, fidl::Error> {
1073            let _response = fidl::client::decode_transaction_body::<
1074                fidl::encoding::ResultType<RecoveryGetBlobImageHandleResponse, i32>,
1075                fidl::encoding::DefaultFuchsiaResourceDialect,
1076                0x5cc0f6646bdb5e57,
1077            >(_buf?)?;
1078            Ok(_response.map(|x| x))
1079        }
1080        self.client.send_query_and_decode::<
1081            fidl::encoding::EmptyPayload,
1082            RecoveryGetBlobImageHandleResult,
1083        >(
1084            (),
1085            0x5cc0f6646bdb5e57,
1086            fidl::encoding::DynamicFlags::empty(),
1087            _decode,
1088        )
1089    }
1090
1091    type InstallBlobImageResponseFut = fidl::client::QueryResponseFut<
1092        RecoveryInstallBlobImageResult,
1093        fidl::encoding::DefaultFuchsiaResourceDialect,
1094    >;
1095    fn r#install_blob_image(&self) -> Self::InstallBlobImageResponseFut {
1096        fn _decode(
1097            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1098        ) -> Result<RecoveryInstallBlobImageResult, fidl::Error> {
1099            let _response = fidl::client::decode_transaction_body::<
1100                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1101                fidl::encoding::DefaultFuchsiaResourceDialect,
1102                0x323375398af8a29,
1103            >(_buf?)?;
1104            Ok(_response.map(|x| x))
1105        }
1106        self.client
1107            .send_query_and_decode::<fidl::encoding::EmptyPayload, RecoveryInstallBlobImageResult>(
1108                (),
1109                0x323375398af8a29,
1110                fidl::encoding::DynamicFlags::empty(),
1111                _decode,
1112            )
1113    }
1114}
1115
1116pub struct RecoveryEventStream {
1117    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1118}
1119
1120impl std::marker::Unpin for RecoveryEventStream {}
1121
1122impl futures::stream::FusedStream for RecoveryEventStream {
1123    fn is_terminated(&self) -> bool {
1124        self.event_receiver.is_terminated()
1125    }
1126}
1127
1128impl futures::Stream for RecoveryEventStream {
1129    type Item = Result<RecoveryEvent, fidl::Error>;
1130
1131    fn poll_next(
1132        mut self: std::pin::Pin<&mut Self>,
1133        cx: &mut std::task::Context<'_>,
1134    ) -> std::task::Poll<Option<Self::Item>> {
1135        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1136            &mut self.event_receiver,
1137            cx
1138        )?) {
1139            Some(buf) => std::task::Poll::Ready(Some(RecoveryEvent::decode(buf))),
1140            None => std::task::Poll::Ready(None),
1141        }
1142    }
1143}
1144
1145#[derive(Debug)]
1146pub enum RecoveryEvent {}
1147
1148impl RecoveryEvent {
1149    /// Decodes a message buffer as a [`RecoveryEvent`].
1150    fn decode(
1151        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1152    ) -> Result<RecoveryEvent, fidl::Error> {
1153        let (bytes, _handles) = buf.split_mut();
1154        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1155        debug_assert_eq!(tx_header.tx_id, 0);
1156        match tx_header.ordinal {
1157            _ => Err(fidl::Error::UnknownOrdinal {
1158                ordinal: tx_header.ordinal,
1159                protocol_name: <RecoveryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1160            }),
1161        }
1162    }
1163}
1164
1165/// A Stream of incoming requests for fuchsia.fshost/Recovery.
1166pub struct RecoveryRequestStream {
1167    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1168    is_terminated: bool,
1169}
1170
1171impl std::marker::Unpin for RecoveryRequestStream {}
1172
1173impl futures::stream::FusedStream for RecoveryRequestStream {
1174    fn is_terminated(&self) -> bool {
1175        self.is_terminated
1176    }
1177}
1178
1179impl fidl::endpoints::RequestStream for RecoveryRequestStream {
1180    type Protocol = RecoveryMarker;
1181    type ControlHandle = RecoveryControlHandle;
1182
1183    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1184        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1185    }
1186
1187    fn control_handle(&self) -> Self::ControlHandle {
1188        RecoveryControlHandle { inner: self.inner.clone() }
1189    }
1190
1191    fn into_inner(
1192        self,
1193    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1194    {
1195        (self.inner, self.is_terminated)
1196    }
1197
1198    fn from_inner(
1199        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1200        is_terminated: bool,
1201    ) -> Self {
1202        Self { inner, is_terminated }
1203    }
1204}
1205
1206impl futures::Stream for RecoveryRequestStream {
1207    type Item = Result<RecoveryRequest, fidl::Error>;
1208
1209    fn poll_next(
1210        mut self: std::pin::Pin<&mut Self>,
1211        cx: &mut std::task::Context<'_>,
1212    ) -> std::task::Poll<Option<Self::Item>> {
1213        let this = &mut *self;
1214        if this.inner.check_shutdown(cx) {
1215            this.is_terminated = true;
1216            return std::task::Poll::Ready(None);
1217        }
1218        if this.is_terminated {
1219            panic!("polled RecoveryRequestStream after completion");
1220        }
1221        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1222            |bytes, handles| {
1223                match this.inner.channel().read_etc(cx, bytes, handles) {
1224                    std::task::Poll::Ready(Ok(())) => {}
1225                    std::task::Poll::Pending => return std::task::Poll::Pending,
1226                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1227                        this.is_terminated = true;
1228                        return std::task::Poll::Ready(None);
1229                    }
1230                    std::task::Poll::Ready(Err(e)) => {
1231                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1232                            e.into(),
1233                        ))));
1234                    }
1235                }
1236
1237                // A message has been received from the channel
1238                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1239
1240                std::task::Poll::Ready(Some(match header.ordinal {
1241                    0x3dcadcbb75e2330b => {
1242                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1243                        let mut req = fidl::new_empty!(
1244                            RecoveryInitSystemPartitionTableRequest,
1245                            fidl::encoding::DefaultFuchsiaResourceDialect
1246                        );
1247                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RecoveryInitSystemPartitionTableRequest>(&header, _body_bytes, handles, &mut req)?;
1248                        let control_handle = RecoveryControlHandle { inner: this.inner.clone() };
1249                        Ok(RecoveryRequest::InitSystemPartitionTable {
1250                            partitions: req.partitions,
1251
1252                            responder: RecoveryInitSystemPartitionTableResponder {
1253                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1254                                tx_id: header.tx_id,
1255                            },
1256                        })
1257                    }
1258                    0xd6cf7b3f57b418d => {
1259                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1260                        let mut req = fidl::new_empty!(
1261                            RecoveryWriteDataFileRequest,
1262                            fidl::encoding::DefaultFuchsiaResourceDialect
1263                        );
1264                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RecoveryWriteDataFileRequest>(&header, _body_bytes, handles, &mut req)?;
1265                        let control_handle = RecoveryControlHandle { inner: this.inner.clone() };
1266                        Ok(RecoveryRequest::WriteDataFile {
1267                            filename: req.filename,
1268                            payload: req.payload,
1269
1270                            responder: RecoveryWriteDataFileResponder {
1271                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1272                                tx_id: header.tx_id,
1273                            },
1274                        })
1275                    }
1276                    0x4e93f6b198f61f7d => {
1277                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1278                        let mut req = fidl::new_empty!(
1279                            fidl::encoding::EmptyPayload,
1280                            fidl::encoding::DefaultFuchsiaResourceDialect
1281                        );
1282                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1283                        let control_handle = RecoveryControlHandle { inner: this.inner.clone() };
1284                        Ok(RecoveryRequest::FormatSystemBlobVolume {
1285                            responder: RecoveryFormatSystemBlobVolumeResponder {
1286                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1287                                tx_id: header.tx_id,
1288                            },
1289                        })
1290                    }
1291                    0x63ddff4240e908c0 => {
1292                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1293                        let mut req = fidl::new_empty!(
1294                            RecoveryMountSystemBlobVolumeRequest,
1295                            fidl::encoding::DefaultFuchsiaResourceDialect
1296                        );
1297                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RecoveryMountSystemBlobVolumeRequest>(&header, _body_bytes, handles, &mut req)?;
1298                        let control_handle = RecoveryControlHandle { inner: this.inner.clone() };
1299                        Ok(RecoveryRequest::MountSystemBlobVolume {
1300                            blob_exposed_dir: req.blob_exposed_dir,
1301
1302                            responder: RecoveryMountSystemBlobVolumeResponder {
1303                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1304                                tx_id: header.tx_id,
1305                            },
1306                        })
1307                    }
1308                    0x5cc0f6646bdb5e57 => {
1309                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1310                        let mut req = fidl::new_empty!(
1311                            fidl::encoding::EmptyPayload,
1312                            fidl::encoding::DefaultFuchsiaResourceDialect
1313                        );
1314                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1315                        let control_handle = RecoveryControlHandle { inner: this.inner.clone() };
1316                        Ok(RecoveryRequest::GetBlobImageHandle {
1317                            responder: RecoveryGetBlobImageHandleResponder {
1318                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1319                                tx_id: header.tx_id,
1320                            },
1321                        })
1322                    }
1323                    0x323375398af8a29 => {
1324                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1325                        let mut req = fidl::new_empty!(
1326                            fidl::encoding::EmptyPayload,
1327                            fidl::encoding::DefaultFuchsiaResourceDialect
1328                        );
1329                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1330                        let control_handle = RecoveryControlHandle { inner: this.inner.clone() };
1331                        Ok(RecoveryRequest::InstallBlobImage {
1332                            responder: RecoveryInstallBlobImageResponder {
1333                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1334                                tx_id: header.tx_id,
1335                            },
1336                        })
1337                    }
1338                    _ => Err(fidl::Error::UnknownOrdinal {
1339                        ordinal: header.ordinal,
1340                        protocol_name:
1341                            <RecoveryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1342                    }),
1343                }))
1344            },
1345        )
1346    }
1347}
1348
1349/// Special functionality that is only intended to be used in recovery and device bringup.
1350///
1351/// *WARNING*: The methods in this protocol are highly specialized and can result in unintended
1352/// data loss if used improperly. Most methods in this protocol assume exclusive access to the
1353/// underlying block device, and it is the responsibility of callers to mediate the use of this
1354/// protocol across components.
1355#[derive(Debug)]
1356pub enum RecoveryRequest {
1357    /// Wipes and re-initializes the system partition table.  This is a destructive operation!
1358    InitSystemPartitionTable {
1359        partitions: Vec<fidl_fuchsia_storage_partitions::PartitionInfo>,
1360        responder: RecoveryInitSystemPartitionTableResponder,
1361    },
1362    /// Writes `filename` into the data partition with contents from `payload`, formatting the data
1363    /// partition if it isn't already formatted.  Overwrites file if it already exists.
1364    ///
1365    /// This can only be called while the data partition isn't already mounted, which is typically
1366    /// in recovery builds where fshost is running with the `ramdisk_image` flag set.
1367    WriteDataFile {
1368        filename: String,
1369        payload: fidl::Vmo,
1370        responder: RecoveryWriteDataFileResponder,
1371    },
1372    /// Formats the blob volume in the system container. If the system container does not have a
1373    /// blob volume, a new one will be created. All existing blobs will be deleted. If the system
1374    /// container is corrupt or unmountable, this function will have no effect and will leave the
1375    /// disk intact.
1376    ///
1377    /// **WARNING**: This can cause irreversible data loss and can render a device unbootable.
1378    FormatSystemBlobVolume { responder: RecoveryFormatSystemBlobVolumeResponder },
1379    /// Mounts the system container's blob volume, and returns a handle to the blob volume's
1380    /// exposed directory to facilitate writing a new system. The system container will remain
1381    /// mounted as long as `blob_exposed_dir` is kept open. Only the blob volume will be mounted.
1382    MountSystemBlobVolume {
1383        blob_exposed_dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1384        responder: RecoveryMountSystemBlobVolumeResponder,
1385    },
1386    /// Obtains a handle to a file where a new system blob volume can be written. The contents of
1387    /// the file must be a valid fxfs partition image containing a blob volume. The existing blob
1388    /// volume will remain unmodified until the system is rebooted, or `InstallBlobImage` is
1389    /// called. The system container will remain mounted as long as `mount_token` is kept open.
1390    /// *NOTE*: This method will delete any existing image data cached on disk. Callers are
1391    /// responsible for keeping the returned `image_file` and `mount_token` alive until the system
1392    /// image has been fully written and flushed to disk.
1393    ///
1394    /// # Errors
1395    ///
1396    /// * `ZX_ERR_IO_DATA_INTEGRITY`: An existing filesystem was found on the device, but it could
1397    ///   not be mounted. This indicates that the filesystem is possibly corrupt, or has a newer
1398    ///   on-disk version than the recovery image. To avoid unintended data loss, the user should
1399    ///   explicitly initiate any remedial action, such as wiping the device or using a newer image.
1400    /// * `ZX_ERR_INTERNAL`: An internal error occured; see fshost logs for more context.
1401    GetBlobImageHandle { responder: RecoveryGetBlobImageHandleResponder },
1402    /// Installs the blob volume previously written via `GetBlobImageHandle`, replacing the
1403    /// existing blob volume in the system container. On failure, the existing blob volume will
1404    /// remain intact, and the written image will be deleted to free space. A new blob image can
1405    /// then be written and the installation process restarted. If no blob volume has been written,
1406    /// this will have no effect. This function will block until the system container is unmounted.
1407    InstallBlobImage { responder: RecoveryInstallBlobImageResponder },
1408}
1409
1410impl RecoveryRequest {
1411    #[allow(irrefutable_let_patterns)]
1412    pub fn into_init_system_partition_table(
1413        self,
1414    ) -> Option<(
1415        Vec<fidl_fuchsia_storage_partitions::PartitionInfo>,
1416        RecoveryInitSystemPartitionTableResponder,
1417    )> {
1418        if let RecoveryRequest::InitSystemPartitionTable { partitions, responder } = self {
1419            Some((partitions, responder))
1420        } else {
1421            None
1422        }
1423    }
1424
1425    #[allow(irrefutable_let_patterns)]
1426    pub fn into_write_data_file(
1427        self,
1428    ) -> Option<(String, fidl::Vmo, RecoveryWriteDataFileResponder)> {
1429        if let RecoveryRequest::WriteDataFile { filename, payload, responder } = self {
1430            Some((filename, payload, responder))
1431        } else {
1432            None
1433        }
1434    }
1435
1436    #[allow(irrefutable_let_patterns)]
1437    pub fn into_format_system_blob_volume(
1438        self,
1439    ) -> Option<(RecoveryFormatSystemBlobVolumeResponder)> {
1440        if let RecoveryRequest::FormatSystemBlobVolume { responder } = self {
1441            Some((responder))
1442        } else {
1443            None
1444        }
1445    }
1446
1447    #[allow(irrefutable_let_patterns)]
1448    pub fn into_mount_system_blob_volume(
1449        self,
1450    ) -> Option<(
1451        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1452        RecoveryMountSystemBlobVolumeResponder,
1453    )> {
1454        if let RecoveryRequest::MountSystemBlobVolume { blob_exposed_dir, responder } = self {
1455            Some((blob_exposed_dir, responder))
1456        } else {
1457            None
1458        }
1459    }
1460
1461    #[allow(irrefutable_let_patterns)]
1462    pub fn into_get_blob_image_handle(self) -> Option<(RecoveryGetBlobImageHandleResponder)> {
1463        if let RecoveryRequest::GetBlobImageHandle { responder } = self {
1464            Some((responder))
1465        } else {
1466            None
1467        }
1468    }
1469
1470    #[allow(irrefutable_let_patterns)]
1471    pub fn into_install_blob_image(self) -> Option<(RecoveryInstallBlobImageResponder)> {
1472        if let RecoveryRequest::InstallBlobImage { responder } = self {
1473            Some((responder))
1474        } else {
1475            None
1476        }
1477    }
1478
1479    /// Name of the method defined in FIDL
1480    pub fn method_name(&self) -> &'static str {
1481        match *self {
1482            RecoveryRequest::InitSystemPartitionTable { .. } => "init_system_partition_table",
1483            RecoveryRequest::WriteDataFile { .. } => "write_data_file",
1484            RecoveryRequest::FormatSystemBlobVolume { .. } => "format_system_blob_volume",
1485            RecoveryRequest::MountSystemBlobVolume { .. } => "mount_system_blob_volume",
1486            RecoveryRequest::GetBlobImageHandle { .. } => "get_blob_image_handle",
1487            RecoveryRequest::InstallBlobImage { .. } => "install_blob_image",
1488        }
1489    }
1490}
1491
1492#[derive(Debug, Clone)]
1493pub struct RecoveryControlHandle {
1494    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1495}
1496
1497impl fidl::endpoints::ControlHandle for RecoveryControlHandle {
1498    fn shutdown(&self) {
1499        self.inner.shutdown()
1500    }
1501
1502    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1503        self.inner.shutdown_with_epitaph(status)
1504    }
1505
1506    fn is_closed(&self) -> bool {
1507        self.inner.channel().is_closed()
1508    }
1509    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1510        self.inner.channel().on_closed()
1511    }
1512
1513    #[cfg(target_os = "fuchsia")]
1514    fn signal_peer(
1515        &self,
1516        clear_mask: zx::Signals,
1517        set_mask: zx::Signals,
1518    ) -> Result<(), zx_status::Status> {
1519        use fidl::Peered;
1520        self.inner.channel().signal_peer(clear_mask, set_mask)
1521    }
1522}
1523
1524impl RecoveryControlHandle {}
1525
1526#[must_use = "FIDL methods require a response to be sent"]
1527#[derive(Debug)]
1528pub struct RecoveryInitSystemPartitionTableResponder {
1529    control_handle: std::mem::ManuallyDrop<RecoveryControlHandle>,
1530    tx_id: u32,
1531}
1532
1533/// Set the the channel to be shutdown (see [`RecoveryControlHandle::shutdown`])
1534/// if the responder is dropped without sending a response, so that the client
1535/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1536impl std::ops::Drop for RecoveryInitSystemPartitionTableResponder {
1537    fn drop(&mut self) {
1538        self.control_handle.shutdown();
1539        // Safety: drops once, never accessed again
1540        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1541    }
1542}
1543
1544impl fidl::endpoints::Responder for RecoveryInitSystemPartitionTableResponder {
1545    type ControlHandle = RecoveryControlHandle;
1546
1547    fn control_handle(&self) -> &RecoveryControlHandle {
1548        &self.control_handle
1549    }
1550
1551    fn drop_without_shutdown(mut self) {
1552        // Safety: drops once, never accessed again due to mem::forget
1553        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1554        // Prevent Drop from running (which would shut down the channel)
1555        std::mem::forget(self);
1556    }
1557}
1558
1559impl RecoveryInitSystemPartitionTableResponder {
1560    /// Sends a response to the FIDL transaction.
1561    ///
1562    /// Sets the channel to shutdown if an error occurs.
1563    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1564        let _result = self.send_raw(result);
1565        if _result.is_err() {
1566            self.control_handle.shutdown();
1567        }
1568        self.drop_without_shutdown();
1569        _result
1570    }
1571
1572    /// Similar to "send" but does not shutdown the channel if an error occurs.
1573    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1574        let _result = self.send_raw(result);
1575        self.drop_without_shutdown();
1576        _result
1577    }
1578
1579    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1580        self.control_handle
1581            .inner
1582            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1583                result,
1584                self.tx_id,
1585                0x3dcadcbb75e2330b,
1586                fidl::encoding::DynamicFlags::empty(),
1587            )
1588    }
1589}
1590
1591#[must_use = "FIDL methods require a response to be sent"]
1592#[derive(Debug)]
1593pub struct RecoveryWriteDataFileResponder {
1594    control_handle: std::mem::ManuallyDrop<RecoveryControlHandle>,
1595    tx_id: u32,
1596}
1597
1598/// Set the the channel to be shutdown (see [`RecoveryControlHandle::shutdown`])
1599/// if the responder is dropped without sending a response, so that the client
1600/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1601impl std::ops::Drop for RecoveryWriteDataFileResponder {
1602    fn drop(&mut self) {
1603        self.control_handle.shutdown();
1604        // Safety: drops once, never accessed again
1605        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1606    }
1607}
1608
1609impl fidl::endpoints::Responder for RecoveryWriteDataFileResponder {
1610    type ControlHandle = RecoveryControlHandle;
1611
1612    fn control_handle(&self) -> &RecoveryControlHandle {
1613        &self.control_handle
1614    }
1615
1616    fn drop_without_shutdown(mut self) {
1617        // Safety: drops once, never accessed again due to mem::forget
1618        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1619        // Prevent Drop from running (which would shut down the channel)
1620        std::mem::forget(self);
1621    }
1622}
1623
1624impl RecoveryWriteDataFileResponder {
1625    /// Sends a response to the FIDL transaction.
1626    ///
1627    /// Sets the channel to shutdown if an error occurs.
1628    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1629        let _result = self.send_raw(result);
1630        if _result.is_err() {
1631            self.control_handle.shutdown();
1632        }
1633        self.drop_without_shutdown();
1634        _result
1635    }
1636
1637    /// Similar to "send" but does not shutdown the channel if an error occurs.
1638    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1639        let _result = self.send_raw(result);
1640        self.drop_without_shutdown();
1641        _result
1642    }
1643
1644    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1645        self.control_handle
1646            .inner
1647            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1648                result,
1649                self.tx_id,
1650                0xd6cf7b3f57b418d,
1651                fidl::encoding::DynamicFlags::empty(),
1652            )
1653    }
1654}
1655
1656#[must_use = "FIDL methods require a response to be sent"]
1657#[derive(Debug)]
1658pub struct RecoveryFormatSystemBlobVolumeResponder {
1659    control_handle: std::mem::ManuallyDrop<RecoveryControlHandle>,
1660    tx_id: u32,
1661}
1662
1663/// Set the the channel to be shutdown (see [`RecoveryControlHandle::shutdown`])
1664/// if the responder is dropped without sending a response, so that the client
1665/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1666impl std::ops::Drop for RecoveryFormatSystemBlobVolumeResponder {
1667    fn drop(&mut self) {
1668        self.control_handle.shutdown();
1669        // Safety: drops once, never accessed again
1670        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1671    }
1672}
1673
1674impl fidl::endpoints::Responder for RecoveryFormatSystemBlobVolumeResponder {
1675    type ControlHandle = RecoveryControlHandle;
1676
1677    fn control_handle(&self) -> &RecoveryControlHandle {
1678        &self.control_handle
1679    }
1680
1681    fn drop_without_shutdown(mut self) {
1682        // Safety: drops once, never accessed again due to mem::forget
1683        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1684        // Prevent Drop from running (which would shut down the channel)
1685        std::mem::forget(self);
1686    }
1687}
1688
1689impl RecoveryFormatSystemBlobVolumeResponder {
1690    /// Sends a response to the FIDL transaction.
1691    ///
1692    /// Sets the channel to shutdown if an error occurs.
1693    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1694        let _result = self.send_raw(result);
1695        if _result.is_err() {
1696            self.control_handle.shutdown();
1697        }
1698        self.drop_without_shutdown();
1699        _result
1700    }
1701
1702    /// Similar to "send" but does not shutdown the channel if an error occurs.
1703    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1704        let _result = self.send_raw(result);
1705        self.drop_without_shutdown();
1706        _result
1707    }
1708
1709    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1710        self.control_handle
1711            .inner
1712            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1713                result,
1714                self.tx_id,
1715                0x4e93f6b198f61f7d,
1716                fidl::encoding::DynamicFlags::empty(),
1717            )
1718    }
1719}
1720
1721#[must_use = "FIDL methods require a response to be sent"]
1722#[derive(Debug)]
1723pub struct RecoveryMountSystemBlobVolumeResponder {
1724    control_handle: std::mem::ManuallyDrop<RecoveryControlHandle>,
1725    tx_id: u32,
1726}
1727
1728/// Set the the channel to be shutdown (see [`RecoveryControlHandle::shutdown`])
1729/// if the responder is dropped without sending a response, so that the client
1730/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1731impl std::ops::Drop for RecoveryMountSystemBlobVolumeResponder {
1732    fn drop(&mut self) {
1733        self.control_handle.shutdown();
1734        // Safety: drops once, never accessed again
1735        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1736    }
1737}
1738
1739impl fidl::endpoints::Responder for RecoveryMountSystemBlobVolumeResponder {
1740    type ControlHandle = RecoveryControlHandle;
1741
1742    fn control_handle(&self) -> &RecoveryControlHandle {
1743        &self.control_handle
1744    }
1745
1746    fn drop_without_shutdown(mut self) {
1747        // Safety: drops once, never accessed again due to mem::forget
1748        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1749        // Prevent Drop from running (which would shut down the channel)
1750        std::mem::forget(self);
1751    }
1752}
1753
1754impl RecoveryMountSystemBlobVolumeResponder {
1755    /// Sends a response to the FIDL transaction.
1756    ///
1757    /// Sets the channel to shutdown if an error occurs.
1758    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1759        let _result = self.send_raw(result);
1760        if _result.is_err() {
1761            self.control_handle.shutdown();
1762        }
1763        self.drop_without_shutdown();
1764        _result
1765    }
1766
1767    /// Similar to "send" but does not shutdown the channel if an error occurs.
1768    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1769        let _result = self.send_raw(result);
1770        self.drop_without_shutdown();
1771        _result
1772    }
1773
1774    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1775        self.control_handle
1776            .inner
1777            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1778                result,
1779                self.tx_id,
1780                0x63ddff4240e908c0,
1781                fidl::encoding::DynamicFlags::empty(),
1782            )
1783    }
1784}
1785
1786#[must_use = "FIDL methods require a response to be sent"]
1787#[derive(Debug)]
1788pub struct RecoveryGetBlobImageHandleResponder {
1789    control_handle: std::mem::ManuallyDrop<RecoveryControlHandle>,
1790    tx_id: u32,
1791}
1792
1793/// Set the the channel to be shutdown (see [`RecoveryControlHandle::shutdown`])
1794/// if the responder is dropped without sending a response, so that the client
1795/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1796impl std::ops::Drop for RecoveryGetBlobImageHandleResponder {
1797    fn drop(&mut self) {
1798        self.control_handle.shutdown();
1799        // Safety: drops once, never accessed again
1800        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1801    }
1802}
1803
1804impl fidl::endpoints::Responder for RecoveryGetBlobImageHandleResponder {
1805    type ControlHandle = RecoveryControlHandle;
1806
1807    fn control_handle(&self) -> &RecoveryControlHandle {
1808        &self.control_handle
1809    }
1810
1811    fn drop_without_shutdown(mut self) {
1812        // Safety: drops once, never accessed again due to mem::forget
1813        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1814        // Prevent Drop from running (which would shut down the channel)
1815        std::mem::forget(self);
1816    }
1817}
1818
1819impl RecoveryGetBlobImageHandleResponder {
1820    /// Sends a response to the FIDL transaction.
1821    ///
1822    /// Sets the channel to shutdown if an error occurs.
1823    pub fn send(
1824        self,
1825        mut result: Result<RecoveryGetBlobImageHandleResponse, i32>,
1826    ) -> Result<(), fidl::Error> {
1827        let _result = self.send_raw(result);
1828        if _result.is_err() {
1829            self.control_handle.shutdown();
1830        }
1831        self.drop_without_shutdown();
1832        _result
1833    }
1834
1835    /// Similar to "send" but does not shutdown the channel if an error occurs.
1836    pub fn send_no_shutdown_on_err(
1837        self,
1838        mut result: Result<RecoveryGetBlobImageHandleResponse, i32>,
1839    ) -> Result<(), fidl::Error> {
1840        let _result = self.send_raw(result);
1841        self.drop_without_shutdown();
1842        _result
1843    }
1844
1845    fn send_raw(
1846        &self,
1847        mut result: Result<RecoveryGetBlobImageHandleResponse, i32>,
1848    ) -> Result<(), fidl::Error> {
1849        self.control_handle
1850            .inner
1851            .send::<fidl::encoding::ResultType<RecoveryGetBlobImageHandleResponse, i32>>(
1852                result.as_mut().map_err(|e| *e),
1853                self.tx_id,
1854                0x5cc0f6646bdb5e57,
1855                fidl::encoding::DynamicFlags::empty(),
1856            )
1857    }
1858}
1859
1860#[must_use = "FIDL methods require a response to be sent"]
1861#[derive(Debug)]
1862pub struct RecoveryInstallBlobImageResponder {
1863    control_handle: std::mem::ManuallyDrop<RecoveryControlHandle>,
1864    tx_id: u32,
1865}
1866
1867/// Set the the channel to be shutdown (see [`RecoveryControlHandle::shutdown`])
1868/// if the responder is dropped without sending a response, so that the client
1869/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1870impl std::ops::Drop for RecoveryInstallBlobImageResponder {
1871    fn drop(&mut self) {
1872        self.control_handle.shutdown();
1873        // Safety: drops once, never accessed again
1874        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1875    }
1876}
1877
1878impl fidl::endpoints::Responder for RecoveryInstallBlobImageResponder {
1879    type ControlHandle = RecoveryControlHandle;
1880
1881    fn control_handle(&self) -> &RecoveryControlHandle {
1882        &self.control_handle
1883    }
1884
1885    fn drop_without_shutdown(mut self) {
1886        // Safety: drops once, never accessed again due to mem::forget
1887        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1888        // Prevent Drop from running (which would shut down the channel)
1889        std::mem::forget(self);
1890    }
1891}
1892
1893impl RecoveryInstallBlobImageResponder {
1894    /// Sends a response to the FIDL transaction.
1895    ///
1896    /// Sets the channel to shutdown if an error occurs.
1897    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1898        let _result = self.send_raw(result);
1899        if _result.is_err() {
1900            self.control_handle.shutdown();
1901        }
1902        self.drop_without_shutdown();
1903        _result
1904    }
1905
1906    /// Similar to "send" but does not shutdown the channel if an error occurs.
1907    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1908        let _result = self.send_raw(result);
1909        self.drop_without_shutdown();
1910        _result
1911    }
1912
1913    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1914        self.control_handle
1915            .inner
1916            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1917                result,
1918                self.tx_id,
1919                0x323375398af8a29,
1920                fidl::encoding::DynamicFlags::empty(),
1921            )
1922    }
1923}
1924
1925#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1926pub struct StarnixVolumeProviderMarker;
1927
1928impl fidl::endpoints::ProtocolMarker for StarnixVolumeProviderMarker {
1929    type Proxy = StarnixVolumeProviderProxy;
1930    type RequestStream = StarnixVolumeProviderRequestStream;
1931    #[cfg(target_os = "fuchsia")]
1932    type SynchronousProxy = StarnixVolumeProviderSynchronousProxy;
1933
1934    const DEBUG_NAME: &'static str = "fuchsia.fshost.StarnixVolumeProvider";
1935}
1936impl fidl::endpoints::DiscoverableProtocolMarker for StarnixVolumeProviderMarker {}
1937pub type StarnixVolumeProviderCheckResult = Result<(), i32>;
1938pub type StarnixVolumeProviderMountResult = Result<[u8; 16], i32>;
1939
1940pub trait StarnixVolumeProviderProxyInterface: Send + Sync {
1941    type CheckResponseFut: std::future::Future<Output = Result<StarnixVolumeProviderCheckResult, fidl::Error>>
1942        + Send;
1943    fn r#check(
1944        &self,
1945        crypt: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
1946    ) -> Self::CheckResponseFut;
1947    type MountResponseFut: std::future::Future<Output = Result<StarnixVolumeProviderMountResult, fidl::Error>>
1948        + Send;
1949    fn r#mount(
1950        &self,
1951        crypt: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
1952        mode: MountMode,
1953        exposed_dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
1954    ) -> Self::MountResponseFut;
1955}
1956#[derive(Debug)]
1957#[cfg(target_os = "fuchsia")]
1958pub struct StarnixVolumeProviderSynchronousProxy {
1959    client: fidl::client::sync::Client,
1960}
1961
1962#[cfg(target_os = "fuchsia")]
1963impl fidl::endpoints::SynchronousProxy for StarnixVolumeProviderSynchronousProxy {
1964    type Proxy = StarnixVolumeProviderProxy;
1965    type Protocol = StarnixVolumeProviderMarker;
1966
1967    fn from_channel(inner: fidl::Channel) -> Self {
1968        Self::new(inner)
1969    }
1970
1971    fn into_channel(self) -> fidl::Channel {
1972        self.client.into_channel()
1973    }
1974
1975    fn as_channel(&self) -> &fidl::Channel {
1976        self.client.as_channel()
1977    }
1978}
1979
1980#[cfg(target_os = "fuchsia")]
1981impl StarnixVolumeProviderSynchronousProxy {
1982    pub fn new(channel: fidl::Channel) -> Self {
1983        Self { client: fidl::client::sync::Client::new(channel) }
1984    }
1985
1986    pub fn into_channel(self) -> fidl::Channel {
1987        self.client.into_channel()
1988    }
1989
1990    /// Waits until an event arrives and returns it. It is safe for other
1991    /// threads to make concurrent requests while waiting for an event.
1992    pub fn wait_for_event(
1993        &self,
1994        deadline: zx::MonotonicInstant,
1995    ) -> Result<StarnixVolumeProviderEvent, fidl::Error> {
1996        StarnixVolumeProviderEvent::decode(
1997            self.client.wait_for_event::<StarnixVolumeProviderMarker>(deadline)?,
1998        )
1999    }
2000
2001    /// Checks the integrity of the main starnix volume if it exists.
2002    ///
2003    /// Silently succeeds if the volume is absent, or if fshost is not configured to check
2004    /// filesystems (fuchsia.fshost.CheckFilesystems).
2005    pub fn r#check(
2006        &self,
2007        mut crypt: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
2008        ___deadline: zx::MonotonicInstant,
2009    ) -> Result<StarnixVolumeProviderCheckResult, fidl::Error> {
2010        let _response = self.client.send_query::<
2011            StarnixVolumeProviderCheckRequest,
2012            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2013            StarnixVolumeProviderMarker,
2014        >(
2015            (crypt,),
2016            0xed29d63b47d8a7b,
2017            fidl::encoding::DynamicFlags::empty(),
2018            ___deadline,
2019        )?;
2020        Ok(_response.map(|x| x))
2021    }
2022
2023    /// Mounts the main starnix volume using `crypt`. `exposed_dir` will be connected to the
2024    /// exposed directory of the mounted starnix volume.
2025    ///
2026    /// If `mode` is `MAYBE_CREATE`, the volume will be created if it does not exist.
2027    /// If `mode` is `ALWAYS_CREATE`, the volume will be created, overwriting any existing volume.
2028    ///
2029    /// Returns the GUID of the mounted volume.
2030    pub fn r#mount(
2031        &self,
2032        mut crypt: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
2033        mut mode: MountMode,
2034        mut exposed_dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
2035        ___deadline: zx::MonotonicInstant,
2036    ) -> Result<StarnixVolumeProviderMountResult, fidl::Error> {
2037        let _response = self.client.send_query::<
2038            StarnixVolumeProviderMountRequest,
2039            fidl::encoding::ResultType<StarnixVolumeProviderMountResponse, i32>,
2040            StarnixVolumeProviderMarker,
2041        >(
2042            (crypt, mode, exposed_dir,),
2043            0x62ae75763dde5af6,
2044            fidl::encoding::DynamicFlags::empty(),
2045            ___deadline,
2046        )?;
2047        Ok(_response.map(|x| x.guid))
2048    }
2049}
2050
2051#[cfg(target_os = "fuchsia")]
2052impl From<StarnixVolumeProviderSynchronousProxy> for zx::NullableHandle {
2053    fn from(value: StarnixVolumeProviderSynchronousProxy) -> Self {
2054        value.into_channel().into()
2055    }
2056}
2057
2058#[cfg(target_os = "fuchsia")]
2059impl From<fidl::Channel> for StarnixVolumeProviderSynchronousProxy {
2060    fn from(value: fidl::Channel) -> Self {
2061        Self::new(value)
2062    }
2063}
2064
2065#[cfg(target_os = "fuchsia")]
2066impl fidl::endpoints::FromClient for StarnixVolumeProviderSynchronousProxy {
2067    type Protocol = StarnixVolumeProviderMarker;
2068
2069    fn from_client(value: fidl::endpoints::ClientEnd<StarnixVolumeProviderMarker>) -> Self {
2070        Self::new(value.into_channel())
2071    }
2072}
2073
2074#[derive(Debug, Clone)]
2075pub struct StarnixVolumeProviderProxy {
2076    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2077}
2078
2079impl fidl::endpoints::Proxy for StarnixVolumeProviderProxy {
2080    type Protocol = StarnixVolumeProviderMarker;
2081
2082    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2083        Self::new(inner)
2084    }
2085
2086    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2087        self.client.into_channel().map_err(|client| Self { client })
2088    }
2089
2090    fn as_channel(&self) -> &::fidl::AsyncChannel {
2091        self.client.as_channel()
2092    }
2093}
2094
2095impl StarnixVolumeProviderProxy {
2096    /// Create a new Proxy for fuchsia.fshost/StarnixVolumeProvider.
2097    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2098        let protocol_name =
2099            <StarnixVolumeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2100        Self { client: fidl::client::Client::new(channel, protocol_name) }
2101    }
2102
2103    /// Get a Stream of events from the remote end of the protocol.
2104    ///
2105    /// # Panics
2106    ///
2107    /// Panics if the event stream was already taken.
2108    pub fn take_event_stream(&self) -> StarnixVolumeProviderEventStream {
2109        StarnixVolumeProviderEventStream { event_receiver: self.client.take_event_receiver() }
2110    }
2111
2112    /// Checks the integrity of the main starnix volume if it exists.
2113    ///
2114    /// Silently succeeds if the volume is absent, or if fshost is not configured to check
2115    /// filesystems (fuchsia.fshost.CheckFilesystems).
2116    pub fn r#check(
2117        &self,
2118        mut crypt: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
2119    ) -> fidl::client::QueryResponseFut<
2120        StarnixVolumeProviderCheckResult,
2121        fidl::encoding::DefaultFuchsiaResourceDialect,
2122    > {
2123        StarnixVolumeProviderProxyInterface::r#check(self, crypt)
2124    }
2125
2126    /// Mounts the main starnix volume using `crypt`. `exposed_dir` will be connected to the
2127    /// exposed directory of the mounted starnix volume.
2128    ///
2129    /// If `mode` is `MAYBE_CREATE`, the volume will be created if it does not exist.
2130    /// If `mode` is `ALWAYS_CREATE`, the volume will be created, overwriting any existing volume.
2131    ///
2132    /// Returns the GUID of the mounted volume.
2133    pub fn r#mount(
2134        &self,
2135        mut crypt: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
2136        mut mode: MountMode,
2137        mut exposed_dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
2138    ) -> fidl::client::QueryResponseFut<
2139        StarnixVolumeProviderMountResult,
2140        fidl::encoding::DefaultFuchsiaResourceDialect,
2141    > {
2142        StarnixVolumeProviderProxyInterface::r#mount(self, crypt, mode, exposed_dir)
2143    }
2144}
2145
2146impl StarnixVolumeProviderProxyInterface for StarnixVolumeProviderProxy {
2147    type CheckResponseFut = fidl::client::QueryResponseFut<
2148        StarnixVolumeProviderCheckResult,
2149        fidl::encoding::DefaultFuchsiaResourceDialect,
2150    >;
2151    fn r#check(
2152        &self,
2153        mut crypt: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
2154    ) -> Self::CheckResponseFut {
2155        fn _decode(
2156            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2157        ) -> Result<StarnixVolumeProviderCheckResult, fidl::Error> {
2158            let _response = fidl::client::decode_transaction_body::<
2159                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2160                fidl::encoding::DefaultFuchsiaResourceDialect,
2161                0xed29d63b47d8a7b,
2162            >(_buf?)?;
2163            Ok(_response.map(|x| x))
2164        }
2165        self.client.send_query_and_decode::<
2166            StarnixVolumeProviderCheckRequest,
2167            StarnixVolumeProviderCheckResult,
2168        >(
2169            (crypt,),
2170            0xed29d63b47d8a7b,
2171            fidl::encoding::DynamicFlags::empty(),
2172            _decode,
2173        )
2174    }
2175
2176    type MountResponseFut = fidl::client::QueryResponseFut<
2177        StarnixVolumeProviderMountResult,
2178        fidl::encoding::DefaultFuchsiaResourceDialect,
2179    >;
2180    fn r#mount(
2181        &self,
2182        mut crypt: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
2183        mut mode: MountMode,
2184        mut exposed_dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
2185    ) -> Self::MountResponseFut {
2186        fn _decode(
2187            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2188        ) -> Result<StarnixVolumeProviderMountResult, fidl::Error> {
2189            let _response = fidl::client::decode_transaction_body::<
2190                fidl::encoding::ResultType<StarnixVolumeProviderMountResponse, i32>,
2191                fidl::encoding::DefaultFuchsiaResourceDialect,
2192                0x62ae75763dde5af6,
2193            >(_buf?)?;
2194            Ok(_response.map(|x| x.guid))
2195        }
2196        self.client.send_query_and_decode::<
2197            StarnixVolumeProviderMountRequest,
2198            StarnixVolumeProviderMountResult,
2199        >(
2200            (crypt, mode, exposed_dir,),
2201            0x62ae75763dde5af6,
2202            fidl::encoding::DynamicFlags::empty(),
2203            _decode,
2204        )
2205    }
2206}
2207
2208pub struct StarnixVolumeProviderEventStream {
2209    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2210}
2211
2212impl std::marker::Unpin for StarnixVolumeProviderEventStream {}
2213
2214impl futures::stream::FusedStream for StarnixVolumeProviderEventStream {
2215    fn is_terminated(&self) -> bool {
2216        self.event_receiver.is_terminated()
2217    }
2218}
2219
2220impl futures::Stream for StarnixVolumeProviderEventStream {
2221    type Item = Result<StarnixVolumeProviderEvent, fidl::Error>;
2222
2223    fn poll_next(
2224        mut self: std::pin::Pin<&mut Self>,
2225        cx: &mut std::task::Context<'_>,
2226    ) -> std::task::Poll<Option<Self::Item>> {
2227        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2228            &mut self.event_receiver,
2229            cx
2230        )?) {
2231            Some(buf) => std::task::Poll::Ready(Some(StarnixVolumeProviderEvent::decode(buf))),
2232            None => std::task::Poll::Ready(None),
2233        }
2234    }
2235}
2236
2237#[derive(Debug)]
2238pub enum StarnixVolumeProviderEvent {}
2239
2240impl StarnixVolumeProviderEvent {
2241    /// Decodes a message buffer as a [`StarnixVolumeProviderEvent`].
2242    fn decode(
2243        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2244    ) -> Result<StarnixVolumeProviderEvent, fidl::Error> {
2245        let (bytes, _handles) = buf.split_mut();
2246        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2247        debug_assert_eq!(tx_header.tx_id, 0);
2248        match tx_header.ordinal {
2249            _ => Err(fidl::Error::UnknownOrdinal {
2250                ordinal: tx_header.ordinal,
2251                protocol_name:
2252                    <StarnixVolumeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2253            }),
2254        }
2255    }
2256}
2257
2258/// A Stream of incoming requests for fuchsia.fshost/StarnixVolumeProvider.
2259pub struct StarnixVolumeProviderRequestStream {
2260    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2261    is_terminated: bool,
2262}
2263
2264impl std::marker::Unpin for StarnixVolumeProviderRequestStream {}
2265
2266impl futures::stream::FusedStream for StarnixVolumeProviderRequestStream {
2267    fn is_terminated(&self) -> bool {
2268        self.is_terminated
2269    }
2270}
2271
2272impl fidl::endpoints::RequestStream for StarnixVolumeProviderRequestStream {
2273    type Protocol = StarnixVolumeProviderMarker;
2274    type ControlHandle = StarnixVolumeProviderControlHandle;
2275
2276    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2277        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2278    }
2279
2280    fn control_handle(&self) -> Self::ControlHandle {
2281        StarnixVolumeProviderControlHandle { inner: self.inner.clone() }
2282    }
2283
2284    fn into_inner(
2285        self,
2286    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2287    {
2288        (self.inner, self.is_terminated)
2289    }
2290
2291    fn from_inner(
2292        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2293        is_terminated: bool,
2294    ) -> Self {
2295        Self { inner, is_terminated }
2296    }
2297}
2298
2299impl futures::Stream for StarnixVolumeProviderRequestStream {
2300    type Item = Result<StarnixVolumeProviderRequest, fidl::Error>;
2301
2302    fn poll_next(
2303        mut self: std::pin::Pin<&mut Self>,
2304        cx: &mut std::task::Context<'_>,
2305    ) -> std::task::Poll<Option<Self::Item>> {
2306        let this = &mut *self;
2307        if this.inner.check_shutdown(cx) {
2308            this.is_terminated = true;
2309            return std::task::Poll::Ready(None);
2310        }
2311        if this.is_terminated {
2312            panic!("polled StarnixVolumeProviderRequestStream after completion");
2313        }
2314        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2315            |bytes, handles| {
2316                match this.inner.channel().read_etc(cx, bytes, handles) {
2317                    std::task::Poll::Ready(Ok(())) => {}
2318                    std::task::Poll::Pending => return std::task::Poll::Pending,
2319                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2320                        this.is_terminated = true;
2321                        return std::task::Poll::Ready(None);
2322                    }
2323                    std::task::Poll::Ready(Err(e)) => {
2324                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2325                            e.into(),
2326                        ))));
2327                    }
2328                }
2329
2330                // A message has been received from the channel
2331                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2332
2333                std::task::Poll::Ready(Some(match header.ordinal {
2334                0xed29d63b47d8a7b => {
2335                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2336                    let mut req = fidl::new_empty!(StarnixVolumeProviderCheckRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2337                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StarnixVolumeProviderCheckRequest>(&header, _body_bytes, handles, &mut req)?;
2338                    let control_handle = StarnixVolumeProviderControlHandle {
2339                        inner: this.inner.clone(),
2340                    };
2341                    Ok(StarnixVolumeProviderRequest::Check {crypt: req.crypt,
2342
2343                        responder: StarnixVolumeProviderCheckResponder {
2344                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2345                            tx_id: header.tx_id,
2346                        },
2347                    })
2348                }
2349                0x62ae75763dde5af6 => {
2350                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2351                    let mut req = fidl::new_empty!(StarnixVolumeProviderMountRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2352                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StarnixVolumeProviderMountRequest>(&header, _body_bytes, handles, &mut req)?;
2353                    let control_handle = StarnixVolumeProviderControlHandle {
2354                        inner: this.inner.clone(),
2355                    };
2356                    Ok(StarnixVolumeProviderRequest::Mount {crypt: req.crypt,
2357mode: req.mode,
2358exposed_dir: req.exposed_dir,
2359
2360                        responder: StarnixVolumeProviderMountResponder {
2361                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2362                            tx_id: header.tx_id,
2363                        },
2364                    })
2365                }
2366                _ => Err(fidl::Error::UnknownOrdinal {
2367                    ordinal: header.ordinal,
2368                    protocol_name: <StarnixVolumeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2369                }),
2370            }))
2371            },
2372        )
2373    }
2374}
2375
2376/// Provides access to the volume which will be used by Starnix to store its data.
2377#[derive(Debug)]
2378pub enum StarnixVolumeProviderRequest {
2379    /// Checks the integrity of the main starnix volume if it exists.
2380    ///
2381    /// Silently succeeds if the volume is absent, or if fshost is not configured to check
2382    /// filesystems (fuchsia.fshost.CheckFilesystems).
2383    Check {
2384        crypt: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
2385        responder: StarnixVolumeProviderCheckResponder,
2386    },
2387    /// Mounts the main starnix volume using `crypt`. `exposed_dir` will be connected to the
2388    /// exposed directory of the mounted starnix volume.
2389    ///
2390    /// If `mode` is `MAYBE_CREATE`, the volume will be created if it does not exist.
2391    /// If `mode` is `ALWAYS_CREATE`, the volume will be created, overwriting any existing volume.
2392    ///
2393    /// Returns the GUID of the mounted volume.
2394    Mount {
2395        crypt: fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
2396        mode: MountMode,
2397        exposed_dir: fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
2398        responder: StarnixVolumeProviderMountResponder,
2399    },
2400}
2401
2402impl StarnixVolumeProviderRequest {
2403    #[allow(irrefutable_let_patterns)]
2404    pub fn into_check(
2405        self,
2406    ) -> Option<(
2407        fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
2408        StarnixVolumeProviderCheckResponder,
2409    )> {
2410        if let StarnixVolumeProviderRequest::Check { crypt, responder } = self {
2411            Some((crypt, responder))
2412        } else {
2413            None
2414        }
2415    }
2416
2417    #[allow(irrefutable_let_patterns)]
2418    pub fn into_mount(
2419        self,
2420    ) -> Option<(
2421        fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
2422        MountMode,
2423        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
2424        StarnixVolumeProviderMountResponder,
2425    )> {
2426        if let StarnixVolumeProviderRequest::Mount { crypt, mode, exposed_dir, responder } = self {
2427            Some((crypt, mode, exposed_dir, responder))
2428        } else {
2429            None
2430        }
2431    }
2432
2433    /// Name of the method defined in FIDL
2434    pub fn method_name(&self) -> &'static str {
2435        match *self {
2436            StarnixVolumeProviderRequest::Check { .. } => "check",
2437            StarnixVolumeProviderRequest::Mount { .. } => "mount",
2438        }
2439    }
2440}
2441
2442#[derive(Debug, Clone)]
2443pub struct StarnixVolumeProviderControlHandle {
2444    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2445}
2446
2447impl fidl::endpoints::ControlHandle for StarnixVolumeProviderControlHandle {
2448    fn shutdown(&self) {
2449        self.inner.shutdown()
2450    }
2451
2452    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2453        self.inner.shutdown_with_epitaph(status)
2454    }
2455
2456    fn is_closed(&self) -> bool {
2457        self.inner.channel().is_closed()
2458    }
2459    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2460        self.inner.channel().on_closed()
2461    }
2462
2463    #[cfg(target_os = "fuchsia")]
2464    fn signal_peer(
2465        &self,
2466        clear_mask: zx::Signals,
2467        set_mask: zx::Signals,
2468    ) -> Result<(), zx_status::Status> {
2469        use fidl::Peered;
2470        self.inner.channel().signal_peer(clear_mask, set_mask)
2471    }
2472}
2473
2474impl StarnixVolumeProviderControlHandle {}
2475
2476#[must_use = "FIDL methods require a response to be sent"]
2477#[derive(Debug)]
2478pub struct StarnixVolumeProviderCheckResponder {
2479    control_handle: std::mem::ManuallyDrop<StarnixVolumeProviderControlHandle>,
2480    tx_id: u32,
2481}
2482
2483/// Set the the channel to be shutdown (see [`StarnixVolumeProviderControlHandle::shutdown`])
2484/// if the responder is dropped without sending a response, so that the client
2485/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2486impl std::ops::Drop for StarnixVolumeProviderCheckResponder {
2487    fn drop(&mut self) {
2488        self.control_handle.shutdown();
2489        // Safety: drops once, never accessed again
2490        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2491    }
2492}
2493
2494impl fidl::endpoints::Responder for StarnixVolumeProviderCheckResponder {
2495    type ControlHandle = StarnixVolumeProviderControlHandle;
2496
2497    fn control_handle(&self) -> &StarnixVolumeProviderControlHandle {
2498        &self.control_handle
2499    }
2500
2501    fn drop_without_shutdown(mut self) {
2502        // Safety: drops once, never accessed again due to mem::forget
2503        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2504        // Prevent Drop from running (which would shut down the channel)
2505        std::mem::forget(self);
2506    }
2507}
2508
2509impl StarnixVolumeProviderCheckResponder {
2510    /// Sends a response to the FIDL transaction.
2511    ///
2512    /// Sets the channel to shutdown if an error occurs.
2513    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2514        let _result = self.send_raw(result);
2515        if _result.is_err() {
2516            self.control_handle.shutdown();
2517        }
2518        self.drop_without_shutdown();
2519        _result
2520    }
2521
2522    /// Similar to "send" but does not shutdown the channel if an error occurs.
2523    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2524        let _result = self.send_raw(result);
2525        self.drop_without_shutdown();
2526        _result
2527    }
2528
2529    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2530        self.control_handle
2531            .inner
2532            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
2533                result,
2534                self.tx_id,
2535                0xed29d63b47d8a7b,
2536                fidl::encoding::DynamicFlags::empty(),
2537            )
2538    }
2539}
2540
2541#[must_use = "FIDL methods require a response to be sent"]
2542#[derive(Debug)]
2543pub struct StarnixVolumeProviderMountResponder {
2544    control_handle: std::mem::ManuallyDrop<StarnixVolumeProviderControlHandle>,
2545    tx_id: u32,
2546}
2547
2548/// Set the the channel to be shutdown (see [`StarnixVolumeProviderControlHandle::shutdown`])
2549/// if the responder is dropped without sending a response, so that the client
2550/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2551impl std::ops::Drop for StarnixVolumeProviderMountResponder {
2552    fn drop(&mut self) {
2553        self.control_handle.shutdown();
2554        // Safety: drops once, never accessed again
2555        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2556    }
2557}
2558
2559impl fidl::endpoints::Responder for StarnixVolumeProviderMountResponder {
2560    type ControlHandle = StarnixVolumeProviderControlHandle;
2561
2562    fn control_handle(&self) -> &StarnixVolumeProviderControlHandle {
2563        &self.control_handle
2564    }
2565
2566    fn drop_without_shutdown(mut self) {
2567        // Safety: drops once, never accessed again due to mem::forget
2568        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2569        // Prevent Drop from running (which would shut down the channel)
2570        std::mem::forget(self);
2571    }
2572}
2573
2574impl StarnixVolumeProviderMountResponder {
2575    /// Sends a response to the FIDL transaction.
2576    ///
2577    /// Sets the channel to shutdown if an error occurs.
2578    pub fn send(self, mut result: Result<&[u8; 16], i32>) -> Result<(), fidl::Error> {
2579        let _result = self.send_raw(result);
2580        if _result.is_err() {
2581            self.control_handle.shutdown();
2582        }
2583        self.drop_without_shutdown();
2584        _result
2585    }
2586
2587    /// Similar to "send" but does not shutdown the channel if an error occurs.
2588    pub fn send_no_shutdown_on_err(
2589        self,
2590        mut result: Result<&[u8; 16], i32>,
2591    ) -> Result<(), fidl::Error> {
2592        let _result = self.send_raw(result);
2593        self.drop_without_shutdown();
2594        _result
2595    }
2596
2597    fn send_raw(&self, mut result: Result<&[u8; 16], i32>) -> Result<(), fidl::Error> {
2598        self.control_handle
2599            .inner
2600            .send::<fidl::encoding::ResultType<StarnixVolumeProviderMountResponse, i32>>(
2601                result.map(|guid| (guid,)),
2602                self.tx_id,
2603                0x62ae75763dde5af6,
2604                fidl::encoding::DynamicFlags::empty(),
2605            )
2606    }
2607}
2608
2609mod internal {
2610    use super::*;
2611
2612    impl fidl::encoding::ResourceTypeMarker for MountedSystemContainer {
2613        type Borrowed<'a> = &'a mut Self;
2614        fn take_or_borrow<'a>(
2615            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2616        ) -> Self::Borrowed<'a> {
2617            value
2618        }
2619    }
2620
2621    unsafe impl fidl::encoding::TypeMarker for MountedSystemContainer {
2622        type Owned = Self;
2623
2624        #[inline(always)]
2625        fn inline_align(_context: fidl::encoding::Context) -> usize {
2626            4
2627        }
2628
2629        #[inline(always)]
2630        fn inline_size(_context: fidl::encoding::Context) -> usize {
2631            8
2632        }
2633    }
2634
2635    unsafe impl
2636        fidl::encoding::Encode<
2637            MountedSystemContainer,
2638            fidl::encoding::DefaultFuchsiaResourceDialect,
2639        > for &mut MountedSystemContainer
2640    {
2641        #[inline]
2642        unsafe fn encode(
2643            self,
2644            encoder: &mut fidl::encoding::Encoder<
2645                '_,
2646                fidl::encoding::DefaultFuchsiaResourceDialect,
2647            >,
2648            offset: usize,
2649            _depth: fidl::encoding::Depth,
2650        ) -> fidl::Result<()> {
2651            encoder.debug_check_bounds::<MountedSystemContainer>(offset);
2652            // Delegate to tuple encoding.
2653            fidl::encoding::Encode::<
2654                MountedSystemContainer,
2655                fidl::encoding::DefaultFuchsiaResourceDialect,
2656            >::encode(
2657                (
2658                    <fidl::encoding::Endpoint<
2659                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
2660                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2661                        &mut self.image_file
2662                    ),
2663                    <fidl::encoding::HandleType<
2664                        fidl::EventPair,
2665                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2666                        2147483648,
2667                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2668                        &mut self.mount_token
2669                    ),
2670                ),
2671                encoder,
2672                offset,
2673                _depth,
2674            )
2675        }
2676    }
2677    unsafe impl<
2678        T0: fidl::encoding::Encode<
2679                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
2680                fidl::encoding::DefaultFuchsiaResourceDialect,
2681            >,
2682        T1: fidl::encoding::Encode<
2683                fidl::encoding::HandleType<
2684                    fidl::EventPair,
2685                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2686                    2147483648,
2687                >,
2688                fidl::encoding::DefaultFuchsiaResourceDialect,
2689            >,
2690    >
2691        fidl::encoding::Encode<
2692            MountedSystemContainer,
2693            fidl::encoding::DefaultFuchsiaResourceDialect,
2694        > for (T0, T1)
2695    {
2696        #[inline]
2697        unsafe fn encode(
2698            self,
2699            encoder: &mut fidl::encoding::Encoder<
2700                '_,
2701                fidl::encoding::DefaultFuchsiaResourceDialect,
2702            >,
2703            offset: usize,
2704            depth: fidl::encoding::Depth,
2705        ) -> fidl::Result<()> {
2706            encoder.debug_check_bounds::<MountedSystemContainer>(offset);
2707            // Zero out padding regions. There's no need to apply masks
2708            // because the unmasked parts will be overwritten by fields.
2709            // Write the fields.
2710            self.0.encode(encoder, offset + 0, depth)?;
2711            self.1.encode(encoder, offset + 4, depth)?;
2712            Ok(())
2713        }
2714    }
2715
2716    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2717        for MountedSystemContainer
2718    {
2719        #[inline(always)]
2720        fn new_empty() -> Self {
2721            Self {
2722                image_file: fidl::new_empty!(
2723                    fidl::encoding::Endpoint<
2724                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
2725                    >,
2726                    fidl::encoding::DefaultFuchsiaResourceDialect
2727                ),
2728                mount_token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2729            }
2730        }
2731
2732        #[inline]
2733        unsafe fn decode(
2734            &mut self,
2735            decoder: &mut fidl::encoding::Decoder<
2736                '_,
2737                fidl::encoding::DefaultFuchsiaResourceDialect,
2738            >,
2739            offset: usize,
2740            _depth: fidl::encoding::Depth,
2741        ) -> fidl::Result<()> {
2742            decoder.debug_check_bounds::<Self>(offset);
2743            // Verify that padding bytes are zero.
2744            fidl::decode!(
2745                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
2746                fidl::encoding::DefaultFuchsiaResourceDialect,
2747                &mut self.image_file,
2748                decoder,
2749                offset + 0,
2750                _depth
2751            )?;
2752            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.mount_token, decoder, offset + 4, _depth)?;
2753            Ok(())
2754        }
2755    }
2756
2757    impl fidl::encoding::ResourceTypeMarker for RecoveryMountSystemBlobVolumeRequest {
2758        type Borrowed<'a> = &'a mut Self;
2759        fn take_or_borrow<'a>(
2760            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2761        ) -> Self::Borrowed<'a> {
2762            value
2763        }
2764    }
2765
2766    unsafe impl fidl::encoding::TypeMarker for RecoveryMountSystemBlobVolumeRequest {
2767        type Owned = Self;
2768
2769        #[inline(always)]
2770        fn inline_align(_context: fidl::encoding::Context) -> usize {
2771            4
2772        }
2773
2774        #[inline(always)]
2775        fn inline_size(_context: fidl::encoding::Context) -> usize {
2776            4
2777        }
2778    }
2779
2780    unsafe impl
2781        fidl::encoding::Encode<
2782            RecoveryMountSystemBlobVolumeRequest,
2783            fidl::encoding::DefaultFuchsiaResourceDialect,
2784        > for &mut RecoveryMountSystemBlobVolumeRequest
2785    {
2786        #[inline]
2787        unsafe fn encode(
2788            self,
2789            encoder: &mut fidl::encoding::Encoder<
2790                '_,
2791                fidl::encoding::DefaultFuchsiaResourceDialect,
2792            >,
2793            offset: usize,
2794            _depth: fidl::encoding::Depth,
2795        ) -> fidl::Result<()> {
2796            encoder.debug_check_bounds::<RecoveryMountSystemBlobVolumeRequest>(offset);
2797            // Delegate to tuple encoding.
2798            fidl::encoding::Encode::<
2799                RecoveryMountSystemBlobVolumeRequest,
2800                fidl::encoding::DefaultFuchsiaResourceDialect,
2801            >::encode(
2802                (<fidl::encoding::Endpoint<
2803                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
2804                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2805                    &mut self.blob_exposed_dir,
2806                ),),
2807                encoder,
2808                offset,
2809                _depth,
2810            )
2811        }
2812    }
2813    unsafe impl<
2814        T0: fidl::encoding::Encode<
2815                fidl::encoding::Endpoint<
2816                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
2817                >,
2818                fidl::encoding::DefaultFuchsiaResourceDialect,
2819            >,
2820    >
2821        fidl::encoding::Encode<
2822            RecoveryMountSystemBlobVolumeRequest,
2823            fidl::encoding::DefaultFuchsiaResourceDialect,
2824        > for (T0,)
2825    {
2826        #[inline]
2827        unsafe fn encode(
2828            self,
2829            encoder: &mut fidl::encoding::Encoder<
2830                '_,
2831                fidl::encoding::DefaultFuchsiaResourceDialect,
2832            >,
2833            offset: usize,
2834            depth: fidl::encoding::Depth,
2835        ) -> fidl::Result<()> {
2836            encoder.debug_check_bounds::<RecoveryMountSystemBlobVolumeRequest>(offset);
2837            // Zero out padding regions. There's no need to apply masks
2838            // because the unmasked parts will be overwritten by fields.
2839            // Write the fields.
2840            self.0.encode(encoder, offset + 0, depth)?;
2841            Ok(())
2842        }
2843    }
2844
2845    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2846        for RecoveryMountSystemBlobVolumeRequest
2847    {
2848        #[inline(always)]
2849        fn new_empty() -> Self {
2850            Self {
2851                blob_exposed_dir: fidl::new_empty!(
2852                    fidl::encoding::Endpoint<
2853                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
2854                    >,
2855                    fidl::encoding::DefaultFuchsiaResourceDialect
2856                ),
2857            }
2858        }
2859
2860        #[inline]
2861        unsafe fn decode(
2862            &mut self,
2863            decoder: &mut fidl::encoding::Decoder<
2864                '_,
2865                fidl::encoding::DefaultFuchsiaResourceDialect,
2866            >,
2867            offset: usize,
2868            _depth: fidl::encoding::Depth,
2869        ) -> fidl::Result<()> {
2870            decoder.debug_check_bounds::<Self>(offset);
2871            // Verify that padding bytes are zero.
2872            fidl::decode!(
2873                fidl::encoding::Endpoint<
2874                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
2875                >,
2876                fidl::encoding::DefaultFuchsiaResourceDialect,
2877                &mut self.blob_exposed_dir,
2878                decoder,
2879                offset + 0,
2880                _depth
2881            )?;
2882            Ok(())
2883        }
2884    }
2885
2886    impl fidl::encoding::ResourceTypeMarker for RecoveryWriteDataFileRequest {
2887        type Borrowed<'a> = &'a mut Self;
2888        fn take_or_borrow<'a>(
2889            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2890        ) -> Self::Borrowed<'a> {
2891            value
2892        }
2893    }
2894
2895    unsafe impl fidl::encoding::TypeMarker for RecoveryWriteDataFileRequest {
2896        type Owned = Self;
2897
2898        #[inline(always)]
2899        fn inline_align(_context: fidl::encoding::Context) -> usize {
2900            8
2901        }
2902
2903        #[inline(always)]
2904        fn inline_size(_context: fidl::encoding::Context) -> usize {
2905            24
2906        }
2907    }
2908
2909    unsafe impl
2910        fidl::encoding::Encode<
2911            RecoveryWriteDataFileRequest,
2912            fidl::encoding::DefaultFuchsiaResourceDialect,
2913        > for &mut RecoveryWriteDataFileRequest
2914    {
2915        #[inline]
2916        unsafe fn encode(
2917            self,
2918            encoder: &mut fidl::encoding::Encoder<
2919                '_,
2920                fidl::encoding::DefaultFuchsiaResourceDialect,
2921            >,
2922            offset: usize,
2923            _depth: fidl::encoding::Depth,
2924        ) -> fidl::Result<()> {
2925            encoder.debug_check_bounds::<RecoveryWriteDataFileRequest>(offset);
2926            // Delegate to tuple encoding.
2927            fidl::encoding::Encode::<RecoveryWriteDataFileRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2928                (
2929                    <fidl::encoding::BoundedString<4095> as fidl::encoding::ValueTypeMarker>::borrow(&self.filename),
2930                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.payload),
2931                ),
2932                encoder, offset, _depth
2933            )
2934        }
2935    }
2936    unsafe impl<
2937        T0: fidl::encoding::Encode<
2938                fidl::encoding::BoundedString<4095>,
2939                fidl::encoding::DefaultFuchsiaResourceDialect,
2940            >,
2941        T1: fidl::encoding::Encode<
2942                fidl::encoding::HandleType<
2943                    fidl::Vmo,
2944                    { fidl::ObjectType::VMO.into_raw() },
2945                    2147483648,
2946                >,
2947                fidl::encoding::DefaultFuchsiaResourceDialect,
2948            >,
2949    >
2950        fidl::encoding::Encode<
2951            RecoveryWriteDataFileRequest,
2952            fidl::encoding::DefaultFuchsiaResourceDialect,
2953        > for (T0, T1)
2954    {
2955        #[inline]
2956        unsafe fn encode(
2957            self,
2958            encoder: &mut fidl::encoding::Encoder<
2959                '_,
2960                fidl::encoding::DefaultFuchsiaResourceDialect,
2961            >,
2962            offset: usize,
2963            depth: fidl::encoding::Depth,
2964        ) -> fidl::Result<()> {
2965            encoder.debug_check_bounds::<RecoveryWriteDataFileRequest>(offset);
2966            // Zero out padding regions. There's no need to apply masks
2967            // because the unmasked parts will be overwritten by fields.
2968            unsafe {
2969                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
2970                (ptr as *mut u64).write_unaligned(0);
2971            }
2972            // Write the fields.
2973            self.0.encode(encoder, offset + 0, depth)?;
2974            self.1.encode(encoder, offset + 16, depth)?;
2975            Ok(())
2976        }
2977    }
2978
2979    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2980        for RecoveryWriteDataFileRequest
2981    {
2982        #[inline(always)]
2983        fn new_empty() -> Self {
2984            Self {
2985                filename: fidl::new_empty!(
2986                    fidl::encoding::BoundedString<4095>,
2987                    fidl::encoding::DefaultFuchsiaResourceDialect
2988                ),
2989                payload: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2990            }
2991        }
2992
2993        #[inline]
2994        unsafe fn decode(
2995            &mut self,
2996            decoder: &mut fidl::encoding::Decoder<
2997                '_,
2998                fidl::encoding::DefaultFuchsiaResourceDialect,
2999            >,
3000            offset: usize,
3001            _depth: fidl::encoding::Depth,
3002        ) -> fidl::Result<()> {
3003            decoder.debug_check_bounds::<Self>(offset);
3004            // Verify that padding bytes are zero.
3005            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3006            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3007            let mask = 0xffffffff00000000u64;
3008            let maskedval = padval & mask;
3009            if maskedval != 0 {
3010                return Err(fidl::Error::NonZeroPadding {
3011                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3012                });
3013            }
3014            fidl::decode!(
3015                fidl::encoding::BoundedString<4095>,
3016                fidl::encoding::DefaultFuchsiaResourceDialect,
3017                &mut self.filename,
3018                decoder,
3019                offset + 0,
3020                _depth
3021            )?;
3022            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.payload, decoder, offset + 16, _depth)?;
3023            Ok(())
3024        }
3025    }
3026
3027    impl fidl::encoding::ResourceTypeMarker for StarnixVolumeProviderCheckRequest {
3028        type Borrowed<'a> = &'a mut Self;
3029        fn take_or_borrow<'a>(
3030            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3031        ) -> Self::Borrowed<'a> {
3032            value
3033        }
3034    }
3035
3036    unsafe impl fidl::encoding::TypeMarker for StarnixVolumeProviderCheckRequest {
3037        type Owned = Self;
3038
3039        #[inline(always)]
3040        fn inline_align(_context: fidl::encoding::Context) -> usize {
3041            4
3042        }
3043
3044        #[inline(always)]
3045        fn inline_size(_context: fidl::encoding::Context) -> usize {
3046            4
3047        }
3048    }
3049
3050    unsafe impl
3051        fidl::encoding::Encode<
3052            StarnixVolumeProviderCheckRequest,
3053            fidl::encoding::DefaultFuchsiaResourceDialect,
3054        > for &mut StarnixVolumeProviderCheckRequest
3055    {
3056        #[inline]
3057        unsafe fn encode(
3058            self,
3059            encoder: &mut fidl::encoding::Encoder<
3060                '_,
3061                fidl::encoding::DefaultFuchsiaResourceDialect,
3062            >,
3063            offset: usize,
3064            _depth: fidl::encoding::Depth,
3065        ) -> fidl::Result<()> {
3066            encoder.debug_check_bounds::<StarnixVolumeProviderCheckRequest>(offset);
3067            // Delegate to tuple encoding.
3068            fidl::encoding::Encode::<
3069                StarnixVolumeProviderCheckRequest,
3070                fidl::encoding::DefaultFuchsiaResourceDialect,
3071            >::encode(
3072                (<fidl::encoding::Endpoint<
3073                    fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
3074                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3075                    &mut self.crypt
3076                ),),
3077                encoder,
3078                offset,
3079                _depth,
3080            )
3081        }
3082    }
3083    unsafe impl<
3084        T0: fidl::encoding::Encode<
3085                fidl::encoding::Endpoint<
3086                    fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
3087                >,
3088                fidl::encoding::DefaultFuchsiaResourceDialect,
3089            >,
3090    >
3091        fidl::encoding::Encode<
3092            StarnixVolumeProviderCheckRequest,
3093            fidl::encoding::DefaultFuchsiaResourceDialect,
3094        > for (T0,)
3095    {
3096        #[inline]
3097        unsafe fn encode(
3098            self,
3099            encoder: &mut fidl::encoding::Encoder<
3100                '_,
3101                fidl::encoding::DefaultFuchsiaResourceDialect,
3102            >,
3103            offset: usize,
3104            depth: fidl::encoding::Depth,
3105        ) -> fidl::Result<()> {
3106            encoder.debug_check_bounds::<StarnixVolumeProviderCheckRequest>(offset);
3107            // Zero out padding regions. There's no need to apply masks
3108            // because the unmasked parts will be overwritten by fields.
3109            // Write the fields.
3110            self.0.encode(encoder, offset + 0, depth)?;
3111            Ok(())
3112        }
3113    }
3114
3115    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3116        for StarnixVolumeProviderCheckRequest
3117    {
3118        #[inline(always)]
3119        fn new_empty() -> Self {
3120            Self {
3121                crypt: fidl::new_empty!(
3122                    fidl::encoding::Endpoint<
3123                        fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
3124                    >,
3125                    fidl::encoding::DefaultFuchsiaResourceDialect
3126                ),
3127            }
3128        }
3129
3130        #[inline]
3131        unsafe fn decode(
3132            &mut self,
3133            decoder: &mut fidl::encoding::Decoder<
3134                '_,
3135                fidl::encoding::DefaultFuchsiaResourceDialect,
3136            >,
3137            offset: usize,
3138            _depth: fidl::encoding::Depth,
3139        ) -> fidl::Result<()> {
3140            decoder.debug_check_bounds::<Self>(offset);
3141            // Verify that padding bytes are zero.
3142            fidl::decode!(
3143                fidl::encoding::Endpoint<
3144                    fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
3145                >,
3146                fidl::encoding::DefaultFuchsiaResourceDialect,
3147                &mut self.crypt,
3148                decoder,
3149                offset + 0,
3150                _depth
3151            )?;
3152            Ok(())
3153        }
3154    }
3155
3156    impl fidl::encoding::ResourceTypeMarker for StarnixVolumeProviderMountRequest {
3157        type Borrowed<'a> = &'a mut Self;
3158        fn take_or_borrow<'a>(
3159            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3160        ) -> Self::Borrowed<'a> {
3161            value
3162        }
3163    }
3164
3165    unsafe impl fidl::encoding::TypeMarker for StarnixVolumeProviderMountRequest {
3166        type Owned = Self;
3167
3168        #[inline(always)]
3169        fn inline_align(_context: fidl::encoding::Context) -> usize {
3170            4
3171        }
3172
3173        #[inline(always)]
3174        fn inline_size(_context: fidl::encoding::Context) -> usize {
3175            12
3176        }
3177    }
3178
3179    unsafe impl
3180        fidl::encoding::Encode<
3181            StarnixVolumeProviderMountRequest,
3182            fidl::encoding::DefaultFuchsiaResourceDialect,
3183        > for &mut StarnixVolumeProviderMountRequest
3184    {
3185        #[inline]
3186        unsafe fn encode(
3187            self,
3188            encoder: &mut fidl::encoding::Encoder<
3189                '_,
3190                fidl::encoding::DefaultFuchsiaResourceDialect,
3191            >,
3192            offset: usize,
3193            _depth: fidl::encoding::Depth,
3194        ) -> fidl::Result<()> {
3195            encoder.debug_check_bounds::<StarnixVolumeProviderMountRequest>(offset);
3196            // Delegate to tuple encoding.
3197            fidl::encoding::Encode::<
3198                StarnixVolumeProviderMountRequest,
3199                fidl::encoding::DefaultFuchsiaResourceDialect,
3200            >::encode(
3201                (
3202                    <fidl::encoding::Endpoint<
3203                        fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
3204                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3205                        &mut self.crypt
3206                    ),
3207                    <MountMode as fidl::encoding::ValueTypeMarker>::borrow(&self.mode),
3208                    <fidl::encoding::Endpoint<
3209                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3210                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3211                        &mut self.exposed_dir
3212                    ),
3213                ),
3214                encoder,
3215                offset,
3216                _depth,
3217            )
3218        }
3219    }
3220    unsafe impl<
3221        T0: fidl::encoding::Encode<
3222                fidl::encoding::Endpoint<
3223                    fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
3224                >,
3225                fidl::encoding::DefaultFuchsiaResourceDialect,
3226            >,
3227        T1: fidl::encoding::Encode<MountMode, fidl::encoding::DefaultFuchsiaResourceDialect>,
3228        T2: fidl::encoding::Encode<
3229                fidl::encoding::Endpoint<
3230                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3231                >,
3232                fidl::encoding::DefaultFuchsiaResourceDialect,
3233            >,
3234    >
3235        fidl::encoding::Encode<
3236            StarnixVolumeProviderMountRequest,
3237            fidl::encoding::DefaultFuchsiaResourceDialect,
3238        > for (T0, T1, T2)
3239    {
3240        #[inline]
3241        unsafe fn encode(
3242            self,
3243            encoder: &mut fidl::encoding::Encoder<
3244                '_,
3245                fidl::encoding::DefaultFuchsiaResourceDialect,
3246            >,
3247            offset: usize,
3248            depth: fidl::encoding::Depth,
3249        ) -> fidl::Result<()> {
3250            encoder.debug_check_bounds::<StarnixVolumeProviderMountRequest>(offset);
3251            // Zero out padding regions. There's no need to apply masks
3252            // because the unmasked parts will be overwritten by fields.
3253            // Write the fields.
3254            self.0.encode(encoder, offset + 0, depth)?;
3255            self.1.encode(encoder, offset + 4, depth)?;
3256            self.2.encode(encoder, offset + 8, depth)?;
3257            Ok(())
3258        }
3259    }
3260
3261    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3262        for StarnixVolumeProviderMountRequest
3263    {
3264        #[inline(always)]
3265        fn new_empty() -> Self {
3266            Self {
3267                crypt: fidl::new_empty!(
3268                    fidl::encoding::Endpoint<
3269                        fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
3270                    >,
3271                    fidl::encoding::DefaultFuchsiaResourceDialect
3272                ),
3273                mode: fidl::new_empty!(MountMode, fidl::encoding::DefaultFuchsiaResourceDialect),
3274                exposed_dir: fidl::new_empty!(
3275                    fidl::encoding::Endpoint<
3276                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3277                    >,
3278                    fidl::encoding::DefaultFuchsiaResourceDialect
3279                ),
3280            }
3281        }
3282
3283        #[inline]
3284        unsafe fn decode(
3285            &mut self,
3286            decoder: &mut fidl::encoding::Decoder<
3287                '_,
3288                fidl::encoding::DefaultFuchsiaResourceDialect,
3289            >,
3290            offset: usize,
3291            _depth: fidl::encoding::Depth,
3292        ) -> fidl::Result<()> {
3293            decoder.debug_check_bounds::<Self>(offset);
3294            // Verify that padding bytes are zero.
3295            fidl::decode!(
3296                fidl::encoding::Endpoint<
3297                    fidl::endpoints::ClientEnd<fidl_fuchsia_fxfs::CryptMarker>,
3298                >,
3299                fidl::encoding::DefaultFuchsiaResourceDialect,
3300                &mut self.crypt,
3301                decoder,
3302                offset + 0,
3303                _depth
3304            )?;
3305            fidl::decode!(
3306                MountMode,
3307                fidl::encoding::DefaultFuchsiaResourceDialect,
3308                &mut self.mode,
3309                decoder,
3310                offset + 4,
3311                _depth
3312            )?;
3313            fidl::decode!(
3314                fidl::encoding::Endpoint<
3315                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3316                >,
3317                fidl::encoding::DefaultFuchsiaResourceDialect,
3318                &mut self.exposed_dir,
3319                decoder,
3320                offset + 8,
3321                _depth
3322            )?;
3323            Ok(())
3324        }
3325    }
3326
3327    impl MountOptions {
3328        #[inline(always)]
3329        fn max_ordinal_present(&self) -> u64 {
3330            if let Some(_) = self.write_compression_algorithm {
3331                return 4;
3332            }
3333            if let Some(_) = self.verbose {
3334                return 3;
3335            }
3336            if let Some(_) = self.collect_metrics {
3337                return 2;
3338            }
3339            if let Some(_) = self.read_only {
3340                return 1;
3341            }
3342            0
3343        }
3344    }
3345
3346    impl fidl::encoding::ResourceTypeMarker for MountOptions {
3347        type Borrowed<'a> = &'a mut Self;
3348        fn take_or_borrow<'a>(
3349            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3350        ) -> Self::Borrowed<'a> {
3351            value
3352        }
3353    }
3354
3355    unsafe impl fidl::encoding::TypeMarker for MountOptions {
3356        type Owned = Self;
3357
3358        #[inline(always)]
3359        fn inline_align(_context: fidl::encoding::Context) -> usize {
3360            8
3361        }
3362
3363        #[inline(always)]
3364        fn inline_size(_context: fidl::encoding::Context) -> usize {
3365            16
3366        }
3367    }
3368
3369    unsafe impl fidl::encoding::Encode<MountOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
3370        for &mut MountOptions
3371    {
3372        unsafe fn encode(
3373            self,
3374            encoder: &mut fidl::encoding::Encoder<
3375                '_,
3376                fidl::encoding::DefaultFuchsiaResourceDialect,
3377            >,
3378            offset: usize,
3379            mut depth: fidl::encoding::Depth,
3380        ) -> fidl::Result<()> {
3381            encoder.debug_check_bounds::<MountOptions>(offset);
3382            // Vector header
3383            let max_ordinal: u64 = self.max_ordinal_present();
3384            encoder.write_num(max_ordinal, offset);
3385            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3386            // Calling encoder.out_of_line_offset(0) is not allowed.
3387            if max_ordinal == 0 {
3388                return Ok(());
3389            }
3390            depth.increment()?;
3391            let envelope_size = 8;
3392            let bytes_len = max_ordinal as usize * envelope_size;
3393            #[allow(unused_variables)]
3394            let offset = encoder.out_of_line_offset(bytes_len);
3395            let mut _prev_end_offset: usize = 0;
3396            if 1 > max_ordinal {
3397                return Ok(());
3398            }
3399
3400            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3401            // are envelope_size bytes.
3402            let cur_offset: usize = (1 - 1) * envelope_size;
3403
3404            // Zero reserved fields.
3405            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3406
3407            // Safety:
3408            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3409            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3410            //   envelope_size bytes, there is always sufficient room.
3411            fidl::encoding::encode_in_envelope_optional::<
3412                bool,
3413                fidl::encoding::DefaultFuchsiaResourceDialect,
3414            >(
3415                self.read_only.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3416                encoder,
3417                offset + cur_offset,
3418                depth,
3419            )?;
3420
3421            _prev_end_offset = cur_offset + envelope_size;
3422            if 2 > max_ordinal {
3423                return Ok(());
3424            }
3425
3426            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3427            // are envelope_size bytes.
3428            let cur_offset: usize = (2 - 1) * envelope_size;
3429
3430            // Zero reserved fields.
3431            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3432
3433            // Safety:
3434            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3435            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3436            //   envelope_size bytes, there is always sufficient room.
3437            fidl::encoding::encode_in_envelope_optional::<
3438                bool,
3439                fidl::encoding::DefaultFuchsiaResourceDialect,
3440            >(
3441                self.collect_metrics
3442                    .as_ref()
3443                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3444                encoder,
3445                offset + cur_offset,
3446                depth,
3447            )?;
3448
3449            _prev_end_offset = cur_offset + envelope_size;
3450            if 3 > max_ordinal {
3451                return Ok(());
3452            }
3453
3454            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3455            // are envelope_size bytes.
3456            let cur_offset: usize = (3 - 1) * envelope_size;
3457
3458            // Zero reserved fields.
3459            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3460
3461            // Safety:
3462            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3463            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3464            //   envelope_size bytes, there is always sufficient room.
3465            fidl::encoding::encode_in_envelope_optional::<
3466                bool,
3467                fidl::encoding::DefaultFuchsiaResourceDialect,
3468            >(
3469                self.verbose.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3470                encoder,
3471                offset + cur_offset,
3472                depth,
3473            )?;
3474
3475            _prev_end_offset = cur_offset + envelope_size;
3476            if 4 > max_ordinal {
3477                return Ok(());
3478            }
3479
3480            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3481            // are envelope_size bytes.
3482            let cur_offset: usize = (4 - 1) * envelope_size;
3483
3484            // Zero reserved fields.
3485            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3486
3487            // Safety:
3488            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3489            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3490            //   envelope_size bytes, there is always sufficient room.
3491            fidl::encoding::encode_in_envelope_optional::<
3492                fidl::encoding::BoundedString<32>,
3493                fidl::encoding::DefaultFuchsiaResourceDialect,
3494            >(
3495                self.write_compression_algorithm.as_ref().map(
3496                    <fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow,
3497                ),
3498                encoder,
3499                offset + cur_offset,
3500                depth,
3501            )?;
3502
3503            _prev_end_offset = cur_offset + envelope_size;
3504
3505            Ok(())
3506        }
3507    }
3508
3509    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for MountOptions {
3510        #[inline(always)]
3511        fn new_empty() -> Self {
3512            Self::default()
3513        }
3514
3515        unsafe fn decode(
3516            &mut self,
3517            decoder: &mut fidl::encoding::Decoder<
3518                '_,
3519                fidl::encoding::DefaultFuchsiaResourceDialect,
3520            >,
3521            offset: usize,
3522            mut depth: fidl::encoding::Depth,
3523        ) -> fidl::Result<()> {
3524            decoder.debug_check_bounds::<Self>(offset);
3525            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3526                None => return Err(fidl::Error::NotNullable),
3527                Some(len) => len,
3528            };
3529            // Calling decoder.out_of_line_offset(0) is not allowed.
3530            if len == 0 {
3531                return Ok(());
3532            };
3533            depth.increment()?;
3534            let envelope_size = 8;
3535            let bytes_len = len * envelope_size;
3536            let offset = decoder.out_of_line_offset(bytes_len)?;
3537            // Decode the envelope for each type.
3538            let mut _next_ordinal_to_read = 0;
3539            let mut next_offset = offset;
3540            let end_offset = offset + bytes_len;
3541            _next_ordinal_to_read += 1;
3542            if next_offset >= end_offset {
3543                return Ok(());
3544            }
3545
3546            // Decode unknown envelopes for gaps in ordinals.
3547            while _next_ordinal_to_read < 1 {
3548                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3549                _next_ordinal_to_read += 1;
3550                next_offset += envelope_size;
3551            }
3552
3553            let next_out_of_line = decoder.next_out_of_line();
3554            let handles_before = decoder.remaining_handles();
3555            if let Some((inlined, num_bytes, num_handles)) =
3556                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3557            {
3558                let member_inline_size =
3559                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3560                if inlined != (member_inline_size <= 4) {
3561                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3562                }
3563                let inner_offset;
3564                let mut inner_depth = depth.clone();
3565                if inlined {
3566                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3567                    inner_offset = next_offset;
3568                } else {
3569                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3570                    inner_depth.increment()?;
3571                }
3572                let val_ref = self.read_only.get_or_insert_with(|| {
3573                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
3574                });
3575                fidl::decode!(
3576                    bool,
3577                    fidl::encoding::DefaultFuchsiaResourceDialect,
3578                    val_ref,
3579                    decoder,
3580                    inner_offset,
3581                    inner_depth
3582                )?;
3583                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3584                {
3585                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3586                }
3587                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3588                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3589                }
3590            }
3591
3592            next_offset += envelope_size;
3593            _next_ordinal_to_read += 1;
3594            if next_offset >= end_offset {
3595                return Ok(());
3596            }
3597
3598            // Decode unknown envelopes for gaps in ordinals.
3599            while _next_ordinal_to_read < 2 {
3600                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3601                _next_ordinal_to_read += 1;
3602                next_offset += envelope_size;
3603            }
3604
3605            let next_out_of_line = decoder.next_out_of_line();
3606            let handles_before = decoder.remaining_handles();
3607            if let Some((inlined, num_bytes, num_handles)) =
3608                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3609            {
3610                let member_inline_size =
3611                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3612                if inlined != (member_inline_size <= 4) {
3613                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3614                }
3615                let inner_offset;
3616                let mut inner_depth = depth.clone();
3617                if inlined {
3618                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3619                    inner_offset = next_offset;
3620                } else {
3621                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3622                    inner_depth.increment()?;
3623                }
3624                let val_ref = self.collect_metrics.get_or_insert_with(|| {
3625                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
3626                });
3627                fidl::decode!(
3628                    bool,
3629                    fidl::encoding::DefaultFuchsiaResourceDialect,
3630                    val_ref,
3631                    decoder,
3632                    inner_offset,
3633                    inner_depth
3634                )?;
3635                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3636                {
3637                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3638                }
3639                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3640                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3641                }
3642            }
3643
3644            next_offset += envelope_size;
3645            _next_ordinal_to_read += 1;
3646            if next_offset >= end_offset {
3647                return Ok(());
3648            }
3649
3650            // Decode unknown envelopes for gaps in ordinals.
3651            while _next_ordinal_to_read < 3 {
3652                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3653                _next_ordinal_to_read += 1;
3654                next_offset += envelope_size;
3655            }
3656
3657            let next_out_of_line = decoder.next_out_of_line();
3658            let handles_before = decoder.remaining_handles();
3659            if let Some((inlined, num_bytes, num_handles)) =
3660                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3661            {
3662                let member_inline_size =
3663                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3664                if inlined != (member_inline_size <= 4) {
3665                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3666                }
3667                let inner_offset;
3668                let mut inner_depth = depth.clone();
3669                if inlined {
3670                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3671                    inner_offset = next_offset;
3672                } else {
3673                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3674                    inner_depth.increment()?;
3675                }
3676                let val_ref = self.verbose.get_or_insert_with(|| {
3677                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
3678                });
3679                fidl::decode!(
3680                    bool,
3681                    fidl::encoding::DefaultFuchsiaResourceDialect,
3682                    val_ref,
3683                    decoder,
3684                    inner_offset,
3685                    inner_depth
3686                )?;
3687                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3688                {
3689                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3690                }
3691                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3692                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3693                }
3694            }
3695
3696            next_offset += envelope_size;
3697            _next_ordinal_to_read += 1;
3698            if next_offset >= end_offset {
3699                return Ok(());
3700            }
3701
3702            // Decode unknown envelopes for gaps in ordinals.
3703            while _next_ordinal_to_read < 4 {
3704                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3705                _next_ordinal_to_read += 1;
3706                next_offset += envelope_size;
3707            }
3708
3709            let next_out_of_line = decoder.next_out_of_line();
3710            let handles_before = decoder.remaining_handles();
3711            if let Some((inlined, num_bytes, num_handles)) =
3712                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3713            {
3714                let member_inline_size =
3715                    <fidl::encoding::BoundedString<32> as fidl::encoding::TypeMarker>::inline_size(
3716                        decoder.context,
3717                    );
3718                if inlined != (member_inline_size <= 4) {
3719                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3720                }
3721                let inner_offset;
3722                let mut inner_depth = depth.clone();
3723                if inlined {
3724                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3725                    inner_offset = next_offset;
3726                } else {
3727                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3728                    inner_depth.increment()?;
3729                }
3730                let val_ref = self.write_compression_algorithm.get_or_insert_with(|| {
3731                    fidl::new_empty!(
3732                        fidl::encoding::BoundedString<32>,
3733                        fidl::encoding::DefaultFuchsiaResourceDialect
3734                    )
3735                });
3736                fidl::decode!(
3737                    fidl::encoding::BoundedString<32>,
3738                    fidl::encoding::DefaultFuchsiaResourceDialect,
3739                    val_ref,
3740                    decoder,
3741                    inner_offset,
3742                    inner_depth
3743                )?;
3744                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3745                {
3746                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3747                }
3748                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3749                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3750                }
3751            }
3752
3753            next_offset += envelope_size;
3754
3755            // Decode the remaining unknown envelopes.
3756            while next_offset < end_offset {
3757                _next_ordinal_to_read += 1;
3758                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3759                next_offset += envelope_size;
3760            }
3761
3762            Ok(())
3763        }
3764    }
3765
3766    impl fidl::encoding::ResourceTypeMarker for RecoveryGetBlobImageHandleResponse {
3767        type Borrowed<'a> = &'a mut Self;
3768        fn take_or_borrow<'a>(
3769            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3770        ) -> Self::Borrowed<'a> {
3771            value
3772        }
3773    }
3774
3775    unsafe impl fidl::encoding::TypeMarker for RecoveryGetBlobImageHandleResponse {
3776        type Owned = Self;
3777
3778        #[inline(always)]
3779        fn inline_align(_context: fidl::encoding::Context) -> usize {
3780            8
3781        }
3782
3783        #[inline(always)]
3784        fn inline_size(_context: fidl::encoding::Context) -> usize {
3785            16
3786        }
3787    }
3788
3789    unsafe impl
3790        fidl::encoding::Encode<
3791            RecoveryGetBlobImageHandleResponse,
3792            fidl::encoding::DefaultFuchsiaResourceDialect,
3793        > for &mut RecoveryGetBlobImageHandleResponse
3794    {
3795        #[inline]
3796        unsafe fn encode(
3797            self,
3798            encoder: &mut fidl::encoding::Encoder<
3799                '_,
3800                fidl::encoding::DefaultFuchsiaResourceDialect,
3801            >,
3802            offset: usize,
3803            _depth: fidl::encoding::Depth,
3804        ) -> fidl::Result<()> {
3805            encoder.debug_check_bounds::<RecoveryGetBlobImageHandleResponse>(offset);
3806            encoder.write_num::<u64>(self.ordinal(), offset);
3807            match self {
3808            RecoveryGetBlobImageHandleResponse::Unformatted(ref val) => {
3809                fidl::encoding::encode_in_envelope::<Unformatted, fidl::encoding::DefaultFuchsiaResourceDialect>(
3810                    <Unformatted as fidl::encoding::ValueTypeMarker>::borrow(val),
3811                    encoder, offset + 8, _depth
3812                )
3813            }
3814            RecoveryGetBlobImageHandleResponse::MountedSystemContainer(ref mut val) => {
3815                fidl::encoding::encode_in_envelope::<MountedSystemContainer, fidl::encoding::DefaultFuchsiaResourceDialect>(
3816                    <MountedSystemContainer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
3817                    encoder, offset + 8, _depth
3818                )
3819            }
3820        }
3821        }
3822    }
3823
3824    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3825        for RecoveryGetBlobImageHandleResponse
3826    {
3827        #[inline(always)]
3828        fn new_empty() -> Self {
3829            Self::Unformatted(fidl::new_empty!(
3830                Unformatted,
3831                fidl::encoding::DefaultFuchsiaResourceDialect
3832            ))
3833        }
3834
3835        #[inline]
3836        unsafe fn decode(
3837            &mut self,
3838            decoder: &mut fidl::encoding::Decoder<
3839                '_,
3840                fidl::encoding::DefaultFuchsiaResourceDialect,
3841            >,
3842            offset: usize,
3843            mut depth: fidl::encoding::Depth,
3844        ) -> fidl::Result<()> {
3845            decoder.debug_check_bounds::<Self>(offset);
3846            #[allow(unused_variables)]
3847            let next_out_of_line = decoder.next_out_of_line();
3848            let handles_before = decoder.remaining_handles();
3849            let (ordinal, inlined, num_bytes, num_handles) =
3850                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
3851
3852            let member_inline_size = match ordinal {
3853                1 => <Unformatted as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3854                2 => <MountedSystemContainer as fidl::encoding::TypeMarker>::inline_size(
3855                    decoder.context,
3856                ),
3857                _ => return Err(fidl::Error::UnknownUnionTag),
3858            };
3859
3860            if inlined != (member_inline_size <= 4) {
3861                return Err(fidl::Error::InvalidInlineBitInEnvelope);
3862            }
3863            let _inner_offset;
3864            if inlined {
3865                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
3866                _inner_offset = offset + 8;
3867            } else {
3868                depth.increment()?;
3869                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3870            }
3871            match ordinal {
3872                1 => {
3873                    #[allow(irrefutable_let_patterns)]
3874                    if let RecoveryGetBlobImageHandleResponse::Unformatted(_) = self {
3875                        // Do nothing, read the value into the object
3876                    } else {
3877                        // Initialize `self` to the right variant
3878                        *self = RecoveryGetBlobImageHandleResponse::Unformatted(fidl::new_empty!(
3879                            Unformatted,
3880                            fidl::encoding::DefaultFuchsiaResourceDialect
3881                        ));
3882                    }
3883                    #[allow(irrefutable_let_patterns)]
3884                    if let RecoveryGetBlobImageHandleResponse::Unformatted(ref mut val) = self {
3885                        fidl::decode!(
3886                            Unformatted,
3887                            fidl::encoding::DefaultFuchsiaResourceDialect,
3888                            val,
3889                            decoder,
3890                            _inner_offset,
3891                            depth
3892                        )?;
3893                    } else {
3894                        unreachable!()
3895                    }
3896                }
3897                2 => {
3898                    #[allow(irrefutable_let_patterns)]
3899                    if let RecoveryGetBlobImageHandleResponse::MountedSystemContainer(_) = self {
3900                        // Do nothing, read the value into the object
3901                    } else {
3902                        // Initialize `self` to the right variant
3903                        *self = RecoveryGetBlobImageHandleResponse::MountedSystemContainer(
3904                            fidl::new_empty!(
3905                                MountedSystemContainer,
3906                                fidl::encoding::DefaultFuchsiaResourceDialect
3907                            ),
3908                        );
3909                    }
3910                    #[allow(irrefutable_let_patterns)]
3911                    if let RecoveryGetBlobImageHandleResponse::MountedSystemContainer(ref mut val) =
3912                        self
3913                    {
3914                        fidl::decode!(
3915                            MountedSystemContainer,
3916                            fidl::encoding::DefaultFuchsiaResourceDialect,
3917                            val,
3918                            decoder,
3919                            _inner_offset,
3920                            depth
3921                        )?;
3922                    } else {
3923                        unreachable!()
3924                    }
3925                }
3926                ordinal => panic!("unexpected ordinal {:?}", ordinal),
3927            }
3928            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
3929                return Err(fidl::Error::InvalidNumBytesInEnvelope);
3930            }
3931            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3932                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3933            }
3934            Ok(())
3935        }
3936    }
3937}