Skip to main content

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