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