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