fidl_fuchsia_hardware_block/
fidl_fuchsia_hardware_block.rs

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