Skip to main content

fidl_fuchsia_fshost/
fidl_fuchsia_fshost.rs

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