Skip to main content

fidl_fuchsia_fshost/
fidl_fuchsia_fshost.rs

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