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