Skip to main content

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