fidl_fuchsia_hardware_ramdisk/
fidl_fuchsia_hardware_ramdisk.rs

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