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