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::Handle {
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    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
762        self.inner.shutdown_with_epitaph(status)
763    }
764
765    fn is_closed(&self) -> bool {
766        self.inner.channel().is_closed()
767    }
768    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
769        self.inner.channel().on_closed()
770    }
771
772    #[cfg(target_os = "fuchsia")]
773    fn signal_peer(
774        &self,
775        clear_mask: zx::Signals,
776        set_mask: zx::Signals,
777    ) -> Result<(), zx_status::Status> {
778        use fidl::Peered;
779        self.inner.channel().signal_peer(clear_mask, set_mask)
780    }
781}
782
783impl ControllerControlHandle {}
784
785#[must_use = "FIDL methods require a response to be sent"]
786#[derive(Debug)]
787pub struct ControllerMountResponder {
788    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
789    tx_id: u32,
790}
791
792/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
793/// if the responder is dropped without sending a response, so that the client
794/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
795impl std::ops::Drop for ControllerMountResponder {
796    fn drop(&mut self) {
797        self.control_handle.shutdown();
798        // Safety: drops once, never accessed again
799        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
800    }
801}
802
803impl fidl::endpoints::Responder for ControllerMountResponder {
804    type ControlHandle = ControllerControlHandle;
805
806    fn control_handle(&self) -> &ControllerControlHandle {
807        &self.control_handle
808    }
809
810    fn drop_without_shutdown(mut self) {
811        // Safety: drops once, never accessed again due to mem::forget
812        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
813        // Prevent Drop from running (which would shut down the channel)
814        std::mem::forget(self);
815    }
816}
817
818impl ControllerMountResponder {
819    /// Sends a response to the FIDL transaction.
820    ///
821    /// Sets the channel to shutdown if an error occurs.
822    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
823        let _result = self.send_raw(result);
824        if _result.is_err() {
825            self.control_handle.shutdown();
826        }
827        self.drop_without_shutdown();
828        _result
829    }
830
831    /// Similar to "send" but does not shutdown the channel if an error occurs.
832    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
833        let _result = self.send_raw(result);
834        self.drop_without_shutdown();
835        _result
836    }
837
838    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
839        self.control_handle
840            .inner
841            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
842                result,
843                self.tx_id,
844                0x49300213a51ec7f7,
845                fidl::encoding::DynamicFlags::empty(),
846            )
847    }
848}
849
850#[must_use = "FIDL methods require a response to be sent"]
851#[derive(Debug)]
852pub struct ControllerUnmountResponder {
853    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
854    tx_id: u32,
855}
856
857/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
858/// if the responder is dropped without sending a response, so that the client
859/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
860impl std::ops::Drop for ControllerUnmountResponder {
861    fn drop(&mut self) {
862        self.control_handle.shutdown();
863        // Safety: drops once, never accessed again
864        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
865    }
866}
867
868impl fidl::endpoints::Responder for ControllerUnmountResponder {
869    type ControlHandle = ControllerControlHandle;
870
871    fn control_handle(&self) -> &ControllerControlHandle {
872        &self.control_handle
873    }
874
875    fn drop_without_shutdown(mut self) {
876        // Safety: drops once, never accessed again due to mem::forget
877        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
878        // Prevent Drop from running (which would shut down the channel)
879        std::mem::forget(self);
880    }
881}
882
883impl ControllerUnmountResponder {
884    /// Sends a response to the FIDL transaction.
885    ///
886    /// Sets the channel to shutdown if an error occurs.
887    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
888        let _result = self.send_raw(result);
889        if _result.is_err() {
890            self.control_handle.shutdown();
891        }
892        self.drop_without_shutdown();
893        _result
894    }
895
896    /// Similar to "send" but does not shutdown the channel if an error occurs.
897    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
898        let _result = self.send_raw(result);
899        self.drop_without_shutdown();
900        _result
901    }
902
903    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
904        self.control_handle
905            .inner
906            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
907                result,
908                self.tx_id,
909                0x2d994ee1a9364179,
910                fidl::encoding::DynamicFlags::empty(),
911            )
912    }
913}
914
915#[must_use = "FIDL methods require a response to be sent"]
916#[derive(Debug)]
917pub struct ControllerFormatResponder {
918    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
919    tx_id: u32,
920}
921
922/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
923/// if the responder is dropped without sending a response, so that the client
924/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
925impl std::ops::Drop for ControllerFormatResponder {
926    fn drop(&mut self) {
927        self.control_handle.shutdown();
928        // Safety: drops once, never accessed again
929        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
930    }
931}
932
933impl fidl::endpoints::Responder for ControllerFormatResponder {
934    type ControlHandle = ControllerControlHandle;
935
936    fn control_handle(&self) -> &ControllerControlHandle {
937        &self.control_handle
938    }
939
940    fn drop_without_shutdown(mut self) {
941        // Safety: drops once, never accessed again due to mem::forget
942        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
943        // Prevent Drop from running (which would shut down the channel)
944        std::mem::forget(self);
945    }
946}
947
948impl ControllerFormatResponder {
949    /// Sends a response to the FIDL transaction.
950    ///
951    /// Sets the channel to shutdown if an error occurs.
952    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
953        let _result = self.send_raw(result);
954        if _result.is_err() {
955            self.control_handle.shutdown();
956        }
957        self.drop_without_shutdown();
958        _result
959    }
960
961    /// Similar to "send" but does not shutdown the channel if an error occurs.
962    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
963        let _result = self.send_raw(result);
964        self.drop_without_shutdown();
965        _result
966    }
967
968    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
969        self.control_handle
970            .inner
971            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
972                result,
973                self.tx_id,
974                0x52ce219e43664bf0,
975                fidl::encoding::DynamicFlags::empty(),
976            )
977    }
978}
979
980#[must_use = "FIDL methods require a response to be sent"]
981#[derive(Debug)]
982pub struct ControllerCheckResponder {
983    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
984    tx_id: u32,
985}
986
987/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
988/// if the responder is dropped without sending a response, so that the client
989/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
990impl std::ops::Drop for ControllerCheckResponder {
991    fn drop(&mut self) {
992        self.control_handle.shutdown();
993        // Safety: drops once, never accessed again
994        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
995    }
996}
997
998impl fidl::endpoints::Responder for ControllerCheckResponder {
999    type ControlHandle = ControllerControlHandle;
1000
1001    fn control_handle(&self) -> &ControllerControlHandle {
1002        &self.control_handle
1003    }
1004
1005    fn drop_without_shutdown(mut self) {
1006        // Safety: drops once, never accessed again due to mem::forget
1007        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1008        // Prevent Drop from running (which would shut down the channel)
1009        std::mem::forget(self);
1010    }
1011}
1012
1013impl ControllerCheckResponder {
1014    /// Sends a response to the FIDL transaction.
1015    ///
1016    /// Sets the channel to shutdown if an error occurs.
1017    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1018        let _result = self.send_raw(result);
1019        if _result.is_err() {
1020            self.control_handle.shutdown();
1021        }
1022        self.drop_without_shutdown();
1023        _result
1024    }
1025
1026    /// Similar to "send" but does not shutdown the channel if an error occurs.
1027    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1028        let _result = self.send_raw(result);
1029        self.drop_without_shutdown();
1030        _result
1031    }
1032
1033    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1034        self.control_handle
1035            .inner
1036            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1037                result,
1038                self.tx_id,
1039                0x20d3ff7c33a9b863,
1040                fidl::encoding::DynamicFlags::empty(),
1041            )
1042    }
1043}
1044
1045mod internal {
1046    use super::*;
1047
1048    impl fidl::encoding::ResourceTypeMarker for ControllerCheckRequest {
1049        type Borrowed<'a> = &'a mut Self;
1050        fn take_or_borrow<'a>(
1051            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1052        ) -> Self::Borrowed<'a> {
1053            value
1054        }
1055    }
1056
1057    unsafe impl fidl::encoding::TypeMarker for ControllerCheckRequest {
1058        type Owned = Self;
1059
1060        #[inline(always)]
1061        fn inline_align(_context: fidl::encoding::Context) -> usize {
1062            8
1063        }
1064
1065        #[inline(always)]
1066        fn inline_size(_context: fidl::encoding::Context) -> usize {
1067            24
1068        }
1069    }
1070
1071    unsafe impl
1072        fidl::encoding::Encode<
1073            ControllerCheckRequest,
1074            fidl::encoding::DefaultFuchsiaResourceDialect,
1075        > for &mut ControllerCheckRequest
1076    {
1077        #[inline]
1078        unsafe fn encode(
1079            self,
1080            encoder: &mut fidl::encoding::Encoder<
1081                '_,
1082                fidl::encoding::DefaultFuchsiaResourceDialect,
1083            >,
1084            offset: usize,
1085            _depth: fidl::encoding::Depth,
1086        ) -> fidl::Result<()> {
1087            encoder.debug_check_bounds::<ControllerCheckRequest>(offset);
1088            // Delegate to tuple encoding.
1089            fidl::encoding::Encode::<
1090                ControllerCheckRequest,
1091                fidl::encoding::DefaultFuchsiaResourceDialect,
1092            >::encode(
1093                (
1094                    <fidl::encoding::Endpoint<
1095                        fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1096                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1097                        &mut self.device
1098                    ),
1099                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1100                        &self.name,
1101                    ),
1102                ),
1103                encoder,
1104                offset,
1105                _depth,
1106            )
1107        }
1108    }
1109    unsafe impl<
1110            T0: fidl::encoding::Encode<
1111                fidl::encoding::Endpoint<
1112                    fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1113                >,
1114                fidl::encoding::DefaultFuchsiaResourceDialect,
1115            >,
1116            T1: fidl::encoding::Encode<
1117                fidl::encoding::BoundedString<255>,
1118                fidl::encoding::DefaultFuchsiaResourceDialect,
1119            >,
1120        >
1121        fidl::encoding::Encode<
1122            ControllerCheckRequest,
1123            fidl::encoding::DefaultFuchsiaResourceDialect,
1124        > for (T0, T1)
1125    {
1126        #[inline]
1127        unsafe fn encode(
1128            self,
1129            encoder: &mut fidl::encoding::Encoder<
1130                '_,
1131                fidl::encoding::DefaultFuchsiaResourceDialect,
1132            >,
1133            offset: usize,
1134            depth: fidl::encoding::Depth,
1135        ) -> fidl::Result<()> {
1136            encoder.debug_check_bounds::<ControllerCheckRequest>(offset);
1137            // Zero out padding regions. There's no need to apply masks
1138            // because the unmasked parts will be overwritten by fields.
1139            unsafe {
1140                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1141                (ptr as *mut u64).write_unaligned(0);
1142            }
1143            // Write the fields.
1144            self.0.encode(encoder, offset + 0, depth)?;
1145            self.1.encode(encoder, offset + 8, depth)?;
1146            Ok(())
1147        }
1148    }
1149
1150    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1151        for ControllerCheckRequest
1152    {
1153        #[inline(always)]
1154        fn new_empty() -> Self {
1155            Self {
1156                device: fidl::new_empty!(
1157                    fidl::encoding::Endpoint<
1158                        fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1159                    >,
1160                    fidl::encoding::DefaultFuchsiaResourceDialect
1161                ),
1162                name: fidl::new_empty!(
1163                    fidl::encoding::BoundedString<255>,
1164                    fidl::encoding::DefaultFuchsiaResourceDialect
1165                ),
1166            }
1167        }
1168
1169        #[inline]
1170        unsafe fn decode(
1171            &mut self,
1172            decoder: &mut fidl::encoding::Decoder<
1173                '_,
1174                fidl::encoding::DefaultFuchsiaResourceDialect,
1175            >,
1176            offset: usize,
1177            _depth: fidl::encoding::Depth,
1178        ) -> fidl::Result<()> {
1179            decoder.debug_check_bounds::<Self>(offset);
1180            // Verify that padding bytes are zero.
1181            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1182            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1183            let mask = 0xffffffff00000000u64;
1184            let maskedval = padval & mask;
1185            if maskedval != 0 {
1186                return Err(fidl::Error::NonZeroPadding {
1187                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1188                });
1189            }
1190            fidl::decode!(
1191                fidl::encoding::Endpoint<
1192                    fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1193                >,
1194                fidl::encoding::DefaultFuchsiaResourceDialect,
1195                &mut self.device,
1196                decoder,
1197                offset + 0,
1198                _depth
1199            )?;
1200            fidl::decode!(
1201                fidl::encoding::BoundedString<255>,
1202                fidl::encoding::DefaultFuchsiaResourceDialect,
1203                &mut self.name,
1204                decoder,
1205                offset + 8,
1206                _depth
1207            )?;
1208            Ok(())
1209        }
1210    }
1211
1212    impl fidl::encoding::ResourceTypeMarker for ControllerFormatRequest {
1213        type Borrowed<'a> = &'a mut Self;
1214        fn take_or_borrow<'a>(
1215            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1216        ) -> Self::Borrowed<'a> {
1217            value
1218        }
1219    }
1220
1221    unsafe impl fidl::encoding::TypeMarker for ControllerFormatRequest {
1222        type Owned = Self;
1223
1224        #[inline(always)]
1225        fn inline_align(_context: fidl::encoding::Context) -> usize {
1226            8
1227        }
1228
1229        #[inline(always)]
1230        fn inline_size(_context: fidl::encoding::Context) -> usize {
1231            40
1232        }
1233    }
1234
1235    unsafe impl
1236        fidl::encoding::Encode<
1237            ControllerFormatRequest,
1238            fidl::encoding::DefaultFuchsiaResourceDialect,
1239        > for &mut ControllerFormatRequest
1240    {
1241        #[inline]
1242        unsafe fn encode(
1243            self,
1244            encoder: &mut fidl::encoding::Encoder<
1245                '_,
1246                fidl::encoding::DefaultFuchsiaResourceDialect,
1247            >,
1248            offset: usize,
1249            _depth: fidl::encoding::Depth,
1250        ) -> fidl::Result<()> {
1251            encoder.debug_check_bounds::<ControllerFormatRequest>(offset);
1252            // Delegate to tuple encoding.
1253            fidl::encoding::Encode::<
1254                ControllerFormatRequest,
1255                fidl::encoding::DefaultFuchsiaResourceDialect,
1256            >::encode(
1257                (
1258                    <fidl::encoding::Endpoint<
1259                        fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1260                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1261                        &mut self.device
1262                    ),
1263                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1264                        &self.name,
1265                    ),
1266                    <FormatOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1267                        &mut self.options,
1268                    ),
1269                ),
1270                encoder,
1271                offset,
1272                _depth,
1273            )
1274        }
1275    }
1276    unsafe impl<
1277            T0: fidl::encoding::Encode<
1278                fidl::encoding::Endpoint<
1279                    fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1280                >,
1281                fidl::encoding::DefaultFuchsiaResourceDialect,
1282            >,
1283            T1: fidl::encoding::Encode<
1284                fidl::encoding::BoundedString<255>,
1285                fidl::encoding::DefaultFuchsiaResourceDialect,
1286            >,
1287            T2: fidl::encoding::Encode<FormatOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
1288        >
1289        fidl::encoding::Encode<
1290            ControllerFormatRequest,
1291            fidl::encoding::DefaultFuchsiaResourceDialect,
1292        > for (T0, T1, T2)
1293    {
1294        #[inline]
1295        unsafe fn encode(
1296            self,
1297            encoder: &mut fidl::encoding::Encoder<
1298                '_,
1299                fidl::encoding::DefaultFuchsiaResourceDialect,
1300            >,
1301            offset: usize,
1302            depth: fidl::encoding::Depth,
1303        ) -> fidl::Result<()> {
1304            encoder.debug_check_bounds::<ControllerFormatRequest>(offset);
1305            // Zero out padding regions. There's no need to apply masks
1306            // because the unmasked parts will be overwritten by fields.
1307            unsafe {
1308                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1309                (ptr as *mut u64).write_unaligned(0);
1310            }
1311            // Write the fields.
1312            self.0.encode(encoder, offset + 0, depth)?;
1313            self.1.encode(encoder, offset + 8, depth)?;
1314            self.2.encode(encoder, offset + 24, depth)?;
1315            Ok(())
1316        }
1317    }
1318
1319    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1320        for ControllerFormatRequest
1321    {
1322        #[inline(always)]
1323        fn new_empty() -> Self {
1324            Self {
1325                device: fidl::new_empty!(
1326                    fidl::encoding::Endpoint<
1327                        fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1328                    >,
1329                    fidl::encoding::DefaultFuchsiaResourceDialect
1330                ),
1331                name: fidl::new_empty!(
1332                    fidl::encoding::BoundedString<255>,
1333                    fidl::encoding::DefaultFuchsiaResourceDialect
1334                ),
1335                options: fidl::new_empty!(
1336                    FormatOptions,
1337                    fidl::encoding::DefaultFuchsiaResourceDialect
1338                ),
1339            }
1340        }
1341
1342        #[inline]
1343        unsafe fn decode(
1344            &mut self,
1345            decoder: &mut fidl::encoding::Decoder<
1346                '_,
1347                fidl::encoding::DefaultFuchsiaResourceDialect,
1348            >,
1349            offset: usize,
1350            _depth: fidl::encoding::Depth,
1351        ) -> fidl::Result<()> {
1352            decoder.debug_check_bounds::<Self>(offset);
1353            // Verify that padding bytes are zero.
1354            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1355            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1356            let mask = 0xffffffff00000000u64;
1357            let maskedval = padval & mask;
1358            if maskedval != 0 {
1359                return Err(fidl::Error::NonZeroPadding {
1360                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1361                });
1362            }
1363            fidl::decode!(
1364                fidl::encoding::Endpoint<
1365                    fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1366                >,
1367                fidl::encoding::DefaultFuchsiaResourceDialect,
1368                &mut self.device,
1369                decoder,
1370                offset + 0,
1371                _depth
1372            )?;
1373            fidl::decode!(
1374                fidl::encoding::BoundedString<255>,
1375                fidl::encoding::DefaultFuchsiaResourceDialect,
1376                &mut self.name,
1377                decoder,
1378                offset + 8,
1379                _depth
1380            )?;
1381            fidl::decode!(
1382                FormatOptions,
1383                fidl::encoding::DefaultFuchsiaResourceDialect,
1384                &mut self.options,
1385                decoder,
1386                offset + 24,
1387                _depth
1388            )?;
1389            Ok(())
1390        }
1391    }
1392
1393    impl fidl::encoding::ResourceTypeMarker for ControllerMountRequest {
1394        type Borrowed<'a> = &'a mut Self;
1395        fn take_or_borrow<'a>(
1396            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1397        ) -> Self::Borrowed<'a> {
1398            value
1399        }
1400    }
1401
1402    unsafe impl fidl::encoding::TypeMarker for ControllerMountRequest {
1403        type Owned = Self;
1404
1405        #[inline(always)]
1406        fn inline_align(_context: fidl::encoding::Context) -> usize {
1407            8
1408        }
1409
1410        #[inline(always)]
1411        fn inline_size(_context: fidl::encoding::Context) -> usize {
1412            40
1413        }
1414    }
1415
1416    unsafe impl
1417        fidl::encoding::Encode<
1418            ControllerMountRequest,
1419            fidl::encoding::DefaultFuchsiaResourceDialect,
1420        > for &mut ControllerMountRequest
1421    {
1422        #[inline]
1423        unsafe fn encode(
1424            self,
1425            encoder: &mut fidl::encoding::Encoder<
1426                '_,
1427                fidl::encoding::DefaultFuchsiaResourceDialect,
1428            >,
1429            offset: usize,
1430            _depth: fidl::encoding::Depth,
1431        ) -> fidl::Result<()> {
1432            encoder.debug_check_bounds::<ControllerMountRequest>(offset);
1433            // Delegate to tuple encoding.
1434            fidl::encoding::Encode::<
1435                ControllerMountRequest,
1436                fidl::encoding::DefaultFuchsiaResourceDialect,
1437            >::encode(
1438                (
1439                    <fidl::encoding::Endpoint<
1440                        fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1441                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1442                        &mut self.device
1443                    ),
1444                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
1445                        &self.name,
1446                    ),
1447                    <MountOptions as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1448                        &mut self.options,
1449                    ),
1450                ),
1451                encoder,
1452                offset,
1453                _depth,
1454            )
1455        }
1456    }
1457    unsafe impl<
1458            T0: fidl::encoding::Encode<
1459                fidl::encoding::Endpoint<
1460                    fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1461                >,
1462                fidl::encoding::DefaultFuchsiaResourceDialect,
1463            >,
1464            T1: fidl::encoding::Encode<
1465                fidl::encoding::BoundedString<255>,
1466                fidl::encoding::DefaultFuchsiaResourceDialect,
1467            >,
1468            T2: fidl::encoding::Encode<MountOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
1469        >
1470        fidl::encoding::Encode<
1471            ControllerMountRequest,
1472            fidl::encoding::DefaultFuchsiaResourceDialect,
1473        > for (T0, T1, T2)
1474    {
1475        #[inline]
1476        unsafe fn encode(
1477            self,
1478            encoder: &mut fidl::encoding::Encoder<
1479                '_,
1480                fidl::encoding::DefaultFuchsiaResourceDialect,
1481            >,
1482            offset: usize,
1483            depth: fidl::encoding::Depth,
1484        ) -> fidl::Result<()> {
1485            encoder.debug_check_bounds::<ControllerMountRequest>(offset);
1486            // Zero out padding regions. There's no need to apply masks
1487            // because the unmasked parts will be overwritten by fields.
1488            unsafe {
1489                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1490                (ptr as *mut u64).write_unaligned(0);
1491            }
1492            // Write the fields.
1493            self.0.encode(encoder, offset + 0, depth)?;
1494            self.1.encode(encoder, offset + 8, depth)?;
1495            self.2.encode(encoder, offset + 24, depth)?;
1496            Ok(())
1497        }
1498    }
1499
1500    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1501        for ControllerMountRequest
1502    {
1503        #[inline(always)]
1504        fn new_empty() -> Self {
1505            Self {
1506                device: fidl::new_empty!(
1507                    fidl::encoding::Endpoint<
1508                        fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1509                    >,
1510                    fidl::encoding::DefaultFuchsiaResourceDialect
1511                ),
1512                name: fidl::new_empty!(
1513                    fidl::encoding::BoundedString<255>,
1514                    fidl::encoding::DefaultFuchsiaResourceDialect
1515                ),
1516                options: fidl::new_empty!(
1517                    MountOptions,
1518                    fidl::encoding::DefaultFuchsiaResourceDialect
1519                ),
1520            }
1521        }
1522
1523        #[inline]
1524        unsafe fn decode(
1525            &mut self,
1526            decoder: &mut fidl::encoding::Decoder<
1527                '_,
1528                fidl::encoding::DefaultFuchsiaResourceDialect,
1529            >,
1530            offset: usize,
1531            _depth: fidl::encoding::Depth,
1532        ) -> fidl::Result<()> {
1533            decoder.debug_check_bounds::<Self>(offset);
1534            // Verify that padding bytes are zero.
1535            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1536            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1537            let mask = 0xffffffff00000000u64;
1538            let maskedval = padval & mask;
1539            if maskedval != 0 {
1540                return Err(fidl::Error::NonZeroPadding {
1541                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1542                });
1543            }
1544            fidl::decode!(
1545                fidl::encoding::Endpoint<
1546                    fidl::endpoints::ClientEnd<fidl_fuchsia_device::ControllerMarker>,
1547                >,
1548                fidl::encoding::DefaultFuchsiaResourceDialect,
1549                &mut self.device,
1550                decoder,
1551                offset + 0,
1552                _depth
1553            )?;
1554            fidl::decode!(
1555                fidl::encoding::BoundedString<255>,
1556                fidl::encoding::DefaultFuchsiaResourceDialect,
1557                &mut self.name,
1558                decoder,
1559                offset + 8,
1560                _depth
1561            )?;
1562            fidl::decode!(
1563                MountOptions,
1564                fidl::encoding::DefaultFuchsiaResourceDialect,
1565                &mut self.options,
1566                decoder,
1567                offset + 24,
1568                _depth
1569            )?;
1570            Ok(())
1571        }
1572    }
1573
1574    impl FormatOptions {
1575        #[inline(always)]
1576        fn max_ordinal_present(&self) -> u64 {
1577            if let Some(_) = self.fvm_data_slices {
1578                return 2;
1579            }
1580            if let Some(_) = self.verbose {
1581                return 1;
1582            }
1583            0
1584        }
1585    }
1586
1587    impl fidl::encoding::ResourceTypeMarker for FormatOptions {
1588        type Borrowed<'a> = &'a mut Self;
1589        fn take_or_borrow<'a>(
1590            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1591        ) -> Self::Borrowed<'a> {
1592            value
1593        }
1594    }
1595
1596    unsafe impl fidl::encoding::TypeMarker for FormatOptions {
1597        type Owned = Self;
1598
1599        #[inline(always)]
1600        fn inline_align(_context: fidl::encoding::Context) -> usize {
1601            8
1602        }
1603
1604        #[inline(always)]
1605        fn inline_size(_context: fidl::encoding::Context) -> usize {
1606            16
1607        }
1608    }
1609
1610    unsafe impl fidl::encoding::Encode<FormatOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
1611        for &mut FormatOptions
1612    {
1613        unsafe fn encode(
1614            self,
1615            encoder: &mut fidl::encoding::Encoder<
1616                '_,
1617                fidl::encoding::DefaultFuchsiaResourceDialect,
1618            >,
1619            offset: usize,
1620            mut depth: fidl::encoding::Depth,
1621        ) -> fidl::Result<()> {
1622            encoder.debug_check_bounds::<FormatOptions>(offset);
1623            // Vector header
1624            let max_ordinal: u64 = self.max_ordinal_present();
1625            encoder.write_num(max_ordinal, offset);
1626            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1627            // Calling encoder.out_of_line_offset(0) is not allowed.
1628            if max_ordinal == 0 {
1629                return Ok(());
1630            }
1631            depth.increment()?;
1632            let envelope_size = 8;
1633            let bytes_len = max_ordinal as usize * envelope_size;
1634            #[allow(unused_variables)]
1635            let offset = encoder.out_of_line_offset(bytes_len);
1636            let mut _prev_end_offset: usize = 0;
1637            if 1 > max_ordinal {
1638                return Ok(());
1639            }
1640
1641            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1642            // are envelope_size bytes.
1643            let cur_offset: usize = (1 - 1) * envelope_size;
1644
1645            // Zero reserved fields.
1646            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1647
1648            // Safety:
1649            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1650            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1651            //   envelope_size bytes, there is always sufficient room.
1652            fidl::encoding::encode_in_envelope_optional::<
1653                bool,
1654                fidl::encoding::DefaultFuchsiaResourceDialect,
1655            >(
1656                self.verbose.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1657                encoder,
1658                offset + cur_offset,
1659                depth,
1660            )?;
1661
1662            _prev_end_offset = cur_offset + envelope_size;
1663            if 2 > max_ordinal {
1664                return Ok(());
1665            }
1666
1667            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1668            // are envelope_size bytes.
1669            let cur_offset: usize = (2 - 1) * envelope_size;
1670
1671            // Zero reserved fields.
1672            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1673
1674            // Safety:
1675            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1676            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1677            //   envelope_size bytes, there is always sufficient room.
1678            fidl::encoding::encode_in_envelope_optional::<
1679                u32,
1680                fidl::encoding::DefaultFuchsiaResourceDialect,
1681            >(
1682                self.fvm_data_slices.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1683                encoder,
1684                offset + cur_offset,
1685                depth,
1686            )?;
1687
1688            _prev_end_offset = cur_offset + envelope_size;
1689
1690            Ok(())
1691        }
1692    }
1693
1694    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for FormatOptions {
1695        #[inline(always)]
1696        fn new_empty() -> Self {
1697            Self::default()
1698        }
1699
1700        unsafe fn decode(
1701            &mut self,
1702            decoder: &mut fidl::encoding::Decoder<
1703                '_,
1704                fidl::encoding::DefaultFuchsiaResourceDialect,
1705            >,
1706            offset: usize,
1707            mut depth: fidl::encoding::Depth,
1708        ) -> fidl::Result<()> {
1709            decoder.debug_check_bounds::<Self>(offset);
1710            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1711                None => return Err(fidl::Error::NotNullable),
1712                Some(len) => len,
1713            };
1714            // Calling decoder.out_of_line_offset(0) is not allowed.
1715            if len == 0 {
1716                return Ok(());
1717            };
1718            depth.increment()?;
1719            let envelope_size = 8;
1720            let bytes_len = len * envelope_size;
1721            let offset = decoder.out_of_line_offset(bytes_len)?;
1722            // Decode the envelope for each type.
1723            let mut _next_ordinal_to_read = 0;
1724            let mut next_offset = offset;
1725            let end_offset = offset + bytes_len;
1726            _next_ordinal_to_read += 1;
1727            if next_offset >= end_offset {
1728                return Ok(());
1729            }
1730
1731            // Decode unknown envelopes for gaps in ordinals.
1732            while _next_ordinal_to_read < 1 {
1733                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1734                _next_ordinal_to_read += 1;
1735                next_offset += envelope_size;
1736            }
1737
1738            let next_out_of_line = decoder.next_out_of_line();
1739            let handles_before = decoder.remaining_handles();
1740            if let Some((inlined, num_bytes, num_handles)) =
1741                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1742            {
1743                let member_inline_size =
1744                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1745                if inlined != (member_inline_size <= 4) {
1746                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1747                }
1748                let inner_offset;
1749                let mut inner_depth = depth.clone();
1750                if inlined {
1751                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1752                    inner_offset = next_offset;
1753                } else {
1754                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1755                    inner_depth.increment()?;
1756                }
1757                let val_ref = self.verbose.get_or_insert_with(|| {
1758                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
1759                });
1760                fidl::decode!(
1761                    bool,
1762                    fidl::encoding::DefaultFuchsiaResourceDialect,
1763                    val_ref,
1764                    decoder,
1765                    inner_offset,
1766                    inner_depth
1767                )?;
1768                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1769                {
1770                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1771                }
1772                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1773                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1774                }
1775            }
1776
1777            next_offset += envelope_size;
1778            _next_ordinal_to_read += 1;
1779            if next_offset >= end_offset {
1780                return Ok(());
1781            }
1782
1783            // Decode unknown envelopes for gaps in ordinals.
1784            while _next_ordinal_to_read < 2 {
1785                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1786                _next_ordinal_to_read += 1;
1787                next_offset += envelope_size;
1788            }
1789
1790            let next_out_of_line = decoder.next_out_of_line();
1791            let handles_before = decoder.remaining_handles();
1792            if let Some((inlined, num_bytes, num_handles)) =
1793                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1794            {
1795                let member_inline_size =
1796                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1797                if inlined != (member_inline_size <= 4) {
1798                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1799                }
1800                let inner_offset;
1801                let mut inner_depth = depth.clone();
1802                if inlined {
1803                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1804                    inner_offset = next_offset;
1805                } else {
1806                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1807                    inner_depth.increment()?;
1808                }
1809                let val_ref = self.fvm_data_slices.get_or_insert_with(|| {
1810                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
1811                });
1812                fidl::decode!(
1813                    u32,
1814                    fidl::encoding::DefaultFuchsiaResourceDialect,
1815                    val_ref,
1816                    decoder,
1817                    inner_offset,
1818                    inner_depth
1819                )?;
1820                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1821                {
1822                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1823                }
1824                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1825                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1826                }
1827            }
1828
1829            next_offset += envelope_size;
1830
1831            // Decode the remaining unknown envelopes.
1832            while next_offset < end_offset {
1833                _next_ordinal_to_read += 1;
1834                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1835                next_offset += envelope_size;
1836            }
1837
1838            Ok(())
1839        }
1840    }
1841
1842    impl MountOptions {
1843        #[inline(always)]
1844        fn max_ordinal_present(&self) -> u64 {
1845            if let Some(_) = self.write_compression_algorithm {
1846                return 3;
1847            }
1848            if let Some(_) = self.verbose {
1849                return 2;
1850            }
1851            if let Some(_) = self.read_only {
1852                return 1;
1853            }
1854            0
1855        }
1856    }
1857
1858    impl fidl::encoding::ResourceTypeMarker for MountOptions {
1859        type Borrowed<'a> = &'a mut Self;
1860        fn take_or_borrow<'a>(
1861            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1862        ) -> Self::Borrowed<'a> {
1863            value
1864        }
1865    }
1866
1867    unsafe impl fidl::encoding::TypeMarker for MountOptions {
1868        type Owned = Self;
1869
1870        #[inline(always)]
1871        fn inline_align(_context: fidl::encoding::Context) -> usize {
1872            8
1873        }
1874
1875        #[inline(always)]
1876        fn inline_size(_context: fidl::encoding::Context) -> usize {
1877            16
1878        }
1879    }
1880
1881    unsafe impl fidl::encoding::Encode<MountOptions, fidl::encoding::DefaultFuchsiaResourceDialect>
1882        for &mut MountOptions
1883    {
1884        unsafe fn encode(
1885            self,
1886            encoder: &mut fidl::encoding::Encoder<
1887                '_,
1888                fidl::encoding::DefaultFuchsiaResourceDialect,
1889            >,
1890            offset: usize,
1891            mut depth: fidl::encoding::Depth,
1892        ) -> fidl::Result<()> {
1893            encoder.debug_check_bounds::<MountOptions>(offset);
1894            // Vector header
1895            let max_ordinal: u64 = self.max_ordinal_present();
1896            encoder.write_num(max_ordinal, offset);
1897            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1898            // Calling encoder.out_of_line_offset(0) is not allowed.
1899            if max_ordinal == 0 {
1900                return Ok(());
1901            }
1902            depth.increment()?;
1903            let envelope_size = 8;
1904            let bytes_len = max_ordinal as usize * envelope_size;
1905            #[allow(unused_variables)]
1906            let offset = encoder.out_of_line_offset(bytes_len);
1907            let mut _prev_end_offset: usize = 0;
1908            if 1 > max_ordinal {
1909                return Ok(());
1910            }
1911
1912            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1913            // are envelope_size bytes.
1914            let cur_offset: usize = (1 - 1) * envelope_size;
1915
1916            // Zero reserved fields.
1917            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1918
1919            // Safety:
1920            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1921            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1922            //   envelope_size bytes, there is always sufficient room.
1923            fidl::encoding::encode_in_envelope_optional::<
1924                bool,
1925                fidl::encoding::DefaultFuchsiaResourceDialect,
1926            >(
1927                self.read_only.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1928                encoder,
1929                offset + cur_offset,
1930                depth,
1931            )?;
1932
1933            _prev_end_offset = cur_offset + envelope_size;
1934            if 2 > max_ordinal {
1935                return Ok(());
1936            }
1937
1938            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1939            // are envelope_size bytes.
1940            let cur_offset: usize = (2 - 1) * envelope_size;
1941
1942            // Zero reserved fields.
1943            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1944
1945            // Safety:
1946            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1947            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1948            //   envelope_size bytes, there is always sufficient room.
1949            fidl::encoding::encode_in_envelope_optional::<
1950                bool,
1951                fidl::encoding::DefaultFuchsiaResourceDialect,
1952            >(
1953                self.verbose.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1954                encoder,
1955                offset + cur_offset,
1956                depth,
1957            )?;
1958
1959            _prev_end_offset = cur_offset + envelope_size;
1960            if 3 > max_ordinal {
1961                return Ok(());
1962            }
1963
1964            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1965            // are envelope_size bytes.
1966            let cur_offset: usize = (3 - 1) * envelope_size;
1967
1968            // Zero reserved fields.
1969            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1970
1971            // Safety:
1972            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1973            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1974            //   envelope_size bytes, there is always sufficient room.
1975            fidl::encoding::encode_in_envelope_optional::<
1976                fidl::encoding::BoundedString<32>,
1977                fidl::encoding::DefaultFuchsiaResourceDialect,
1978            >(
1979                self.write_compression_algorithm.as_ref().map(
1980                    <fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow,
1981                ),
1982                encoder,
1983                offset + cur_offset,
1984                depth,
1985            )?;
1986
1987            _prev_end_offset = cur_offset + envelope_size;
1988
1989            Ok(())
1990        }
1991    }
1992
1993    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for MountOptions {
1994        #[inline(always)]
1995        fn new_empty() -> Self {
1996            Self::default()
1997        }
1998
1999        unsafe fn decode(
2000            &mut self,
2001            decoder: &mut fidl::encoding::Decoder<
2002                '_,
2003                fidl::encoding::DefaultFuchsiaResourceDialect,
2004            >,
2005            offset: usize,
2006            mut depth: fidl::encoding::Depth,
2007        ) -> fidl::Result<()> {
2008            decoder.debug_check_bounds::<Self>(offset);
2009            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2010                None => return Err(fidl::Error::NotNullable),
2011                Some(len) => len,
2012            };
2013            // Calling decoder.out_of_line_offset(0) is not allowed.
2014            if len == 0 {
2015                return Ok(());
2016            };
2017            depth.increment()?;
2018            let envelope_size = 8;
2019            let bytes_len = len * envelope_size;
2020            let offset = decoder.out_of_line_offset(bytes_len)?;
2021            // Decode the envelope for each type.
2022            let mut _next_ordinal_to_read = 0;
2023            let mut next_offset = offset;
2024            let end_offset = offset + bytes_len;
2025            _next_ordinal_to_read += 1;
2026            if next_offset >= end_offset {
2027                return Ok(());
2028            }
2029
2030            // Decode unknown envelopes for gaps in ordinals.
2031            while _next_ordinal_to_read < 1 {
2032                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2033                _next_ordinal_to_read += 1;
2034                next_offset += envelope_size;
2035            }
2036
2037            let next_out_of_line = decoder.next_out_of_line();
2038            let handles_before = decoder.remaining_handles();
2039            if let Some((inlined, num_bytes, num_handles)) =
2040                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2041            {
2042                let member_inline_size =
2043                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2044                if inlined != (member_inline_size <= 4) {
2045                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2046                }
2047                let inner_offset;
2048                let mut inner_depth = depth.clone();
2049                if inlined {
2050                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2051                    inner_offset = next_offset;
2052                } else {
2053                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2054                    inner_depth.increment()?;
2055                }
2056                let val_ref = self.read_only.get_or_insert_with(|| {
2057                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
2058                });
2059                fidl::decode!(
2060                    bool,
2061                    fidl::encoding::DefaultFuchsiaResourceDialect,
2062                    val_ref,
2063                    decoder,
2064                    inner_offset,
2065                    inner_depth
2066                )?;
2067                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2068                {
2069                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2070                }
2071                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2072                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2073                }
2074            }
2075
2076            next_offset += envelope_size;
2077            _next_ordinal_to_read += 1;
2078            if next_offset >= end_offset {
2079                return Ok(());
2080            }
2081
2082            // Decode unknown envelopes for gaps in ordinals.
2083            while _next_ordinal_to_read < 2 {
2084                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2085                _next_ordinal_to_read += 1;
2086                next_offset += envelope_size;
2087            }
2088
2089            let next_out_of_line = decoder.next_out_of_line();
2090            let handles_before = decoder.remaining_handles();
2091            if let Some((inlined, num_bytes, num_handles)) =
2092                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2093            {
2094                let member_inline_size =
2095                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2096                if inlined != (member_inline_size <= 4) {
2097                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2098                }
2099                let inner_offset;
2100                let mut inner_depth = depth.clone();
2101                if inlined {
2102                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2103                    inner_offset = next_offset;
2104                } else {
2105                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2106                    inner_depth.increment()?;
2107                }
2108                let val_ref = self.verbose.get_or_insert_with(|| {
2109                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
2110                });
2111                fidl::decode!(
2112                    bool,
2113                    fidl::encoding::DefaultFuchsiaResourceDialect,
2114                    val_ref,
2115                    decoder,
2116                    inner_offset,
2117                    inner_depth
2118                )?;
2119                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2120                {
2121                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2122                }
2123                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2124                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2125                }
2126            }
2127
2128            next_offset += envelope_size;
2129            _next_ordinal_to_read += 1;
2130            if next_offset >= end_offset {
2131                return Ok(());
2132            }
2133
2134            // Decode unknown envelopes for gaps in ordinals.
2135            while _next_ordinal_to_read < 3 {
2136                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2137                _next_ordinal_to_read += 1;
2138                next_offset += envelope_size;
2139            }
2140
2141            let next_out_of_line = decoder.next_out_of_line();
2142            let handles_before = decoder.remaining_handles();
2143            if let Some((inlined, num_bytes, num_handles)) =
2144                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2145            {
2146                let member_inline_size =
2147                    <fidl::encoding::BoundedString<32> as fidl::encoding::TypeMarker>::inline_size(
2148                        decoder.context,
2149                    );
2150                if inlined != (member_inline_size <= 4) {
2151                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2152                }
2153                let inner_offset;
2154                let mut inner_depth = depth.clone();
2155                if inlined {
2156                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2157                    inner_offset = next_offset;
2158                } else {
2159                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2160                    inner_depth.increment()?;
2161                }
2162                let val_ref = self.write_compression_algorithm.get_or_insert_with(|| {
2163                    fidl::new_empty!(
2164                        fidl::encoding::BoundedString<32>,
2165                        fidl::encoding::DefaultFuchsiaResourceDialect
2166                    )
2167                });
2168                fidl::decode!(
2169                    fidl::encoding::BoundedString<32>,
2170                    fidl::encoding::DefaultFuchsiaResourceDialect,
2171                    val_ref,
2172                    decoder,
2173                    inner_offset,
2174                    inner_depth
2175                )?;
2176                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2177                {
2178                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2179                }
2180                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2181                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2182                }
2183            }
2184
2185            next_offset += envelope_size;
2186
2187            // Decode the remaining unknown envelopes.
2188            while next_offset < end_offset {
2189                _next_ordinal_to_read += 1;
2190                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2191                next_offset += envelope_size;
2192            }
2193
2194            Ok(())
2195        }
2196    }
2197}