Skip to main content

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