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