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