fidl_fuchsia_fs_realm/
fidl_fuchsia_fs_realm.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_fs_realm__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ControllerCheckRequest {
16    pub device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
17    pub name: String,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ControllerCheckRequest {}
21
22#[derive(Debug, PartialEq)]
23pub struct ControllerFormatRequest {
24    pub device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
25    pub name: String,
26    pub options: FormatOptions,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ControllerFormatRequest {}
30
31#[derive(Debug, PartialEq)]
32pub struct ControllerMountRequest {
33    pub device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
34    pub name: String,
35    pub options: MountOptions,
36}
37
38impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ControllerMountRequest {}
39
40#[derive(Debug, Default, PartialEq)]
41pub struct FormatOptions {
42    pub verbose: Option<bool>,
43    pub fvm_data_slices: Option<u32>,
44    #[doc(hidden)]
45    pub __source_breaking: fidl::marker::SourceBreaking,
46}
47
48impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for FormatOptions {}
49
50#[derive(Debug, Default, PartialEq)]
51pub struct MountOptions {
52    pub read_only: Option<bool>,
53    pub verbose: Option<bool>,
54    pub write_compression_algorithm: Option<String>,
55    #[doc(hidden)]
56    pub __source_breaking: fidl::marker::SourceBreaking,
57}
58
59impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for MountOptions {}
60
61#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
62pub struct ControllerMarker;
63
64impl fidl::endpoints::ProtocolMarker for ControllerMarker {
65    type Proxy = ControllerProxy;
66    type RequestStream = ControllerRequestStream;
67    #[cfg(target_os = "fuchsia")]
68    type SynchronousProxy = ControllerSynchronousProxy;
69
70    const DEBUG_NAME: &'static str = "fuchsia.fs.realm.Controller";
71}
72impl fidl::endpoints::DiscoverableProtocolMarker for ControllerMarker {}
73pub type ControllerMountResult = Result<(), i32>;
74pub type ControllerUnmountResult = Result<(), i32>;
75pub type ControllerFormatResult = Result<(), i32>;
76pub type ControllerCheckResult = Result<(), i32>;
77
78pub trait ControllerProxyInterface: Send + Sync {
79    type MountResponseFut: std::future::Future<Output = Result<ControllerMountResult, fidl::Error>>
80        + Send;
81    fn r#mount(
82        &self,
83        device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
84        name: &str,
85        options: MountOptions,
86    ) -> Self::MountResponseFut;
87    type UnmountResponseFut: std::future::Future<Output = Result<ControllerUnmountResult, fidl::Error>>
88        + Send;
89    fn r#unmount(&self, name: &str) -> Self::UnmountResponseFut;
90    type FormatResponseFut: std::future::Future<Output = Result<ControllerFormatResult, fidl::Error>>
91        + Send;
92    fn r#format(
93        &self,
94        device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
95        name: &str,
96        options: FormatOptions,
97    ) -> Self::FormatResponseFut;
98    type CheckResponseFut: std::future::Future<Output = Result<ControllerCheckResult, fidl::Error>>
99        + Send;
100    fn r#check(
101        &self,
102        device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
103        name: &str,
104    ) -> Self::CheckResponseFut;
105}
106#[derive(Debug)]
107#[cfg(target_os = "fuchsia")]
108pub struct ControllerSynchronousProxy {
109    client: fidl::client::sync::Client,
110}
111
112#[cfg(target_os = "fuchsia")]
113impl fidl::endpoints::SynchronousProxy for ControllerSynchronousProxy {
114    type Proxy = ControllerProxy;
115    type Protocol = ControllerMarker;
116
117    fn from_channel(inner: fidl::Channel) -> Self {
118        Self::new(inner)
119    }
120
121    fn into_channel(self) -> fidl::Channel {
122        self.client.into_channel()
123    }
124
125    fn as_channel(&self) -> &fidl::Channel {
126        self.client.as_channel()
127    }
128}
129
130#[cfg(target_os = "fuchsia")]
131impl ControllerSynchronousProxy {
132    pub fn new(channel: fidl::Channel) -> Self {
133        let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
134        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
135    }
136
137    pub fn into_channel(self) -> fidl::Channel {
138        self.client.into_channel()
139    }
140
141    /// Waits until an event arrives and returns it. It is safe for other
142    /// threads to make concurrent requests while waiting for an event.
143    pub fn wait_for_event(
144        &self,
145        deadline: zx::MonotonicInstant,
146    ) -> Result<ControllerEvent, fidl::Error> {
147        ControllerEvent::decode(self.client.wait_for_event(deadline)?)
148    }
149
150    /// Mounts a filesystem on a block device.
151    pub fn r#mount(
152        &self,
153        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
154        mut name: &str,
155        mut options: MountOptions,
156        ___deadline: zx::MonotonicInstant,
157    ) -> Result<ControllerMountResult, fidl::Error> {
158        let _response = self.client.send_query::<
159            ControllerMountRequest,
160            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
161        >(
162            (device, name, &mut options,),
163            0x49300213a51ec7f7,
164            fidl::encoding::DynamicFlags::empty(),
165            ___deadline,
166        )?;
167        Ok(_response.map(|x| x))
168    }
169
170    /// Unmounts a previously mounted filesystem.
171    pub fn r#unmount(
172        &self,
173        mut name: &str,
174        ___deadline: zx::MonotonicInstant,
175    ) -> Result<ControllerUnmountResult, fidl::Error> {
176        let _response = self.client.send_query::<
177            ControllerUnmountRequest,
178            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
179        >(
180            (name,),
181            0x2d994ee1a9364179,
182            fidl::encoding::DynamicFlags::empty(),
183            ___deadline,
184        )?;
185        Ok(_response.map(|x| x))
186    }
187
188    /// Formats a block device with a particular filesystem format
189    pub fn r#format(
190        &self,
191        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
192        mut name: &str,
193        mut options: FormatOptions,
194        ___deadline: zx::MonotonicInstant,
195    ) -> Result<ControllerFormatResult, fidl::Error> {
196        let _response = self.client.send_query::<
197            ControllerFormatRequest,
198            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
199        >(
200            (device, name, &mut options,),
201            0x52ce219e43664bf0,
202            fidl::encoding::DynamicFlags::empty(),
203            ___deadline,
204        )?;
205        Ok(_response.map(|x| x))
206    }
207
208    /// Checks the consistency of the filesystem formatted on
209    /// the block device
210    pub fn r#check(
211        &self,
212        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
213        mut name: &str,
214        ___deadline: zx::MonotonicInstant,
215    ) -> Result<ControllerCheckResult, fidl::Error> {
216        let _response = self.client.send_query::<
217            ControllerCheckRequest,
218            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
219        >(
220            (device, name,),
221            0x20d3ff7c33a9b863,
222            fidl::encoding::DynamicFlags::empty(),
223            ___deadline,
224        )?;
225        Ok(_response.map(|x| x))
226    }
227}
228
229#[cfg(target_os = "fuchsia")]
230impl From<ControllerSynchronousProxy> for zx::NullableHandle {
231    fn from(value: ControllerSynchronousProxy) -> Self {
232        value.into_channel().into()
233    }
234}
235
236#[cfg(target_os = "fuchsia")]
237impl From<fidl::Channel> for ControllerSynchronousProxy {
238    fn from(value: fidl::Channel) -> Self {
239        Self::new(value)
240    }
241}
242
243#[cfg(target_os = "fuchsia")]
244impl fidl::endpoints::FromClient for ControllerSynchronousProxy {
245    type Protocol = ControllerMarker;
246
247    fn from_client(value: fidl::endpoints::ClientEnd<ControllerMarker>) -> Self {
248        Self::new(value.into_channel())
249    }
250}
251
252#[derive(Debug, Clone)]
253pub struct ControllerProxy {
254    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
255}
256
257impl fidl::endpoints::Proxy for ControllerProxy {
258    type Protocol = ControllerMarker;
259
260    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
261        Self::new(inner)
262    }
263
264    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
265        self.client.into_channel().map_err(|client| Self { client })
266    }
267
268    fn as_channel(&self) -> &::fidl::AsyncChannel {
269        self.client.as_channel()
270    }
271}
272
273impl ControllerProxy {
274    /// Create a new Proxy for fuchsia.fs.realm/Controller.
275    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
276        let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
277        Self { client: fidl::client::Client::new(channel, protocol_name) }
278    }
279
280    /// Get a Stream of events from the remote end of the protocol.
281    ///
282    /// # Panics
283    ///
284    /// Panics if the event stream was already taken.
285    pub fn take_event_stream(&self) -> ControllerEventStream {
286        ControllerEventStream { event_receiver: self.client.take_event_receiver() }
287    }
288
289    /// Mounts a filesystem on a block device.
290    pub fn r#mount(
291        &self,
292        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
293        mut name: &str,
294        mut options: MountOptions,
295    ) -> fidl::client::QueryResponseFut<
296        ControllerMountResult,
297        fidl::encoding::DefaultFuchsiaResourceDialect,
298    > {
299        ControllerProxyInterface::r#mount(self, device, name, options)
300    }
301
302    /// Unmounts a previously mounted filesystem.
303    pub fn r#unmount(
304        &self,
305        mut name: &str,
306    ) -> fidl::client::QueryResponseFut<
307        ControllerUnmountResult,
308        fidl::encoding::DefaultFuchsiaResourceDialect,
309    > {
310        ControllerProxyInterface::r#unmount(self, name)
311    }
312
313    /// Formats a block device with a particular filesystem format
314    pub fn r#format(
315        &self,
316        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
317        mut name: &str,
318        mut options: FormatOptions,
319    ) -> fidl::client::QueryResponseFut<
320        ControllerFormatResult,
321        fidl::encoding::DefaultFuchsiaResourceDialect,
322    > {
323        ControllerProxyInterface::r#format(self, device, name, options)
324    }
325
326    /// Checks the consistency of the filesystem formatted on
327    /// the block device
328    pub fn r#check(
329        &self,
330        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
331        mut name: &str,
332    ) -> fidl::client::QueryResponseFut<
333        ControllerCheckResult,
334        fidl::encoding::DefaultFuchsiaResourceDialect,
335    > {
336        ControllerProxyInterface::r#check(self, device, name)
337    }
338}
339
340impl ControllerProxyInterface for ControllerProxy {
341    type MountResponseFut = fidl::client::QueryResponseFut<
342        ControllerMountResult,
343        fidl::encoding::DefaultFuchsiaResourceDialect,
344    >;
345    fn r#mount(
346        &self,
347        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
348        mut name: &str,
349        mut options: MountOptions,
350    ) -> Self::MountResponseFut {
351        fn _decode(
352            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
353        ) -> Result<ControllerMountResult, fidl::Error> {
354            let _response = fidl::client::decode_transaction_body::<
355                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
356                fidl::encoding::DefaultFuchsiaResourceDialect,
357                0x49300213a51ec7f7,
358            >(_buf?)?;
359            Ok(_response.map(|x| x))
360        }
361        self.client.send_query_and_decode::<ControllerMountRequest, ControllerMountResult>(
362            (device, name, &mut options),
363            0x49300213a51ec7f7,
364            fidl::encoding::DynamicFlags::empty(),
365            _decode,
366        )
367    }
368
369    type UnmountResponseFut = fidl::client::QueryResponseFut<
370        ControllerUnmountResult,
371        fidl::encoding::DefaultFuchsiaResourceDialect,
372    >;
373    fn r#unmount(&self, mut name: &str) -> Self::UnmountResponseFut {
374        fn _decode(
375            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
376        ) -> Result<ControllerUnmountResult, fidl::Error> {
377            let _response = fidl::client::decode_transaction_body::<
378                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
379                fidl::encoding::DefaultFuchsiaResourceDialect,
380                0x2d994ee1a9364179,
381            >(_buf?)?;
382            Ok(_response.map(|x| x))
383        }
384        self.client.send_query_and_decode::<ControllerUnmountRequest, ControllerUnmountResult>(
385            (name,),
386            0x2d994ee1a9364179,
387            fidl::encoding::DynamicFlags::empty(),
388            _decode,
389        )
390    }
391
392    type FormatResponseFut = fidl::client::QueryResponseFut<
393        ControllerFormatResult,
394        fidl::encoding::DefaultFuchsiaResourceDialect,
395    >;
396    fn r#format(
397        &self,
398        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
399        mut name: &str,
400        mut options: FormatOptions,
401    ) -> Self::FormatResponseFut {
402        fn _decode(
403            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
404        ) -> Result<ControllerFormatResult, fidl::Error> {
405            let _response = fidl::client::decode_transaction_body::<
406                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
407                fidl::encoding::DefaultFuchsiaResourceDialect,
408                0x52ce219e43664bf0,
409            >(_buf?)?;
410            Ok(_response.map(|x| x))
411        }
412        self.client.send_query_and_decode::<ControllerFormatRequest, ControllerFormatResult>(
413            (device, name, &mut options),
414            0x52ce219e43664bf0,
415            fidl::encoding::DynamicFlags::empty(),
416            _decode,
417        )
418    }
419
420    type CheckResponseFut = fidl::client::QueryResponseFut<
421        ControllerCheckResult,
422        fidl::encoding::DefaultFuchsiaResourceDialect,
423    >;
424    fn r#check(
425        &self,
426        mut device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
427        mut name: &str,
428    ) -> Self::CheckResponseFut {
429        fn _decode(
430            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
431        ) -> Result<ControllerCheckResult, fidl::Error> {
432            let _response = fidl::client::decode_transaction_body::<
433                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
434                fidl::encoding::DefaultFuchsiaResourceDialect,
435                0x20d3ff7c33a9b863,
436            >(_buf?)?;
437            Ok(_response.map(|x| x))
438        }
439        self.client.send_query_and_decode::<ControllerCheckRequest, ControllerCheckResult>(
440            (device, name),
441            0x20d3ff7c33a9b863,
442            fidl::encoding::DynamicFlags::empty(),
443            _decode,
444        )
445    }
446}
447
448pub struct ControllerEventStream {
449    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
450}
451
452impl std::marker::Unpin for ControllerEventStream {}
453
454impl futures::stream::FusedStream for ControllerEventStream {
455    fn is_terminated(&self) -> bool {
456        self.event_receiver.is_terminated()
457    }
458}
459
460impl futures::Stream for ControllerEventStream {
461    type Item = Result<ControllerEvent, fidl::Error>;
462
463    fn poll_next(
464        mut self: std::pin::Pin<&mut Self>,
465        cx: &mut std::task::Context<'_>,
466    ) -> std::task::Poll<Option<Self::Item>> {
467        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
468            &mut self.event_receiver,
469            cx
470        )?) {
471            Some(buf) => std::task::Poll::Ready(Some(ControllerEvent::decode(buf))),
472            None => std::task::Poll::Ready(None),
473        }
474    }
475}
476
477#[derive(Debug)]
478pub enum ControllerEvent {}
479
480impl ControllerEvent {
481    /// Decodes a message buffer as a [`ControllerEvent`].
482    fn decode(
483        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
484    ) -> Result<ControllerEvent, fidl::Error> {
485        let (bytes, _handles) = buf.split_mut();
486        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
487        debug_assert_eq!(tx_header.tx_id, 0);
488        match tx_header.ordinal {
489            _ => Err(fidl::Error::UnknownOrdinal {
490                ordinal: tx_header.ordinal,
491                protocol_name: <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
492            }),
493        }
494    }
495}
496
497/// A Stream of incoming requests for fuchsia.fs.realm/Controller.
498pub struct ControllerRequestStream {
499    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
500    is_terminated: bool,
501}
502
503impl std::marker::Unpin for ControllerRequestStream {}
504
505impl futures::stream::FusedStream for ControllerRequestStream {
506    fn is_terminated(&self) -> bool {
507        self.is_terminated
508    }
509}
510
511impl fidl::endpoints::RequestStream for ControllerRequestStream {
512    type Protocol = ControllerMarker;
513    type ControlHandle = ControllerControlHandle;
514
515    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
516        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
517    }
518
519    fn control_handle(&self) -> Self::ControlHandle {
520        ControllerControlHandle { inner: self.inner.clone() }
521    }
522
523    fn into_inner(
524        self,
525    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
526    {
527        (self.inner, self.is_terminated)
528    }
529
530    fn from_inner(
531        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
532        is_terminated: bool,
533    ) -> Self {
534        Self { inner, is_terminated }
535    }
536}
537
538impl futures::Stream for ControllerRequestStream {
539    type Item = Result<ControllerRequest, fidl::Error>;
540
541    fn poll_next(
542        mut self: std::pin::Pin<&mut Self>,
543        cx: &mut std::task::Context<'_>,
544    ) -> std::task::Poll<Option<Self::Item>> {
545        let this = &mut *self;
546        if this.inner.check_shutdown(cx) {
547            this.is_terminated = true;
548            return std::task::Poll::Ready(None);
549        }
550        if this.is_terminated {
551            panic!("polled ControllerRequestStream after completion");
552        }
553        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
554            |bytes, handles| {
555                match this.inner.channel().read_etc(cx, bytes, handles) {
556                    std::task::Poll::Ready(Ok(())) => {}
557                    std::task::Poll::Pending => return std::task::Poll::Pending,
558                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
559                        this.is_terminated = true;
560                        return std::task::Poll::Ready(None);
561                    }
562                    std::task::Poll::Ready(Err(e)) => {
563                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
564                            e.into(),
565                        ))));
566                    }
567                }
568
569                // A message has been received from the channel
570                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
571
572                std::task::Poll::Ready(Some(match header.ordinal {
573                    0x49300213a51ec7f7 => {
574                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
575                        let mut req = fidl::new_empty!(
576                            ControllerMountRequest,
577                            fidl::encoding::DefaultFuchsiaResourceDialect
578                        );
579                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerMountRequest>(&header, _body_bytes, handles, &mut req)?;
580                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
581                        Ok(ControllerRequest::Mount {
582                            device: req.device,
583                            name: req.name,
584                            options: req.options,
585
586                            responder: ControllerMountResponder {
587                                control_handle: std::mem::ManuallyDrop::new(control_handle),
588                                tx_id: header.tx_id,
589                            },
590                        })
591                    }
592                    0x2d994ee1a9364179 => {
593                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
594                        let mut req = fidl::new_empty!(
595                            ControllerUnmountRequest,
596                            fidl::encoding::DefaultFuchsiaResourceDialect
597                        );
598                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerUnmountRequest>(&header, _body_bytes, handles, &mut req)?;
599                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
600                        Ok(ControllerRequest::Unmount {
601                            name: req.name,
602
603                            responder: ControllerUnmountResponder {
604                                control_handle: std::mem::ManuallyDrop::new(control_handle),
605                                tx_id: header.tx_id,
606                            },
607                        })
608                    }
609                    0x52ce219e43664bf0 => {
610                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
611                        let mut req = fidl::new_empty!(
612                            ControllerFormatRequest,
613                            fidl::encoding::DefaultFuchsiaResourceDialect
614                        );
615                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerFormatRequest>(&header, _body_bytes, handles, &mut req)?;
616                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
617                        Ok(ControllerRequest::Format {
618                            device: req.device,
619                            name: req.name,
620                            options: req.options,
621
622                            responder: ControllerFormatResponder {
623                                control_handle: std::mem::ManuallyDrop::new(control_handle),
624                                tx_id: header.tx_id,
625                            },
626                        })
627                    }
628                    0x20d3ff7c33a9b863 => {
629                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
630                        let mut req = fidl::new_empty!(
631                            ControllerCheckRequest,
632                            fidl::encoding::DefaultFuchsiaResourceDialect
633                        );
634                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerCheckRequest>(&header, _body_bytes, handles, &mut req)?;
635                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
636                        Ok(ControllerRequest::Check {
637                            device: req.device,
638                            name: req.name,
639
640                            responder: ControllerCheckResponder {
641                                control_handle: std::mem::ManuallyDrop::new(control_handle),
642                                tx_id: header.tx_id,
643                            },
644                        })
645                    }
646                    _ => Err(fidl::Error::UnknownOrdinal {
647                        ordinal: header.ordinal,
648                        protocol_name:
649                            <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
650                    }),
651                }))
652            },
653        )
654    }
655}
656
657#[derive(Debug)]
658pub enum ControllerRequest {
659    /// Mounts a filesystem on a block device.
660    Mount {
661        device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
662        name: String,
663        options: MountOptions,
664        responder: ControllerMountResponder,
665    },
666    /// Unmounts a previously mounted filesystem.
667    Unmount { name: String, responder: ControllerUnmountResponder },
668    /// Formats a block device with a particular filesystem format
669    Format {
670        device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
671        name: String,
672        options: FormatOptions,
673        responder: ControllerFormatResponder,
674    },
675    /// Checks the consistency of the filesystem formatted on
676    /// the block device
677    Check {
678        device: fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
679        name: String,
680        responder: ControllerCheckResponder,
681    },
682}
683
684impl ControllerRequest {
685    #[allow(irrefutable_let_patterns)]
686    pub fn into_mount(
687        self,
688    ) -> Option<(
689        fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
690        String,
691        MountOptions,
692        ControllerMountResponder,
693    )> {
694        if let ControllerRequest::Mount { device, name, options, responder } = self {
695            Some((device, name, options, responder))
696        } else {
697            None
698        }
699    }
700
701    #[allow(irrefutable_let_patterns)]
702    pub fn into_unmount(self) -> Option<(String, ControllerUnmountResponder)> {
703        if let ControllerRequest::Unmount { name, responder } = self {
704            Some((name, responder))
705        } else {
706            None
707        }
708    }
709
710    #[allow(irrefutable_let_patterns)]
711    pub fn into_format(
712        self,
713    ) -> Option<(
714        fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
715        String,
716        FormatOptions,
717        ControllerFormatResponder,
718    )> {
719        if let ControllerRequest::Format { device, name, options, responder } = self {
720            Some((device, name, options, responder))
721        } else {
722            None
723        }
724    }
725
726    #[allow(irrefutable_let_patterns)]
727    pub fn into_check(
728        self,
729    ) -> Option<(
730        fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
731        String,
732        ControllerCheckResponder,
733    )> {
734        if let ControllerRequest::Check { device, name, responder } = self {
735            Some((device, name, responder))
736        } else {
737            None
738        }
739    }
740
741    /// Name of the method defined in FIDL
742    pub fn method_name(&self) -> &'static str {
743        match *self {
744            ControllerRequest::Mount { .. } => "mount",
745            ControllerRequest::Unmount { .. } => "unmount",
746            ControllerRequest::Format { .. } => "format",
747            ControllerRequest::Check { .. } => "check",
748        }
749    }
750}
751
752#[derive(Debug, Clone)]
753pub struct ControllerControlHandle {
754    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
755}
756
757impl fidl::endpoints::ControlHandle for ControllerControlHandle {
758    fn shutdown(&self) {
759        self.inner.shutdown()
760    }
761
762    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
763        self.inner.shutdown_with_epitaph(status)
764    }
765
766    fn is_closed(&self) -> bool {
767        self.inner.channel().is_closed()
768    }
769    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
770        self.inner.channel().on_closed()
771    }
772
773    #[cfg(target_os = "fuchsia")]
774    fn signal_peer(
775        &self,
776        clear_mask: zx::Signals,
777        set_mask: zx::Signals,
778    ) -> Result<(), zx_status::Status> {
779        use fidl::Peered;
780        self.inner.channel().signal_peer(clear_mask, set_mask)
781    }
782}
783
784impl ControllerControlHandle {}
785
786#[must_use = "FIDL methods require a response to be sent"]
787#[derive(Debug)]
788pub struct ControllerMountResponder {
789    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
790    tx_id: u32,
791}
792
793/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
794/// if the responder is dropped without sending a response, so that the client
795/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
796impl std::ops::Drop for ControllerMountResponder {
797    fn drop(&mut self) {
798        self.control_handle.shutdown();
799        // Safety: drops once, never accessed again
800        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
801    }
802}
803
804impl fidl::endpoints::Responder for ControllerMountResponder {
805    type ControlHandle = ControllerControlHandle;
806
807    fn control_handle(&self) -> &ControllerControlHandle {
808        &self.control_handle
809    }
810
811    fn drop_without_shutdown(mut self) {
812        // Safety: drops once, never accessed again due to mem::forget
813        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
814        // Prevent Drop from running (which would shut down the channel)
815        std::mem::forget(self);
816    }
817}
818
819impl ControllerMountResponder {
820    /// Sends a response to the FIDL transaction.
821    ///
822    /// Sets the channel to shutdown if an error occurs.
823    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
824        let _result = self.send_raw(result);
825        if _result.is_err() {
826            self.control_handle.shutdown();
827        }
828        self.drop_without_shutdown();
829        _result
830    }
831
832    /// Similar to "send" but does not shutdown the channel if an error occurs.
833    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
834        let _result = self.send_raw(result);
835        self.drop_without_shutdown();
836        _result
837    }
838
839    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
840        self.control_handle
841            .inner
842            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
843                result,
844                self.tx_id,
845                0x49300213a51ec7f7,
846                fidl::encoding::DynamicFlags::empty(),
847            )
848    }
849}
850
851#[must_use = "FIDL methods require a response to be sent"]
852#[derive(Debug)]
853pub struct ControllerUnmountResponder {
854    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
855    tx_id: u32,
856}
857
858/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
859/// if the responder is dropped without sending a response, so that the client
860/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
861impl std::ops::Drop for ControllerUnmountResponder {
862    fn drop(&mut self) {
863        self.control_handle.shutdown();
864        // Safety: drops once, never accessed again
865        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
866    }
867}
868
869impl fidl::endpoints::Responder for ControllerUnmountResponder {
870    type ControlHandle = ControllerControlHandle;
871
872    fn control_handle(&self) -> &ControllerControlHandle {
873        &self.control_handle
874    }
875
876    fn drop_without_shutdown(mut self) {
877        // Safety: drops once, never accessed again due to mem::forget
878        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
879        // Prevent Drop from running (which would shut down the channel)
880        std::mem::forget(self);
881    }
882}
883
884impl ControllerUnmountResponder {
885    /// Sends a response to the FIDL transaction.
886    ///
887    /// Sets the channel to shutdown if an error occurs.
888    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
889        let _result = self.send_raw(result);
890        if _result.is_err() {
891            self.control_handle.shutdown();
892        }
893        self.drop_without_shutdown();
894        _result
895    }
896
897    /// Similar to "send" but does not shutdown the channel if an error occurs.
898    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
899        let _result = self.send_raw(result);
900        self.drop_without_shutdown();
901        _result
902    }
903
904    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
905        self.control_handle
906            .inner
907            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
908                result,
909                self.tx_id,
910                0x2d994ee1a9364179,
911                fidl::encoding::DynamicFlags::empty(),
912            )
913    }
914}
915
916#[must_use = "FIDL methods require a response to be sent"]
917#[derive(Debug)]
918pub struct ControllerFormatResponder {
919    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
920    tx_id: u32,
921}
922
923/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
924/// if the responder is dropped without sending a response, so that the client
925/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
926impl std::ops::Drop for ControllerFormatResponder {
927    fn drop(&mut self) {
928        self.control_handle.shutdown();
929        // Safety: drops once, never accessed again
930        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
931    }
932}
933
934impl fidl::endpoints::Responder for ControllerFormatResponder {
935    type ControlHandle = ControllerControlHandle;
936
937    fn control_handle(&self) -> &ControllerControlHandle {
938        &self.control_handle
939    }
940
941    fn drop_without_shutdown(mut self) {
942        // Safety: drops once, never accessed again due to mem::forget
943        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
944        // Prevent Drop from running (which would shut down the channel)
945        std::mem::forget(self);
946    }
947}
948
949impl ControllerFormatResponder {
950    /// Sends a response to the FIDL transaction.
951    ///
952    /// Sets the channel to shutdown if an error occurs.
953    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
954        let _result = self.send_raw(result);
955        if _result.is_err() {
956            self.control_handle.shutdown();
957        }
958        self.drop_without_shutdown();
959        _result
960    }
961
962    /// Similar to "send" but does not shutdown the channel if an error occurs.
963    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
964        let _result = self.send_raw(result);
965        self.drop_without_shutdown();
966        _result
967    }
968
969    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
970        self.control_handle
971            .inner
972            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
973                result,
974                self.tx_id,
975                0x52ce219e43664bf0,
976                fidl::encoding::DynamicFlags::empty(),
977            )
978    }
979}
980
981#[must_use = "FIDL methods require a response to be sent"]
982#[derive(Debug)]
983pub struct ControllerCheckResponder {
984    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
985    tx_id: u32,
986}
987
988/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
989/// if the responder is dropped without sending a response, so that the client
990/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
991impl std::ops::Drop for ControllerCheckResponder {
992    fn drop(&mut self) {
993        self.control_handle.shutdown();
994        // Safety: drops once, never accessed again
995        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
996    }
997}
998
999impl fidl::endpoints::Responder for ControllerCheckResponder {
1000    type ControlHandle = ControllerControlHandle;
1001
1002    fn control_handle(&self) -> &ControllerControlHandle {
1003        &self.control_handle
1004    }
1005
1006    fn drop_without_shutdown(mut self) {
1007        // Safety: drops once, never accessed again due to mem::forget
1008        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1009        // Prevent Drop from running (which would shut down the channel)
1010        std::mem::forget(self);
1011    }
1012}
1013
1014impl ControllerCheckResponder {
1015    /// Sends a response to the FIDL transaction.
1016    ///
1017    /// Sets the channel to shutdown if an error occurs.
1018    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1019        let _result = self.send_raw(result);
1020        if _result.is_err() {
1021            self.control_handle.shutdown();
1022        }
1023        self.drop_without_shutdown();
1024        _result
1025    }
1026
1027    /// Similar to "send" but does not shutdown the channel if an error occurs.
1028    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1029        let _result = self.send_raw(result);
1030        self.drop_without_shutdown();
1031        _result
1032    }
1033
1034    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1035        self.control_handle
1036            .inner
1037            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1038                result,
1039                self.tx_id,
1040                0x20d3ff7c33a9b863,
1041                fidl::encoding::DynamicFlags::empty(),
1042            )
1043    }
1044}
1045
1046mod internal {
1047    use super::*;
1048
1049    impl fidl::encoding::ResourceTypeMarker for ControllerCheckRequest {
1050        type Borrowed<'a> = &'a mut Self;
1051        fn take_or_borrow<'a>(
1052            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1053        ) -> Self::Borrowed<'a> {
1054            value
1055        }
1056    }
1057
1058    unsafe impl fidl::encoding::TypeMarker for ControllerCheckRequest {
1059        type Owned = Self;
1060
1061        #[inline(always)]
1062        fn inline_align(_context: fidl::encoding::Context) -> usize {
1063            8
1064        }
1065
1066        #[inline(always)]
1067        fn inline_size(_context: fidl::encoding::Context) -> usize {
1068            24
1069        }
1070    }
1071
1072    unsafe impl
1073        fidl::encoding::Encode<
1074            ControllerCheckRequest,
1075            fidl::encoding::DefaultFuchsiaResourceDialect,
1076        > for &mut ControllerCheckRequest
1077    {
1078        #[inline]
1079        unsafe fn encode(
1080            self,
1081            encoder: &mut fidl::encoding::Encoder<
1082                '_,
1083                fidl::encoding::DefaultFuchsiaResourceDialect,
1084            >,
1085            offset: usize,
1086            _depth: fidl::encoding::Depth,
1087        ) -> fidl::Result<()> {
1088            encoder.debug_check_bounds::<ControllerCheckRequest>(offset);
1089            // Delegate to tuple encoding.
1090            fidl::encoding::Encode::<
1091                ControllerCheckRequest,
1092                fidl::encoding::DefaultFuchsiaResourceDialect,
1093            >::encode(
1094                (
1095                    <fidl::encoding::Endpoint<
1096                        fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1097                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1098                        &mut self.device
1099                    ),
1100                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1101                        &self.name,
1102                    ),
1103                ),
1104                encoder,
1105                offset,
1106                _depth,
1107            )
1108        }
1109    }
1110    unsafe impl<
1111        T0: fidl::encoding::Encode<
1112                fidl::encoding::Endpoint<
1113                    fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1114                >,
1115                fidl::encoding::DefaultFuchsiaResourceDialect,
1116            >,
1117        T1: fidl::encoding::Encode<
1118                fidl::encoding::BoundedString<255>,
1119                fidl::encoding::DefaultFuchsiaResourceDialect,
1120            >,
1121    >
1122        fidl::encoding::Encode<
1123            ControllerCheckRequest,
1124            fidl::encoding::DefaultFuchsiaResourceDialect,
1125        > for (T0, T1)
1126    {
1127        #[inline]
1128        unsafe fn encode(
1129            self,
1130            encoder: &mut fidl::encoding::Encoder<
1131                '_,
1132                fidl::encoding::DefaultFuchsiaResourceDialect,
1133            >,
1134            offset: usize,
1135            depth: fidl::encoding::Depth,
1136        ) -> fidl::Result<()> {
1137            encoder.debug_check_bounds::<ControllerCheckRequest>(offset);
1138            // Zero out padding regions. There's no need to apply masks
1139            // because the unmasked parts will be overwritten by fields.
1140            unsafe {
1141                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1142                (ptr as *mut u64).write_unaligned(0);
1143            }
1144            // Write the fields.
1145            self.0.encode(encoder, offset + 0, depth)?;
1146            self.1.encode(encoder, offset + 8, depth)?;
1147            Ok(())
1148        }
1149    }
1150
1151    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1152        for ControllerCheckRequest
1153    {
1154        #[inline(always)]
1155        fn new_empty() -> Self {
1156            Self {
1157                device: fidl::new_empty!(
1158                    fidl::encoding::Endpoint<
1159                        fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1160                    >,
1161                    fidl::encoding::DefaultFuchsiaResourceDialect
1162                ),
1163                name: fidl::new_empty!(
1164                    fidl::encoding::BoundedString<255>,
1165                    fidl::encoding::DefaultFuchsiaResourceDialect
1166                ),
1167            }
1168        }
1169
1170        #[inline]
1171        unsafe fn decode(
1172            &mut self,
1173            decoder: &mut fidl::encoding::Decoder<
1174                '_,
1175                fidl::encoding::DefaultFuchsiaResourceDialect,
1176            >,
1177            offset: usize,
1178            _depth: fidl::encoding::Depth,
1179        ) -> fidl::Result<()> {
1180            decoder.debug_check_bounds::<Self>(offset);
1181            // Verify that padding bytes are zero.
1182            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1183            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1184            let mask = 0xffffffff00000000u64;
1185            let maskedval = padval & mask;
1186            if maskedval != 0 {
1187                return Err(fidl::Error::NonZeroPadding {
1188                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1189                });
1190            }
1191            fidl::decode!(
1192                fidl::encoding::Endpoint<
1193                    fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1194                >,
1195                fidl::encoding::DefaultFuchsiaResourceDialect,
1196                &mut self.device,
1197                decoder,
1198                offset + 0,
1199                _depth
1200            )?;
1201            fidl::decode!(
1202                fidl::encoding::BoundedString<255>,
1203                fidl::encoding::DefaultFuchsiaResourceDialect,
1204                &mut self.name,
1205                decoder,
1206                offset + 8,
1207                _depth
1208            )?;
1209            Ok(())
1210        }
1211    }
1212
1213    impl fidl::encoding::ResourceTypeMarker for ControllerFormatRequest {
1214        type Borrowed<'a> = &'a mut Self;
1215        fn take_or_borrow<'a>(
1216            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1217        ) -> Self::Borrowed<'a> {
1218            value
1219        }
1220    }
1221
1222    unsafe impl fidl::encoding::TypeMarker for ControllerFormatRequest {
1223        type Owned = Self;
1224
1225        #[inline(always)]
1226        fn inline_align(_context: fidl::encoding::Context) -> usize {
1227            8
1228        }
1229
1230        #[inline(always)]
1231        fn inline_size(_context: fidl::encoding::Context) -> usize {
1232            40
1233        }
1234    }
1235
1236    unsafe impl
1237        fidl::encoding::Encode<
1238            ControllerFormatRequest,
1239            fidl::encoding::DefaultFuchsiaResourceDialect,
1240        > for &mut ControllerFormatRequest
1241    {
1242        #[inline]
1243        unsafe fn encode(
1244            self,
1245            encoder: &mut fidl::encoding::Encoder<
1246                '_,
1247                fidl::encoding::DefaultFuchsiaResourceDialect,
1248            >,
1249            offset: usize,
1250            _depth: fidl::encoding::Depth,
1251        ) -> fidl::Result<()> {
1252            encoder.debug_check_bounds::<ControllerFormatRequest>(offset);
1253            // Delegate to tuple encoding.
1254            fidl::encoding::Encode::<
1255                ControllerFormatRequest,
1256                fidl::encoding::DefaultFuchsiaResourceDialect,
1257            >::encode(
1258                (
1259                    <fidl::encoding::Endpoint<
1260                        fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1261                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1262                        &mut self.device
1263                    ),
1264                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1265                        &self.name,
1266                    ),
1267                    <FormatOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1268                        &mut self.options,
1269                    ),
1270                ),
1271                encoder,
1272                offset,
1273                _depth,
1274            )
1275        }
1276    }
1277    unsafe impl<
1278        T0: fidl::encoding::Encode<
1279                fidl::encoding::Endpoint<
1280                    fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1281                >,
1282                fidl::encoding::DefaultFuchsiaResourceDialect,
1283            >,
1284        T1: fidl::encoding::Encode<
1285                fidl::encoding::BoundedString<255>,
1286                fidl::encoding::DefaultFuchsiaResourceDialect,
1287            >,
1288        T2: fidl::encoding::Encode<FormatOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
1289    >
1290        fidl::encoding::Encode<
1291            ControllerFormatRequest,
1292            fidl::encoding::DefaultFuchsiaResourceDialect,
1293        > for (T0, T1, T2)
1294    {
1295        #[inline]
1296        unsafe fn encode(
1297            self,
1298            encoder: &mut fidl::encoding::Encoder<
1299                '_,
1300                fidl::encoding::DefaultFuchsiaResourceDialect,
1301            >,
1302            offset: usize,
1303            depth: fidl::encoding::Depth,
1304        ) -> fidl::Result<()> {
1305            encoder.debug_check_bounds::<ControllerFormatRequest>(offset);
1306            // Zero out padding regions. There's no need to apply masks
1307            // because the unmasked parts will be overwritten by fields.
1308            unsafe {
1309                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1310                (ptr as *mut u64).write_unaligned(0);
1311            }
1312            // Write the fields.
1313            self.0.encode(encoder, offset + 0, depth)?;
1314            self.1.encode(encoder, offset + 8, depth)?;
1315            self.2.encode(encoder, offset + 24, depth)?;
1316            Ok(())
1317        }
1318    }
1319
1320    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1321        for ControllerFormatRequest
1322    {
1323        #[inline(always)]
1324        fn new_empty() -> Self {
1325            Self {
1326                device: fidl::new_empty!(
1327                    fidl::encoding::Endpoint<
1328                        fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1329                    >,
1330                    fidl::encoding::DefaultFuchsiaResourceDialect
1331                ),
1332                name: fidl::new_empty!(
1333                    fidl::encoding::BoundedString<255>,
1334                    fidl::encoding::DefaultFuchsiaResourceDialect
1335                ),
1336                options: fidl::new_empty!(
1337                    FormatOptions,
1338                    fidl::encoding::DefaultFuchsiaResourceDialect
1339                ),
1340            }
1341        }
1342
1343        #[inline]
1344        unsafe fn decode(
1345            &mut self,
1346            decoder: &mut fidl::encoding::Decoder<
1347                '_,
1348                fidl::encoding::DefaultFuchsiaResourceDialect,
1349            >,
1350            offset: usize,
1351            _depth: fidl::encoding::Depth,
1352        ) -> fidl::Result<()> {
1353            decoder.debug_check_bounds::<Self>(offset);
1354            // Verify that padding bytes are zero.
1355            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1356            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1357            let mask = 0xffffffff00000000u64;
1358            let maskedval = padval & mask;
1359            if maskedval != 0 {
1360                return Err(fidl::Error::NonZeroPadding {
1361                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1362                });
1363            }
1364            fidl::decode!(
1365                fidl::encoding::Endpoint<
1366                    fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1367                >,
1368                fidl::encoding::DefaultFuchsiaResourceDialect,
1369                &mut self.device,
1370                decoder,
1371                offset + 0,
1372                _depth
1373            )?;
1374            fidl::decode!(
1375                fidl::encoding::BoundedString<255>,
1376                fidl::encoding::DefaultFuchsiaResourceDialect,
1377                &mut self.name,
1378                decoder,
1379                offset + 8,
1380                _depth
1381            )?;
1382            fidl::decode!(
1383                FormatOptions,
1384                fidl::encoding::DefaultFuchsiaResourceDialect,
1385                &mut self.options,
1386                decoder,
1387                offset + 24,
1388                _depth
1389            )?;
1390            Ok(())
1391        }
1392    }
1393
1394    impl fidl::encoding::ResourceTypeMarker for ControllerMountRequest {
1395        type Borrowed<'a> = &'a mut Self;
1396        fn take_or_borrow<'a>(
1397            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1398        ) -> Self::Borrowed<'a> {
1399            value
1400        }
1401    }
1402
1403    unsafe impl fidl::encoding::TypeMarker for ControllerMountRequest {
1404        type Owned = Self;
1405
1406        #[inline(always)]
1407        fn inline_align(_context: fidl::encoding::Context) -> usize {
1408            8
1409        }
1410
1411        #[inline(always)]
1412        fn inline_size(_context: fidl::encoding::Context) -> usize {
1413            40
1414        }
1415    }
1416
1417    unsafe impl
1418        fidl::encoding::Encode<
1419            ControllerMountRequest,
1420            fidl::encoding::DefaultFuchsiaResourceDialect,
1421        > for &mut ControllerMountRequest
1422    {
1423        #[inline]
1424        unsafe fn encode(
1425            self,
1426            encoder: &mut fidl::encoding::Encoder<
1427                '_,
1428                fidl::encoding::DefaultFuchsiaResourceDialect,
1429            >,
1430            offset: usize,
1431            _depth: fidl::encoding::Depth,
1432        ) -> fidl::Result<()> {
1433            encoder.debug_check_bounds::<ControllerMountRequest>(offset);
1434            // Delegate to tuple encoding.
1435            fidl::encoding::Encode::<
1436                ControllerMountRequest,
1437                fidl::encoding::DefaultFuchsiaResourceDialect,
1438            >::encode(
1439                (
1440                    <fidl::encoding::Endpoint<
1441                        fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1442                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1443                        &mut self.device
1444                    ),
1445                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1446                        &self.name,
1447                    ),
1448                    <MountOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1449                        &mut self.options,
1450                    ),
1451                ),
1452                encoder,
1453                offset,
1454                _depth,
1455            )
1456        }
1457    }
1458    unsafe impl<
1459        T0: fidl::encoding::Encode<
1460                fidl::encoding::Endpoint<
1461                    fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1462                >,
1463                fidl::encoding::DefaultFuchsiaResourceDialect,
1464            >,
1465        T1: fidl::encoding::Encode<
1466                fidl::encoding::BoundedString<255>,
1467                fidl::encoding::DefaultFuchsiaResourceDialect,
1468            >,
1469        T2: fidl::encoding::Encode<MountOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
1470    >
1471        fidl::encoding::Encode<
1472            ControllerMountRequest,
1473            fidl::encoding::DefaultFuchsiaResourceDialect,
1474        > for (T0, T1, T2)
1475    {
1476        #[inline]
1477        unsafe fn encode(
1478            self,
1479            encoder: &mut fidl::encoding::Encoder<
1480                '_,
1481                fidl::encoding::DefaultFuchsiaResourceDialect,
1482            >,
1483            offset: usize,
1484            depth: fidl::encoding::Depth,
1485        ) -> fidl::Result<()> {
1486            encoder.debug_check_bounds::<ControllerMountRequest>(offset);
1487            // Zero out padding regions. There's no need to apply masks
1488            // because the unmasked parts will be overwritten by fields.
1489            unsafe {
1490                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1491                (ptr as *mut u64).write_unaligned(0);
1492            }
1493            // Write the fields.
1494            self.0.encode(encoder, offset + 0, depth)?;
1495            self.1.encode(encoder, offset + 8, depth)?;
1496            self.2.encode(encoder, offset + 24, depth)?;
1497            Ok(())
1498        }
1499    }
1500
1501    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1502        for ControllerMountRequest
1503    {
1504        #[inline(always)]
1505        fn new_empty() -> Self {
1506            Self {
1507                device: fidl::new_empty!(
1508                    fidl::encoding::Endpoint<
1509                        fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1510                    >,
1511                    fidl::encoding::DefaultFuchsiaResourceDialect
1512                ),
1513                name: fidl::new_empty!(
1514                    fidl::encoding::BoundedString<255>,
1515                    fidl::encoding::DefaultFuchsiaResourceDialect
1516                ),
1517                options: fidl::new_empty!(
1518                    MountOptions,
1519                    fidl::encoding::DefaultFuchsiaResourceDialect
1520                ),
1521            }
1522        }
1523
1524        #[inline]
1525        unsafe fn decode(
1526            &mut self,
1527            decoder: &mut fidl::encoding::Decoder<
1528                '_,
1529                fidl::encoding::DefaultFuchsiaResourceDialect,
1530            >,
1531            offset: usize,
1532            _depth: fidl::encoding::Depth,
1533        ) -> fidl::Result<()> {
1534            decoder.debug_check_bounds::<Self>(offset);
1535            // Verify that padding bytes are zero.
1536            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1537            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1538            let mask = 0xffffffff00000000u64;
1539            let maskedval = padval & mask;
1540            if maskedval != 0 {
1541                return Err(fidl::Error::NonZeroPadding {
1542                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1543                });
1544            }
1545            fidl::decode!(
1546                fidl::encoding::Endpoint<
1547                    fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1548                >,
1549                fidl::encoding::DefaultFuchsiaResourceDialect,
1550                &mut self.device,
1551                decoder,
1552                offset + 0,
1553                _depth
1554            )?;
1555            fidl::decode!(
1556                fidl::encoding::BoundedString<255>,
1557                fidl::encoding::DefaultFuchsiaResourceDialect,
1558                &mut self.name,
1559                decoder,
1560                offset + 8,
1561                _depth
1562            )?;
1563            fidl::decode!(
1564                MountOptions,
1565                fidl::encoding::DefaultFuchsiaResourceDialect,
1566                &mut self.options,
1567                decoder,
1568                offset + 24,
1569                _depth
1570            )?;
1571            Ok(())
1572        }
1573    }
1574
1575    impl FormatOptions {
1576        #[inline(always)]
1577        fn max_ordinal_present(&self) -> u64 {
1578            if let Some(_) = self.fvm_data_slices {
1579                return 2;
1580            }
1581            if let Some(_) = self.verbose {
1582                return 1;
1583            }
1584            0
1585        }
1586    }
1587
1588    impl fidl::encoding::ResourceTypeMarker for FormatOptions {
1589        type Borrowed<'a> = &'a mut Self;
1590        fn take_or_borrow<'a>(
1591            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1592        ) -> Self::Borrowed<'a> {
1593            value
1594        }
1595    }
1596
1597    unsafe impl fidl::encoding::TypeMarker for FormatOptions {
1598        type Owned = Self;
1599
1600        #[inline(always)]
1601        fn inline_align(_context: fidl::encoding::Context) -> usize {
1602            8
1603        }
1604
1605        #[inline(always)]
1606        fn inline_size(_context: fidl::encoding::Context) -> usize {
1607            16
1608        }
1609    }
1610
1611    unsafe impl fidl::encoding::Encode<FormatOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
1612        for &mut FormatOptions
1613    {
1614        unsafe fn encode(
1615            self,
1616            encoder: &mut fidl::encoding::Encoder<
1617                '_,
1618                fidl::encoding::DefaultFuchsiaResourceDialect,
1619            >,
1620            offset: usize,
1621            mut depth: fidl::encoding::Depth,
1622        ) -> fidl::Result<()> {
1623            encoder.debug_check_bounds::<FormatOptions>(offset);
1624            // Vector header
1625            let max_ordinal: u64 = self.max_ordinal_present();
1626            encoder.write_num(max_ordinal, offset);
1627            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1628            // Calling encoder.out_of_line_offset(0) is not allowed.
1629            if max_ordinal == 0 {
1630                return Ok(());
1631            }
1632            depth.increment()?;
1633            let envelope_size = 8;
1634            let bytes_len = max_ordinal as usize * envelope_size;
1635            #[allow(unused_variables)]
1636            let offset = encoder.out_of_line_offset(bytes_len);
1637            let mut _prev_end_offset: usize = 0;
1638            if 1 > max_ordinal {
1639                return Ok(());
1640            }
1641
1642            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1643            // are envelope_size bytes.
1644            let cur_offset: usize = (1 - 1) * envelope_size;
1645
1646            // Zero reserved fields.
1647            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1648
1649            // Safety:
1650            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1651            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1652            //   envelope_size bytes, there is always sufficient room.
1653            fidl::encoding::encode_in_envelope_optional::<
1654                bool,
1655                fidl::encoding::DefaultFuchsiaResourceDialect,
1656            >(
1657                self.verbose.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1658                encoder,
1659                offset + cur_offset,
1660                depth,
1661            )?;
1662
1663            _prev_end_offset = cur_offset + envelope_size;
1664            if 2 > max_ordinal {
1665                return Ok(());
1666            }
1667
1668            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1669            // are envelope_size bytes.
1670            let cur_offset: usize = (2 - 1) * envelope_size;
1671
1672            // Zero reserved fields.
1673            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1674
1675            // Safety:
1676            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1677            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1678            //   envelope_size bytes, there is always sufficient room.
1679            fidl::encoding::encode_in_envelope_optional::<
1680                u32,
1681                fidl::encoding::DefaultFuchsiaResourceDialect,
1682            >(
1683                self.fvm_data_slices.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1684                encoder,
1685                offset + cur_offset,
1686                depth,
1687            )?;
1688
1689            _prev_end_offset = cur_offset + envelope_size;
1690
1691            Ok(())
1692        }
1693    }
1694
1695    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for FormatOptions {
1696        #[inline(always)]
1697        fn new_empty() -> Self {
1698            Self::default()
1699        }
1700
1701        unsafe fn decode(
1702            &mut self,
1703            decoder: &mut fidl::encoding::Decoder<
1704                '_,
1705                fidl::encoding::DefaultFuchsiaResourceDialect,
1706            >,
1707            offset: usize,
1708            mut depth: fidl::encoding::Depth,
1709        ) -> fidl::Result<()> {
1710            decoder.debug_check_bounds::<Self>(offset);
1711            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1712                None => return Err(fidl::Error::NotNullable),
1713                Some(len) => len,
1714            };
1715            // Calling decoder.out_of_line_offset(0) is not allowed.
1716            if len == 0 {
1717                return Ok(());
1718            };
1719            depth.increment()?;
1720            let envelope_size = 8;
1721            let bytes_len = len * envelope_size;
1722            let offset = decoder.out_of_line_offset(bytes_len)?;
1723            // Decode the envelope for each type.
1724            let mut _next_ordinal_to_read = 0;
1725            let mut next_offset = offset;
1726            let end_offset = offset + bytes_len;
1727            _next_ordinal_to_read += 1;
1728            if next_offset >= end_offset {
1729                return Ok(());
1730            }
1731
1732            // Decode unknown envelopes for gaps in ordinals.
1733            while _next_ordinal_to_read < 1 {
1734                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1735                _next_ordinal_to_read += 1;
1736                next_offset += envelope_size;
1737            }
1738
1739            let next_out_of_line = decoder.next_out_of_line();
1740            let handles_before = decoder.remaining_handles();
1741            if let Some((inlined, num_bytes, num_handles)) =
1742                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1743            {
1744                let member_inline_size =
1745                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1746                if inlined != (member_inline_size <= 4) {
1747                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1748                }
1749                let inner_offset;
1750                let mut inner_depth = depth.clone();
1751                if inlined {
1752                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1753                    inner_offset = next_offset;
1754                } else {
1755                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1756                    inner_depth.increment()?;
1757                }
1758                let val_ref = self.verbose.get_or_insert_with(|| {
1759                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
1760                });
1761                fidl::decode!(
1762                    bool,
1763                    fidl::encoding::DefaultFuchsiaResourceDialect,
1764                    val_ref,
1765                    decoder,
1766                    inner_offset,
1767                    inner_depth
1768                )?;
1769                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1770                {
1771                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1772                }
1773                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1774                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1775                }
1776            }
1777
1778            next_offset += envelope_size;
1779            _next_ordinal_to_read += 1;
1780            if next_offset >= end_offset {
1781                return Ok(());
1782            }
1783
1784            // Decode unknown envelopes for gaps in ordinals.
1785            while _next_ordinal_to_read < 2 {
1786                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1787                _next_ordinal_to_read += 1;
1788                next_offset += envelope_size;
1789            }
1790
1791            let next_out_of_line = decoder.next_out_of_line();
1792            let handles_before = decoder.remaining_handles();
1793            if let Some((inlined, num_bytes, num_handles)) =
1794                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1795            {
1796                let member_inline_size =
1797                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1798                if inlined != (member_inline_size <= 4) {
1799                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1800                }
1801                let inner_offset;
1802                let mut inner_depth = depth.clone();
1803                if inlined {
1804                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1805                    inner_offset = next_offset;
1806                } else {
1807                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1808                    inner_depth.increment()?;
1809                }
1810                let val_ref = self.fvm_data_slices.get_or_insert_with(|| {
1811                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
1812                });
1813                fidl::decode!(
1814                    u32,
1815                    fidl::encoding::DefaultFuchsiaResourceDialect,
1816                    val_ref,
1817                    decoder,
1818                    inner_offset,
1819                    inner_depth
1820                )?;
1821                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1822                {
1823                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1824                }
1825                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1826                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1827                }
1828            }
1829
1830            next_offset += envelope_size;
1831
1832            // Decode the remaining unknown envelopes.
1833            while next_offset < end_offset {
1834                _next_ordinal_to_read += 1;
1835                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1836                next_offset += envelope_size;
1837            }
1838
1839            Ok(())
1840        }
1841    }
1842
1843    impl MountOptions {
1844        #[inline(always)]
1845        fn max_ordinal_present(&self) -> u64 {
1846            if let Some(_) = self.write_compression_algorithm {
1847                return 3;
1848            }
1849            if let Some(_) = self.verbose {
1850                return 2;
1851            }
1852            if let Some(_) = self.read_only {
1853                return 1;
1854            }
1855            0
1856        }
1857    }
1858
1859    impl fidl::encoding::ResourceTypeMarker for MountOptions {
1860        type Borrowed<'a> = &'a mut Self;
1861        fn take_or_borrow<'a>(
1862            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1863        ) -> Self::Borrowed<'a> {
1864            value
1865        }
1866    }
1867
1868    unsafe impl fidl::encoding::TypeMarker for MountOptions {
1869        type Owned = Self;
1870
1871        #[inline(always)]
1872        fn inline_align(_context: fidl::encoding::Context) -> usize {
1873            8
1874        }
1875
1876        #[inline(always)]
1877        fn inline_size(_context: fidl::encoding::Context) -> usize {
1878            16
1879        }
1880    }
1881
1882    unsafe impl fidl::encoding::Encode<MountOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
1883        for &mut MountOptions
1884    {
1885        unsafe fn encode(
1886            self,
1887            encoder: &mut fidl::encoding::Encoder<
1888                '_,
1889                fidl::encoding::DefaultFuchsiaResourceDialect,
1890            >,
1891            offset: usize,
1892            mut depth: fidl::encoding::Depth,
1893        ) -> fidl::Result<()> {
1894            encoder.debug_check_bounds::<MountOptions>(offset);
1895            // Vector header
1896            let max_ordinal: u64 = self.max_ordinal_present();
1897            encoder.write_num(max_ordinal, offset);
1898            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1899            // Calling encoder.out_of_line_offset(0) is not allowed.
1900            if max_ordinal == 0 {
1901                return Ok(());
1902            }
1903            depth.increment()?;
1904            let envelope_size = 8;
1905            let bytes_len = max_ordinal as usize * envelope_size;
1906            #[allow(unused_variables)]
1907            let offset = encoder.out_of_line_offset(bytes_len);
1908            let mut _prev_end_offset: usize = 0;
1909            if 1 > max_ordinal {
1910                return Ok(());
1911            }
1912
1913            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1914            // are envelope_size bytes.
1915            let cur_offset: usize = (1 - 1) * envelope_size;
1916
1917            // Zero reserved fields.
1918            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1919
1920            // Safety:
1921            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1922            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1923            //   envelope_size bytes, there is always sufficient room.
1924            fidl::encoding::encode_in_envelope_optional::<
1925                bool,
1926                fidl::encoding::DefaultFuchsiaResourceDialect,
1927            >(
1928                self.read_only.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1929                encoder,
1930                offset + cur_offset,
1931                depth,
1932            )?;
1933
1934            _prev_end_offset = cur_offset + envelope_size;
1935            if 2 > max_ordinal {
1936                return Ok(());
1937            }
1938
1939            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1940            // are envelope_size bytes.
1941            let cur_offset: usize = (2 - 1) * envelope_size;
1942
1943            // Zero reserved fields.
1944            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1945
1946            // Safety:
1947            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1948            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1949            //   envelope_size bytes, there is always sufficient room.
1950            fidl::encoding::encode_in_envelope_optional::<
1951                bool,
1952                fidl::encoding::DefaultFuchsiaResourceDialect,
1953            >(
1954                self.verbose.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1955                encoder,
1956                offset + cur_offset,
1957                depth,
1958            )?;
1959
1960            _prev_end_offset = cur_offset + envelope_size;
1961            if 3 > max_ordinal {
1962                return Ok(());
1963            }
1964
1965            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1966            // are envelope_size bytes.
1967            let cur_offset: usize = (3 - 1) * envelope_size;
1968
1969            // Zero reserved fields.
1970            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1971
1972            // Safety:
1973            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1974            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1975            //   envelope_size bytes, there is always sufficient room.
1976            fidl::encoding::encode_in_envelope_optional::<
1977                fidl::encoding::BoundedString<32>,
1978                fidl::encoding::DefaultFuchsiaResourceDialect,
1979            >(
1980                self.write_compression_algorithm.as_ref().map(
1981                    <fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow,
1982                ),
1983                encoder,
1984                offset + cur_offset,
1985                depth,
1986            )?;
1987
1988            _prev_end_offset = cur_offset + envelope_size;
1989
1990            Ok(())
1991        }
1992    }
1993
1994    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for MountOptions {
1995        #[inline(always)]
1996        fn new_empty() -> Self {
1997            Self::default()
1998        }
1999
2000        unsafe fn decode(
2001            &mut self,
2002            decoder: &mut fidl::encoding::Decoder<
2003                '_,
2004                fidl::encoding::DefaultFuchsiaResourceDialect,
2005            >,
2006            offset: usize,
2007            mut depth: fidl::encoding::Depth,
2008        ) -> fidl::Result<()> {
2009            decoder.debug_check_bounds::<Self>(offset);
2010            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2011                None => return Err(fidl::Error::NotNullable),
2012                Some(len) => len,
2013            };
2014            // Calling decoder.out_of_line_offset(0) is not allowed.
2015            if len == 0 {
2016                return Ok(());
2017            };
2018            depth.increment()?;
2019            let envelope_size = 8;
2020            let bytes_len = len * envelope_size;
2021            let offset = decoder.out_of_line_offset(bytes_len)?;
2022            // Decode the envelope for each type.
2023            let mut _next_ordinal_to_read = 0;
2024            let mut next_offset = offset;
2025            let end_offset = offset + bytes_len;
2026            _next_ordinal_to_read += 1;
2027            if next_offset >= end_offset {
2028                return Ok(());
2029            }
2030
2031            // Decode unknown envelopes for gaps in ordinals.
2032            while _next_ordinal_to_read < 1 {
2033                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2034                _next_ordinal_to_read += 1;
2035                next_offset += envelope_size;
2036            }
2037
2038            let next_out_of_line = decoder.next_out_of_line();
2039            let handles_before = decoder.remaining_handles();
2040            if let Some((inlined, num_bytes, num_handles)) =
2041                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2042            {
2043                let member_inline_size =
2044                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2045                if inlined != (member_inline_size <= 4) {
2046                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2047                }
2048                let inner_offset;
2049                let mut inner_depth = depth.clone();
2050                if inlined {
2051                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2052                    inner_offset = next_offset;
2053                } else {
2054                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2055                    inner_depth.increment()?;
2056                }
2057                let val_ref = self.read_only.get_or_insert_with(|| {
2058                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
2059                });
2060                fidl::decode!(
2061                    bool,
2062                    fidl::encoding::DefaultFuchsiaResourceDialect,
2063                    val_ref,
2064                    decoder,
2065                    inner_offset,
2066                    inner_depth
2067                )?;
2068                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2069                {
2070                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2071                }
2072                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2073                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2074                }
2075            }
2076
2077            next_offset += envelope_size;
2078            _next_ordinal_to_read += 1;
2079            if next_offset >= end_offset {
2080                return Ok(());
2081            }
2082
2083            // Decode unknown envelopes for gaps in ordinals.
2084            while _next_ordinal_to_read < 2 {
2085                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2086                _next_ordinal_to_read += 1;
2087                next_offset += envelope_size;
2088            }
2089
2090            let next_out_of_line = decoder.next_out_of_line();
2091            let handles_before = decoder.remaining_handles();
2092            if let Some((inlined, num_bytes, num_handles)) =
2093                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2094            {
2095                let member_inline_size =
2096                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2097                if inlined != (member_inline_size <= 4) {
2098                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2099                }
2100                let inner_offset;
2101                let mut inner_depth = depth.clone();
2102                if inlined {
2103                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2104                    inner_offset = next_offset;
2105                } else {
2106                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2107                    inner_depth.increment()?;
2108                }
2109                let val_ref = self.verbose.get_or_insert_with(|| {
2110                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
2111                });
2112                fidl::decode!(
2113                    bool,
2114                    fidl::encoding::DefaultFuchsiaResourceDialect,
2115                    val_ref,
2116                    decoder,
2117                    inner_offset,
2118                    inner_depth
2119                )?;
2120                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2121                {
2122                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2123                }
2124                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2125                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2126                }
2127            }
2128
2129            next_offset += envelope_size;
2130            _next_ordinal_to_read += 1;
2131            if next_offset >= end_offset {
2132                return Ok(());
2133            }
2134
2135            // Decode unknown envelopes for gaps in ordinals.
2136            while _next_ordinal_to_read < 3 {
2137                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2138                _next_ordinal_to_read += 1;
2139                next_offset += envelope_size;
2140            }
2141
2142            let next_out_of_line = decoder.next_out_of_line();
2143            let handles_before = decoder.remaining_handles();
2144            if let Some((inlined, num_bytes, num_handles)) =
2145                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2146            {
2147                let member_inline_size =
2148                    <fidl::encoding::BoundedString<32> as fidl::encoding::TypeMarker>::inline_size(
2149                        decoder.context,
2150                    );
2151                if inlined != (member_inline_size <= 4) {
2152                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2153                }
2154                let inner_offset;
2155                let mut inner_depth = depth.clone();
2156                if inlined {
2157                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2158                    inner_offset = next_offset;
2159                } else {
2160                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2161                    inner_depth.increment()?;
2162                }
2163                let val_ref = self.write_compression_algorithm.get_or_insert_with(|| {
2164                    fidl::new_empty!(
2165                        fidl::encoding::BoundedString<32>,
2166                        fidl::encoding::DefaultFuchsiaResourceDialect
2167                    )
2168                });
2169                fidl::decode!(
2170                    fidl::encoding::BoundedString<32>,
2171                    fidl::encoding::DefaultFuchsiaResourceDialect,
2172                    val_ref,
2173                    decoder,
2174                    inner_offset,
2175                    inner_depth
2176                )?;
2177                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2178                {
2179                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2180                }
2181                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2182                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2183                }
2184            }
2185
2186            next_offset += envelope_size;
2187
2188            // Decode the remaining unknown envelopes.
2189            while next_offset < end_offset {
2190                _next_ordinal_to_read += 1;
2191                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2192                next_offset += envelope_size;
2193            }
2194
2195            Ok(())
2196        }
2197    }
2198}