fidl_fuchsia_fs_realm/
fidl_fuchsia_fs_realm.rs

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