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