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