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