fidl_fuchsia_hardware_ramdisk/
fidl_fuchsia_hardware_ramdisk.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_hardware_ramdisk__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ControllerCreateResponse {
16    pub outgoing: fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
17    pub lifeline: fidl::EventPair,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ControllerCreateResponse {}
21
22#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
23pub struct RamdiskControllerCreateFromVmoRequest {
24    pub vmo: fidl::Vmo,
25}
26
27impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
28    for RamdiskControllerCreateFromVmoRequest
29{
30}
31
32#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
33pub struct RamdiskControllerCreateFromVmoWithParamsRequest {
34    pub vmo: fidl::Vmo,
35    pub block_size: u64,
36    pub type_guid: Option<Box<Guid>>,
37}
38
39impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
40    for RamdiskControllerCreateFromVmoWithParamsRequest
41{
42}
43
44/// Options for creating a ram-disk.  Some combinations are invalid and will
45/// result in ZX_ERR_INVALID_ARGS.
46#[derive(Debug, Default, PartialEq)]
47pub struct Options {
48    /// If unspecified, the system page size is used.
49    pub block_size: Option<u32>,
50    /// If unspecified, will be deduced from `vmo`.
51    pub block_count: Option<u64>,
52    /// Optional type GUID returned in the fuchsia.hardware.block.partition.Partition protocol.
53    pub type_guid: Option<Guid>,
54    /// If unspecified, a VMO will be created, in which case `block_count` must be specified.
55    pub vmo: Option<fidl::Vmo>,
56    /// If true, expose fuchsia.hardware.block.volume.Service for the ramdisk.
57    pub publish: Option<bool>,
58    /// If unspecified, there is no maximum.
59    pub max_transfer_blocks: Option<u32>,
60    #[doc(hidden)]
61    pub __source_breaking: fidl::marker::SourceBreaking,
62}
63
64impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Options {}
65
66#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
67pub struct ControllerMarker;
68
69impl fidl::endpoints::ProtocolMarker for ControllerMarker {
70    type Proxy = ControllerProxy;
71    type RequestStream = ControllerRequestStream;
72    #[cfg(target_os = "fuchsia")]
73    type SynchronousProxy = ControllerSynchronousProxy;
74
75    const DEBUG_NAME: &'static str = "(anonymous) Controller";
76}
77pub type ControllerCreateResult =
78    Result<(fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>, fidl::EventPair), i32>;
79
80pub trait ControllerProxyInterface: Send + Sync {
81    type CreateResponseFut: std::future::Future<Output = Result<ControllerCreateResult, fidl::Error>>
82        + Send;
83    fn r#create(&self, payload: Options) -> Self::CreateResponseFut;
84}
85#[derive(Debug)]
86#[cfg(target_os = "fuchsia")]
87pub struct ControllerSynchronousProxy {
88    client: fidl::client::sync::Client,
89}
90
91#[cfg(target_os = "fuchsia")]
92impl fidl::endpoints::SynchronousProxy for ControllerSynchronousProxy {
93    type Proxy = ControllerProxy;
94    type Protocol = ControllerMarker;
95
96    fn from_channel(inner: fidl::Channel) -> Self {
97        Self::new(inner)
98    }
99
100    fn into_channel(self) -> fidl::Channel {
101        self.client.into_channel()
102    }
103
104    fn as_channel(&self) -> &fidl::Channel {
105        self.client.as_channel()
106    }
107}
108
109#[cfg(target_os = "fuchsia")]
110impl ControllerSynchronousProxy {
111    pub fn new(channel: fidl::Channel) -> Self {
112        let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
113        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
114    }
115
116    pub fn into_channel(self) -> fidl::Channel {
117        self.client.into_channel()
118    }
119
120    /// Waits until an event arrives and returns it. It is safe for other
121    /// threads to make concurrent requests while waiting for an event.
122    pub fn wait_for_event(
123        &self,
124        deadline: zx::MonotonicInstant,
125    ) -> Result<ControllerEvent, fidl::Error> {
126        ControllerEvent::decode(self.client.wait_for_event(deadline)?)
127    }
128
129    /// Initializes a new Ramdisk instance with the specified options.  Returns an outgoing
130    /// directory for the ramdisk which will export the Ramdisk and
131    /// fuchsia.hardware.block.volume.Volume protocols.
132    pub fn r#create(
133        &self,
134        mut payload: Options,
135        ___deadline: zx::MonotonicInstant,
136    ) -> Result<ControllerCreateResult, fidl::Error> {
137        let _response = self
138            .client
139            .send_query::<Options, fidl::encoding::ResultType<ControllerCreateResponse, i32>>(
140                &mut payload,
141                0x70c20e8a741fecb8,
142                fidl::encoding::DynamicFlags::empty(),
143                ___deadline,
144            )?;
145        Ok(_response.map(|x| (x.outgoing, x.lifeline)))
146    }
147}
148
149#[cfg(target_os = "fuchsia")]
150impl From<ControllerSynchronousProxy> for zx::Handle {
151    fn from(value: ControllerSynchronousProxy) -> Self {
152        value.into_channel().into()
153    }
154}
155
156#[cfg(target_os = "fuchsia")]
157impl From<fidl::Channel> for ControllerSynchronousProxy {
158    fn from(value: fidl::Channel) -> Self {
159        Self::new(value)
160    }
161}
162
163#[cfg(target_os = "fuchsia")]
164impl fidl::endpoints::FromClient for ControllerSynchronousProxy {
165    type Protocol = ControllerMarker;
166
167    fn from_client(value: fidl::endpoints::ClientEnd<ControllerMarker>) -> Self {
168        Self::new(value.into_channel())
169    }
170}
171
172#[derive(Debug, Clone)]
173pub struct ControllerProxy {
174    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
175}
176
177impl fidl::endpoints::Proxy for ControllerProxy {
178    type Protocol = ControllerMarker;
179
180    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
181        Self::new(inner)
182    }
183
184    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
185        self.client.into_channel().map_err(|client| Self { client })
186    }
187
188    fn as_channel(&self) -> &::fidl::AsyncChannel {
189        self.client.as_channel()
190    }
191}
192
193impl ControllerProxy {
194    /// Create a new Proxy for fuchsia.hardware.ramdisk/Controller.
195    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
196        let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
197        Self { client: fidl::client::Client::new(channel, protocol_name) }
198    }
199
200    /// Get a Stream of events from the remote end of the protocol.
201    ///
202    /// # Panics
203    ///
204    /// Panics if the event stream was already taken.
205    pub fn take_event_stream(&self) -> ControllerEventStream {
206        ControllerEventStream { event_receiver: self.client.take_event_receiver() }
207    }
208
209    /// Initializes a new Ramdisk instance with the specified options.  Returns an outgoing
210    /// directory for the ramdisk which will export the Ramdisk and
211    /// fuchsia.hardware.block.volume.Volume protocols.
212    pub fn r#create(
213        &self,
214        mut payload: Options,
215    ) -> fidl::client::QueryResponseFut<
216        ControllerCreateResult,
217        fidl::encoding::DefaultFuchsiaResourceDialect,
218    > {
219        ControllerProxyInterface::r#create(self, payload)
220    }
221}
222
223impl ControllerProxyInterface for ControllerProxy {
224    type CreateResponseFut = fidl::client::QueryResponseFut<
225        ControllerCreateResult,
226        fidl::encoding::DefaultFuchsiaResourceDialect,
227    >;
228    fn r#create(&self, mut payload: Options) -> Self::CreateResponseFut {
229        fn _decode(
230            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
231        ) -> Result<ControllerCreateResult, fidl::Error> {
232            let _response = fidl::client::decode_transaction_body::<
233                fidl::encoding::ResultType<ControllerCreateResponse, i32>,
234                fidl::encoding::DefaultFuchsiaResourceDialect,
235                0x70c20e8a741fecb8,
236            >(_buf?)?;
237            Ok(_response.map(|x| (x.outgoing, x.lifeline)))
238        }
239        self.client.send_query_and_decode::<Options, ControllerCreateResult>(
240            &mut payload,
241            0x70c20e8a741fecb8,
242            fidl::encoding::DynamicFlags::empty(),
243            _decode,
244        )
245    }
246}
247
248pub struct ControllerEventStream {
249    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
250}
251
252impl std::marker::Unpin for ControllerEventStream {}
253
254impl futures::stream::FusedStream for ControllerEventStream {
255    fn is_terminated(&self) -> bool {
256        self.event_receiver.is_terminated()
257    }
258}
259
260impl futures::Stream for ControllerEventStream {
261    type Item = Result<ControllerEvent, fidl::Error>;
262
263    fn poll_next(
264        mut self: std::pin::Pin<&mut Self>,
265        cx: &mut std::task::Context<'_>,
266    ) -> std::task::Poll<Option<Self::Item>> {
267        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
268            &mut self.event_receiver,
269            cx
270        )?) {
271            Some(buf) => std::task::Poll::Ready(Some(ControllerEvent::decode(buf))),
272            None => std::task::Poll::Ready(None),
273        }
274    }
275}
276
277#[derive(Debug)]
278pub enum ControllerEvent {
279    #[non_exhaustive]
280    _UnknownEvent {
281        /// Ordinal of the event that was sent.
282        ordinal: u64,
283    },
284}
285
286impl ControllerEvent {
287    /// Decodes a message buffer as a [`ControllerEvent`].
288    fn decode(
289        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
290    ) -> Result<ControllerEvent, fidl::Error> {
291        let (bytes, _handles) = buf.split_mut();
292        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
293        debug_assert_eq!(tx_header.tx_id, 0);
294        match tx_header.ordinal {
295            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
296                Ok(ControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
297            }
298            _ => Err(fidl::Error::UnknownOrdinal {
299                ordinal: tx_header.ordinal,
300                protocol_name: <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
301            }),
302        }
303    }
304}
305
306/// A Stream of incoming requests for fuchsia.hardware.ramdisk/Controller.
307pub struct ControllerRequestStream {
308    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
309    is_terminated: bool,
310}
311
312impl std::marker::Unpin for ControllerRequestStream {}
313
314impl futures::stream::FusedStream for ControllerRequestStream {
315    fn is_terminated(&self) -> bool {
316        self.is_terminated
317    }
318}
319
320impl fidl::endpoints::RequestStream for ControllerRequestStream {
321    type Protocol = ControllerMarker;
322    type ControlHandle = ControllerControlHandle;
323
324    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
325        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
326    }
327
328    fn control_handle(&self) -> Self::ControlHandle {
329        ControllerControlHandle { inner: self.inner.clone() }
330    }
331
332    fn into_inner(
333        self,
334    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
335    {
336        (self.inner, self.is_terminated)
337    }
338
339    fn from_inner(
340        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
341        is_terminated: bool,
342    ) -> Self {
343        Self { inner, is_terminated }
344    }
345}
346
347impl futures::Stream for ControllerRequestStream {
348    type Item = Result<ControllerRequest, fidl::Error>;
349
350    fn poll_next(
351        mut self: std::pin::Pin<&mut Self>,
352        cx: &mut std::task::Context<'_>,
353    ) -> std::task::Poll<Option<Self::Item>> {
354        let this = &mut *self;
355        if this.inner.check_shutdown(cx) {
356            this.is_terminated = true;
357            return std::task::Poll::Ready(None);
358        }
359        if this.is_terminated {
360            panic!("polled ControllerRequestStream after completion");
361        }
362        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
363            |bytes, handles| {
364                match this.inner.channel().read_etc(cx, bytes, handles) {
365                    std::task::Poll::Ready(Ok(())) => {}
366                    std::task::Poll::Pending => return std::task::Poll::Pending,
367                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
368                        this.is_terminated = true;
369                        return std::task::Poll::Ready(None);
370                    }
371                    std::task::Poll::Ready(Err(e)) => {
372                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
373                            e.into(),
374                        ))))
375                    }
376                }
377
378                // A message has been received from the channel
379                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
380
381                std::task::Poll::Ready(Some(match header.ordinal {
382                    0x70c20e8a741fecb8 => {
383                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
384                        let mut req = fidl::new_empty!(
385                            Options,
386                            fidl::encoding::DefaultFuchsiaResourceDialect
387                        );
388                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Options>(&header, _body_bytes, handles, &mut req)?;
389                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
390                        Ok(ControllerRequest::Create {
391                            payload: req,
392                            responder: ControllerCreateResponder {
393                                control_handle: std::mem::ManuallyDrop::new(control_handle),
394                                tx_id: header.tx_id,
395                            },
396                        })
397                    }
398                    _ if header.tx_id == 0
399                        && header
400                            .dynamic_flags()
401                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
402                    {
403                        Ok(ControllerRequest::_UnknownMethod {
404                            ordinal: header.ordinal,
405                            control_handle: ControllerControlHandle { inner: this.inner.clone() },
406                            method_type: fidl::MethodType::OneWay,
407                        })
408                    }
409                    _ if header
410                        .dynamic_flags()
411                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
412                    {
413                        this.inner.send_framework_err(
414                            fidl::encoding::FrameworkErr::UnknownMethod,
415                            header.tx_id,
416                            header.ordinal,
417                            header.dynamic_flags(),
418                            (bytes, handles),
419                        )?;
420                        Ok(ControllerRequest::_UnknownMethod {
421                            ordinal: header.ordinal,
422                            control_handle: ControllerControlHandle { inner: this.inner.clone() },
423                            method_type: fidl::MethodType::TwoWay,
424                        })
425                    }
426                    _ => Err(fidl::Error::UnknownOrdinal {
427                        ordinal: header.ordinal,
428                        protocol_name:
429                            <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
430                    }),
431                }))
432            },
433        )
434    }
435}
436
437#[derive(Debug)]
438pub enum ControllerRequest {
439    /// Initializes a new Ramdisk instance with the specified options.  Returns an outgoing
440    /// directory for the ramdisk which will export the Ramdisk and
441    /// fuchsia.hardware.block.volume.Volume protocols.
442    Create { payload: Options, responder: ControllerCreateResponder },
443    /// An interaction was received which does not match any known method.
444    #[non_exhaustive]
445    _UnknownMethod {
446        /// Ordinal of the method that was called.
447        ordinal: u64,
448        control_handle: ControllerControlHandle,
449        method_type: fidl::MethodType,
450    },
451}
452
453impl ControllerRequest {
454    #[allow(irrefutable_let_patterns)]
455    pub fn into_create(self) -> Option<(Options, ControllerCreateResponder)> {
456        if let ControllerRequest::Create { payload, responder } = self {
457            Some((payload, responder))
458        } else {
459            None
460        }
461    }
462
463    /// Name of the method defined in FIDL
464    pub fn method_name(&self) -> &'static str {
465        match *self {
466            ControllerRequest::Create { .. } => "create",
467            ControllerRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
468                "unknown one-way method"
469            }
470            ControllerRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
471                "unknown two-way method"
472            }
473        }
474    }
475}
476
477#[derive(Debug, Clone)]
478pub struct ControllerControlHandle {
479    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
480}
481
482impl fidl::endpoints::ControlHandle for ControllerControlHandle {
483    fn shutdown(&self) {
484        self.inner.shutdown()
485    }
486    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
487        self.inner.shutdown_with_epitaph(status)
488    }
489
490    fn is_closed(&self) -> bool {
491        self.inner.channel().is_closed()
492    }
493    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
494        self.inner.channel().on_closed()
495    }
496
497    #[cfg(target_os = "fuchsia")]
498    fn signal_peer(
499        &self,
500        clear_mask: zx::Signals,
501        set_mask: zx::Signals,
502    ) -> Result<(), zx_status::Status> {
503        use fidl::Peered;
504        self.inner.channel().signal_peer(clear_mask, set_mask)
505    }
506}
507
508impl ControllerControlHandle {}
509
510#[must_use = "FIDL methods require a response to be sent"]
511#[derive(Debug)]
512pub struct ControllerCreateResponder {
513    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
514    tx_id: u32,
515}
516
517/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
518/// if the responder is dropped without sending a response, so that the client
519/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
520impl std::ops::Drop for ControllerCreateResponder {
521    fn drop(&mut self) {
522        self.control_handle.shutdown();
523        // Safety: drops once, never accessed again
524        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
525    }
526}
527
528impl fidl::endpoints::Responder for ControllerCreateResponder {
529    type ControlHandle = ControllerControlHandle;
530
531    fn control_handle(&self) -> &ControllerControlHandle {
532        &self.control_handle
533    }
534
535    fn drop_without_shutdown(mut self) {
536        // Safety: drops once, never accessed again due to mem::forget
537        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
538        // Prevent Drop from running (which would shut down the channel)
539        std::mem::forget(self);
540    }
541}
542
543impl ControllerCreateResponder {
544    /// Sends a response to the FIDL transaction.
545    ///
546    /// Sets the channel to shutdown if an error occurs.
547    pub fn send(
548        self,
549        mut result: Result<
550            (fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>, fidl::EventPair),
551            i32,
552        >,
553    ) -> Result<(), fidl::Error> {
554        let _result = self.send_raw(result);
555        if _result.is_err() {
556            self.control_handle.shutdown();
557        }
558        self.drop_without_shutdown();
559        _result
560    }
561
562    /// Similar to "send" but does not shutdown the channel if an error occurs.
563    pub fn send_no_shutdown_on_err(
564        self,
565        mut result: Result<
566            (fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>, fidl::EventPair),
567            i32,
568        >,
569    ) -> Result<(), fidl::Error> {
570        let _result = self.send_raw(result);
571        self.drop_without_shutdown();
572        _result
573    }
574
575    fn send_raw(
576        &self,
577        mut result: Result<
578            (fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>, fidl::EventPair),
579            i32,
580        >,
581    ) -> Result<(), fidl::Error> {
582        self.control_handle.inner.send::<fidl::encoding::ResultType<ControllerCreateResponse, i32>>(
583            result,
584            self.tx_id,
585            0x70c20e8a741fecb8,
586            fidl::encoding::DynamicFlags::empty(),
587        )
588    }
589}
590
591#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
592pub struct RamdiskMarker;
593
594impl fidl::endpoints::ProtocolMarker for RamdiskMarker {
595    type Proxy = RamdiskProxy;
596    type RequestStream = RamdiskRequestStream;
597    #[cfg(target_os = "fuchsia")]
598    type SynchronousProxy = RamdiskSynchronousProxy;
599
600    const DEBUG_NAME: &'static str = "fuchsia.hardware.ramdisk.Ramdisk";
601}
602impl fidl::endpoints::DiscoverableProtocolMarker for RamdiskMarker {}
603
604pub trait RamdiskProxyInterface: Send + Sync {
605    type SetFlagsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
606    fn r#set_flags(&self, flags: RamdiskFlag) -> Self::SetFlagsResponseFut;
607    type WakeResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
608    fn r#wake(&self) -> Self::WakeResponseFut;
609    type SleepAfterResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
610    fn r#sleep_after(&self, count: u64) -> Self::SleepAfterResponseFut;
611    type GetBlockCountsResponseFut: std::future::Future<Output = Result<BlockWriteCounts, fidl::Error>>
612        + Send;
613    fn r#get_block_counts(&self) -> Self::GetBlockCountsResponseFut;
614}
615#[derive(Debug)]
616#[cfg(target_os = "fuchsia")]
617pub struct RamdiskSynchronousProxy {
618    client: fidl::client::sync::Client,
619}
620
621#[cfg(target_os = "fuchsia")]
622impl fidl::endpoints::SynchronousProxy for RamdiskSynchronousProxy {
623    type Proxy = RamdiskProxy;
624    type Protocol = RamdiskMarker;
625
626    fn from_channel(inner: fidl::Channel) -> Self {
627        Self::new(inner)
628    }
629
630    fn into_channel(self) -> fidl::Channel {
631        self.client.into_channel()
632    }
633
634    fn as_channel(&self) -> &fidl::Channel {
635        self.client.as_channel()
636    }
637}
638
639#[cfg(target_os = "fuchsia")]
640impl RamdiskSynchronousProxy {
641    pub fn new(channel: fidl::Channel) -> Self {
642        let protocol_name = <RamdiskMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
643        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
644    }
645
646    pub fn into_channel(self) -> fidl::Channel {
647        self.client.into_channel()
648    }
649
650    /// Waits until an event arrives and returns it. It is safe for other
651    /// threads to make concurrent requests while waiting for an event.
652    pub fn wait_for_event(
653        &self,
654        deadline: zx::MonotonicInstant,
655    ) -> Result<RamdiskEvent, fidl::Error> {
656        RamdiskEvent::decode(self.client.wait_for_event(deadline)?)
657    }
658
659    /// Sets any of the `RAMDISK_FLAG_*` flags.
660    pub fn r#set_flags(
661        &self,
662        mut flags: RamdiskFlag,
663        ___deadline: zx::MonotonicInstant,
664    ) -> Result<(), fidl::Error> {
665        let _response =
666            self.client.send_query::<RamdiskSetFlagsRequest, fidl::encoding::EmptyPayload>(
667                (flags,),
668                0x1ac23f463dc2c8de,
669                fidl::encoding::DynamicFlags::empty(),
670                ___deadline,
671            )?;
672        Ok(_response)
673    }
674
675    /// Wakes a ramdisk, if it was sleeping.
676    ///
677    /// Resets the block counts being stored by the ramdisk.
678    pub fn r#wake(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
679        let _response =
680            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
681                (),
682                0x1b2142ad9617bde4,
683                fidl::encoding::DynamicFlags::empty(),
684                ___deadline,
685            )?;
686        Ok(_response)
687    }
688
689    /// Causes the ramdisk to sleep after `count` blocks are written successfully.
690    /// After `count` blocks are written, requests either wait for the ramdisk to
691    /// be awoken (if RESUME_ON_WAKE has been set), or begin failing immediately.
692    ///
693    /// Resets the block counts being stored by the ramdisk.
694    pub fn r#sleep_after(
695        &self,
696        mut count: u64,
697        ___deadline: zx::MonotonicInstant,
698    ) -> Result<(), fidl::Error> {
699        let _response =
700            self.client.send_query::<RamdiskSleepAfterRequest, fidl::encoding::EmptyPayload>(
701                (count,),
702                0x38cafa087fbc1195,
703                fidl::encoding::DynamicFlags::empty(),
704                ___deadline,
705            )?;
706        Ok(_response)
707    }
708
709    /// Returns the number of write requests since the last call to either
710    /// "SleepAfter" or "Wake".
711    pub fn r#get_block_counts(
712        &self,
713        ___deadline: zx::MonotonicInstant,
714    ) -> Result<BlockWriteCounts, fidl::Error> {
715        let _response =
716            self.client.send_query::<fidl::encoding::EmptyPayload, RamdiskGetBlockCountsResponse>(
717                (),
718                0x346b0058ac937682,
719                fidl::encoding::DynamicFlags::empty(),
720                ___deadline,
721            )?;
722        Ok(_response.counts)
723    }
724}
725
726#[cfg(target_os = "fuchsia")]
727impl From<RamdiskSynchronousProxy> for zx::Handle {
728    fn from(value: RamdiskSynchronousProxy) -> Self {
729        value.into_channel().into()
730    }
731}
732
733#[cfg(target_os = "fuchsia")]
734impl From<fidl::Channel> for RamdiskSynchronousProxy {
735    fn from(value: fidl::Channel) -> Self {
736        Self::new(value)
737    }
738}
739
740#[cfg(target_os = "fuchsia")]
741impl fidl::endpoints::FromClient for RamdiskSynchronousProxy {
742    type Protocol = RamdiskMarker;
743
744    fn from_client(value: fidl::endpoints::ClientEnd<RamdiskMarker>) -> Self {
745        Self::new(value.into_channel())
746    }
747}
748
749#[derive(Debug, Clone)]
750pub struct RamdiskProxy {
751    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
752}
753
754impl fidl::endpoints::Proxy for RamdiskProxy {
755    type Protocol = RamdiskMarker;
756
757    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
758        Self::new(inner)
759    }
760
761    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
762        self.client.into_channel().map_err(|client| Self { client })
763    }
764
765    fn as_channel(&self) -> &::fidl::AsyncChannel {
766        self.client.as_channel()
767    }
768}
769
770impl RamdiskProxy {
771    /// Create a new Proxy for fuchsia.hardware.ramdisk/Ramdisk.
772    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
773        let protocol_name = <RamdiskMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
774        Self { client: fidl::client::Client::new(channel, protocol_name) }
775    }
776
777    /// Get a Stream of events from the remote end of the protocol.
778    ///
779    /// # Panics
780    ///
781    /// Panics if the event stream was already taken.
782    pub fn take_event_stream(&self) -> RamdiskEventStream {
783        RamdiskEventStream { event_receiver: self.client.take_event_receiver() }
784    }
785
786    /// Sets any of the `RAMDISK_FLAG_*` flags.
787    pub fn r#set_flags(
788        &self,
789        mut flags: RamdiskFlag,
790    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
791        RamdiskProxyInterface::r#set_flags(self, flags)
792    }
793
794    /// Wakes a ramdisk, if it was sleeping.
795    ///
796    /// Resets the block counts being stored by the ramdisk.
797    pub fn r#wake(
798        &self,
799    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
800        RamdiskProxyInterface::r#wake(self)
801    }
802
803    /// Causes the ramdisk to sleep after `count` blocks are written successfully.
804    /// After `count` blocks are written, requests either wait for the ramdisk to
805    /// be awoken (if RESUME_ON_WAKE has been set), or begin failing immediately.
806    ///
807    /// Resets the block counts being stored by the ramdisk.
808    pub fn r#sleep_after(
809        &self,
810        mut count: u64,
811    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
812        RamdiskProxyInterface::r#sleep_after(self, count)
813    }
814
815    /// Returns the number of write requests since the last call to either
816    /// "SleepAfter" or "Wake".
817    pub fn r#get_block_counts(
818        &self,
819    ) -> fidl::client::QueryResponseFut<
820        BlockWriteCounts,
821        fidl::encoding::DefaultFuchsiaResourceDialect,
822    > {
823        RamdiskProxyInterface::r#get_block_counts(self)
824    }
825}
826
827impl RamdiskProxyInterface for RamdiskProxy {
828    type SetFlagsResponseFut =
829        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
830    fn r#set_flags(&self, mut flags: RamdiskFlag) -> Self::SetFlagsResponseFut {
831        fn _decode(
832            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
833        ) -> Result<(), fidl::Error> {
834            let _response = fidl::client::decode_transaction_body::<
835                fidl::encoding::EmptyPayload,
836                fidl::encoding::DefaultFuchsiaResourceDialect,
837                0x1ac23f463dc2c8de,
838            >(_buf?)?;
839            Ok(_response)
840        }
841        self.client.send_query_and_decode::<RamdiskSetFlagsRequest, ()>(
842            (flags,),
843            0x1ac23f463dc2c8de,
844            fidl::encoding::DynamicFlags::empty(),
845            _decode,
846        )
847    }
848
849    type WakeResponseFut =
850        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
851    fn r#wake(&self) -> Self::WakeResponseFut {
852        fn _decode(
853            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
854        ) -> Result<(), fidl::Error> {
855            let _response = fidl::client::decode_transaction_body::<
856                fidl::encoding::EmptyPayload,
857                fidl::encoding::DefaultFuchsiaResourceDialect,
858                0x1b2142ad9617bde4,
859            >(_buf?)?;
860            Ok(_response)
861        }
862        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
863            (),
864            0x1b2142ad9617bde4,
865            fidl::encoding::DynamicFlags::empty(),
866            _decode,
867        )
868    }
869
870    type SleepAfterResponseFut =
871        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
872    fn r#sleep_after(&self, mut count: u64) -> Self::SleepAfterResponseFut {
873        fn _decode(
874            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
875        ) -> Result<(), fidl::Error> {
876            let _response = fidl::client::decode_transaction_body::<
877                fidl::encoding::EmptyPayload,
878                fidl::encoding::DefaultFuchsiaResourceDialect,
879                0x38cafa087fbc1195,
880            >(_buf?)?;
881            Ok(_response)
882        }
883        self.client.send_query_and_decode::<RamdiskSleepAfterRequest, ()>(
884            (count,),
885            0x38cafa087fbc1195,
886            fidl::encoding::DynamicFlags::empty(),
887            _decode,
888        )
889    }
890
891    type GetBlockCountsResponseFut = fidl::client::QueryResponseFut<
892        BlockWriteCounts,
893        fidl::encoding::DefaultFuchsiaResourceDialect,
894    >;
895    fn r#get_block_counts(&self) -> Self::GetBlockCountsResponseFut {
896        fn _decode(
897            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
898        ) -> Result<BlockWriteCounts, fidl::Error> {
899            let _response = fidl::client::decode_transaction_body::<
900                RamdiskGetBlockCountsResponse,
901                fidl::encoding::DefaultFuchsiaResourceDialect,
902                0x346b0058ac937682,
903            >(_buf?)?;
904            Ok(_response.counts)
905        }
906        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, BlockWriteCounts>(
907            (),
908            0x346b0058ac937682,
909            fidl::encoding::DynamicFlags::empty(),
910            _decode,
911        )
912    }
913}
914
915pub struct RamdiskEventStream {
916    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
917}
918
919impl std::marker::Unpin for RamdiskEventStream {}
920
921impl futures::stream::FusedStream for RamdiskEventStream {
922    fn is_terminated(&self) -> bool {
923        self.event_receiver.is_terminated()
924    }
925}
926
927impl futures::Stream for RamdiskEventStream {
928    type Item = Result<RamdiskEvent, fidl::Error>;
929
930    fn poll_next(
931        mut self: std::pin::Pin<&mut Self>,
932        cx: &mut std::task::Context<'_>,
933    ) -> std::task::Poll<Option<Self::Item>> {
934        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
935            &mut self.event_receiver,
936            cx
937        )?) {
938            Some(buf) => std::task::Poll::Ready(Some(RamdiskEvent::decode(buf))),
939            None => std::task::Poll::Ready(None),
940        }
941    }
942}
943
944#[derive(Debug)]
945pub enum RamdiskEvent {}
946
947impl RamdiskEvent {
948    /// Decodes a message buffer as a [`RamdiskEvent`].
949    fn decode(
950        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
951    ) -> Result<RamdiskEvent, fidl::Error> {
952        let (bytes, _handles) = buf.split_mut();
953        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
954        debug_assert_eq!(tx_header.tx_id, 0);
955        match tx_header.ordinal {
956            _ => Err(fidl::Error::UnknownOrdinal {
957                ordinal: tx_header.ordinal,
958                protocol_name: <RamdiskMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
959            }),
960        }
961    }
962}
963
964/// A Stream of incoming requests for fuchsia.hardware.ramdisk/Ramdisk.
965pub struct RamdiskRequestStream {
966    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
967    is_terminated: bool,
968}
969
970impl std::marker::Unpin for RamdiskRequestStream {}
971
972impl futures::stream::FusedStream for RamdiskRequestStream {
973    fn is_terminated(&self) -> bool {
974        self.is_terminated
975    }
976}
977
978impl fidl::endpoints::RequestStream for RamdiskRequestStream {
979    type Protocol = RamdiskMarker;
980    type ControlHandle = RamdiskControlHandle;
981
982    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
983        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
984    }
985
986    fn control_handle(&self) -> Self::ControlHandle {
987        RamdiskControlHandle { inner: self.inner.clone() }
988    }
989
990    fn into_inner(
991        self,
992    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
993    {
994        (self.inner, self.is_terminated)
995    }
996
997    fn from_inner(
998        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
999        is_terminated: bool,
1000    ) -> Self {
1001        Self { inner, is_terminated }
1002    }
1003}
1004
1005impl futures::Stream for RamdiskRequestStream {
1006    type Item = Result<RamdiskRequest, fidl::Error>;
1007
1008    fn poll_next(
1009        mut self: std::pin::Pin<&mut Self>,
1010        cx: &mut std::task::Context<'_>,
1011    ) -> std::task::Poll<Option<Self::Item>> {
1012        let this = &mut *self;
1013        if this.inner.check_shutdown(cx) {
1014            this.is_terminated = true;
1015            return std::task::Poll::Ready(None);
1016        }
1017        if this.is_terminated {
1018            panic!("polled RamdiskRequestStream after completion");
1019        }
1020        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1021            |bytes, handles| {
1022                match this.inner.channel().read_etc(cx, bytes, handles) {
1023                    std::task::Poll::Ready(Ok(())) => {}
1024                    std::task::Poll::Pending => return std::task::Poll::Pending,
1025                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1026                        this.is_terminated = true;
1027                        return std::task::Poll::Ready(None);
1028                    }
1029                    std::task::Poll::Ready(Err(e)) => {
1030                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1031                            e.into(),
1032                        ))))
1033                    }
1034                }
1035
1036                // A message has been received from the channel
1037                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1038
1039                std::task::Poll::Ready(Some(match header.ordinal {
1040                    0x1ac23f463dc2c8de => {
1041                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1042                        let mut req = fidl::new_empty!(
1043                            RamdiskSetFlagsRequest,
1044                            fidl::encoding::DefaultFuchsiaResourceDialect
1045                        );
1046                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RamdiskSetFlagsRequest>(&header, _body_bytes, handles, &mut req)?;
1047                        let control_handle = RamdiskControlHandle { inner: this.inner.clone() };
1048                        Ok(RamdiskRequest::SetFlags {
1049                            flags: req.flags,
1050
1051                            responder: RamdiskSetFlagsResponder {
1052                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1053                                tx_id: header.tx_id,
1054                            },
1055                        })
1056                    }
1057                    0x1b2142ad9617bde4 => {
1058                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1059                        let mut req = fidl::new_empty!(
1060                            fidl::encoding::EmptyPayload,
1061                            fidl::encoding::DefaultFuchsiaResourceDialect
1062                        );
1063                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1064                        let control_handle = RamdiskControlHandle { inner: this.inner.clone() };
1065                        Ok(RamdiskRequest::Wake {
1066                            responder: RamdiskWakeResponder {
1067                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1068                                tx_id: header.tx_id,
1069                            },
1070                        })
1071                    }
1072                    0x38cafa087fbc1195 => {
1073                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1074                        let mut req = fidl::new_empty!(
1075                            RamdiskSleepAfterRequest,
1076                            fidl::encoding::DefaultFuchsiaResourceDialect
1077                        );
1078                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RamdiskSleepAfterRequest>(&header, _body_bytes, handles, &mut req)?;
1079                        let control_handle = RamdiskControlHandle { inner: this.inner.clone() };
1080                        Ok(RamdiskRequest::SleepAfter {
1081                            count: req.count,
1082
1083                            responder: RamdiskSleepAfterResponder {
1084                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1085                                tx_id: header.tx_id,
1086                            },
1087                        })
1088                    }
1089                    0x346b0058ac937682 => {
1090                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1091                        let mut req = fidl::new_empty!(
1092                            fidl::encoding::EmptyPayload,
1093                            fidl::encoding::DefaultFuchsiaResourceDialect
1094                        );
1095                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1096                        let control_handle = RamdiskControlHandle { inner: this.inner.clone() };
1097                        Ok(RamdiskRequest::GetBlockCounts {
1098                            responder: RamdiskGetBlockCountsResponder {
1099                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1100                                tx_id: header.tx_id,
1101                            },
1102                        })
1103                    }
1104                    _ => Err(fidl::Error::UnknownOrdinal {
1105                        ordinal: header.ordinal,
1106                        protocol_name:
1107                            <RamdiskMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1108                    }),
1109                }))
1110            },
1111        )
1112    }
1113}
1114
1115/// The protocol for interacting with a instance of a ramdisk.
1116#[derive(Debug)]
1117pub enum RamdiskRequest {
1118    /// Sets any of the `RAMDISK_FLAG_*` flags.
1119    SetFlags { flags: RamdiskFlag, responder: RamdiskSetFlagsResponder },
1120    /// Wakes a ramdisk, if it was sleeping.
1121    ///
1122    /// Resets the block counts being stored by the ramdisk.
1123    Wake { responder: RamdiskWakeResponder },
1124    /// Causes the ramdisk to sleep after `count` blocks are written successfully.
1125    /// After `count` blocks are written, requests either wait for the ramdisk to
1126    /// be awoken (if RESUME_ON_WAKE has been set), or begin failing immediately.
1127    ///
1128    /// Resets the block counts being stored by the ramdisk.
1129    SleepAfter { count: u64, responder: RamdiskSleepAfterResponder },
1130    /// Returns the number of write requests since the last call to either
1131    /// "SleepAfter" or "Wake".
1132    GetBlockCounts { responder: RamdiskGetBlockCountsResponder },
1133}
1134
1135impl RamdiskRequest {
1136    #[allow(irrefutable_let_patterns)]
1137    pub fn into_set_flags(self) -> Option<(RamdiskFlag, RamdiskSetFlagsResponder)> {
1138        if let RamdiskRequest::SetFlags { flags, responder } = self {
1139            Some((flags, responder))
1140        } else {
1141            None
1142        }
1143    }
1144
1145    #[allow(irrefutable_let_patterns)]
1146    pub fn into_wake(self) -> Option<(RamdiskWakeResponder)> {
1147        if let RamdiskRequest::Wake { responder } = self {
1148            Some((responder))
1149        } else {
1150            None
1151        }
1152    }
1153
1154    #[allow(irrefutable_let_patterns)]
1155    pub fn into_sleep_after(self) -> Option<(u64, RamdiskSleepAfterResponder)> {
1156        if let RamdiskRequest::SleepAfter { count, responder } = self {
1157            Some((count, responder))
1158        } else {
1159            None
1160        }
1161    }
1162
1163    #[allow(irrefutable_let_patterns)]
1164    pub fn into_get_block_counts(self) -> Option<(RamdiskGetBlockCountsResponder)> {
1165        if let RamdiskRequest::GetBlockCounts { responder } = self {
1166            Some((responder))
1167        } else {
1168            None
1169        }
1170    }
1171
1172    /// Name of the method defined in FIDL
1173    pub fn method_name(&self) -> &'static str {
1174        match *self {
1175            RamdiskRequest::SetFlags { .. } => "set_flags",
1176            RamdiskRequest::Wake { .. } => "wake",
1177            RamdiskRequest::SleepAfter { .. } => "sleep_after",
1178            RamdiskRequest::GetBlockCounts { .. } => "get_block_counts",
1179        }
1180    }
1181}
1182
1183#[derive(Debug, Clone)]
1184pub struct RamdiskControlHandle {
1185    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1186}
1187
1188impl fidl::endpoints::ControlHandle for RamdiskControlHandle {
1189    fn shutdown(&self) {
1190        self.inner.shutdown()
1191    }
1192    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1193        self.inner.shutdown_with_epitaph(status)
1194    }
1195
1196    fn is_closed(&self) -> bool {
1197        self.inner.channel().is_closed()
1198    }
1199    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1200        self.inner.channel().on_closed()
1201    }
1202
1203    #[cfg(target_os = "fuchsia")]
1204    fn signal_peer(
1205        &self,
1206        clear_mask: zx::Signals,
1207        set_mask: zx::Signals,
1208    ) -> Result<(), zx_status::Status> {
1209        use fidl::Peered;
1210        self.inner.channel().signal_peer(clear_mask, set_mask)
1211    }
1212}
1213
1214impl RamdiskControlHandle {}
1215
1216#[must_use = "FIDL methods require a response to be sent"]
1217#[derive(Debug)]
1218pub struct RamdiskSetFlagsResponder {
1219    control_handle: std::mem::ManuallyDrop<RamdiskControlHandle>,
1220    tx_id: u32,
1221}
1222
1223/// Set the the channel to be shutdown (see [`RamdiskControlHandle::shutdown`])
1224/// if the responder is dropped without sending a response, so that the client
1225/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1226impl std::ops::Drop for RamdiskSetFlagsResponder {
1227    fn drop(&mut self) {
1228        self.control_handle.shutdown();
1229        // Safety: drops once, never accessed again
1230        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1231    }
1232}
1233
1234impl fidl::endpoints::Responder for RamdiskSetFlagsResponder {
1235    type ControlHandle = RamdiskControlHandle;
1236
1237    fn control_handle(&self) -> &RamdiskControlHandle {
1238        &self.control_handle
1239    }
1240
1241    fn drop_without_shutdown(mut self) {
1242        // Safety: drops once, never accessed again due to mem::forget
1243        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1244        // Prevent Drop from running (which would shut down the channel)
1245        std::mem::forget(self);
1246    }
1247}
1248
1249impl RamdiskSetFlagsResponder {
1250    /// Sends a response to the FIDL transaction.
1251    ///
1252    /// Sets the channel to shutdown if an error occurs.
1253    pub fn send(self) -> Result<(), fidl::Error> {
1254        let _result = self.send_raw();
1255        if _result.is_err() {
1256            self.control_handle.shutdown();
1257        }
1258        self.drop_without_shutdown();
1259        _result
1260    }
1261
1262    /// Similar to "send" but does not shutdown the channel if an error occurs.
1263    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1264        let _result = self.send_raw();
1265        self.drop_without_shutdown();
1266        _result
1267    }
1268
1269    fn send_raw(&self) -> Result<(), fidl::Error> {
1270        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1271            (),
1272            self.tx_id,
1273            0x1ac23f463dc2c8de,
1274            fidl::encoding::DynamicFlags::empty(),
1275        )
1276    }
1277}
1278
1279#[must_use = "FIDL methods require a response to be sent"]
1280#[derive(Debug)]
1281pub struct RamdiskWakeResponder {
1282    control_handle: std::mem::ManuallyDrop<RamdiskControlHandle>,
1283    tx_id: u32,
1284}
1285
1286/// Set the the channel to be shutdown (see [`RamdiskControlHandle::shutdown`])
1287/// if the responder is dropped without sending a response, so that the client
1288/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1289impl std::ops::Drop for RamdiskWakeResponder {
1290    fn drop(&mut self) {
1291        self.control_handle.shutdown();
1292        // Safety: drops once, never accessed again
1293        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1294    }
1295}
1296
1297impl fidl::endpoints::Responder for RamdiskWakeResponder {
1298    type ControlHandle = RamdiskControlHandle;
1299
1300    fn control_handle(&self) -> &RamdiskControlHandle {
1301        &self.control_handle
1302    }
1303
1304    fn drop_without_shutdown(mut self) {
1305        // Safety: drops once, never accessed again due to mem::forget
1306        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1307        // Prevent Drop from running (which would shut down the channel)
1308        std::mem::forget(self);
1309    }
1310}
1311
1312impl RamdiskWakeResponder {
1313    /// Sends a response to the FIDL transaction.
1314    ///
1315    /// Sets the channel to shutdown if an error occurs.
1316    pub fn send(self) -> Result<(), fidl::Error> {
1317        let _result = self.send_raw();
1318        if _result.is_err() {
1319            self.control_handle.shutdown();
1320        }
1321        self.drop_without_shutdown();
1322        _result
1323    }
1324
1325    /// Similar to "send" but does not shutdown the channel if an error occurs.
1326    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1327        let _result = self.send_raw();
1328        self.drop_without_shutdown();
1329        _result
1330    }
1331
1332    fn send_raw(&self) -> Result<(), fidl::Error> {
1333        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1334            (),
1335            self.tx_id,
1336            0x1b2142ad9617bde4,
1337            fidl::encoding::DynamicFlags::empty(),
1338        )
1339    }
1340}
1341
1342#[must_use = "FIDL methods require a response to be sent"]
1343#[derive(Debug)]
1344pub struct RamdiskSleepAfterResponder {
1345    control_handle: std::mem::ManuallyDrop<RamdiskControlHandle>,
1346    tx_id: u32,
1347}
1348
1349/// Set the the channel to be shutdown (see [`RamdiskControlHandle::shutdown`])
1350/// if the responder is dropped without sending a response, so that the client
1351/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1352impl std::ops::Drop for RamdiskSleepAfterResponder {
1353    fn drop(&mut self) {
1354        self.control_handle.shutdown();
1355        // Safety: drops once, never accessed again
1356        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1357    }
1358}
1359
1360impl fidl::endpoints::Responder for RamdiskSleepAfterResponder {
1361    type ControlHandle = RamdiskControlHandle;
1362
1363    fn control_handle(&self) -> &RamdiskControlHandle {
1364        &self.control_handle
1365    }
1366
1367    fn drop_without_shutdown(mut self) {
1368        // Safety: drops once, never accessed again due to mem::forget
1369        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1370        // Prevent Drop from running (which would shut down the channel)
1371        std::mem::forget(self);
1372    }
1373}
1374
1375impl RamdiskSleepAfterResponder {
1376    /// Sends a response to the FIDL transaction.
1377    ///
1378    /// Sets the channel to shutdown if an error occurs.
1379    pub fn send(self) -> Result<(), fidl::Error> {
1380        let _result = self.send_raw();
1381        if _result.is_err() {
1382            self.control_handle.shutdown();
1383        }
1384        self.drop_without_shutdown();
1385        _result
1386    }
1387
1388    /// Similar to "send" but does not shutdown the channel if an error occurs.
1389    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1390        let _result = self.send_raw();
1391        self.drop_without_shutdown();
1392        _result
1393    }
1394
1395    fn send_raw(&self) -> Result<(), fidl::Error> {
1396        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1397            (),
1398            self.tx_id,
1399            0x38cafa087fbc1195,
1400            fidl::encoding::DynamicFlags::empty(),
1401        )
1402    }
1403}
1404
1405#[must_use = "FIDL methods require a response to be sent"]
1406#[derive(Debug)]
1407pub struct RamdiskGetBlockCountsResponder {
1408    control_handle: std::mem::ManuallyDrop<RamdiskControlHandle>,
1409    tx_id: u32,
1410}
1411
1412/// Set the the channel to be shutdown (see [`RamdiskControlHandle::shutdown`])
1413/// if the responder is dropped without sending a response, so that the client
1414/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1415impl std::ops::Drop for RamdiskGetBlockCountsResponder {
1416    fn drop(&mut self) {
1417        self.control_handle.shutdown();
1418        // Safety: drops once, never accessed again
1419        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1420    }
1421}
1422
1423impl fidl::endpoints::Responder for RamdiskGetBlockCountsResponder {
1424    type ControlHandle = RamdiskControlHandle;
1425
1426    fn control_handle(&self) -> &RamdiskControlHandle {
1427        &self.control_handle
1428    }
1429
1430    fn drop_without_shutdown(mut self) {
1431        // Safety: drops once, never accessed again due to mem::forget
1432        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1433        // Prevent Drop from running (which would shut down the channel)
1434        std::mem::forget(self);
1435    }
1436}
1437
1438impl RamdiskGetBlockCountsResponder {
1439    /// Sends a response to the FIDL transaction.
1440    ///
1441    /// Sets the channel to shutdown if an error occurs.
1442    pub fn send(self, mut counts: &BlockWriteCounts) -> Result<(), fidl::Error> {
1443        let _result = self.send_raw(counts);
1444        if _result.is_err() {
1445            self.control_handle.shutdown();
1446        }
1447        self.drop_without_shutdown();
1448        _result
1449    }
1450
1451    /// Similar to "send" but does not shutdown the channel if an error occurs.
1452    pub fn send_no_shutdown_on_err(self, mut counts: &BlockWriteCounts) -> Result<(), fidl::Error> {
1453        let _result = self.send_raw(counts);
1454        self.drop_without_shutdown();
1455        _result
1456    }
1457
1458    fn send_raw(&self, mut counts: &BlockWriteCounts) -> Result<(), fidl::Error> {
1459        self.control_handle.inner.send::<RamdiskGetBlockCountsResponse>(
1460            (counts,),
1461            self.tx_id,
1462            0x346b0058ac937682,
1463            fidl::encoding::DynamicFlags::empty(),
1464        )
1465    }
1466}
1467
1468#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1469pub struct RamdiskControllerMarker;
1470
1471impl fidl::endpoints::ProtocolMarker for RamdiskControllerMarker {
1472    type Proxy = RamdiskControllerProxy;
1473    type RequestStream = RamdiskControllerRequestStream;
1474    #[cfg(target_os = "fuchsia")]
1475    type SynchronousProxy = RamdiskControllerSynchronousProxy;
1476
1477    const DEBUG_NAME: &'static str = "(anonymous) RamdiskController";
1478}
1479pub type RamdiskControllerCreateResult = Result<Option<String>, i32>;
1480pub type RamdiskControllerCreateFromVmoResult = Result<Option<String>, i32>;
1481pub type RamdiskControllerCreateFromVmoWithParamsResult = Result<Option<String>, i32>;
1482
1483pub trait RamdiskControllerProxyInterface: Send + Sync {
1484    type CreateResponseFut: std::future::Future<Output = Result<RamdiskControllerCreateResult, fidl::Error>>
1485        + Send;
1486    fn r#create(
1487        &self,
1488        block_size: u64,
1489        block_count: u64,
1490        type_guid: Option<&Guid>,
1491    ) -> Self::CreateResponseFut;
1492    type CreateFromVmoResponseFut: std::future::Future<Output = Result<RamdiskControllerCreateFromVmoResult, fidl::Error>>
1493        + Send;
1494    fn r#create_from_vmo(&self, vmo: fidl::Vmo) -> Self::CreateFromVmoResponseFut;
1495    type CreateFromVmoWithParamsResponseFut: std::future::Future<
1496            Output = Result<RamdiskControllerCreateFromVmoWithParamsResult, fidl::Error>,
1497        > + Send;
1498    fn r#create_from_vmo_with_params(
1499        &self,
1500        vmo: fidl::Vmo,
1501        block_size: u64,
1502        type_guid: Option<&Guid>,
1503    ) -> Self::CreateFromVmoWithParamsResponseFut;
1504}
1505#[derive(Debug)]
1506#[cfg(target_os = "fuchsia")]
1507pub struct RamdiskControllerSynchronousProxy {
1508    client: fidl::client::sync::Client,
1509}
1510
1511#[cfg(target_os = "fuchsia")]
1512impl fidl::endpoints::SynchronousProxy for RamdiskControllerSynchronousProxy {
1513    type Proxy = RamdiskControllerProxy;
1514    type Protocol = RamdiskControllerMarker;
1515
1516    fn from_channel(inner: fidl::Channel) -> Self {
1517        Self::new(inner)
1518    }
1519
1520    fn into_channel(self) -> fidl::Channel {
1521        self.client.into_channel()
1522    }
1523
1524    fn as_channel(&self) -> &fidl::Channel {
1525        self.client.as_channel()
1526    }
1527}
1528
1529#[cfg(target_os = "fuchsia")]
1530impl RamdiskControllerSynchronousProxy {
1531    pub fn new(channel: fidl::Channel) -> Self {
1532        let protocol_name =
1533            <RamdiskControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1534        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1535    }
1536
1537    pub fn into_channel(self) -> fidl::Channel {
1538        self.client.into_channel()
1539    }
1540
1541    /// Waits until an event arrives and returns it. It is safe for other
1542    /// threads to make concurrent requests while waiting for an event.
1543    pub fn wait_for_event(
1544        &self,
1545        deadline: zx::MonotonicInstant,
1546    ) -> Result<RamdiskControllerEvent, fidl::Error> {
1547        RamdiskControllerEvent::decode(self.client.wait_for_event(deadline)?)
1548    }
1549
1550    /// Initializes a new Ramdisk instance with the provided block size and block count.
1551    /// Takes an optional `type_guid`, which may be queried from the ramdisk instance.
1552    pub fn r#create(
1553        &self,
1554        mut block_size: u64,
1555        mut block_count: u64,
1556        mut type_guid: Option<&Guid>,
1557        ___deadline: zx::MonotonicInstant,
1558    ) -> Result<RamdiskControllerCreateResult, fidl::Error> {
1559        let _response = self.client.send_query::<
1560            RamdiskControllerCreateRequest,
1561            fidl::encoding::ResultType<RamdiskControllerCreateResponse, i32>,
1562        >(
1563            (block_size, block_count, type_guid,),
1564            0x21cd800cc5ff7c3f,
1565            fidl::encoding::DynamicFlags::empty(),
1566            ___deadline,
1567        )?;
1568        Ok(_response.map(|x| x.name))
1569    }
1570
1571    /// Initializes a new Ramdisk instance from a VMO. Uses a block size of `PAGE_SIZE`,
1572    /// and derives the block count from the size of the VMO.
1573    pub fn r#create_from_vmo(
1574        &self,
1575        mut vmo: fidl::Vmo,
1576        ___deadline: zx::MonotonicInstant,
1577    ) -> Result<RamdiskControllerCreateFromVmoResult, fidl::Error> {
1578        let _response = self.client.send_query::<
1579            RamdiskControllerCreateFromVmoRequest,
1580            fidl::encoding::ResultType<RamdiskControllerCreateFromVmoResponse, i32>,
1581        >(
1582            (vmo,),
1583            0x5d37434da8f680b4,
1584            fidl::encoding::DynamicFlags::empty(),
1585            ___deadline,
1586        )?;
1587        Ok(_response.map(|x| x.name))
1588    }
1589
1590    /// Same as CreateFromVmo, but with the given `block_size` and optional `type_guid`. If
1591    /// `block_size` is zero, `PAGE_SIZE` will be used as `block_size`.
1592    pub fn r#create_from_vmo_with_params(
1593        &self,
1594        mut vmo: fidl::Vmo,
1595        mut block_size: u64,
1596        mut type_guid: Option<&Guid>,
1597        ___deadline: zx::MonotonicInstant,
1598    ) -> Result<RamdiskControllerCreateFromVmoWithParamsResult, fidl::Error> {
1599        let _response = self.client.send_query::<
1600            RamdiskControllerCreateFromVmoWithParamsRequest,
1601            fidl::encoding::ResultType<RamdiskControllerCreateFromVmoWithParamsResponse, i32>,
1602        >(
1603            (vmo, block_size, type_guid,),
1604            0x776dd021e9e6677e,
1605            fidl::encoding::DynamicFlags::empty(),
1606            ___deadline,
1607        )?;
1608        Ok(_response.map(|x| x.name))
1609    }
1610}
1611
1612#[cfg(target_os = "fuchsia")]
1613impl From<RamdiskControllerSynchronousProxy> for zx::Handle {
1614    fn from(value: RamdiskControllerSynchronousProxy) -> Self {
1615        value.into_channel().into()
1616    }
1617}
1618
1619#[cfg(target_os = "fuchsia")]
1620impl From<fidl::Channel> for RamdiskControllerSynchronousProxy {
1621    fn from(value: fidl::Channel) -> Self {
1622        Self::new(value)
1623    }
1624}
1625
1626#[cfg(target_os = "fuchsia")]
1627impl fidl::endpoints::FromClient for RamdiskControllerSynchronousProxy {
1628    type Protocol = RamdiskControllerMarker;
1629
1630    fn from_client(value: fidl::endpoints::ClientEnd<RamdiskControllerMarker>) -> Self {
1631        Self::new(value.into_channel())
1632    }
1633}
1634
1635#[derive(Debug, Clone)]
1636pub struct RamdiskControllerProxy {
1637    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1638}
1639
1640impl fidl::endpoints::Proxy for RamdiskControllerProxy {
1641    type Protocol = RamdiskControllerMarker;
1642
1643    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1644        Self::new(inner)
1645    }
1646
1647    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1648        self.client.into_channel().map_err(|client| Self { client })
1649    }
1650
1651    fn as_channel(&self) -> &::fidl::AsyncChannel {
1652        self.client.as_channel()
1653    }
1654}
1655
1656impl RamdiskControllerProxy {
1657    /// Create a new Proxy for fuchsia.hardware.ramdisk/RamdiskController.
1658    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1659        let protocol_name =
1660            <RamdiskControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1661        Self { client: fidl::client::Client::new(channel, protocol_name) }
1662    }
1663
1664    /// Get a Stream of events from the remote end of the protocol.
1665    ///
1666    /// # Panics
1667    ///
1668    /// Panics if the event stream was already taken.
1669    pub fn take_event_stream(&self) -> RamdiskControllerEventStream {
1670        RamdiskControllerEventStream { event_receiver: self.client.take_event_receiver() }
1671    }
1672
1673    /// Initializes a new Ramdisk instance with the provided block size and block count.
1674    /// Takes an optional `type_guid`, which may be queried from the ramdisk instance.
1675    pub fn r#create(
1676        &self,
1677        mut block_size: u64,
1678        mut block_count: u64,
1679        mut type_guid: Option<&Guid>,
1680    ) -> fidl::client::QueryResponseFut<
1681        RamdiskControllerCreateResult,
1682        fidl::encoding::DefaultFuchsiaResourceDialect,
1683    > {
1684        RamdiskControllerProxyInterface::r#create(self, block_size, block_count, type_guid)
1685    }
1686
1687    /// Initializes a new Ramdisk instance from a VMO. Uses a block size of `PAGE_SIZE`,
1688    /// and derives the block count from the size of the VMO.
1689    pub fn r#create_from_vmo(
1690        &self,
1691        mut vmo: fidl::Vmo,
1692    ) -> fidl::client::QueryResponseFut<
1693        RamdiskControllerCreateFromVmoResult,
1694        fidl::encoding::DefaultFuchsiaResourceDialect,
1695    > {
1696        RamdiskControllerProxyInterface::r#create_from_vmo(self, vmo)
1697    }
1698
1699    /// Same as CreateFromVmo, but with the given `block_size` and optional `type_guid`. If
1700    /// `block_size` is zero, `PAGE_SIZE` will be used as `block_size`.
1701    pub fn r#create_from_vmo_with_params(
1702        &self,
1703        mut vmo: fidl::Vmo,
1704        mut block_size: u64,
1705        mut type_guid: Option<&Guid>,
1706    ) -> fidl::client::QueryResponseFut<
1707        RamdiskControllerCreateFromVmoWithParamsResult,
1708        fidl::encoding::DefaultFuchsiaResourceDialect,
1709    > {
1710        RamdiskControllerProxyInterface::r#create_from_vmo_with_params(
1711            self, vmo, block_size, type_guid,
1712        )
1713    }
1714}
1715
1716impl RamdiskControllerProxyInterface for RamdiskControllerProxy {
1717    type CreateResponseFut = fidl::client::QueryResponseFut<
1718        RamdiskControllerCreateResult,
1719        fidl::encoding::DefaultFuchsiaResourceDialect,
1720    >;
1721    fn r#create(
1722        &self,
1723        mut block_size: u64,
1724        mut block_count: u64,
1725        mut type_guid: Option<&Guid>,
1726    ) -> Self::CreateResponseFut {
1727        fn _decode(
1728            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1729        ) -> Result<RamdiskControllerCreateResult, fidl::Error> {
1730            let _response = fidl::client::decode_transaction_body::<
1731                fidl::encoding::ResultType<RamdiskControllerCreateResponse, i32>,
1732                fidl::encoding::DefaultFuchsiaResourceDialect,
1733                0x21cd800cc5ff7c3f,
1734            >(_buf?)?;
1735            Ok(_response.map(|x| x.name))
1736        }
1737        self.client
1738            .send_query_and_decode::<RamdiskControllerCreateRequest, RamdiskControllerCreateResult>(
1739                (block_size, block_count, type_guid),
1740                0x21cd800cc5ff7c3f,
1741                fidl::encoding::DynamicFlags::empty(),
1742                _decode,
1743            )
1744    }
1745
1746    type CreateFromVmoResponseFut = fidl::client::QueryResponseFut<
1747        RamdiskControllerCreateFromVmoResult,
1748        fidl::encoding::DefaultFuchsiaResourceDialect,
1749    >;
1750    fn r#create_from_vmo(&self, mut vmo: fidl::Vmo) -> Self::CreateFromVmoResponseFut {
1751        fn _decode(
1752            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1753        ) -> Result<RamdiskControllerCreateFromVmoResult, fidl::Error> {
1754            let _response = fidl::client::decode_transaction_body::<
1755                fidl::encoding::ResultType<RamdiskControllerCreateFromVmoResponse, i32>,
1756                fidl::encoding::DefaultFuchsiaResourceDialect,
1757                0x5d37434da8f680b4,
1758            >(_buf?)?;
1759            Ok(_response.map(|x| x.name))
1760        }
1761        self.client.send_query_and_decode::<
1762            RamdiskControllerCreateFromVmoRequest,
1763            RamdiskControllerCreateFromVmoResult,
1764        >(
1765            (vmo,),
1766            0x5d37434da8f680b4,
1767            fidl::encoding::DynamicFlags::empty(),
1768            _decode,
1769        )
1770    }
1771
1772    type CreateFromVmoWithParamsResponseFut = fidl::client::QueryResponseFut<
1773        RamdiskControllerCreateFromVmoWithParamsResult,
1774        fidl::encoding::DefaultFuchsiaResourceDialect,
1775    >;
1776    fn r#create_from_vmo_with_params(
1777        &self,
1778        mut vmo: fidl::Vmo,
1779        mut block_size: u64,
1780        mut type_guid: Option<&Guid>,
1781    ) -> Self::CreateFromVmoWithParamsResponseFut {
1782        fn _decode(
1783            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1784        ) -> Result<RamdiskControllerCreateFromVmoWithParamsResult, fidl::Error> {
1785            let _response = fidl::client::decode_transaction_body::<
1786                fidl::encoding::ResultType<RamdiskControllerCreateFromVmoWithParamsResponse, i32>,
1787                fidl::encoding::DefaultFuchsiaResourceDialect,
1788                0x776dd021e9e6677e,
1789            >(_buf?)?;
1790            Ok(_response.map(|x| x.name))
1791        }
1792        self.client.send_query_and_decode::<
1793            RamdiskControllerCreateFromVmoWithParamsRequest,
1794            RamdiskControllerCreateFromVmoWithParamsResult,
1795        >(
1796            (vmo, block_size, type_guid,),
1797            0x776dd021e9e6677e,
1798            fidl::encoding::DynamicFlags::empty(),
1799            _decode,
1800        )
1801    }
1802}
1803
1804pub struct RamdiskControllerEventStream {
1805    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1806}
1807
1808impl std::marker::Unpin for RamdiskControllerEventStream {}
1809
1810impl futures::stream::FusedStream for RamdiskControllerEventStream {
1811    fn is_terminated(&self) -> bool {
1812        self.event_receiver.is_terminated()
1813    }
1814}
1815
1816impl futures::Stream for RamdiskControllerEventStream {
1817    type Item = Result<RamdiskControllerEvent, fidl::Error>;
1818
1819    fn poll_next(
1820        mut self: std::pin::Pin<&mut Self>,
1821        cx: &mut std::task::Context<'_>,
1822    ) -> std::task::Poll<Option<Self::Item>> {
1823        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1824            &mut self.event_receiver,
1825            cx
1826        )?) {
1827            Some(buf) => std::task::Poll::Ready(Some(RamdiskControllerEvent::decode(buf))),
1828            None => std::task::Poll::Ready(None),
1829        }
1830    }
1831}
1832
1833#[derive(Debug)]
1834pub enum RamdiskControllerEvent {}
1835
1836impl RamdiskControllerEvent {
1837    /// Decodes a message buffer as a [`RamdiskControllerEvent`].
1838    fn decode(
1839        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1840    ) -> Result<RamdiskControllerEvent, fidl::Error> {
1841        let (bytes, _handles) = buf.split_mut();
1842        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1843        debug_assert_eq!(tx_header.tx_id, 0);
1844        match tx_header.ordinal {
1845            _ => Err(fidl::Error::UnknownOrdinal {
1846                ordinal: tx_header.ordinal,
1847                protocol_name:
1848                    <RamdiskControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1849            }),
1850        }
1851    }
1852}
1853
1854/// A Stream of incoming requests for fuchsia.hardware.ramdisk/RamdiskController.
1855pub struct RamdiskControllerRequestStream {
1856    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1857    is_terminated: bool,
1858}
1859
1860impl std::marker::Unpin for RamdiskControllerRequestStream {}
1861
1862impl futures::stream::FusedStream for RamdiskControllerRequestStream {
1863    fn is_terminated(&self) -> bool {
1864        self.is_terminated
1865    }
1866}
1867
1868impl fidl::endpoints::RequestStream for RamdiskControllerRequestStream {
1869    type Protocol = RamdiskControllerMarker;
1870    type ControlHandle = RamdiskControllerControlHandle;
1871
1872    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1873        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1874    }
1875
1876    fn control_handle(&self) -> Self::ControlHandle {
1877        RamdiskControllerControlHandle { inner: self.inner.clone() }
1878    }
1879
1880    fn into_inner(
1881        self,
1882    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1883    {
1884        (self.inner, self.is_terminated)
1885    }
1886
1887    fn from_inner(
1888        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1889        is_terminated: bool,
1890    ) -> Self {
1891        Self { inner, is_terminated }
1892    }
1893}
1894
1895impl futures::Stream for RamdiskControllerRequestStream {
1896    type Item = Result<RamdiskControllerRequest, fidl::Error>;
1897
1898    fn poll_next(
1899        mut self: std::pin::Pin<&mut Self>,
1900        cx: &mut std::task::Context<'_>,
1901    ) -> std::task::Poll<Option<Self::Item>> {
1902        let this = &mut *self;
1903        if this.inner.check_shutdown(cx) {
1904            this.is_terminated = true;
1905            return std::task::Poll::Ready(None);
1906        }
1907        if this.is_terminated {
1908            panic!("polled RamdiskControllerRequestStream after completion");
1909        }
1910        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1911            |bytes, handles| {
1912                match this.inner.channel().read_etc(cx, bytes, handles) {
1913                    std::task::Poll::Ready(Ok(())) => {}
1914                    std::task::Poll::Pending => return std::task::Poll::Pending,
1915                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1916                        this.is_terminated = true;
1917                        return std::task::Poll::Ready(None);
1918                    }
1919                    std::task::Poll::Ready(Err(e)) => {
1920                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1921                            e.into(),
1922                        ))))
1923                    }
1924                }
1925
1926                // A message has been received from the channel
1927                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1928
1929                std::task::Poll::Ready(Some(match header.ordinal {
1930                    0x21cd800cc5ff7c3f => {
1931                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1932                        let mut req = fidl::new_empty!(
1933                            RamdiskControllerCreateRequest,
1934                            fidl::encoding::DefaultFuchsiaResourceDialect
1935                        );
1936                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RamdiskControllerCreateRequest>(&header, _body_bytes, handles, &mut req)?;
1937                        let control_handle =
1938                            RamdiskControllerControlHandle { inner: this.inner.clone() };
1939                        Ok(RamdiskControllerRequest::Create {
1940                            block_size: req.block_size,
1941                            block_count: req.block_count,
1942                            type_guid: req.type_guid,
1943
1944                            responder: RamdiskControllerCreateResponder {
1945                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1946                                tx_id: header.tx_id,
1947                            },
1948                        })
1949                    }
1950                    0x5d37434da8f680b4 => {
1951                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1952                        let mut req = fidl::new_empty!(
1953                            RamdiskControllerCreateFromVmoRequest,
1954                            fidl::encoding::DefaultFuchsiaResourceDialect
1955                        );
1956                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RamdiskControllerCreateFromVmoRequest>(&header, _body_bytes, handles, &mut req)?;
1957                        let control_handle =
1958                            RamdiskControllerControlHandle { inner: this.inner.clone() };
1959                        Ok(RamdiskControllerRequest::CreateFromVmo {
1960                            vmo: req.vmo,
1961
1962                            responder: RamdiskControllerCreateFromVmoResponder {
1963                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1964                                tx_id: header.tx_id,
1965                            },
1966                        })
1967                    }
1968                    0x776dd021e9e6677e => {
1969                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1970                        let mut req = fidl::new_empty!(
1971                            RamdiskControllerCreateFromVmoWithParamsRequest,
1972                            fidl::encoding::DefaultFuchsiaResourceDialect
1973                        );
1974                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RamdiskControllerCreateFromVmoWithParamsRequest>(&header, _body_bytes, handles, &mut req)?;
1975                        let control_handle =
1976                            RamdiskControllerControlHandle { inner: this.inner.clone() };
1977                        Ok(RamdiskControllerRequest::CreateFromVmoWithParams {
1978                            vmo: req.vmo,
1979                            block_size: req.block_size,
1980                            type_guid: req.type_guid,
1981
1982                            responder: RamdiskControllerCreateFromVmoWithParamsResponder {
1983                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1984                                tx_id: header.tx_id,
1985                            },
1986                        })
1987                    }
1988                    _ => Err(fidl::Error::UnknownOrdinal {
1989                        ordinal: header.ordinal,
1990                        protocol_name:
1991                            <RamdiskControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1992                    }),
1993                }))
1994            },
1995        )
1996    }
1997}
1998
1999#[derive(Debug)]
2000pub enum RamdiskControllerRequest {
2001    /// Initializes a new Ramdisk instance with the provided block size and block count.
2002    /// Takes an optional `type_guid`, which may be queried from the ramdisk instance.
2003    Create {
2004        block_size: u64,
2005        block_count: u64,
2006        type_guid: Option<Box<Guid>>,
2007        responder: RamdiskControllerCreateResponder,
2008    },
2009    /// Initializes a new Ramdisk instance from a VMO. Uses a block size of `PAGE_SIZE`,
2010    /// and derives the block count from the size of the VMO.
2011    CreateFromVmo { vmo: fidl::Vmo, responder: RamdiskControllerCreateFromVmoResponder },
2012    /// Same as CreateFromVmo, but with the given `block_size` and optional `type_guid`. If
2013    /// `block_size` is zero, `PAGE_SIZE` will be used as `block_size`.
2014    CreateFromVmoWithParams {
2015        vmo: fidl::Vmo,
2016        block_size: u64,
2017        type_guid: Option<Box<Guid>>,
2018        responder: RamdiskControllerCreateFromVmoWithParamsResponder,
2019    },
2020}
2021
2022impl RamdiskControllerRequest {
2023    #[allow(irrefutable_let_patterns)]
2024    pub fn into_create(
2025        self,
2026    ) -> Option<(u64, u64, Option<Box<Guid>>, RamdiskControllerCreateResponder)> {
2027        if let RamdiskControllerRequest::Create { block_size, block_count, type_guid, responder } =
2028            self
2029        {
2030            Some((block_size, block_count, type_guid, responder))
2031        } else {
2032            None
2033        }
2034    }
2035
2036    #[allow(irrefutable_let_patterns)]
2037    pub fn into_create_from_vmo(
2038        self,
2039    ) -> Option<(fidl::Vmo, RamdiskControllerCreateFromVmoResponder)> {
2040        if let RamdiskControllerRequest::CreateFromVmo { vmo, responder } = self {
2041            Some((vmo, responder))
2042        } else {
2043            None
2044        }
2045    }
2046
2047    #[allow(irrefutable_let_patterns)]
2048    pub fn into_create_from_vmo_with_params(
2049        self,
2050    ) -> Option<(
2051        fidl::Vmo,
2052        u64,
2053        Option<Box<Guid>>,
2054        RamdiskControllerCreateFromVmoWithParamsResponder,
2055    )> {
2056        if let RamdiskControllerRequest::CreateFromVmoWithParams {
2057            vmo,
2058            block_size,
2059            type_guid,
2060            responder,
2061        } = self
2062        {
2063            Some((vmo, block_size, type_guid, responder))
2064        } else {
2065            None
2066        }
2067    }
2068
2069    /// Name of the method defined in FIDL
2070    pub fn method_name(&self) -> &'static str {
2071        match *self {
2072            RamdiskControllerRequest::Create { .. } => "create",
2073            RamdiskControllerRequest::CreateFromVmo { .. } => "create_from_vmo",
2074            RamdiskControllerRequest::CreateFromVmoWithParams { .. } => {
2075                "create_from_vmo_with_params"
2076            }
2077        }
2078    }
2079}
2080
2081#[derive(Debug, Clone)]
2082pub struct RamdiskControllerControlHandle {
2083    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2084}
2085
2086impl fidl::endpoints::ControlHandle for RamdiskControllerControlHandle {
2087    fn shutdown(&self) {
2088        self.inner.shutdown()
2089    }
2090    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2091        self.inner.shutdown_with_epitaph(status)
2092    }
2093
2094    fn is_closed(&self) -> bool {
2095        self.inner.channel().is_closed()
2096    }
2097    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2098        self.inner.channel().on_closed()
2099    }
2100
2101    #[cfg(target_os = "fuchsia")]
2102    fn signal_peer(
2103        &self,
2104        clear_mask: zx::Signals,
2105        set_mask: zx::Signals,
2106    ) -> Result<(), zx_status::Status> {
2107        use fidl::Peered;
2108        self.inner.channel().signal_peer(clear_mask, set_mask)
2109    }
2110}
2111
2112impl RamdiskControllerControlHandle {}
2113
2114#[must_use = "FIDL methods require a response to be sent"]
2115#[derive(Debug)]
2116pub struct RamdiskControllerCreateResponder {
2117    control_handle: std::mem::ManuallyDrop<RamdiskControllerControlHandle>,
2118    tx_id: u32,
2119}
2120
2121/// Set the the channel to be shutdown (see [`RamdiskControllerControlHandle::shutdown`])
2122/// if the responder is dropped without sending a response, so that the client
2123/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2124impl std::ops::Drop for RamdiskControllerCreateResponder {
2125    fn drop(&mut self) {
2126        self.control_handle.shutdown();
2127        // Safety: drops once, never accessed again
2128        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2129    }
2130}
2131
2132impl fidl::endpoints::Responder for RamdiskControllerCreateResponder {
2133    type ControlHandle = RamdiskControllerControlHandle;
2134
2135    fn control_handle(&self) -> &RamdiskControllerControlHandle {
2136        &self.control_handle
2137    }
2138
2139    fn drop_without_shutdown(mut self) {
2140        // Safety: drops once, never accessed again due to mem::forget
2141        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2142        // Prevent Drop from running (which would shut down the channel)
2143        std::mem::forget(self);
2144    }
2145}
2146
2147impl RamdiskControllerCreateResponder {
2148    /// Sends a response to the FIDL transaction.
2149    ///
2150    /// Sets the channel to shutdown if an error occurs.
2151    pub fn send(self, mut result: Result<Option<&str>, i32>) -> Result<(), fidl::Error> {
2152        let _result = self.send_raw(result);
2153        if _result.is_err() {
2154            self.control_handle.shutdown();
2155        }
2156        self.drop_without_shutdown();
2157        _result
2158    }
2159
2160    /// Similar to "send" but does not shutdown the channel if an error occurs.
2161    pub fn send_no_shutdown_on_err(
2162        self,
2163        mut result: Result<Option<&str>, i32>,
2164    ) -> Result<(), fidl::Error> {
2165        let _result = self.send_raw(result);
2166        self.drop_without_shutdown();
2167        _result
2168    }
2169
2170    fn send_raw(&self, mut result: Result<Option<&str>, i32>) -> Result<(), fidl::Error> {
2171        self.control_handle
2172            .inner
2173            .send::<fidl::encoding::ResultType<RamdiskControllerCreateResponse, i32>>(
2174                result.map(|name| (name,)),
2175                self.tx_id,
2176                0x21cd800cc5ff7c3f,
2177                fidl::encoding::DynamicFlags::empty(),
2178            )
2179    }
2180}
2181
2182#[must_use = "FIDL methods require a response to be sent"]
2183#[derive(Debug)]
2184pub struct RamdiskControllerCreateFromVmoResponder {
2185    control_handle: std::mem::ManuallyDrop<RamdiskControllerControlHandle>,
2186    tx_id: u32,
2187}
2188
2189/// Set the the channel to be shutdown (see [`RamdiskControllerControlHandle::shutdown`])
2190/// if the responder is dropped without sending a response, so that the client
2191/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2192impl std::ops::Drop for RamdiskControllerCreateFromVmoResponder {
2193    fn drop(&mut self) {
2194        self.control_handle.shutdown();
2195        // Safety: drops once, never accessed again
2196        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2197    }
2198}
2199
2200impl fidl::endpoints::Responder for RamdiskControllerCreateFromVmoResponder {
2201    type ControlHandle = RamdiskControllerControlHandle;
2202
2203    fn control_handle(&self) -> &RamdiskControllerControlHandle {
2204        &self.control_handle
2205    }
2206
2207    fn drop_without_shutdown(mut self) {
2208        // Safety: drops once, never accessed again due to mem::forget
2209        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2210        // Prevent Drop from running (which would shut down the channel)
2211        std::mem::forget(self);
2212    }
2213}
2214
2215impl RamdiskControllerCreateFromVmoResponder {
2216    /// Sends a response to the FIDL transaction.
2217    ///
2218    /// Sets the channel to shutdown if an error occurs.
2219    pub fn send(self, mut result: Result<Option<&str>, i32>) -> Result<(), fidl::Error> {
2220        let _result = self.send_raw(result);
2221        if _result.is_err() {
2222            self.control_handle.shutdown();
2223        }
2224        self.drop_without_shutdown();
2225        _result
2226    }
2227
2228    /// Similar to "send" but does not shutdown the channel if an error occurs.
2229    pub fn send_no_shutdown_on_err(
2230        self,
2231        mut result: Result<Option<&str>, i32>,
2232    ) -> Result<(), fidl::Error> {
2233        let _result = self.send_raw(result);
2234        self.drop_without_shutdown();
2235        _result
2236    }
2237
2238    fn send_raw(&self, mut result: Result<Option<&str>, i32>) -> Result<(), fidl::Error> {
2239        self.control_handle.inner.send::<fidl::encoding::ResultType<
2240            RamdiskControllerCreateFromVmoResponse,
2241            i32,
2242        >>(
2243            result.map(|name| (name,)),
2244            self.tx_id,
2245            0x5d37434da8f680b4,
2246            fidl::encoding::DynamicFlags::empty(),
2247        )
2248    }
2249}
2250
2251#[must_use = "FIDL methods require a response to be sent"]
2252#[derive(Debug)]
2253pub struct RamdiskControllerCreateFromVmoWithParamsResponder {
2254    control_handle: std::mem::ManuallyDrop<RamdiskControllerControlHandle>,
2255    tx_id: u32,
2256}
2257
2258/// Set the the channel to be shutdown (see [`RamdiskControllerControlHandle::shutdown`])
2259/// if the responder is dropped without sending a response, so that the client
2260/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2261impl std::ops::Drop for RamdiskControllerCreateFromVmoWithParamsResponder {
2262    fn drop(&mut self) {
2263        self.control_handle.shutdown();
2264        // Safety: drops once, never accessed again
2265        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2266    }
2267}
2268
2269impl fidl::endpoints::Responder for RamdiskControllerCreateFromVmoWithParamsResponder {
2270    type ControlHandle = RamdiskControllerControlHandle;
2271
2272    fn control_handle(&self) -> &RamdiskControllerControlHandle {
2273        &self.control_handle
2274    }
2275
2276    fn drop_without_shutdown(mut self) {
2277        // Safety: drops once, never accessed again due to mem::forget
2278        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2279        // Prevent Drop from running (which would shut down the channel)
2280        std::mem::forget(self);
2281    }
2282}
2283
2284impl RamdiskControllerCreateFromVmoWithParamsResponder {
2285    /// Sends a response to the FIDL transaction.
2286    ///
2287    /// Sets the channel to shutdown if an error occurs.
2288    pub fn send(self, mut result: Result<Option<&str>, i32>) -> Result<(), fidl::Error> {
2289        let _result = self.send_raw(result);
2290        if _result.is_err() {
2291            self.control_handle.shutdown();
2292        }
2293        self.drop_without_shutdown();
2294        _result
2295    }
2296
2297    /// Similar to "send" but does not shutdown the channel if an error occurs.
2298    pub fn send_no_shutdown_on_err(
2299        self,
2300        mut result: Result<Option<&str>, i32>,
2301    ) -> Result<(), fidl::Error> {
2302        let _result = self.send_raw(result);
2303        self.drop_without_shutdown();
2304        _result
2305    }
2306
2307    fn send_raw(&self, mut result: Result<Option<&str>, i32>) -> Result<(), fidl::Error> {
2308        self.control_handle.inner.send::<fidl::encoding::ResultType<
2309            RamdiskControllerCreateFromVmoWithParamsResponse,
2310            i32,
2311        >>(
2312            result.map(|name| (name,)),
2313            self.tx_id,
2314            0x776dd021e9e6677e,
2315            fidl::encoding::DynamicFlags::empty(),
2316        )
2317    }
2318}
2319
2320#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2321pub struct ServiceMarker;
2322
2323#[cfg(target_os = "fuchsia")]
2324impl fidl::endpoints::ServiceMarker for ServiceMarker {
2325    type Proxy = ServiceProxy;
2326    type Request = ServiceRequest;
2327    const SERVICE_NAME: &'static str = "fuchsia.hardware.ramdisk.Service";
2328}
2329
2330/// A request for one of the member protocols of Service.
2331///
2332/// The v2 ramdisk driver will expose this service.
2333#[cfg(target_os = "fuchsia")]
2334pub enum ServiceRequest {
2335    Controller(ControllerRequestStream),
2336}
2337
2338#[cfg(target_os = "fuchsia")]
2339impl fidl::endpoints::ServiceRequest for ServiceRequest {
2340    type Service = ServiceMarker;
2341
2342    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2343        match name {
2344            "controller" => Self::Controller(
2345                <ControllerRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
2346            ),
2347            _ => panic!("no such member protocol name for service Service"),
2348        }
2349    }
2350
2351    fn member_names() -> &'static [&'static str] {
2352        &["controller"]
2353    }
2354}
2355/// The v2 ramdisk driver will expose this service.
2356#[cfg(target_os = "fuchsia")]
2357pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2358
2359#[cfg(target_os = "fuchsia")]
2360impl fidl::endpoints::ServiceProxy for ServiceProxy {
2361    type Service = ServiceMarker;
2362
2363    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2364        Self(opener)
2365    }
2366}
2367
2368#[cfg(target_os = "fuchsia")]
2369impl ServiceProxy {
2370    pub fn connect_to_controller(&self) -> Result<ControllerProxy, fidl::Error> {
2371        let (proxy, server_end) = fidl::endpoints::create_proxy::<ControllerMarker>();
2372        self.connect_channel_to_controller(server_end)?;
2373        Ok(proxy)
2374    }
2375
2376    /// Like `connect_to_controller`, but returns a sync proxy.
2377    /// See [`Self::connect_to_controller`] for more details.
2378    pub fn connect_to_controller_sync(&self) -> Result<ControllerSynchronousProxy, fidl::Error> {
2379        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ControllerMarker>();
2380        self.connect_channel_to_controller(server_end)?;
2381        Ok(proxy)
2382    }
2383
2384    /// Like `connect_to_controller`, but accepts a server end.
2385    /// See [`Self::connect_to_controller`] for more details.
2386    pub fn connect_channel_to_controller(
2387        &self,
2388        server_end: fidl::endpoints::ServerEnd<ControllerMarker>,
2389    ) -> Result<(), fidl::Error> {
2390        self.0.open_member("controller", server_end.into_channel())
2391    }
2392
2393    pub fn instance_name(&self) -> &str {
2394        self.0.instance_name()
2395    }
2396}
2397
2398mod internal {
2399    use super::*;
2400
2401    impl fidl::encoding::ResourceTypeMarker for ControllerCreateResponse {
2402        type Borrowed<'a> = &'a mut Self;
2403        fn take_or_borrow<'a>(
2404            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2405        ) -> Self::Borrowed<'a> {
2406            value
2407        }
2408    }
2409
2410    unsafe impl fidl::encoding::TypeMarker for ControllerCreateResponse {
2411        type Owned = Self;
2412
2413        #[inline(always)]
2414        fn inline_align(_context: fidl::encoding::Context) -> usize {
2415            4
2416        }
2417
2418        #[inline(always)]
2419        fn inline_size(_context: fidl::encoding::Context) -> usize {
2420            8
2421        }
2422    }
2423
2424    unsafe impl
2425        fidl::encoding::Encode<
2426            ControllerCreateResponse,
2427            fidl::encoding::DefaultFuchsiaResourceDialect,
2428        > for &mut ControllerCreateResponse
2429    {
2430        #[inline]
2431        unsafe fn encode(
2432            self,
2433            encoder: &mut fidl::encoding::Encoder<
2434                '_,
2435                fidl::encoding::DefaultFuchsiaResourceDialect,
2436            >,
2437            offset: usize,
2438            _depth: fidl::encoding::Depth,
2439        ) -> fidl::Result<()> {
2440            encoder.debug_check_bounds::<ControllerCreateResponse>(offset);
2441            // Delegate to tuple encoding.
2442            fidl::encoding::Encode::<
2443                ControllerCreateResponse,
2444                fidl::encoding::DefaultFuchsiaResourceDialect,
2445            >::encode(
2446                (
2447                    <fidl::encoding::Endpoint<
2448                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
2449                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2450                        &mut self.outgoing
2451                    ),
2452                    <fidl::encoding::HandleType<
2453                        fidl::EventPair,
2454                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2455                        2147483648,
2456                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2457                        &mut self.lifeline
2458                    ),
2459                ),
2460                encoder,
2461                offset,
2462                _depth,
2463            )
2464        }
2465    }
2466    unsafe impl<
2467            T0: fidl::encoding::Encode<
2468                fidl::encoding::Endpoint<
2469                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
2470                >,
2471                fidl::encoding::DefaultFuchsiaResourceDialect,
2472            >,
2473            T1: fidl::encoding::Encode<
2474                fidl::encoding::HandleType<
2475                    fidl::EventPair,
2476                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2477                    2147483648,
2478                >,
2479                fidl::encoding::DefaultFuchsiaResourceDialect,
2480            >,
2481        >
2482        fidl::encoding::Encode<
2483            ControllerCreateResponse,
2484            fidl::encoding::DefaultFuchsiaResourceDialect,
2485        > for (T0, T1)
2486    {
2487        #[inline]
2488        unsafe fn encode(
2489            self,
2490            encoder: &mut fidl::encoding::Encoder<
2491                '_,
2492                fidl::encoding::DefaultFuchsiaResourceDialect,
2493            >,
2494            offset: usize,
2495            depth: fidl::encoding::Depth,
2496        ) -> fidl::Result<()> {
2497            encoder.debug_check_bounds::<ControllerCreateResponse>(offset);
2498            // Zero out padding regions. There's no need to apply masks
2499            // because the unmasked parts will be overwritten by fields.
2500            // Write the fields.
2501            self.0.encode(encoder, offset + 0, depth)?;
2502            self.1.encode(encoder, offset + 4, depth)?;
2503            Ok(())
2504        }
2505    }
2506
2507    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2508        for ControllerCreateResponse
2509    {
2510        #[inline(always)]
2511        fn new_empty() -> Self {
2512            Self {
2513                outgoing: fidl::new_empty!(
2514                    fidl::encoding::Endpoint<
2515                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
2516                    >,
2517                    fidl::encoding::DefaultFuchsiaResourceDialect
2518                ),
2519                lifeline: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2520            }
2521        }
2522
2523        #[inline]
2524        unsafe fn decode(
2525            &mut self,
2526            decoder: &mut fidl::encoding::Decoder<
2527                '_,
2528                fidl::encoding::DefaultFuchsiaResourceDialect,
2529            >,
2530            offset: usize,
2531            _depth: fidl::encoding::Depth,
2532        ) -> fidl::Result<()> {
2533            decoder.debug_check_bounds::<Self>(offset);
2534            // Verify that padding bytes are zero.
2535            fidl::decode!(
2536                fidl::encoding::Endpoint<
2537                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
2538                >,
2539                fidl::encoding::DefaultFuchsiaResourceDialect,
2540                &mut self.outgoing,
2541                decoder,
2542                offset + 0,
2543                _depth
2544            )?;
2545            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.lifeline, decoder, offset + 4, _depth)?;
2546            Ok(())
2547        }
2548    }
2549
2550    impl fidl::encoding::ResourceTypeMarker for RamdiskControllerCreateFromVmoRequest {
2551        type Borrowed<'a> = &'a mut Self;
2552        fn take_or_borrow<'a>(
2553            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2554        ) -> Self::Borrowed<'a> {
2555            value
2556        }
2557    }
2558
2559    unsafe impl fidl::encoding::TypeMarker for RamdiskControllerCreateFromVmoRequest {
2560        type Owned = Self;
2561
2562        #[inline(always)]
2563        fn inline_align(_context: fidl::encoding::Context) -> usize {
2564            4
2565        }
2566
2567        #[inline(always)]
2568        fn inline_size(_context: fidl::encoding::Context) -> usize {
2569            4
2570        }
2571    }
2572
2573    unsafe impl
2574        fidl::encoding::Encode<
2575            RamdiskControllerCreateFromVmoRequest,
2576            fidl::encoding::DefaultFuchsiaResourceDialect,
2577        > for &mut RamdiskControllerCreateFromVmoRequest
2578    {
2579        #[inline]
2580        unsafe fn encode(
2581            self,
2582            encoder: &mut fidl::encoding::Encoder<
2583                '_,
2584                fidl::encoding::DefaultFuchsiaResourceDialect,
2585            >,
2586            offset: usize,
2587            _depth: fidl::encoding::Depth,
2588        ) -> fidl::Result<()> {
2589            encoder.debug_check_bounds::<RamdiskControllerCreateFromVmoRequest>(offset);
2590            // Delegate to tuple encoding.
2591            fidl::encoding::Encode::<
2592                RamdiskControllerCreateFromVmoRequest,
2593                fidl::encoding::DefaultFuchsiaResourceDialect,
2594            >::encode(
2595                (<fidl::encoding::HandleType<
2596                    fidl::Vmo,
2597                    { fidl::ObjectType::VMO.into_raw() },
2598                    2147483648,
2599                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2600                    &mut self.vmo
2601                ),),
2602                encoder,
2603                offset,
2604                _depth,
2605            )
2606        }
2607    }
2608    unsafe impl<
2609            T0: fidl::encoding::Encode<
2610                fidl::encoding::HandleType<
2611                    fidl::Vmo,
2612                    { fidl::ObjectType::VMO.into_raw() },
2613                    2147483648,
2614                >,
2615                fidl::encoding::DefaultFuchsiaResourceDialect,
2616            >,
2617        >
2618        fidl::encoding::Encode<
2619            RamdiskControllerCreateFromVmoRequest,
2620            fidl::encoding::DefaultFuchsiaResourceDialect,
2621        > for (T0,)
2622    {
2623        #[inline]
2624        unsafe fn encode(
2625            self,
2626            encoder: &mut fidl::encoding::Encoder<
2627                '_,
2628                fidl::encoding::DefaultFuchsiaResourceDialect,
2629            >,
2630            offset: usize,
2631            depth: fidl::encoding::Depth,
2632        ) -> fidl::Result<()> {
2633            encoder.debug_check_bounds::<RamdiskControllerCreateFromVmoRequest>(offset);
2634            // Zero out padding regions. There's no need to apply masks
2635            // because the unmasked parts will be overwritten by fields.
2636            // Write the fields.
2637            self.0.encode(encoder, offset + 0, depth)?;
2638            Ok(())
2639        }
2640    }
2641
2642    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2643        for RamdiskControllerCreateFromVmoRequest
2644    {
2645        #[inline(always)]
2646        fn new_empty() -> Self {
2647            Self {
2648                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2649            }
2650        }
2651
2652        #[inline]
2653        unsafe fn decode(
2654            &mut self,
2655            decoder: &mut fidl::encoding::Decoder<
2656                '_,
2657                fidl::encoding::DefaultFuchsiaResourceDialect,
2658            >,
2659            offset: usize,
2660            _depth: fidl::encoding::Depth,
2661        ) -> fidl::Result<()> {
2662            decoder.debug_check_bounds::<Self>(offset);
2663            // Verify that padding bytes are zero.
2664            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
2665            Ok(())
2666        }
2667    }
2668
2669    impl fidl::encoding::ResourceTypeMarker for RamdiskControllerCreateFromVmoWithParamsRequest {
2670        type Borrowed<'a> = &'a mut Self;
2671        fn take_or_borrow<'a>(
2672            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2673        ) -> Self::Borrowed<'a> {
2674            value
2675        }
2676    }
2677
2678    unsafe impl fidl::encoding::TypeMarker for RamdiskControllerCreateFromVmoWithParamsRequest {
2679        type Owned = Self;
2680
2681        #[inline(always)]
2682        fn inline_align(_context: fidl::encoding::Context) -> usize {
2683            8
2684        }
2685
2686        #[inline(always)]
2687        fn inline_size(_context: fidl::encoding::Context) -> usize {
2688            24
2689        }
2690    }
2691
2692    unsafe impl
2693        fidl::encoding::Encode<
2694            RamdiskControllerCreateFromVmoWithParamsRequest,
2695            fidl::encoding::DefaultFuchsiaResourceDialect,
2696        > for &mut RamdiskControllerCreateFromVmoWithParamsRequest
2697    {
2698        #[inline]
2699        unsafe fn encode(
2700            self,
2701            encoder: &mut fidl::encoding::Encoder<
2702                '_,
2703                fidl::encoding::DefaultFuchsiaResourceDialect,
2704            >,
2705            offset: usize,
2706            _depth: fidl::encoding::Depth,
2707        ) -> fidl::Result<()> {
2708            encoder.debug_check_bounds::<RamdiskControllerCreateFromVmoWithParamsRequest>(offset);
2709            // Delegate to tuple encoding.
2710            fidl::encoding::Encode::<
2711                RamdiskControllerCreateFromVmoWithParamsRequest,
2712                fidl::encoding::DefaultFuchsiaResourceDialect,
2713            >::encode(
2714                (
2715                    <fidl::encoding::HandleType<
2716                        fidl::Vmo,
2717                        { fidl::ObjectType::VMO.into_raw() },
2718                        2147483648,
2719                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2720                        &mut self.vmo
2721                    ),
2722                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.block_size),
2723                    <fidl::encoding::Boxed<Guid> as fidl::encoding::ValueTypeMarker>::borrow(
2724                        &self.type_guid,
2725                    ),
2726                ),
2727                encoder,
2728                offset,
2729                _depth,
2730            )
2731        }
2732    }
2733    unsafe impl<
2734            T0: fidl::encoding::Encode<
2735                fidl::encoding::HandleType<
2736                    fidl::Vmo,
2737                    { fidl::ObjectType::VMO.into_raw() },
2738                    2147483648,
2739                >,
2740                fidl::encoding::DefaultFuchsiaResourceDialect,
2741            >,
2742            T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
2743            T2: fidl::encoding::Encode<
2744                fidl::encoding::Boxed<Guid>,
2745                fidl::encoding::DefaultFuchsiaResourceDialect,
2746            >,
2747        >
2748        fidl::encoding::Encode<
2749            RamdiskControllerCreateFromVmoWithParamsRequest,
2750            fidl::encoding::DefaultFuchsiaResourceDialect,
2751        > for (T0, T1, T2)
2752    {
2753        #[inline]
2754        unsafe fn encode(
2755            self,
2756            encoder: &mut fidl::encoding::Encoder<
2757                '_,
2758                fidl::encoding::DefaultFuchsiaResourceDialect,
2759            >,
2760            offset: usize,
2761            depth: fidl::encoding::Depth,
2762        ) -> fidl::Result<()> {
2763            encoder.debug_check_bounds::<RamdiskControllerCreateFromVmoWithParamsRequest>(offset);
2764            // Zero out padding regions. There's no need to apply masks
2765            // because the unmasked parts will be overwritten by fields.
2766            unsafe {
2767                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
2768                (ptr as *mut u64).write_unaligned(0);
2769            }
2770            // Write the fields.
2771            self.0.encode(encoder, offset + 0, depth)?;
2772            self.1.encode(encoder, offset + 8, depth)?;
2773            self.2.encode(encoder, offset + 16, depth)?;
2774            Ok(())
2775        }
2776    }
2777
2778    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2779        for RamdiskControllerCreateFromVmoWithParamsRequest
2780    {
2781        #[inline(always)]
2782        fn new_empty() -> Self {
2783            Self {
2784                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2785                block_size: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
2786                type_guid: fidl::new_empty!(
2787                    fidl::encoding::Boxed<Guid>,
2788                    fidl::encoding::DefaultFuchsiaResourceDialect
2789                ),
2790            }
2791        }
2792
2793        #[inline]
2794        unsafe fn decode(
2795            &mut self,
2796            decoder: &mut fidl::encoding::Decoder<
2797                '_,
2798                fidl::encoding::DefaultFuchsiaResourceDialect,
2799            >,
2800            offset: usize,
2801            _depth: fidl::encoding::Depth,
2802        ) -> fidl::Result<()> {
2803            decoder.debug_check_bounds::<Self>(offset);
2804            // Verify that padding bytes are zero.
2805            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
2806            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2807            let mask = 0xffffffff00000000u64;
2808            let maskedval = padval & mask;
2809            if maskedval != 0 {
2810                return Err(fidl::Error::NonZeroPadding {
2811                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
2812                });
2813            }
2814            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
2815            fidl::decode!(
2816                u64,
2817                fidl::encoding::DefaultFuchsiaResourceDialect,
2818                &mut self.block_size,
2819                decoder,
2820                offset + 8,
2821                _depth
2822            )?;
2823            fidl::decode!(
2824                fidl::encoding::Boxed<Guid>,
2825                fidl::encoding::DefaultFuchsiaResourceDialect,
2826                &mut self.type_guid,
2827                decoder,
2828                offset + 16,
2829                _depth
2830            )?;
2831            Ok(())
2832        }
2833    }
2834
2835    impl Options {
2836        #[inline(always)]
2837        fn max_ordinal_present(&self) -> u64 {
2838            if let Some(_) = self.max_transfer_blocks {
2839                return 6;
2840            }
2841            if let Some(_) = self.publish {
2842                return 5;
2843            }
2844            if let Some(_) = self.vmo {
2845                return 4;
2846            }
2847            if let Some(_) = self.type_guid {
2848                return 3;
2849            }
2850            if let Some(_) = self.block_count {
2851                return 2;
2852            }
2853            if let Some(_) = self.block_size {
2854                return 1;
2855            }
2856            0
2857        }
2858    }
2859
2860    impl fidl::encoding::ResourceTypeMarker for Options {
2861        type Borrowed<'a> = &'a mut Self;
2862        fn take_or_borrow<'a>(
2863            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2864        ) -> Self::Borrowed<'a> {
2865            value
2866        }
2867    }
2868
2869    unsafe impl fidl::encoding::TypeMarker for Options {
2870        type Owned = Self;
2871
2872        #[inline(always)]
2873        fn inline_align(_context: fidl::encoding::Context) -> usize {
2874            8
2875        }
2876
2877        #[inline(always)]
2878        fn inline_size(_context: fidl::encoding::Context) -> usize {
2879            16
2880        }
2881    }
2882
2883    unsafe impl fidl::encoding::Encode<Options, fidl::encoding::DefaultFuchsiaResourceDialect>
2884        for &mut Options
2885    {
2886        unsafe fn encode(
2887            self,
2888            encoder: &mut fidl::encoding::Encoder<
2889                '_,
2890                fidl::encoding::DefaultFuchsiaResourceDialect,
2891            >,
2892            offset: usize,
2893            mut depth: fidl::encoding::Depth,
2894        ) -> fidl::Result<()> {
2895            encoder.debug_check_bounds::<Options>(offset);
2896            // Vector header
2897            let max_ordinal: u64 = self.max_ordinal_present();
2898            encoder.write_num(max_ordinal, offset);
2899            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2900            // Calling encoder.out_of_line_offset(0) is not allowed.
2901            if max_ordinal == 0 {
2902                return Ok(());
2903            }
2904            depth.increment()?;
2905            let envelope_size = 8;
2906            let bytes_len = max_ordinal as usize * envelope_size;
2907            #[allow(unused_variables)]
2908            let offset = encoder.out_of_line_offset(bytes_len);
2909            let mut _prev_end_offset: usize = 0;
2910            if 1 > max_ordinal {
2911                return Ok(());
2912            }
2913
2914            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2915            // are envelope_size bytes.
2916            let cur_offset: usize = (1 - 1) * envelope_size;
2917
2918            // Zero reserved fields.
2919            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2920
2921            // Safety:
2922            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2923            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2924            //   envelope_size bytes, there is always sufficient room.
2925            fidl::encoding::encode_in_envelope_optional::<
2926                u32,
2927                fidl::encoding::DefaultFuchsiaResourceDialect,
2928            >(
2929                self.block_size.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
2930                encoder,
2931                offset + cur_offset,
2932                depth,
2933            )?;
2934
2935            _prev_end_offset = cur_offset + envelope_size;
2936            if 2 > max_ordinal {
2937                return Ok(());
2938            }
2939
2940            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2941            // are envelope_size bytes.
2942            let cur_offset: usize = (2 - 1) * envelope_size;
2943
2944            // Zero reserved fields.
2945            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2946
2947            // Safety:
2948            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2949            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2950            //   envelope_size bytes, there is always sufficient room.
2951            fidl::encoding::encode_in_envelope_optional::<
2952                u64,
2953                fidl::encoding::DefaultFuchsiaResourceDialect,
2954            >(
2955                self.block_count.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2956                encoder,
2957                offset + cur_offset,
2958                depth,
2959            )?;
2960
2961            _prev_end_offset = cur_offset + envelope_size;
2962            if 3 > max_ordinal {
2963                return Ok(());
2964            }
2965
2966            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2967            // are envelope_size bytes.
2968            let cur_offset: usize = (3 - 1) * envelope_size;
2969
2970            // Zero reserved fields.
2971            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2972
2973            // Safety:
2974            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2975            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2976            //   envelope_size bytes, there is always sufficient room.
2977            fidl::encoding::encode_in_envelope_optional::<
2978                Guid,
2979                fidl::encoding::DefaultFuchsiaResourceDialect,
2980            >(
2981                self.type_guid.as_ref().map(<Guid as fidl::encoding::ValueTypeMarker>::borrow),
2982                encoder,
2983                offset + cur_offset,
2984                depth,
2985            )?;
2986
2987            _prev_end_offset = cur_offset + envelope_size;
2988            if 4 > max_ordinal {
2989                return Ok(());
2990            }
2991
2992            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2993            // are envelope_size bytes.
2994            let cur_offset: usize = (4 - 1) * envelope_size;
2995
2996            // Zero reserved fields.
2997            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2998
2999            // Safety:
3000            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3001            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3002            //   envelope_size bytes, there is always sufficient room.
3003            fidl::encoding::encode_in_envelope_optional::<
3004                fidl::encoding::HandleType<
3005                    fidl::Vmo,
3006                    { fidl::ObjectType::VMO.into_raw() },
3007                    2147483648,
3008                >,
3009                fidl::encoding::DefaultFuchsiaResourceDialect,
3010            >(
3011                self.vmo.as_mut().map(
3012                    <fidl::encoding::HandleType<
3013                        fidl::Vmo,
3014                        { fidl::ObjectType::VMO.into_raw() },
3015                        2147483648,
3016                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3017                ),
3018                encoder,
3019                offset + cur_offset,
3020                depth,
3021            )?;
3022
3023            _prev_end_offset = cur_offset + envelope_size;
3024            if 5 > max_ordinal {
3025                return Ok(());
3026            }
3027
3028            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3029            // are envelope_size bytes.
3030            let cur_offset: usize = (5 - 1) * envelope_size;
3031
3032            // Zero reserved fields.
3033            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3034
3035            // Safety:
3036            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3037            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3038            //   envelope_size bytes, there is always sufficient room.
3039            fidl::encoding::encode_in_envelope_optional::<
3040                bool,
3041                fidl::encoding::DefaultFuchsiaResourceDialect,
3042            >(
3043                self.publish.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
3044                encoder,
3045                offset + cur_offset,
3046                depth,
3047            )?;
3048
3049            _prev_end_offset = cur_offset + envelope_size;
3050            if 6 > max_ordinal {
3051                return Ok(());
3052            }
3053
3054            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3055            // are envelope_size bytes.
3056            let cur_offset: usize = (6 - 1) * envelope_size;
3057
3058            // Zero reserved fields.
3059            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3060
3061            // Safety:
3062            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3063            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3064            //   envelope_size bytes, there is always sufficient room.
3065            fidl::encoding::encode_in_envelope_optional::<
3066                u32,
3067                fidl::encoding::DefaultFuchsiaResourceDialect,
3068            >(
3069                self.max_transfer_blocks
3070                    .as_ref()
3071                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
3072                encoder,
3073                offset + cur_offset,
3074                depth,
3075            )?;
3076
3077            _prev_end_offset = cur_offset + envelope_size;
3078
3079            Ok(())
3080        }
3081    }
3082
3083    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Options {
3084        #[inline(always)]
3085        fn new_empty() -> Self {
3086            Self::default()
3087        }
3088
3089        unsafe fn decode(
3090            &mut self,
3091            decoder: &mut fidl::encoding::Decoder<
3092                '_,
3093                fidl::encoding::DefaultFuchsiaResourceDialect,
3094            >,
3095            offset: usize,
3096            mut depth: fidl::encoding::Depth,
3097        ) -> fidl::Result<()> {
3098            decoder.debug_check_bounds::<Self>(offset);
3099            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3100                None => return Err(fidl::Error::NotNullable),
3101                Some(len) => len,
3102            };
3103            // Calling decoder.out_of_line_offset(0) is not allowed.
3104            if len == 0 {
3105                return Ok(());
3106            };
3107            depth.increment()?;
3108            let envelope_size = 8;
3109            let bytes_len = len * envelope_size;
3110            let offset = decoder.out_of_line_offset(bytes_len)?;
3111            // Decode the envelope for each type.
3112            let mut _next_ordinal_to_read = 0;
3113            let mut next_offset = offset;
3114            let end_offset = offset + bytes_len;
3115            _next_ordinal_to_read += 1;
3116            if next_offset >= end_offset {
3117                return Ok(());
3118            }
3119
3120            // Decode unknown envelopes for gaps in ordinals.
3121            while _next_ordinal_to_read < 1 {
3122                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3123                _next_ordinal_to_read += 1;
3124                next_offset += envelope_size;
3125            }
3126
3127            let next_out_of_line = decoder.next_out_of_line();
3128            let handles_before = decoder.remaining_handles();
3129            if let Some((inlined, num_bytes, num_handles)) =
3130                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3131            {
3132                let member_inline_size =
3133                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3134                if inlined != (member_inline_size <= 4) {
3135                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3136                }
3137                let inner_offset;
3138                let mut inner_depth = depth.clone();
3139                if inlined {
3140                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3141                    inner_offset = next_offset;
3142                } else {
3143                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3144                    inner_depth.increment()?;
3145                }
3146                let val_ref = self.block_size.get_or_insert_with(|| {
3147                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
3148                });
3149                fidl::decode!(
3150                    u32,
3151                    fidl::encoding::DefaultFuchsiaResourceDialect,
3152                    val_ref,
3153                    decoder,
3154                    inner_offset,
3155                    inner_depth
3156                )?;
3157                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3158                {
3159                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3160                }
3161                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3162                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3163                }
3164            }
3165
3166            next_offset += envelope_size;
3167            _next_ordinal_to_read += 1;
3168            if next_offset >= end_offset {
3169                return Ok(());
3170            }
3171
3172            // Decode unknown envelopes for gaps in ordinals.
3173            while _next_ordinal_to_read < 2 {
3174                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3175                _next_ordinal_to_read += 1;
3176                next_offset += envelope_size;
3177            }
3178
3179            let next_out_of_line = decoder.next_out_of_line();
3180            let handles_before = decoder.remaining_handles();
3181            if let Some((inlined, num_bytes, num_handles)) =
3182                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3183            {
3184                let member_inline_size =
3185                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3186                if inlined != (member_inline_size <= 4) {
3187                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3188                }
3189                let inner_offset;
3190                let mut inner_depth = depth.clone();
3191                if inlined {
3192                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3193                    inner_offset = next_offset;
3194                } else {
3195                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3196                    inner_depth.increment()?;
3197                }
3198                let val_ref = self.block_count.get_or_insert_with(|| {
3199                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
3200                });
3201                fidl::decode!(
3202                    u64,
3203                    fidl::encoding::DefaultFuchsiaResourceDialect,
3204                    val_ref,
3205                    decoder,
3206                    inner_offset,
3207                    inner_depth
3208                )?;
3209                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3210                {
3211                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3212                }
3213                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3214                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3215                }
3216            }
3217
3218            next_offset += envelope_size;
3219            _next_ordinal_to_read += 1;
3220            if next_offset >= end_offset {
3221                return Ok(());
3222            }
3223
3224            // Decode unknown envelopes for gaps in ordinals.
3225            while _next_ordinal_to_read < 3 {
3226                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3227                _next_ordinal_to_read += 1;
3228                next_offset += envelope_size;
3229            }
3230
3231            let next_out_of_line = decoder.next_out_of_line();
3232            let handles_before = decoder.remaining_handles();
3233            if let Some((inlined, num_bytes, num_handles)) =
3234                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3235            {
3236                let member_inline_size =
3237                    <Guid as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3238                if inlined != (member_inline_size <= 4) {
3239                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3240                }
3241                let inner_offset;
3242                let mut inner_depth = depth.clone();
3243                if inlined {
3244                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3245                    inner_offset = next_offset;
3246                } else {
3247                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3248                    inner_depth.increment()?;
3249                }
3250                let val_ref = self.type_guid.get_or_insert_with(|| {
3251                    fidl::new_empty!(Guid, fidl::encoding::DefaultFuchsiaResourceDialect)
3252                });
3253                fidl::decode!(
3254                    Guid,
3255                    fidl::encoding::DefaultFuchsiaResourceDialect,
3256                    val_ref,
3257                    decoder,
3258                    inner_offset,
3259                    inner_depth
3260                )?;
3261                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3262                {
3263                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3264                }
3265                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3266                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3267                }
3268            }
3269
3270            next_offset += envelope_size;
3271            _next_ordinal_to_read += 1;
3272            if next_offset >= end_offset {
3273                return Ok(());
3274            }
3275
3276            // Decode unknown envelopes for gaps in ordinals.
3277            while _next_ordinal_to_read < 4 {
3278                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3279                _next_ordinal_to_read += 1;
3280                next_offset += envelope_size;
3281            }
3282
3283            let next_out_of_line = decoder.next_out_of_line();
3284            let handles_before = decoder.remaining_handles();
3285            if let Some((inlined, num_bytes, num_handles)) =
3286                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3287            {
3288                let member_inline_size = <fidl::encoding::HandleType<
3289                    fidl::Vmo,
3290                    { fidl::ObjectType::VMO.into_raw() },
3291                    2147483648,
3292                > as fidl::encoding::TypeMarker>::inline_size(
3293                    decoder.context
3294                );
3295                if inlined != (member_inline_size <= 4) {
3296                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3297                }
3298                let inner_offset;
3299                let mut inner_depth = depth.clone();
3300                if inlined {
3301                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3302                    inner_offset = next_offset;
3303                } else {
3304                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3305                    inner_depth.increment()?;
3306                }
3307                let val_ref =
3308                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
3309                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3310                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3311                {
3312                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3313                }
3314                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3315                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3316                }
3317            }
3318
3319            next_offset += envelope_size;
3320            _next_ordinal_to_read += 1;
3321            if next_offset >= end_offset {
3322                return Ok(());
3323            }
3324
3325            // Decode unknown envelopes for gaps in ordinals.
3326            while _next_ordinal_to_read < 5 {
3327                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3328                _next_ordinal_to_read += 1;
3329                next_offset += envelope_size;
3330            }
3331
3332            let next_out_of_line = decoder.next_out_of_line();
3333            let handles_before = decoder.remaining_handles();
3334            if let Some((inlined, num_bytes, num_handles)) =
3335                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3336            {
3337                let member_inline_size =
3338                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3339                if inlined != (member_inline_size <= 4) {
3340                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3341                }
3342                let inner_offset;
3343                let mut inner_depth = depth.clone();
3344                if inlined {
3345                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3346                    inner_offset = next_offset;
3347                } else {
3348                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3349                    inner_depth.increment()?;
3350                }
3351                let val_ref = self.publish.get_or_insert_with(|| {
3352                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
3353                });
3354                fidl::decode!(
3355                    bool,
3356                    fidl::encoding::DefaultFuchsiaResourceDialect,
3357                    val_ref,
3358                    decoder,
3359                    inner_offset,
3360                    inner_depth
3361                )?;
3362                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3363                {
3364                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3365                }
3366                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3367                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3368                }
3369            }
3370
3371            next_offset += envelope_size;
3372            _next_ordinal_to_read += 1;
3373            if next_offset >= end_offset {
3374                return Ok(());
3375            }
3376
3377            // Decode unknown envelopes for gaps in ordinals.
3378            while _next_ordinal_to_read < 6 {
3379                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3380                _next_ordinal_to_read += 1;
3381                next_offset += envelope_size;
3382            }
3383
3384            let next_out_of_line = decoder.next_out_of_line();
3385            let handles_before = decoder.remaining_handles();
3386            if let Some((inlined, num_bytes, num_handles)) =
3387                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3388            {
3389                let member_inline_size =
3390                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3391                if inlined != (member_inline_size <= 4) {
3392                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3393                }
3394                let inner_offset;
3395                let mut inner_depth = depth.clone();
3396                if inlined {
3397                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3398                    inner_offset = next_offset;
3399                } else {
3400                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3401                    inner_depth.increment()?;
3402                }
3403                let val_ref = self.max_transfer_blocks.get_or_insert_with(|| {
3404                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
3405                });
3406                fidl::decode!(
3407                    u32,
3408                    fidl::encoding::DefaultFuchsiaResourceDialect,
3409                    val_ref,
3410                    decoder,
3411                    inner_offset,
3412                    inner_depth
3413                )?;
3414                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3415                {
3416                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3417                }
3418                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3419                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3420                }
3421            }
3422
3423            next_offset += envelope_size;
3424
3425            // Decode the remaining unknown envelopes.
3426            while next_offset < end_offset {
3427                _next_ordinal_to_read += 1;
3428                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3429                next_offset += envelope_size;
3430            }
3431
3432            Ok(())
3433        }
3434    }
3435}