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