fidl_fuchsia_hardware_block_volume/
fidl_fuchsia_hardware_block_volume.rs

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