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