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