Skip to main content

fidl_fuchsia_storage_block/
fidl_fuchsia_storage_block.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_storage_block_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct BlockConnectMapperRequest {
16    pub server_end: fidl::endpoints::ServerEnd<MapperMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlockConnectMapperRequest {}
20
21#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
22pub struct BlockOpenSessionRequest {
23    pub session: fidl::endpoints::ServerEnd<SessionMarker>,
24}
25
26impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlockOpenSessionRequest {}
27
28#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
29pub struct BlockOpenSessionWithOptionsRequest {
30    pub session: fidl::endpoints::ServerEnd<SessionMarker>,
31    pub mappings: Vec<BlockOffsetMapping>,
32}
33
34impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
35    for BlockOpenSessionWithOptionsRequest
36{
37}
38
39#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
40pub struct MapperOpenSessionRequest {
41    pub session: fidl::endpoints::ServerEnd<MapperSessionMarker>,
42    /// VMO that contains the mappings.
43    pub mapping_vmo: fidl::Vmo,
44    /// Page requests will be delivered on the port.
45    pub port: Option<fidl::Port>,
46    /// Completed requests are delivered on this queue.
47    pub delivery_queue: Option<fidl::Vmo>,
48}
49
50impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for MapperOpenSessionRequest {}
51
52#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
53pub struct MapperSessionOpenChildSessionRequest {
54    pub session: fidl::endpoints::ServerEnd<MapperSessionMarker>,
55    /// VMO that contains the mappings.
56    pub mapping_vmo: fidl::Vmo,
57    /// Key in the parent session identifying the parent mapping to route through.
58    pub parent_key: u64,
59    /// Page requests will be delivered on the port.
60    pub port: Option<fidl::Port>,
61    /// Completed requests are delivered on this queue.
62    pub delivery_queue: Option<fidl::Vmo>,
63}
64
65impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
66    for MapperSessionOpenChildSessionRequest
67{
68}
69
70#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
71pub struct MapperSessionRecordProfileRequest {
72    pub recording: fidl::endpoints::ServerEnd<RecordingMarker>,
73}
74
75impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
76    for MapperSessionRecordProfileRequest
77{
78}
79
80#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
81pub struct MapperSessionCreateVmoResponse {
82    pub vmo: fidl::Vmo,
83}
84
85impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
86    for MapperSessionCreateVmoResponse
87{
88}
89
90#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
91pub struct RecordingStopResponse {
92    pub vmo: fidl::Vmo,
93}
94
95impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for RecordingStopResponse {}
96
97#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
98pub struct SessionAttachVmoRequest {
99    pub vmo: fidl::Vmo,
100}
101
102impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SessionAttachVmoRequest {}
103
104#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
105pub struct SessionRegisterKeyRequest {
106    pub key_token: fidl::EventPair,
107}
108
109impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SessionRegisterKeyRequest {}
110
111#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
112pub struct SessionGetFifoResponse {
113    pub fifo: fidl::Fifo,
114}
115
116impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SessionGetFifoResponse {}
117
118#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
119pub struct BlockMarker;
120
121impl fidl::endpoints::ProtocolMarker for BlockMarker {
122    type Proxy = BlockProxy;
123    type RequestStream = BlockRequestStream;
124    #[cfg(target_os = "fuchsia")]
125    type SynchronousProxy = BlockSynchronousProxy;
126
127    const DEBUG_NAME: &'static str = "fuchsia.storage.block.Block";
128}
129impl fidl::endpoints::DiscoverableProtocolMarker for BlockMarker {}
130pub type BlockGetInfoResult = Result<BlockInfo, i32>;
131pub type BlockConnectMapperResult = Result<(), i32>;
132pub type BlockGetMetadataResult = Result<PartitionInfo, i32>;
133
134pub trait BlockProxyInterface: Send + Sync {
135    type GetInfoResponseFut: std::future::Future<Output = Result<BlockGetInfoResult, fidl::Error>>
136        + Send;
137    fn r#get_info(&self) -> Self::GetInfoResponseFut;
138    fn r#open_session(
139        &self,
140        session: fidl::endpoints::ServerEnd<SessionMarker>,
141    ) -> Result<(), fidl::Error>;
142    fn r#open_session_with_options(
143        &self,
144        session: fidl::endpoints::ServerEnd<SessionMarker>,
145        mappings: &[BlockOffsetMapping],
146    ) -> Result<(), fidl::Error>;
147    type ConnectMapperResponseFut: std::future::Future<Output = Result<BlockConnectMapperResult, fidl::Error>>
148        + Send;
149    fn r#connect_mapper(
150        &self,
151        server_end: fidl::endpoints::ServerEnd<MapperMarker>,
152    ) -> Self::ConnectMapperResponseFut;
153    type GetTypeGuidResponseFut: std::future::Future<Output = Result<(i32, Option<Box<Guid>>), fidl::Error>>
154        + Send;
155    fn r#get_type_guid(&self) -> Self::GetTypeGuidResponseFut;
156    type GetInstanceGuidResponseFut: std::future::Future<Output = Result<(i32, Option<Box<Guid>>), fidl::Error>>
157        + Send;
158    fn r#get_instance_guid(&self) -> Self::GetInstanceGuidResponseFut;
159    type GetNameResponseFut: std::future::Future<Output = Result<(i32, Option<String>), fidl::Error>>
160        + Send;
161    fn r#get_name(&self) -> Self::GetNameResponseFut;
162    type GetMetadataResponseFut: std::future::Future<Output = Result<BlockGetMetadataResult, fidl::Error>>
163        + Send;
164    fn r#get_metadata(&self) -> Self::GetMetadataResponseFut;
165    type QuerySlicesResponseFut: std::future::Future<Output = Result<(i32, [VsliceRange; 16], u64), fidl::Error>>
166        + Send;
167    fn r#query_slices(&self, start_slices: &[u64]) -> Self::QuerySlicesResponseFut;
168    type GetVolumeInfoResponseFut: std::future::Future<
169            Output = Result<
170                (i32, Option<Box<VolumeManagerInfo>>, Option<Box<VolumeInfo>>),
171                fidl::Error,
172            >,
173        > + Send;
174    fn r#get_volume_info(&self) -> Self::GetVolumeInfoResponseFut;
175    type ExtendResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
176    fn r#extend(&self, start_slice: u64, slice_count: u64) -> Self::ExtendResponseFut;
177    type ShrinkResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
178    fn r#shrink(&self, start_slice: u64, slice_count: u64) -> Self::ShrinkResponseFut;
179    type DestroyResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
180    fn r#destroy(&self) -> Self::DestroyResponseFut;
181}
182#[derive(Debug)]
183#[cfg(target_os = "fuchsia")]
184pub struct BlockSynchronousProxy {
185    client: fidl::client::sync::Client,
186}
187
188#[cfg(target_os = "fuchsia")]
189impl fidl::endpoints::SynchronousProxy for BlockSynchronousProxy {
190    type Proxy = BlockProxy;
191    type Protocol = BlockMarker;
192
193    fn from_channel(inner: fidl::Channel) -> Self {
194        Self::new(inner)
195    }
196
197    fn into_channel(self) -> fidl::Channel {
198        self.client.into_channel()
199    }
200
201    fn as_channel(&self) -> &fidl::Channel {
202        self.client.as_channel()
203    }
204}
205
206#[cfg(target_os = "fuchsia")]
207impl BlockSynchronousProxy {
208    pub fn new(channel: fidl::Channel) -> Self {
209        Self { client: fidl::client::sync::Client::new(channel) }
210    }
211
212    pub fn into_channel(self) -> fidl::Channel {
213        self.client.into_channel()
214    }
215
216    /// Waits until an event arrives and returns it. It is safe for other
217    /// threads to make concurrent requests while waiting for an event.
218    pub fn wait_for_event(
219        &self,
220        deadline: zx::MonotonicInstant,
221    ) -> Result<BlockEvent, fidl::Error> {
222        BlockEvent::decode(self.client.wait_for_event::<BlockMarker>(deadline)?)
223    }
224
225    /// Get information about the underlying block device.
226    pub fn r#get_info(
227        &self,
228        ___deadline: zx::MonotonicInstant,
229    ) -> Result<BlockGetInfoResult, fidl::Error> {
230        let _response = self.client.send_query::<
231            fidl::encoding::EmptyPayload,
232            fidl::encoding::ResultType<BlockGetInfoResponse, i32>,
233            BlockMarker,
234        >(
235            (),
236            0x58777a4a31cc9a47,
237            fidl::encoding::DynamicFlags::empty(),
238            ___deadline,
239        )?;
240        Ok(_response.map(|x| x.info))
241    }
242
243    /// Opens a new FIFO-based session on the block device.
244    pub fn r#open_session(
245        &self,
246        mut session: fidl::endpoints::ServerEnd<SessionMarker>,
247    ) -> Result<(), fidl::Error> {
248        self.client.send::<BlockOpenSessionRequest>(
249            (session,),
250            0x2ca32f8c64f1d6c8,
251            fidl::encoding::DynamicFlags::empty(),
252        )
253    }
254
255    /// Opens a new FIFO-based session on the block device, with additional options.
256    ///
257    /// # Mappings
258    ///
259    /// The `mappings` argument is a list of logical -> physical block mappings, which the server
260    /// will transparently apply to device offsets in block FIFO requests within this session.
261    /// The mappings are logically contiguous starting from logical offset 0.
262    ///
263    /// This interface is intended to be used internally between nested Block implementations, in
264    /// order to provide passthrough I/O.  For example, a fixed partition map (e.g. GPT) will serve
265    /// a Block protocol for each partition, and will respond to OpenSession requests by calling
266    /// OpenSessionWithOptions on the underlying block device, providing mappings which translate
267    /// block offsets which are relative to (and bounded by) the partition to absolute offsets on
268    /// the device.
269    ///
270    /// Mappings can only ever restrict the visible range of a device; servers will reject mappings
271    /// which exceed the range of the device.
272    ///
273    /// If `mappings` is empty, the session channel will be closed with epitaph
274    /// `ZX_ERR_INVALID_ARGS`.
275    pub fn r#open_session_with_options(
276        &self,
277        mut session: fidl::endpoints::ServerEnd<SessionMarker>,
278        mut mappings: &[BlockOffsetMapping],
279    ) -> Result<(), fidl::Error> {
280        self.client.send::<BlockOpenSessionWithOptionsRequest>(
281            (session, mappings),
282            0x1974e5f7b9de6f0c,
283            fidl::encoding::DynamicFlags::empty(),
284        )
285    }
286
287    /// Connects to the device's Mapper protocol, allowing read-only mapped page-in.
288    /// Since the caller already holds a handle to Block (which grants full read/write access
289    /// to the device), this method provides a direct way to obtain the corresponding Mapper
290    /// protocol without requiring an out-of-band channel or separate capability routing.
291    ///
292    /// If the device or driver does not support the Mapper protocol, ZX_ERR_NOT_SUPPORTED
293    /// is returned.
294    pub fn r#connect_mapper(
295        &self,
296        mut server_end: fidl::endpoints::ServerEnd<MapperMarker>,
297        ___deadline: zx::MonotonicInstant,
298    ) -> Result<BlockConnectMapperResult, fidl::Error> {
299        let _response = self.client.send_query::<
300            BlockConnectMapperRequest,
301            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
302            BlockMarker,
303        >(
304            (server_end,),
305            0xa38a3fbbe3412c3,
306            fidl::encoding::DynamicFlags::empty(),
307            ___deadline,
308        )?;
309        Ok(_response.map(|x| x))
310    }
311
312    /// Gets the type GUID of the partition (if one exists).
313    /// If the partition has no type GUID, ZX_ERR_NOT_SUPPORTED is returned.
314    pub fn r#get_type_guid(
315        &self,
316        ___deadline: zx::MonotonicInstant,
317    ) -> Result<(i32, Option<Box<Guid>>), fidl::Error> {
318        let _response = self
319            .client
320            .send_query::<fidl::encoding::EmptyPayload, BlockGetTypeGuidResponse, BlockMarker>(
321                (),
322                0xefe4e41dafce4cc,
323                fidl::encoding::DynamicFlags::empty(),
324                ___deadline,
325            )?;
326        Ok((_response.status, _response.guid))
327    }
328
329    /// Gets the instance GUID of the partition (if one exists).
330    /// If the partition has no instance GUID, ZX_ERR_NOT_SUPPORTED is returned.
331    pub fn r#get_instance_guid(
332        &self,
333        ___deadline: zx::MonotonicInstant,
334    ) -> Result<(i32, Option<Box<Guid>>), fidl::Error> {
335        let _response = self
336            .client
337            .send_query::<fidl::encoding::EmptyPayload, BlockGetInstanceGuidResponse, BlockMarker>(
338                (),
339                0x2e85011aabeb87fb,
340                fidl::encoding::DynamicFlags::empty(),
341                ___deadline,
342            )?;
343        Ok((_response.status, _response.guid))
344    }
345
346    /// Gets the name of the partition (if one exists).
347    /// If the partition has no name, ZX_ERR_NOT_SUPPORTED is returned.
348    pub fn r#get_name(
349        &self,
350        ___deadline: zx::MonotonicInstant,
351    ) -> Result<(i32, Option<String>), fidl::Error> {
352        let _response = self
353            .client
354            .send_query::<fidl::encoding::EmptyPayload, BlockGetNameResponse, BlockMarker>(
355                (),
356                0x630be18badedbb05,
357                fidl::encoding::DynamicFlags::empty(),
358                ___deadline,
359            )?;
360        Ok((_response.status, _response.name))
361    }
362
363    /// Gets the metadata for the partition.
364    ///
365    /// Fields may be absent if the partition doesn't have the given metadata.
366    pub fn r#get_metadata(
367        &self,
368        ___deadline: zx::MonotonicInstant,
369    ) -> Result<BlockGetMetadataResult, fidl::Error> {
370        let _response = self.client.send_query::<
371            fidl::encoding::EmptyPayload,
372            fidl::encoding::ResultType<PartitionInfo, i32>,
373            BlockMarker,
374        >(
375            (),
376            0x2c76b02ef9382533,
377            fidl::encoding::DynamicFlags::empty(),
378            ___deadline,
379        )?;
380        Ok(_response.map(|x| x))
381    }
382
383    /// Returns the number of contiguous allocated (or unallocated) vslices
384    /// starting from each vslice.
385    ///
386    /// Returns ZX_ERR_NOT_SUPPORTED if the device is not a volume.
387    pub fn r#query_slices(
388        &self,
389        mut start_slices: &[u64],
390        ___deadline: zx::MonotonicInstant,
391    ) -> Result<(i32, [VsliceRange; 16], u64), fidl::Error> {
392        let _response = self
393            .client
394            .send_query::<BlockQuerySlicesRequest, BlockQuerySlicesResponse, BlockMarker>(
395                (start_slices,),
396                0x289240ac4fbaa190,
397                fidl::encoding::DynamicFlags::empty(),
398                ___deadline,
399            )?;
400        Ok((_response.status, _response.response, _response.response_count))
401    }
402
403    /// Returns the information about this volume and the volume manager it is embedded in.
404    ///
405    /// Returns ZX_ERR_NOT_SUPPORTED if the device is not a volume.
406    pub fn r#get_volume_info(
407        &self,
408        ___deadline: zx::MonotonicInstant,
409    ) -> Result<(i32, Option<Box<VolumeManagerInfo>>, Option<Box<VolumeInfo>>), fidl::Error> {
410        let _response = self
411            .client
412            .send_query::<fidl::encoding::EmptyPayload, BlockGetVolumeInfoResponse, BlockMarker>(
413                (),
414                0x3a7dc69ea5d788d4,
415                fidl::encoding::DynamicFlags::empty(),
416                ___deadline,
417            )?;
418        Ok((_response.status, _response.manager, _response.volume))
419    }
420
421    /// Extends the mapping of this partition.
422    ///
423    /// The ability to extend the partition is dependent on having sufficient free space on the
424    /// underlying device, having sufficient free slots for tracking the bytes in the volume
425    /// manager header, and the partition limit (see VolumeManager.SetPartitionLimit).
426    ///
427    /// Returns ZX_ERR_NOT_SUPPORTED if the device is not a volume.
428    pub fn r#extend(
429        &self,
430        mut start_slice: u64,
431        mut slice_count: u64,
432        ___deadline: zx::MonotonicInstant,
433    ) -> Result<i32, fidl::Error> {
434        let _response =
435            self.client.send_query::<BlockExtendRequest, BlockExtendResponse, BlockMarker>(
436                (start_slice, slice_count),
437                0x273fb2980ff24157,
438                fidl::encoding::DynamicFlags::empty(),
439                ___deadline,
440            )?;
441        Ok(_response.status)
442    }
443
444    /// Shrinks a virtual partition. Returns `ZX_OK` if ANY slices are
445    /// freed, even if part of the requested range contains unallocated slices.
446    ///
447    /// Returns ZX_ERR_NOT_SUPPORTED if the device is not a volume.
448    pub fn r#shrink(
449        &self,
450        mut start_slice: u64,
451        mut slice_count: u64,
452        ___deadline: zx::MonotonicInstant,
453    ) -> Result<i32, fidl::Error> {
454        let _response =
455            self.client.send_query::<BlockShrinkRequest, BlockShrinkResponse, BlockMarker>(
456                (start_slice, slice_count),
457                0x73da6de865600a8b,
458                fidl::encoding::DynamicFlags::empty(),
459                ___deadline,
460            )?;
461        Ok(_response.status)
462    }
463
464    /// Destroys the current volume, removing it from the VolumeManager, and
465    /// freeing all underlying storage. The connection to the volume is also closed.
466    ///
467    /// Returns ZX_ERR_NOT_SUPPORTED if the device is not a volume.
468    pub fn r#destroy(&self, ___deadline: zx::MonotonicInstant) -> Result<i32, fidl::Error> {
469        let _response = self
470            .client
471            .send_query::<fidl::encoding::EmptyPayload, BlockDestroyResponse, BlockMarker>(
472                (),
473                0x5866ba764e05a68e,
474                fidl::encoding::DynamicFlags::empty(),
475                ___deadline,
476            )?;
477        Ok(_response.status)
478    }
479}
480
481#[cfg(target_os = "fuchsia")]
482impl From<BlockSynchronousProxy> for zx::NullableHandle {
483    fn from(value: BlockSynchronousProxy) -> Self {
484        value.into_channel().into()
485    }
486}
487
488#[cfg(target_os = "fuchsia")]
489impl From<fidl::Channel> for BlockSynchronousProxy {
490    fn from(value: fidl::Channel) -> Self {
491        Self::new(value)
492    }
493}
494
495#[cfg(target_os = "fuchsia")]
496impl fidl::endpoints::FromClient for BlockSynchronousProxy {
497    type Protocol = BlockMarker;
498
499    fn from_client(value: fidl::endpoints::ClientEnd<BlockMarker>) -> Self {
500        Self::new(value.into_channel())
501    }
502}
503
504#[derive(Debug, Clone)]
505pub struct BlockProxy {
506    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
507}
508
509impl fidl::endpoints::Proxy for BlockProxy {
510    type Protocol = BlockMarker;
511
512    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
513        Self::new(inner)
514    }
515
516    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
517        self.client.into_channel().map_err(|client| Self { client })
518    }
519
520    fn as_channel(&self) -> &::fidl::AsyncChannel {
521        self.client.as_channel()
522    }
523}
524
525impl BlockProxy {
526    /// Create a new Proxy for fuchsia.storage.block/Block.
527    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
528        let protocol_name = <BlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
529        Self { client: fidl::client::Client::new(channel, protocol_name) }
530    }
531
532    /// Get a Stream of events from the remote end of the protocol.
533    ///
534    /// # Panics
535    ///
536    /// Panics if the event stream was already taken.
537    pub fn take_event_stream(&self) -> BlockEventStream {
538        BlockEventStream { event_receiver: self.client.take_event_receiver() }
539    }
540
541    /// Get information about the underlying block device.
542    pub fn r#get_info(
543        &self,
544    ) -> fidl::client::QueryResponseFut<
545        BlockGetInfoResult,
546        fidl::encoding::DefaultFuchsiaResourceDialect,
547    > {
548        BlockProxyInterface::r#get_info(self)
549    }
550
551    /// Opens a new FIFO-based session on the block device.
552    pub fn r#open_session(
553        &self,
554        mut session: fidl::endpoints::ServerEnd<SessionMarker>,
555    ) -> Result<(), fidl::Error> {
556        BlockProxyInterface::r#open_session(self, session)
557    }
558
559    /// Opens a new FIFO-based session on the block device, with additional options.
560    ///
561    /// # Mappings
562    ///
563    /// The `mappings` argument is a list of logical -> physical block mappings, which the server
564    /// will transparently apply to device offsets in block FIFO requests within this session.
565    /// The mappings are logically contiguous starting from logical offset 0.
566    ///
567    /// This interface is intended to be used internally between nested Block implementations, in
568    /// order to provide passthrough I/O.  For example, a fixed partition map (e.g. GPT) will serve
569    /// a Block protocol for each partition, and will respond to OpenSession requests by calling
570    /// OpenSessionWithOptions on the underlying block device, providing mappings which translate
571    /// block offsets which are relative to (and bounded by) the partition to absolute offsets on
572    /// the device.
573    ///
574    /// Mappings can only ever restrict the visible range of a device; servers will reject mappings
575    /// which exceed the range of the device.
576    ///
577    /// If `mappings` is empty, the session channel will be closed with epitaph
578    /// `ZX_ERR_INVALID_ARGS`.
579    pub fn r#open_session_with_options(
580        &self,
581        mut session: fidl::endpoints::ServerEnd<SessionMarker>,
582        mut mappings: &[BlockOffsetMapping],
583    ) -> Result<(), fidl::Error> {
584        BlockProxyInterface::r#open_session_with_options(self, session, mappings)
585    }
586
587    /// Connects to the device's Mapper protocol, allowing read-only mapped page-in.
588    /// Since the caller already holds a handle to Block (which grants full read/write access
589    /// to the device), this method provides a direct way to obtain the corresponding Mapper
590    /// protocol without requiring an out-of-band channel or separate capability routing.
591    ///
592    /// If the device or driver does not support the Mapper protocol, ZX_ERR_NOT_SUPPORTED
593    /// is returned.
594    pub fn r#connect_mapper(
595        &self,
596        mut server_end: fidl::endpoints::ServerEnd<MapperMarker>,
597    ) -> fidl::client::QueryResponseFut<
598        BlockConnectMapperResult,
599        fidl::encoding::DefaultFuchsiaResourceDialect,
600    > {
601        BlockProxyInterface::r#connect_mapper(self, server_end)
602    }
603
604    /// Gets the type GUID of the partition (if one exists).
605    /// If the partition has no type GUID, ZX_ERR_NOT_SUPPORTED is returned.
606    pub fn r#get_type_guid(
607        &self,
608    ) -> fidl::client::QueryResponseFut<
609        (i32, Option<Box<Guid>>),
610        fidl::encoding::DefaultFuchsiaResourceDialect,
611    > {
612        BlockProxyInterface::r#get_type_guid(self)
613    }
614
615    /// Gets the instance GUID of the partition (if one exists).
616    /// If the partition has no instance GUID, ZX_ERR_NOT_SUPPORTED is returned.
617    pub fn r#get_instance_guid(
618        &self,
619    ) -> fidl::client::QueryResponseFut<
620        (i32, Option<Box<Guid>>),
621        fidl::encoding::DefaultFuchsiaResourceDialect,
622    > {
623        BlockProxyInterface::r#get_instance_guid(self)
624    }
625
626    /// Gets the name of the partition (if one exists).
627    /// If the partition has no name, ZX_ERR_NOT_SUPPORTED is returned.
628    pub fn r#get_name(
629        &self,
630    ) -> fidl::client::QueryResponseFut<
631        (i32, Option<String>),
632        fidl::encoding::DefaultFuchsiaResourceDialect,
633    > {
634        BlockProxyInterface::r#get_name(self)
635    }
636
637    /// Gets the metadata for the partition.
638    ///
639    /// Fields may be absent if the partition doesn't have the given metadata.
640    pub fn r#get_metadata(
641        &self,
642    ) -> fidl::client::QueryResponseFut<
643        BlockGetMetadataResult,
644        fidl::encoding::DefaultFuchsiaResourceDialect,
645    > {
646        BlockProxyInterface::r#get_metadata(self)
647    }
648
649    /// Returns the number of contiguous allocated (or unallocated) vslices
650    /// starting from each vslice.
651    ///
652    /// Returns ZX_ERR_NOT_SUPPORTED if the device is not a volume.
653    pub fn r#query_slices(
654        &self,
655        mut start_slices: &[u64],
656    ) -> fidl::client::QueryResponseFut<
657        (i32, [VsliceRange; 16], u64),
658        fidl::encoding::DefaultFuchsiaResourceDialect,
659    > {
660        BlockProxyInterface::r#query_slices(self, start_slices)
661    }
662
663    /// Returns the information about this volume and the volume manager it is embedded in.
664    ///
665    /// Returns ZX_ERR_NOT_SUPPORTED if the device is not a volume.
666    pub fn r#get_volume_info(
667        &self,
668    ) -> fidl::client::QueryResponseFut<
669        (i32, Option<Box<VolumeManagerInfo>>, Option<Box<VolumeInfo>>),
670        fidl::encoding::DefaultFuchsiaResourceDialect,
671    > {
672        BlockProxyInterface::r#get_volume_info(self)
673    }
674
675    /// Extends the mapping of this partition.
676    ///
677    /// The ability to extend the partition is dependent on having sufficient free space on the
678    /// underlying device, having sufficient free slots for tracking the bytes in the volume
679    /// manager header, and the partition limit (see VolumeManager.SetPartitionLimit).
680    ///
681    /// Returns ZX_ERR_NOT_SUPPORTED if the device is not a volume.
682    pub fn r#extend(
683        &self,
684        mut start_slice: u64,
685        mut slice_count: u64,
686    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
687        BlockProxyInterface::r#extend(self, start_slice, slice_count)
688    }
689
690    /// Shrinks a virtual partition. Returns `ZX_OK` if ANY slices are
691    /// freed, even if part of the requested range contains unallocated slices.
692    ///
693    /// Returns ZX_ERR_NOT_SUPPORTED if the device is not a volume.
694    pub fn r#shrink(
695        &self,
696        mut start_slice: u64,
697        mut slice_count: u64,
698    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
699        BlockProxyInterface::r#shrink(self, start_slice, slice_count)
700    }
701
702    /// Destroys the current volume, removing it from the VolumeManager, and
703    /// freeing all underlying storage. The connection to the volume is also closed.
704    ///
705    /// Returns ZX_ERR_NOT_SUPPORTED if the device is not a volume.
706    pub fn r#destroy(
707        &self,
708    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
709        BlockProxyInterface::r#destroy(self)
710    }
711}
712
713impl BlockProxyInterface for BlockProxy {
714    type GetInfoResponseFut = fidl::client::QueryResponseFut<
715        BlockGetInfoResult,
716        fidl::encoding::DefaultFuchsiaResourceDialect,
717    >;
718    fn r#get_info(&self) -> Self::GetInfoResponseFut {
719        fn _decode(
720            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
721        ) -> Result<BlockGetInfoResult, fidl::Error> {
722            let _response = fidl::client::decode_transaction_body::<
723                fidl::encoding::ResultType<BlockGetInfoResponse, i32>,
724                fidl::encoding::DefaultFuchsiaResourceDialect,
725                0x58777a4a31cc9a47,
726            >(_buf?)?;
727            Ok(_response.map(|x| x.info))
728        }
729        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, BlockGetInfoResult>(
730            (),
731            0x58777a4a31cc9a47,
732            fidl::encoding::DynamicFlags::empty(),
733            _decode,
734        )
735    }
736
737    fn r#open_session(
738        &self,
739        mut session: fidl::endpoints::ServerEnd<SessionMarker>,
740    ) -> Result<(), fidl::Error> {
741        self.client.send::<BlockOpenSessionRequest>(
742            (session,),
743            0x2ca32f8c64f1d6c8,
744            fidl::encoding::DynamicFlags::empty(),
745        )
746    }
747
748    fn r#open_session_with_options(
749        &self,
750        mut session: fidl::endpoints::ServerEnd<SessionMarker>,
751        mut mappings: &[BlockOffsetMapping],
752    ) -> Result<(), fidl::Error> {
753        self.client.send::<BlockOpenSessionWithOptionsRequest>(
754            (session, mappings),
755            0x1974e5f7b9de6f0c,
756            fidl::encoding::DynamicFlags::empty(),
757        )
758    }
759
760    type ConnectMapperResponseFut = fidl::client::QueryResponseFut<
761        BlockConnectMapperResult,
762        fidl::encoding::DefaultFuchsiaResourceDialect,
763    >;
764    fn r#connect_mapper(
765        &self,
766        mut server_end: fidl::endpoints::ServerEnd<MapperMarker>,
767    ) -> Self::ConnectMapperResponseFut {
768        fn _decode(
769            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
770        ) -> Result<BlockConnectMapperResult, fidl::Error> {
771            let _response = fidl::client::decode_transaction_body::<
772                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
773                fidl::encoding::DefaultFuchsiaResourceDialect,
774                0xa38a3fbbe3412c3,
775            >(_buf?)?;
776            Ok(_response.map(|x| x))
777        }
778        self.client.send_query_and_decode::<BlockConnectMapperRequest, BlockConnectMapperResult>(
779            (server_end,),
780            0xa38a3fbbe3412c3,
781            fidl::encoding::DynamicFlags::empty(),
782            _decode,
783        )
784    }
785
786    type GetTypeGuidResponseFut = fidl::client::QueryResponseFut<
787        (i32, Option<Box<Guid>>),
788        fidl::encoding::DefaultFuchsiaResourceDialect,
789    >;
790    fn r#get_type_guid(&self) -> Self::GetTypeGuidResponseFut {
791        fn _decode(
792            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
793        ) -> Result<(i32, Option<Box<Guid>>), fidl::Error> {
794            let _response = fidl::client::decode_transaction_body::<
795                BlockGetTypeGuidResponse,
796                fidl::encoding::DefaultFuchsiaResourceDialect,
797                0xefe4e41dafce4cc,
798            >(_buf?)?;
799            Ok((_response.status, _response.guid))
800        }
801        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, Option<Box<Guid>>)>(
802            (),
803            0xefe4e41dafce4cc,
804            fidl::encoding::DynamicFlags::empty(),
805            _decode,
806        )
807    }
808
809    type GetInstanceGuidResponseFut = fidl::client::QueryResponseFut<
810        (i32, Option<Box<Guid>>),
811        fidl::encoding::DefaultFuchsiaResourceDialect,
812    >;
813    fn r#get_instance_guid(&self) -> Self::GetInstanceGuidResponseFut {
814        fn _decode(
815            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
816        ) -> Result<(i32, Option<Box<Guid>>), fidl::Error> {
817            let _response = fidl::client::decode_transaction_body::<
818                BlockGetInstanceGuidResponse,
819                fidl::encoding::DefaultFuchsiaResourceDialect,
820                0x2e85011aabeb87fb,
821            >(_buf?)?;
822            Ok((_response.status, _response.guid))
823        }
824        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, Option<Box<Guid>>)>(
825            (),
826            0x2e85011aabeb87fb,
827            fidl::encoding::DynamicFlags::empty(),
828            _decode,
829        )
830    }
831
832    type GetNameResponseFut = fidl::client::QueryResponseFut<
833        (i32, Option<String>),
834        fidl::encoding::DefaultFuchsiaResourceDialect,
835    >;
836    fn r#get_name(&self) -> Self::GetNameResponseFut {
837        fn _decode(
838            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
839        ) -> Result<(i32, Option<String>), fidl::Error> {
840            let _response = fidl::client::decode_transaction_body::<
841                BlockGetNameResponse,
842                fidl::encoding::DefaultFuchsiaResourceDialect,
843                0x630be18badedbb05,
844            >(_buf?)?;
845            Ok((_response.status, _response.name))
846        }
847        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, Option<String>)>(
848            (),
849            0x630be18badedbb05,
850            fidl::encoding::DynamicFlags::empty(),
851            _decode,
852        )
853    }
854
855    type GetMetadataResponseFut = fidl::client::QueryResponseFut<
856        BlockGetMetadataResult,
857        fidl::encoding::DefaultFuchsiaResourceDialect,
858    >;
859    fn r#get_metadata(&self) -> Self::GetMetadataResponseFut {
860        fn _decode(
861            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
862        ) -> Result<BlockGetMetadataResult, fidl::Error> {
863            let _response = fidl::client::decode_transaction_body::<
864                fidl::encoding::ResultType<PartitionInfo, i32>,
865                fidl::encoding::DefaultFuchsiaResourceDialect,
866                0x2c76b02ef9382533,
867            >(_buf?)?;
868            Ok(_response.map(|x| x))
869        }
870        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, BlockGetMetadataResult>(
871            (),
872            0x2c76b02ef9382533,
873            fidl::encoding::DynamicFlags::empty(),
874            _decode,
875        )
876    }
877
878    type QuerySlicesResponseFut = fidl::client::QueryResponseFut<
879        (i32, [VsliceRange; 16], u64),
880        fidl::encoding::DefaultFuchsiaResourceDialect,
881    >;
882    fn r#query_slices(&self, mut start_slices: &[u64]) -> Self::QuerySlicesResponseFut {
883        fn _decode(
884            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
885        ) -> Result<(i32, [VsliceRange; 16], u64), fidl::Error> {
886            let _response = fidl::client::decode_transaction_body::<
887                BlockQuerySlicesResponse,
888                fidl::encoding::DefaultFuchsiaResourceDialect,
889                0x289240ac4fbaa190,
890            >(_buf?)?;
891            Ok((_response.status, _response.response, _response.response_count))
892        }
893        self.client.send_query_and_decode::<BlockQuerySlicesRequest, (i32, [VsliceRange; 16], u64)>(
894            (start_slices,),
895            0x289240ac4fbaa190,
896            fidl::encoding::DynamicFlags::empty(),
897            _decode,
898        )
899    }
900
901    type GetVolumeInfoResponseFut = fidl::client::QueryResponseFut<
902        (i32, Option<Box<VolumeManagerInfo>>, Option<Box<VolumeInfo>>),
903        fidl::encoding::DefaultFuchsiaResourceDialect,
904    >;
905    fn r#get_volume_info(&self) -> Self::GetVolumeInfoResponseFut {
906        fn _decode(
907            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
908        ) -> Result<(i32, Option<Box<VolumeManagerInfo>>, Option<Box<VolumeInfo>>), fidl::Error>
909        {
910            let _response = fidl::client::decode_transaction_body::<
911                BlockGetVolumeInfoResponse,
912                fidl::encoding::DefaultFuchsiaResourceDialect,
913                0x3a7dc69ea5d788d4,
914            >(_buf?)?;
915            Ok((_response.status, _response.manager, _response.volume))
916        }
917        self.client.send_query_and_decode::<
918            fidl::encoding::EmptyPayload,
919            (i32, Option<Box<VolumeManagerInfo>>, Option<Box<VolumeInfo>>),
920        >(
921            (),
922            0x3a7dc69ea5d788d4,
923            fidl::encoding::DynamicFlags::empty(),
924            _decode,
925        )
926    }
927
928    type ExtendResponseFut =
929        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
930    fn r#extend(&self, mut start_slice: u64, mut slice_count: u64) -> Self::ExtendResponseFut {
931        fn _decode(
932            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
933        ) -> Result<i32, fidl::Error> {
934            let _response = fidl::client::decode_transaction_body::<
935                BlockExtendResponse,
936                fidl::encoding::DefaultFuchsiaResourceDialect,
937                0x273fb2980ff24157,
938            >(_buf?)?;
939            Ok(_response.status)
940        }
941        self.client.send_query_and_decode::<BlockExtendRequest, i32>(
942            (start_slice, slice_count),
943            0x273fb2980ff24157,
944            fidl::encoding::DynamicFlags::empty(),
945            _decode,
946        )
947    }
948
949    type ShrinkResponseFut =
950        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
951    fn r#shrink(&self, mut start_slice: u64, mut slice_count: u64) -> Self::ShrinkResponseFut {
952        fn _decode(
953            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
954        ) -> Result<i32, fidl::Error> {
955            let _response = fidl::client::decode_transaction_body::<
956                BlockShrinkResponse,
957                fidl::encoding::DefaultFuchsiaResourceDialect,
958                0x73da6de865600a8b,
959            >(_buf?)?;
960            Ok(_response.status)
961        }
962        self.client.send_query_and_decode::<BlockShrinkRequest, i32>(
963            (start_slice, slice_count),
964            0x73da6de865600a8b,
965            fidl::encoding::DynamicFlags::empty(),
966            _decode,
967        )
968    }
969
970    type DestroyResponseFut =
971        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
972    fn r#destroy(&self) -> Self::DestroyResponseFut {
973        fn _decode(
974            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
975        ) -> Result<i32, fidl::Error> {
976            let _response = fidl::client::decode_transaction_body::<
977                BlockDestroyResponse,
978                fidl::encoding::DefaultFuchsiaResourceDialect,
979                0x5866ba764e05a68e,
980            >(_buf?)?;
981            Ok(_response.status)
982        }
983        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i32>(
984            (),
985            0x5866ba764e05a68e,
986            fidl::encoding::DynamicFlags::empty(),
987            _decode,
988        )
989    }
990}
991
992pub struct BlockEventStream {
993    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
994}
995
996impl std::marker::Unpin for BlockEventStream {}
997
998impl futures::stream::FusedStream for BlockEventStream {
999    fn is_terminated(&self) -> bool {
1000        self.event_receiver.is_terminated()
1001    }
1002}
1003
1004impl futures::Stream for BlockEventStream {
1005    type Item = Result<BlockEvent, fidl::Error>;
1006
1007    fn poll_next(
1008        mut self: std::pin::Pin<&mut Self>,
1009        cx: &mut std::task::Context<'_>,
1010    ) -> std::task::Poll<Option<Self::Item>> {
1011        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1012            &mut self.event_receiver,
1013            cx
1014        )?) {
1015            Some(buf) => std::task::Poll::Ready(Some(BlockEvent::decode(buf))),
1016            None => std::task::Poll::Ready(None),
1017        }
1018    }
1019}
1020
1021#[derive(Debug)]
1022pub enum BlockEvent {}
1023
1024impl BlockEvent {
1025    /// Decodes a message buffer as a [`BlockEvent`].
1026    fn decode(
1027        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1028    ) -> Result<BlockEvent, fidl::Error> {
1029        let (bytes, _handles) = buf.split_mut();
1030        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1031        debug_assert_eq!(tx_header.tx_id, 0);
1032        match tx_header.ordinal {
1033            _ => Err(fidl::Error::UnknownOrdinal {
1034                ordinal: tx_header.ordinal,
1035                protocol_name: <BlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1036            }),
1037        }
1038    }
1039}
1040
1041/// A Stream of incoming requests for fuchsia.storage.block/Block.
1042pub struct BlockRequestStream {
1043    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1044    is_terminated: bool,
1045}
1046
1047impl std::marker::Unpin for BlockRequestStream {}
1048
1049impl futures::stream::FusedStream for BlockRequestStream {
1050    fn is_terminated(&self) -> bool {
1051        self.is_terminated
1052    }
1053}
1054
1055impl fidl::endpoints::RequestStream for BlockRequestStream {
1056    type Protocol = BlockMarker;
1057    type ControlHandle = BlockControlHandle;
1058
1059    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1060        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1061    }
1062
1063    fn control_handle(&self) -> Self::ControlHandle {
1064        BlockControlHandle { inner: self.inner.clone() }
1065    }
1066
1067    fn into_inner(
1068        self,
1069    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1070    {
1071        (self.inner, self.is_terminated)
1072    }
1073
1074    fn from_inner(
1075        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1076        is_terminated: bool,
1077    ) -> Self {
1078        Self { inner, is_terminated }
1079    }
1080}
1081
1082impl futures::Stream for BlockRequestStream {
1083    type Item = Result<BlockRequest, fidl::Error>;
1084
1085    fn poll_next(
1086        mut self: std::pin::Pin<&mut Self>,
1087        cx: &mut std::task::Context<'_>,
1088    ) -> std::task::Poll<Option<Self::Item>> {
1089        let this = &mut *self;
1090        if this.inner.check_shutdown(cx) {
1091            this.is_terminated = true;
1092            return std::task::Poll::Ready(None);
1093        }
1094        if this.is_terminated {
1095            panic!("polled BlockRequestStream after completion");
1096        }
1097        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1098            |bytes, handles| {
1099                match this.inner.channel().read_etc(cx, bytes, handles) {
1100                    std::task::Poll::Ready(Ok(())) => {}
1101                    std::task::Poll::Pending => return std::task::Poll::Pending,
1102                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1103                        this.is_terminated = true;
1104                        return std::task::Poll::Ready(None);
1105                    }
1106                    std::task::Poll::Ready(Err(e)) => {
1107                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1108                            e.into(),
1109                        ))));
1110                    }
1111                }
1112
1113                // A message has been received from the channel
1114                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1115
1116                std::task::Poll::Ready(Some(match header.ordinal {
1117                    0x58777a4a31cc9a47 => {
1118                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1119                        let mut req = fidl::new_empty!(
1120                            fidl::encoding::EmptyPayload,
1121                            fidl::encoding::DefaultFuchsiaResourceDialect
1122                        );
1123                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1124                        let control_handle = BlockControlHandle { inner: this.inner.clone() };
1125                        Ok(BlockRequest::GetInfo {
1126                            responder: BlockGetInfoResponder {
1127                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1128                                tx_id: header.tx_id,
1129                            },
1130                        })
1131                    }
1132                    0x2ca32f8c64f1d6c8 => {
1133                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1134                        let mut req = fidl::new_empty!(
1135                            BlockOpenSessionRequest,
1136                            fidl::encoding::DefaultFuchsiaResourceDialect
1137                        );
1138                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BlockOpenSessionRequest>(&header, _body_bytes, handles, &mut req)?;
1139                        let control_handle = BlockControlHandle { inner: this.inner.clone() };
1140                        Ok(BlockRequest::OpenSession { session: req.session, control_handle })
1141                    }
1142                    0x1974e5f7b9de6f0c => {
1143                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1144                        let mut req = fidl::new_empty!(
1145                            BlockOpenSessionWithOptionsRequest,
1146                            fidl::encoding::DefaultFuchsiaResourceDialect
1147                        );
1148                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BlockOpenSessionWithOptionsRequest>(&header, _body_bytes, handles, &mut req)?;
1149                        let control_handle = BlockControlHandle { inner: this.inner.clone() };
1150                        Ok(BlockRequest::OpenSessionWithOptions {
1151                            session: req.session,
1152                            mappings: req.mappings,
1153
1154                            control_handle,
1155                        })
1156                    }
1157                    0xa38a3fbbe3412c3 => {
1158                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1159                        let mut req = fidl::new_empty!(
1160                            BlockConnectMapperRequest,
1161                            fidl::encoding::DefaultFuchsiaResourceDialect
1162                        );
1163                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BlockConnectMapperRequest>(&header, _body_bytes, handles, &mut req)?;
1164                        let control_handle = BlockControlHandle { inner: this.inner.clone() };
1165                        Ok(BlockRequest::ConnectMapper {
1166                            server_end: req.server_end,
1167
1168                            responder: BlockConnectMapperResponder {
1169                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1170                                tx_id: header.tx_id,
1171                            },
1172                        })
1173                    }
1174                    0xefe4e41dafce4cc => {
1175                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1176                        let mut req = fidl::new_empty!(
1177                            fidl::encoding::EmptyPayload,
1178                            fidl::encoding::DefaultFuchsiaResourceDialect
1179                        );
1180                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1181                        let control_handle = BlockControlHandle { inner: this.inner.clone() };
1182                        Ok(BlockRequest::GetTypeGuid {
1183                            responder: BlockGetTypeGuidResponder {
1184                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1185                                tx_id: header.tx_id,
1186                            },
1187                        })
1188                    }
1189                    0x2e85011aabeb87fb => {
1190                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1191                        let mut req = fidl::new_empty!(
1192                            fidl::encoding::EmptyPayload,
1193                            fidl::encoding::DefaultFuchsiaResourceDialect
1194                        );
1195                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1196                        let control_handle = BlockControlHandle { inner: this.inner.clone() };
1197                        Ok(BlockRequest::GetInstanceGuid {
1198                            responder: BlockGetInstanceGuidResponder {
1199                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1200                                tx_id: header.tx_id,
1201                            },
1202                        })
1203                    }
1204                    0x630be18badedbb05 => {
1205                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1206                        let mut req = fidl::new_empty!(
1207                            fidl::encoding::EmptyPayload,
1208                            fidl::encoding::DefaultFuchsiaResourceDialect
1209                        );
1210                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1211                        let control_handle = BlockControlHandle { inner: this.inner.clone() };
1212                        Ok(BlockRequest::GetName {
1213                            responder: BlockGetNameResponder {
1214                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1215                                tx_id: header.tx_id,
1216                            },
1217                        })
1218                    }
1219                    0x2c76b02ef9382533 => {
1220                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1221                        let mut req = fidl::new_empty!(
1222                            fidl::encoding::EmptyPayload,
1223                            fidl::encoding::DefaultFuchsiaResourceDialect
1224                        );
1225                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1226                        let control_handle = BlockControlHandle { inner: this.inner.clone() };
1227                        Ok(BlockRequest::GetMetadata {
1228                            responder: BlockGetMetadataResponder {
1229                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1230                                tx_id: header.tx_id,
1231                            },
1232                        })
1233                    }
1234                    0x289240ac4fbaa190 => {
1235                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1236                        let mut req = fidl::new_empty!(
1237                            BlockQuerySlicesRequest,
1238                            fidl::encoding::DefaultFuchsiaResourceDialect
1239                        );
1240                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BlockQuerySlicesRequest>(&header, _body_bytes, handles, &mut req)?;
1241                        let control_handle = BlockControlHandle { inner: this.inner.clone() };
1242                        Ok(BlockRequest::QuerySlices {
1243                            start_slices: req.start_slices,
1244
1245                            responder: BlockQuerySlicesResponder {
1246                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1247                                tx_id: header.tx_id,
1248                            },
1249                        })
1250                    }
1251                    0x3a7dc69ea5d788d4 => {
1252                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1253                        let mut req = fidl::new_empty!(
1254                            fidl::encoding::EmptyPayload,
1255                            fidl::encoding::DefaultFuchsiaResourceDialect
1256                        );
1257                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1258                        let control_handle = BlockControlHandle { inner: this.inner.clone() };
1259                        Ok(BlockRequest::GetVolumeInfo {
1260                            responder: BlockGetVolumeInfoResponder {
1261                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1262                                tx_id: header.tx_id,
1263                            },
1264                        })
1265                    }
1266                    0x273fb2980ff24157 => {
1267                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1268                        let mut req = fidl::new_empty!(
1269                            BlockExtendRequest,
1270                            fidl::encoding::DefaultFuchsiaResourceDialect
1271                        );
1272                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BlockExtendRequest>(&header, _body_bytes, handles, &mut req)?;
1273                        let control_handle = BlockControlHandle { inner: this.inner.clone() };
1274                        Ok(BlockRequest::Extend {
1275                            start_slice: req.start_slice,
1276                            slice_count: req.slice_count,
1277
1278                            responder: BlockExtendResponder {
1279                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1280                                tx_id: header.tx_id,
1281                            },
1282                        })
1283                    }
1284                    0x73da6de865600a8b => {
1285                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1286                        let mut req = fidl::new_empty!(
1287                            BlockShrinkRequest,
1288                            fidl::encoding::DefaultFuchsiaResourceDialect
1289                        );
1290                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BlockShrinkRequest>(&header, _body_bytes, handles, &mut req)?;
1291                        let control_handle = BlockControlHandle { inner: this.inner.clone() };
1292                        Ok(BlockRequest::Shrink {
1293                            start_slice: req.start_slice,
1294                            slice_count: req.slice_count,
1295
1296                            responder: BlockShrinkResponder {
1297                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1298                                tx_id: header.tx_id,
1299                            },
1300                        })
1301                    }
1302                    0x5866ba764e05a68e => {
1303                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1304                        let mut req = fidl::new_empty!(
1305                            fidl::encoding::EmptyPayload,
1306                            fidl::encoding::DefaultFuchsiaResourceDialect
1307                        );
1308                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1309                        let control_handle = BlockControlHandle { inner: this.inner.clone() };
1310                        Ok(BlockRequest::Destroy {
1311                            responder: BlockDestroyResponder {
1312                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1313                                tx_id: header.tx_id,
1314                            },
1315                        })
1316                    }
1317                    _ => Err(fidl::Error::UnknownOrdinal {
1318                        ordinal: header.ordinal,
1319                        protocol_name: <BlockMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1320                    }),
1321                }))
1322            },
1323        )
1324    }
1325}
1326
1327/// Defines access to a device which is accessible in block-granularity chunks
1328/// for reading and writing.
1329#[derive(Debug)]
1330pub enum BlockRequest {
1331    /// Get information about the underlying block device.
1332    GetInfo { responder: BlockGetInfoResponder },
1333    /// Opens a new FIFO-based session on the block device.
1334    OpenSession {
1335        session: fidl::endpoints::ServerEnd<SessionMarker>,
1336        control_handle: BlockControlHandle,
1337    },
1338    /// Opens a new FIFO-based session on the block device, with additional options.
1339    ///
1340    /// # Mappings
1341    ///
1342    /// The `mappings` argument is a list of logical -> physical block mappings, which the server
1343    /// will transparently apply to device offsets in block FIFO requests within this session.
1344    /// The mappings are logically contiguous starting from logical offset 0.
1345    ///
1346    /// This interface is intended to be used internally between nested Block implementations, in
1347    /// order to provide passthrough I/O.  For example, a fixed partition map (e.g. GPT) will serve
1348    /// a Block protocol for each partition, and will respond to OpenSession requests by calling
1349    /// OpenSessionWithOptions on the underlying block device, providing mappings which translate
1350    /// block offsets which are relative to (and bounded by) the partition to absolute offsets on
1351    /// the device.
1352    ///
1353    /// Mappings can only ever restrict the visible range of a device; servers will reject mappings
1354    /// which exceed the range of the device.
1355    ///
1356    /// If `mappings` is empty, the session channel will be closed with epitaph
1357    /// `ZX_ERR_INVALID_ARGS`.
1358    OpenSessionWithOptions {
1359        session: fidl::endpoints::ServerEnd<SessionMarker>,
1360        mappings: Vec<BlockOffsetMapping>,
1361        control_handle: BlockControlHandle,
1362    },
1363    /// Connects to the device's Mapper protocol, allowing read-only mapped page-in.
1364    /// Since the caller already holds a handle to Block (which grants full read/write access
1365    /// to the device), this method provides a direct way to obtain the corresponding Mapper
1366    /// protocol without requiring an out-of-band channel or separate capability routing.
1367    ///
1368    /// If the device or driver does not support the Mapper protocol, ZX_ERR_NOT_SUPPORTED
1369    /// is returned.
1370    ConnectMapper {
1371        server_end: fidl::endpoints::ServerEnd<MapperMarker>,
1372        responder: BlockConnectMapperResponder,
1373    },
1374    /// Gets the type GUID of the partition (if one exists).
1375    /// If the partition has no type GUID, ZX_ERR_NOT_SUPPORTED is returned.
1376    GetTypeGuid { responder: BlockGetTypeGuidResponder },
1377    /// Gets the instance GUID of the partition (if one exists).
1378    /// If the partition has no instance GUID, ZX_ERR_NOT_SUPPORTED is returned.
1379    GetInstanceGuid { responder: BlockGetInstanceGuidResponder },
1380    /// Gets the name of the partition (if one exists).
1381    /// If the partition has no name, ZX_ERR_NOT_SUPPORTED is returned.
1382    GetName { responder: BlockGetNameResponder },
1383    /// Gets the metadata for the partition.
1384    ///
1385    /// Fields may be absent if the partition doesn't have the given metadata.
1386    GetMetadata { responder: BlockGetMetadataResponder },
1387    /// Returns the number of contiguous allocated (or unallocated) vslices
1388    /// starting from each vslice.
1389    ///
1390    /// Returns ZX_ERR_NOT_SUPPORTED if the device is not a volume.
1391    QuerySlices { start_slices: Vec<u64>, responder: BlockQuerySlicesResponder },
1392    /// Returns the information about this volume and the volume manager it is embedded in.
1393    ///
1394    /// Returns ZX_ERR_NOT_SUPPORTED if the device is not a volume.
1395    GetVolumeInfo { responder: BlockGetVolumeInfoResponder },
1396    /// Extends the mapping of this partition.
1397    ///
1398    /// The ability to extend the partition is dependent on having sufficient free space on the
1399    /// underlying device, having sufficient free slots for tracking the bytes in the volume
1400    /// manager header, and the partition limit (see VolumeManager.SetPartitionLimit).
1401    ///
1402    /// Returns ZX_ERR_NOT_SUPPORTED if the device is not a volume.
1403    Extend { start_slice: u64, slice_count: u64, responder: BlockExtendResponder },
1404    /// Shrinks a virtual partition. Returns `ZX_OK` if ANY slices are
1405    /// freed, even if part of the requested range contains unallocated slices.
1406    ///
1407    /// Returns ZX_ERR_NOT_SUPPORTED if the device is not a volume.
1408    Shrink { start_slice: u64, slice_count: u64, responder: BlockShrinkResponder },
1409    /// Destroys the current volume, removing it from the VolumeManager, and
1410    /// freeing all underlying storage. The connection to the volume is also closed.
1411    ///
1412    /// Returns ZX_ERR_NOT_SUPPORTED if the device is not a volume.
1413    Destroy { responder: BlockDestroyResponder },
1414}
1415
1416impl BlockRequest {
1417    #[allow(irrefutable_let_patterns)]
1418    pub fn into_get_info(self) -> Option<(BlockGetInfoResponder)> {
1419        if let BlockRequest::GetInfo { responder } = self { Some((responder)) } else { None }
1420    }
1421
1422    #[allow(irrefutable_let_patterns)]
1423    pub fn into_open_session(
1424        self,
1425    ) -> Option<(fidl::endpoints::ServerEnd<SessionMarker>, BlockControlHandle)> {
1426        if let BlockRequest::OpenSession { session, control_handle } = self {
1427            Some((session, control_handle))
1428        } else {
1429            None
1430        }
1431    }
1432
1433    #[allow(irrefutable_let_patterns)]
1434    pub fn into_open_session_with_options(
1435        self,
1436    ) -> Option<(
1437        fidl::endpoints::ServerEnd<SessionMarker>,
1438        Vec<BlockOffsetMapping>,
1439        BlockControlHandle,
1440    )> {
1441        if let BlockRequest::OpenSessionWithOptions { session, mappings, control_handle } = self {
1442            Some((session, mappings, control_handle))
1443        } else {
1444            None
1445        }
1446    }
1447
1448    #[allow(irrefutable_let_patterns)]
1449    pub fn into_connect_mapper(
1450        self,
1451    ) -> Option<(fidl::endpoints::ServerEnd<MapperMarker>, BlockConnectMapperResponder)> {
1452        if let BlockRequest::ConnectMapper { server_end, responder } = self {
1453            Some((server_end, responder))
1454        } else {
1455            None
1456        }
1457    }
1458
1459    #[allow(irrefutable_let_patterns)]
1460    pub fn into_get_type_guid(self) -> Option<(BlockGetTypeGuidResponder)> {
1461        if let BlockRequest::GetTypeGuid { responder } = self { Some((responder)) } else { None }
1462    }
1463
1464    #[allow(irrefutable_let_patterns)]
1465    pub fn into_get_instance_guid(self) -> Option<(BlockGetInstanceGuidResponder)> {
1466        if let BlockRequest::GetInstanceGuid { responder } = self {
1467            Some((responder))
1468        } else {
1469            None
1470        }
1471    }
1472
1473    #[allow(irrefutable_let_patterns)]
1474    pub fn into_get_name(self) -> Option<(BlockGetNameResponder)> {
1475        if let BlockRequest::GetName { responder } = self { Some((responder)) } else { None }
1476    }
1477
1478    #[allow(irrefutable_let_patterns)]
1479    pub fn into_get_metadata(self) -> Option<(BlockGetMetadataResponder)> {
1480        if let BlockRequest::GetMetadata { responder } = self { Some((responder)) } else { None }
1481    }
1482
1483    #[allow(irrefutable_let_patterns)]
1484    pub fn into_query_slices(self) -> Option<(Vec<u64>, BlockQuerySlicesResponder)> {
1485        if let BlockRequest::QuerySlices { start_slices, responder } = self {
1486            Some((start_slices, responder))
1487        } else {
1488            None
1489        }
1490    }
1491
1492    #[allow(irrefutable_let_patterns)]
1493    pub fn into_get_volume_info(self) -> Option<(BlockGetVolumeInfoResponder)> {
1494        if let BlockRequest::GetVolumeInfo { responder } = self { Some((responder)) } else { None }
1495    }
1496
1497    #[allow(irrefutable_let_patterns)]
1498    pub fn into_extend(self) -> Option<(u64, u64, BlockExtendResponder)> {
1499        if let BlockRequest::Extend { start_slice, slice_count, responder } = self {
1500            Some((start_slice, slice_count, responder))
1501        } else {
1502            None
1503        }
1504    }
1505
1506    #[allow(irrefutable_let_patterns)]
1507    pub fn into_shrink(self) -> Option<(u64, u64, BlockShrinkResponder)> {
1508        if let BlockRequest::Shrink { start_slice, slice_count, responder } = self {
1509            Some((start_slice, slice_count, responder))
1510        } else {
1511            None
1512        }
1513    }
1514
1515    #[allow(irrefutable_let_patterns)]
1516    pub fn into_destroy(self) -> Option<(BlockDestroyResponder)> {
1517        if let BlockRequest::Destroy { responder } = self { Some((responder)) } else { None }
1518    }
1519
1520    /// Name of the method defined in FIDL
1521    pub fn method_name(&self) -> &'static str {
1522        match *self {
1523            BlockRequest::GetInfo { .. } => "get_info",
1524            BlockRequest::OpenSession { .. } => "open_session",
1525            BlockRequest::OpenSessionWithOptions { .. } => "open_session_with_options",
1526            BlockRequest::ConnectMapper { .. } => "connect_mapper",
1527            BlockRequest::GetTypeGuid { .. } => "get_type_guid",
1528            BlockRequest::GetInstanceGuid { .. } => "get_instance_guid",
1529            BlockRequest::GetName { .. } => "get_name",
1530            BlockRequest::GetMetadata { .. } => "get_metadata",
1531            BlockRequest::QuerySlices { .. } => "query_slices",
1532            BlockRequest::GetVolumeInfo { .. } => "get_volume_info",
1533            BlockRequest::Extend { .. } => "extend",
1534            BlockRequest::Shrink { .. } => "shrink",
1535            BlockRequest::Destroy { .. } => "destroy",
1536        }
1537    }
1538}
1539
1540#[derive(Debug, Clone)]
1541pub struct BlockControlHandle {
1542    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1543}
1544
1545impl BlockControlHandle {
1546    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1547        self.inner.shutdown_with_epitaph(status.into())
1548    }
1549}
1550
1551impl fidl::endpoints::ControlHandle for BlockControlHandle {
1552    fn shutdown(&self) {
1553        self.inner.shutdown()
1554    }
1555
1556    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1557        self.inner.shutdown_with_epitaph(status)
1558    }
1559
1560    fn is_closed(&self) -> bool {
1561        self.inner.channel().is_closed()
1562    }
1563    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1564        self.inner.channel().on_closed()
1565    }
1566
1567    #[cfg(target_os = "fuchsia")]
1568    fn signal_peer(
1569        &self,
1570        clear_mask: zx::Signals,
1571        set_mask: zx::Signals,
1572    ) -> Result<(), zx_status::Status> {
1573        use fidl::Peered;
1574        self.inner.channel().signal_peer(clear_mask, set_mask)
1575    }
1576}
1577
1578impl BlockControlHandle {}
1579
1580#[must_use = "FIDL methods require a response to be sent"]
1581#[derive(Debug)]
1582pub struct BlockGetInfoResponder {
1583    control_handle: std::mem::ManuallyDrop<BlockControlHandle>,
1584    tx_id: u32,
1585}
1586
1587/// Set the the channel to be shutdown (see [`BlockControlHandle::shutdown`])
1588/// if the responder is dropped without sending a response, so that the client
1589/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1590impl std::ops::Drop for BlockGetInfoResponder {
1591    fn drop(&mut self) {
1592        self.control_handle.shutdown();
1593        // Safety: drops once, never accessed again
1594        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1595    }
1596}
1597
1598impl fidl::endpoints::Responder for BlockGetInfoResponder {
1599    type ControlHandle = BlockControlHandle;
1600
1601    fn control_handle(&self) -> &BlockControlHandle {
1602        &self.control_handle
1603    }
1604
1605    fn drop_without_shutdown(mut self) {
1606        // Safety: drops once, never accessed again due to mem::forget
1607        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1608        // Prevent Drop from running (which would shut down the channel)
1609        std::mem::forget(self);
1610    }
1611}
1612
1613impl BlockGetInfoResponder {
1614    /// Sends a response to the FIDL transaction.
1615    ///
1616    /// Sets the channel to shutdown if an error occurs.
1617    pub fn send(self, mut result: Result<&BlockInfo, i32>) -> Result<(), fidl::Error> {
1618        let _result = self.send_raw(result);
1619        if _result.is_err() {
1620            self.control_handle.shutdown();
1621        }
1622        self.drop_without_shutdown();
1623        _result
1624    }
1625
1626    /// Similar to "send" but does not shutdown the channel if an error occurs.
1627    pub fn send_no_shutdown_on_err(
1628        self,
1629        mut result: Result<&BlockInfo, i32>,
1630    ) -> Result<(), fidl::Error> {
1631        let _result = self.send_raw(result);
1632        self.drop_without_shutdown();
1633        _result
1634    }
1635
1636    fn send_raw(&self, mut result: Result<&BlockInfo, i32>) -> Result<(), fidl::Error> {
1637        self.control_handle.inner.send::<fidl::encoding::ResultType<BlockGetInfoResponse, i32>>(
1638            result.map(|info| (info,)),
1639            self.tx_id,
1640            0x58777a4a31cc9a47,
1641            fidl::encoding::DynamicFlags::empty(),
1642        )
1643    }
1644}
1645
1646#[must_use = "FIDL methods require a response to be sent"]
1647#[derive(Debug)]
1648pub struct BlockConnectMapperResponder {
1649    control_handle: std::mem::ManuallyDrop<BlockControlHandle>,
1650    tx_id: u32,
1651}
1652
1653/// Set the the channel to be shutdown (see [`BlockControlHandle::shutdown`])
1654/// if the responder is dropped without sending a response, so that the client
1655/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1656impl std::ops::Drop for BlockConnectMapperResponder {
1657    fn drop(&mut self) {
1658        self.control_handle.shutdown();
1659        // Safety: drops once, never accessed again
1660        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1661    }
1662}
1663
1664impl fidl::endpoints::Responder for BlockConnectMapperResponder {
1665    type ControlHandle = BlockControlHandle;
1666
1667    fn control_handle(&self) -> &BlockControlHandle {
1668        &self.control_handle
1669    }
1670
1671    fn drop_without_shutdown(mut self) {
1672        // Safety: drops once, never accessed again due to mem::forget
1673        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1674        // Prevent Drop from running (which would shut down the channel)
1675        std::mem::forget(self);
1676    }
1677}
1678
1679impl BlockConnectMapperResponder {
1680    /// Sends a response to the FIDL transaction.
1681    ///
1682    /// Sets the channel to shutdown if an error occurs.
1683    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1684        let _result = self.send_raw(result);
1685        if _result.is_err() {
1686            self.control_handle.shutdown();
1687        }
1688        self.drop_without_shutdown();
1689        _result
1690    }
1691
1692    /// Similar to "send" but does not shutdown the channel if an error occurs.
1693    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1694        let _result = self.send_raw(result);
1695        self.drop_without_shutdown();
1696        _result
1697    }
1698
1699    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1700        self.control_handle
1701            .inner
1702            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1703                result,
1704                self.tx_id,
1705                0xa38a3fbbe3412c3,
1706                fidl::encoding::DynamicFlags::empty(),
1707            )
1708    }
1709}
1710
1711#[must_use = "FIDL methods require a response to be sent"]
1712#[derive(Debug)]
1713pub struct BlockGetTypeGuidResponder {
1714    control_handle: std::mem::ManuallyDrop<BlockControlHandle>,
1715    tx_id: u32,
1716}
1717
1718/// Set the the channel to be shutdown (see [`BlockControlHandle::shutdown`])
1719/// if the responder is dropped without sending a response, so that the client
1720/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1721impl std::ops::Drop for BlockGetTypeGuidResponder {
1722    fn drop(&mut self) {
1723        self.control_handle.shutdown();
1724        // Safety: drops once, never accessed again
1725        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1726    }
1727}
1728
1729impl fidl::endpoints::Responder for BlockGetTypeGuidResponder {
1730    type ControlHandle = BlockControlHandle;
1731
1732    fn control_handle(&self) -> &BlockControlHandle {
1733        &self.control_handle
1734    }
1735
1736    fn drop_without_shutdown(mut self) {
1737        // Safety: drops once, never accessed again due to mem::forget
1738        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1739        // Prevent Drop from running (which would shut down the channel)
1740        std::mem::forget(self);
1741    }
1742}
1743
1744impl BlockGetTypeGuidResponder {
1745    /// Sends a response to the FIDL transaction.
1746    ///
1747    /// Sets the channel to shutdown if an error occurs.
1748    pub fn send(self, mut status: i32, mut guid: Option<&Guid>) -> Result<(), fidl::Error> {
1749        let _result = self.send_raw(status, guid);
1750        if _result.is_err() {
1751            self.control_handle.shutdown();
1752        }
1753        self.drop_without_shutdown();
1754        _result
1755    }
1756
1757    /// Similar to "send" but does not shutdown the channel if an error occurs.
1758    pub fn send_no_shutdown_on_err(
1759        self,
1760        mut status: i32,
1761        mut guid: Option<&Guid>,
1762    ) -> Result<(), fidl::Error> {
1763        let _result = self.send_raw(status, guid);
1764        self.drop_without_shutdown();
1765        _result
1766    }
1767
1768    fn send_raw(&self, mut status: i32, mut guid: Option<&Guid>) -> Result<(), fidl::Error> {
1769        self.control_handle.inner.send::<BlockGetTypeGuidResponse>(
1770            (status, guid),
1771            self.tx_id,
1772            0xefe4e41dafce4cc,
1773            fidl::encoding::DynamicFlags::empty(),
1774        )
1775    }
1776}
1777
1778#[must_use = "FIDL methods require a response to be sent"]
1779#[derive(Debug)]
1780pub struct BlockGetInstanceGuidResponder {
1781    control_handle: std::mem::ManuallyDrop<BlockControlHandle>,
1782    tx_id: u32,
1783}
1784
1785/// Set the the channel to be shutdown (see [`BlockControlHandle::shutdown`])
1786/// if the responder is dropped without sending a response, so that the client
1787/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1788impl std::ops::Drop for BlockGetInstanceGuidResponder {
1789    fn drop(&mut self) {
1790        self.control_handle.shutdown();
1791        // Safety: drops once, never accessed again
1792        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1793    }
1794}
1795
1796impl fidl::endpoints::Responder for BlockGetInstanceGuidResponder {
1797    type ControlHandle = BlockControlHandle;
1798
1799    fn control_handle(&self) -> &BlockControlHandle {
1800        &self.control_handle
1801    }
1802
1803    fn drop_without_shutdown(mut self) {
1804        // Safety: drops once, never accessed again due to mem::forget
1805        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1806        // Prevent Drop from running (which would shut down the channel)
1807        std::mem::forget(self);
1808    }
1809}
1810
1811impl BlockGetInstanceGuidResponder {
1812    /// Sends a response to the FIDL transaction.
1813    ///
1814    /// Sets the channel to shutdown if an error occurs.
1815    pub fn send(self, mut status: i32, mut guid: Option<&Guid>) -> Result<(), fidl::Error> {
1816        let _result = self.send_raw(status, guid);
1817        if _result.is_err() {
1818            self.control_handle.shutdown();
1819        }
1820        self.drop_without_shutdown();
1821        _result
1822    }
1823
1824    /// Similar to "send" but does not shutdown the channel if an error occurs.
1825    pub fn send_no_shutdown_on_err(
1826        self,
1827        mut status: i32,
1828        mut guid: Option<&Guid>,
1829    ) -> Result<(), fidl::Error> {
1830        let _result = self.send_raw(status, guid);
1831        self.drop_without_shutdown();
1832        _result
1833    }
1834
1835    fn send_raw(&self, mut status: i32, mut guid: Option<&Guid>) -> Result<(), fidl::Error> {
1836        self.control_handle.inner.send::<BlockGetInstanceGuidResponse>(
1837            (status, guid),
1838            self.tx_id,
1839            0x2e85011aabeb87fb,
1840            fidl::encoding::DynamicFlags::empty(),
1841        )
1842    }
1843}
1844
1845#[must_use = "FIDL methods require a response to be sent"]
1846#[derive(Debug)]
1847pub struct BlockGetNameResponder {
1848    control_handle: std::mem::ManuallyDrop<BlockControlHandle>,
1849    tx_id: u32,
1850}
1851
1852/// Set the the channel to be shutdown (see [`BlockControlHandle::shutdown`])
1853/// if the responder is dropped without sending a response, so that the client
1854/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1855impl std::ops::Drop for BlockGetNameResponder {
1856    fn drop(&mut self) {
1857        self.control_handle.shutdown();
1858        // Safety: drops once, never accessed again
1859        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1860    }
1861}
1862
1863impl fidl::endpoints::Responder for BlockGetNameResponder {
1864    type ControlHandle = BlockControlHandle;
1865
1866    fn control_handle(&self) -> &BlockControlHandle {
1867        &self.control_handle
1868    }
1869
1870    fn drop_without_shutdown(mut self) {
1871        // Safety: drops once, never accessed again due to mem::forget
1872        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1873        // Prevent Drop from running (which would shut down the channel)
1874        std::mem::forget(self);
1875    }
1876}
1877
1878impl BlockGetNameResponder {
1879    /// Sends a response to the FIDL transaction.
1880    ///
1881    /// Sets the channel to shutdown if an error occurs.
1882    pub fn send(self, mut status: i32, mut name: Option<&str>) -> Result<(), fidl::Error> {
1883        let _result = self.send_raw(status, name);
1884        if _result.is_err() {
1885            self.control_handle.shutdown();
1886        }
1887        self.drop_without_shutdown();
1888        _result
1889    }
1890
1891    /// Similar to "send" but does not shutdown the channel if an error occurs.
1892    pub fn send_no_shutdown_on_err(
1893        self,
1894        mut status: i32,
1895        mut name: Option<&str>,
1896    ) -> Result<(), fidl::Error> {
1897        let _result = self.send_raw(status, name);
1898        self.drop_without_shutdown();
1899        _result
1900    }
1901
1902    fn send_raw(&self, mut status: i32, mut name: Option<&str>) -> Result<(), fidl::Error> {
1903        self.control_handle.inner.send::<BlockGetNameResponse>(
1904            (status, name),
1905            self.tx_id,
1906            0x630be18badedbb05,
1907            fidl::encoding::DynamicFlags::empty(),
1908        )
1909    }
1910}
1911
1912#[must_use = "FIDL methods require a response to be sent"]
1913#[derive(Debug)]
1914pub struct BlockGetMetadataResponder {
1915    control_handle: std::mem::ManuallyDrop<BlockControlHandle>,
1916    tx_id: u32,
1917}
1918
1919/// Set the the channel to be shutdown (see [`BlockControlHandle::shutdown`])
1920/// if the responder is dropped without sending a response, so that the client
1921/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1922impl std::ops::Drop for BlockGetMetadataResponder {
1923    fn drop(&mut self) {
1924        self.control_handle.shutdown();
1925        // Safety: drops once, never accessed again
1926        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1927    }
1928}
1929
1930impl fidl::endpoints::Responder for BlockGetMetadataResponder {
1931    type ControlHandle = BlockControlHandle;
1932
1933    fn control_handle(&self) -> &BlockControlHandle {
1934        &self.control_handle
1935    }
1936
1937    fn drop_without_shutdown(mut self) {
1938        // Safety: drops once, never accessed again due to mem::forget
1939        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1940        // Prevent Drop from running (which would shut down the channel)
1941        std::mem::forget(self);
1942    }
1943}
1944
1945impl BlockGetMetadataResponder {
1946    /// Sends a response to the FIDL transaction.
1947    ///
1948    /// Sets the channel to shutdown if an error occurs.
1949    pub fn send(self, mut result: Result<&PartitionInfo, i32>) -> Result<(), fidl::Error> {
1950        let _result = self.send_raw(result);
1951        if _result.is_err() {
1952            self.control_handle.shutdown();
1953        }
1954        self.drop_without_shutdown();
1955        _result
1956    }
1957
1958    /// Similar to "send" but does not shutdown the channel if an error occurs.
1959    pub fn send_no_shutdown_on_err(
1960        self,
1961        mut result: Result<&PartitionInfo, i32>,
1962    ) -> Result<(), fidl::Error> {
1963        let _result = self.send_raw(result);
1964        self.drop_without_shutdown();
1965        _result
1966    }
1967
1968    fn send_raw(&self, mut result: Result<&PartitionInfo, i32>) -> Result<(), fidl::Error> {
1969        self.control_handle.inner.send::<fidl::encoding::ResultType<PartitionInfo, i32>>(
1970            result,
1971            self.tx_id,
1972            0x2c76b02ef9382533,
1973            fidl::encoding::DynamicFlags::empty(),
1974        )
1975    }
1976}
1977
1978#[must_use = "FIDL methods require a response to be sent"]
1979#[derive(Debug)]
1980pub struct BlockQuerySlicesResponder {
1981    control_handle: std::mem::ManuallyDrop<BlockControlHandle>,
1982    tx_id: u32,
1983}
1984
1985/// Set the the channel to be shutdown (see [`BlockControlHandle::shutdown`])
1986/// if the responder is dropped without sending a response, so that the client
1987/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1988impl std::ops::Drop for BlockQuerySlicesResponder {
1989    fn drop(&mut self) {
1990        self.control_handle.shutdown();
1991        // Safety: drops once, never accessed again
1992        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1993    }
1994}
1995
1996impl fidl::endpoints::Responder for BlockQuerySlicesResponder {
1997    type ControlHandle = BlockControlHandle;
1998
1999    fn control_handle(&self) -> &BlockControlHandle {
2000        &self.control_handle
2001    }
2002
2003    fn drop_without_shutdown(mut self) {
2004        // Safety: drops once, never accessed again due to mem::forget
2005        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2006        // Prevent Drop from running (which would shut down the channel)
2007        std::mem::forget(self);
2008    }
2009}
2010
2011impl BlockQuerySlicesResponder {
2012    /// Sends a response to the FIDL transaction.
2013    ///
2014    /// Sets the channel to shutdown if an error occurs.
2015    pub fn send(
2016        self,
2017        mut status: i32,
2018        mut response: &[VsliceRange; 16],
2019        mut response_count: u64,
2020    ) -> Result<(), fidl::Error> {
2021        let _result = self.send_raw(status, response, response_count);
2022        if _result.is_err() {
2023            self.control_handle.shutdown();
2024        }
2025        self.drop_without_shutdown();
2026        _result
2027    }
2028
2029    /// Similar to "send" but does not shutdown the channel if an error occurs.
2030    pub fn send_no_shutdown_on_err(
2031        self,
2032        mut status: i32,
2033        mut response: &[VsliceRange; 16],
2034        mut response_count: u64,
2035    ) -> Result<(), fidl::Error> {
2036        let _result = self.send_raw(status, response, response_count);
2037        self.drop_without_shutdown();
2038        _result
2039    }
2040
2041    fn send_raw(
2042        &self,
2043        mut status: i32,
2044        mut response: &[VsliceRange; 16],
2045        mut response_count: u64,
2046    ) -> Result<(), fidl::Error> {
2047        self.control_handle.inner.send::<BlockQuerySlicesResponse>(
2048            (status, response, response_count),
2049            self.tx_id,
2050            0x289240ac4fbaa190,
2051            fidl::encoding::DynamicFlags::empty(),
2052        )
2053    }
2054}
2055
2056#[must_use = "FIDL methods require a response to be sent"]
2057#[derive(Debug)]
2058pub struct BlockGetVolumeInfoResponder {
2059    control_handle: std::mem::ManuallyDrop<BlockControlHandle>,
2060    tx_id: u32,
2061}
2062
2063/// Set the the channel to be shutdown (see [`BlockControlHandle::shutdown`])
2064/// if the responder is dropped without sending a response, so that the client
2065/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2066impl std::ops::Drop for BlockGetVolumeInfoResponder {
2067    fn drop(&mut self) {
2068        self.control_handle.shutdown();
2069        // Safety: drops once, never accessed again
2070        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2071    }
2072}
2073
2074impl fidl::endpoints::Responder for BlockGetVolumeInfoResponder {
2075    type ControlHandle = BlockControlHandle;
2076
2077    fn control_handle(&self) -> &BlockControlHandle {
2078        &self.control_handle
2079    }
2080
2081    fn drop_without_shutdown(mut self) {
2082        // Safety: drops once, never accessed again due to mem::forget
2083        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2084        // Prevent Drop from running (which would shut down the channel)
2085        std::mem::forget(self);
2086    }
2087}
2088
2089impl BlockGetVolumeInfoResponder {
2090    /// Sends a response to the FIDL transaction.
2091    ///
2092    /// Sets the channel to shutdown if an error occurs.
2093    pub fn send(
2094        self,
2095        mut status: i32,
2096        mut manager: Option<&VolumeManagerInfo>,
2097        mut volume: Option<&VolumeInfo>,
2098    ) -> Result<(), fidl::Error> {
2099        let _result = self.send_raw(status, manager, volume);
2100        if _result.is_err() {
2101            self.control_handle.shutdown();
2102        }
2103        self.drop_without_shutdown();
2104        _result
2105    }
2106
2107    /// Similar to "send" but does not shutdown the channel if an error occurs.
2108    pub fn send_no_shutdown_on_err(
2109        self,
2110        mut status: i32,
2111        mut manager: Option<&VolumeManagerInfo>,
2112        mut volume: Option<&VolumeInfo>,
2113    ) -> Result<(), fidl::Error> {
2114        let _result = self.send_raw(status, manager, volume);
2115        self.drop_without_shutdown();
2116        _result
2117    }
2118
2119    fn send_raw(
2120        &self,
2121        mut status: i32,
2122        mut manager: Option<&VolumeManagerInfo>,
2123        mut volume: Option<&VolumeInfo>,
2124    ) -> Result<(), fidl::Error> {
2125        self.control_handle.inner.send::<BlockGetVolumeInfoResponse>(
2126            (status, manager, volume),
2127            self.tx_id,
2128            0x3a7dc69ea5d788d4,
2129            fidl::encoding::DynamicFlags::empty(),
2130        )
2131    }
2132}
2133
2134#[must_use = "FIDL methods require a response to be sent"]
2135#[derive(Debug)]
2136pub struct BlockExtendResponder {
2137    control_handle: std::mem::ManuallyDrop<BlockControlHandle>,
2138    tx_id: u32,
2139}
2140
2141/// Set the the channel to be shutdown (see [`BlockControlHandle::shutdown`])
2142/// if the responder is dropped without sending a response, so that the client
2143/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2144impl std::ops::Drop for BlockExtendResponder {
2145    fn drop(&mut self) {
2146        self.control_handle.shutdown();
2147        // Safety: drops once, never accessed again
2148        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2149    }
2150}
2151
2152impl fidl::endpoints::Responder for BlockExtendResponder {
2153    type ControlHandle = BlockControlHandle;
2154
2155    fn control_handle(&self) -> &BlockControlHandle {
2156        &self.control_handle
2157    }
2158
2159    fn drop_without_shutdown(mut self) {
2160        // Safety: drops once, never accessed again due to mem::forget
2161        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2162        // Prevent Drop from running (which would shut down the channel)
2163        std::mem::forget(self);
2164    }
2165}
2166
2167impl BlockExtendResponder {
2168    /// Sends a response to the FIDL transaction.
2169    ///
2170    /// Sets the channel to shutdown if an error occurs.
2171    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
2172        let _result = self.send_raw(status);
2173        if _result.is_err() {
2174            self.control_handle.shutdown();
2175        }
2176        self.drop_without_shutdown();
2177        _result
2178    }
2179
2180    /// Similar to "send" but does not shutdown the channel if an error occurs.
2181    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
2182        let _result = self.send_raw(status);
2183        self.drop_without_shutdown();
2184        _result
2185    }
2186
2187    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
2188        self.control_handle.inner.send::<BlockExtendResponse>(
2189            (status,),
2190            self.tx_id,
2191            0x273fb2980ff24157,
2192            fidl::encoding::DynamicFlags::empty(),
2193        )
2194    }
2195}
2196
2197#[must_use = "FIDL methods require a response to be sent"]
2198#[derive(Debug)]
2199pub struct BlockShrinkResponder {
2200    control_handle: std::mem::ManuallyDrop<BlockControlHandle>,
2201    tx_id: u32,
2202}
2203
2204/// Set the the channel to be shutdown (see [`BlockControlHandle::shutdown`])
2205/// if the responder is dropped without sending a response, so that the client
2206/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2207impl std::ops::Drop for BlockShrinkResponder {
2208    fn drop(&mut self) {
2209        self.control_handle.shutdown();
2210        // Safety: drops once, never accessed again
2211        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2212    }
2213}
2214
2215impl fidl::endpoints::Responder for BlockShrinkResponder {
2216    type ControlHandle = BlockControlHandle;
2217
2218    fn control_handle(&self) -> &BlockControlHandle {
2219        &self.control_handle
2220    }
2221
2222    fn drop_without_shutdown(mut self) {
2223        // Safety: drops once, never accessed again due to mem::forget
2224        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2225        // Prevent Drop from running (which would shut down the channel)
2226        std::mem::forget(self);
2227    }
2228}
2229
2230impl BlockShrinkResponder {
2231    /// Sends a response to the FIDL transaction.
2232    ///
2233    /// Sets the channel to shutdown if an error occurs.
2234    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
2235        let _result = self.send_raw(status);
2236        if _result.is_err() {
2237            self.control_handle.shutdown();
2238        }
2239        self.drop_without_shutdown();
2240        _result
2241    }
2242
2243    /// Similar to "send" but does not shutdown the channel if an error occurs.
2244    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
2245        let _result = self.send_raw(status);
2246        self.drop_without_shutdown();
2247        _result
2248    }
2249
2250    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
2251        self.control_handle.inner.send::<BlockShrinkResponse>(
2252            (status,),
2253            self.tx_id,
2254            0x73da6de865600a8b,
2255            fidl::encoding::DynamicFlags::empty(),
2256        )
2257    }
2258}
2259
2260#[must_use = "FIDL methods require a response to be sent"]
2261#[derive(Debug)]
2262pub struct BlockDestroyResponder {
2263    control_handle: std::mem::ManuallyDrop<BlockControlHandle>,
2264    tx_id: u32,
2265}
2266
2267/// Set the the channel to be shutdown (see [`BlockControlHandle::shutdown`])
2268/// if the responder is dropped without sending a response, so that the client
2269/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2270impl std::ops::Drop for BlockDestroyResponder {
2271    fn drop(&mut self) {
2272        self.control_handle.shutdown();
2273        // Safety: drops once, never accessed again
2274        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2275    }
2276}
2277
2278impl fidl::endpoints::Responder for BlockDestroyResponder {
2279    type ControlHandle = BlockControlHandle;
2280
2281    fn control_handle(&self) -> &BlockControlHandle {
2282        &self.control_handle
2283    }
2284
2285    fn drop_without_shutdown(mut self) {
2286        // Safety: drops once, never accessed again due to mem::forget
2287        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2288        // Prevent Drop from running (which would shut down the channel)
2289        std::mem::forget(self);
2290    }
2291}
2292
2293impl BlockDestroyResponder {
2294    /// Sends a response to the FIDL transaction.
2295    ///
2296    /// Sets the channel to shutdown if an error occurs.
2297    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
2298        let _result = self.send_raw(status);
2299        if _result.is_err() {
2300            self.control_handle.shutdown();
2301        }
2302        self.drop_without_shutdown();
2303        _result
2304    }
2305
2306    /// Similar to "send" but does not shutdown the channel if an error occurs.
2307    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
2308        let _result = self.send_raw(status);
2309        self.drop_without_shutdown();
2310        _result
2311    }
2312
2313    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
2314        self.control_handle.inner.send::<BlockDestroyResponse>(
2315            (status,),
2316            self.tx_id,
2317            0x5866ba764e05a68e,
2318            fidl::encoding::DynamicFlags::empty(),
2319        )
2320    }
2321}
2322
2323#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2324pub struct MapperMarker;
2325
2326impl fidl::endpoints::ProtocolMarker for MapperMarker {
2327    type Proxy = MapperProxy;
2328    type RequestStream = MapperRequestStream;
2329    #[cfg(target_os = "fuchsia")]
2330    type SynchronousProxy = MapperSynchronousProxy;
2331
2332    const DEBUG_NAME: &'static str = "fuchsia.storage.block.Mapper";
2333}
2334impl fidl::endpoints::DiscoverableProtocolMarker for MapperMarker {}
2335pub type MapperOpenSessionResult = Result<(), i32>;
2336
2337pub trait MapperProxyInterface: Send + Sync {
2338    type OpenSessionResponseFut: std::future::Future<Output = Result<MapperOpenSessionResult, fidl::Error>>
2339        + Send;
2340    fn r#open_session(
2341        &self,
2342        session: fidl::endpoints::ServerEnd<MapperSessionMarker>,
2343        mapping_vmo: fidl::Vmo,
2344        port: Option<fidl::Port>,
2345        delivery_queue: Option<fidl::Vmo>,
2346    ) -> Self::OpenSessionResponseFut;
2347}
2348#[derive(Debug)]
2349#[cfg(target_os = "fuchsia")]
2350pub struct MapperSynchronousProxy {
2351    client: fidl::client::sync::Client,
2352}
2353
2354#[cfg(target_os = "fuchsia")]
2355impl fidl::endpoints::SynchronousProxy for MapperSynchronousProxy {
2356    type Proxy = MapperProxy;
2357    type Protocol = MapperMarker;
2358
2359    fn from_channel(inner: fidl::Channel) -> Self {
2360        Self::new(inner)
2361    }
2362
2363    fn into_channel(self) -> fidl::Channel {
2364        self.client.into_channel()
2365    }
2366
2367    fn as_channel(&self) -> &fidl::Channel {
2368        self.client.as_channel()
2369    }
2370}
2371
2372#[cfg(target_os = "fuchsia")]
2373impl MapperSynchronousProxy {
2374    pub fn new(channel: fidl::Channel) -> Self {
2375        Self { client: fidl::client::sync::Client::new(channel) }
2376    }
2377
2378    pub fn into_channel(self) -> fidl::Channel {
2379        self.client.into_channel()
2380    }
2381
2382    /// Waits until an event arrives and returns it. It is safe for other
2383    /// threads to make concurrent requests while waiting for an event.
2384    pub fn wait_for_event(
2385        &self,
2386        deadline: zx::MonotonicInstant,
2387    ) -> Result<MapperEvent, fidl::Error> {
2388        MapperEvent::decode(self.client.wait_for_event::<MapperMarker>(deadline)?)
2389    }
2390
2391    /// Bootstraps the driver mapper with the mapping VMO and verifier handles.
2392    pub fn r#open_session(
2393        &self,
2394        mut session: fidl::endpoints::ServerEnd<MapperSessionMarker>,
2395        mut mapping_vmo: fidl::Vmo,
2396        mut port: Option<fidl::Port>,
2397        mut delivery_queue: Option<fidl::Vmo>,
2398        ___deadline: zx::MonotonicInstant,
2399    ) -> Result<MapperOpenSessionResult, fidl::Error> {
2400        let _response = self.client.send_query::<
2401            MapperOpenSessionRequest,
2402            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2403            MapperMarker,
2404        >(
2405            (session, mapping_vmo, port, delivery_queue,),
2406            0x638c49dbdff13a9c,
2407            fidl::encoding::DynamicFlags::FLEXIBLE,
2408            ___deadline,
2409        )?
2410        .into_result::<MapperMarker>("open_session")?;
2411        Ok(_response.map(|x| x))
2412    }
2413}
2414
2415#[cfg(target_os = "fuchsia")]
2416impl From<MapperSynchronousProxy> for zx::NullableHandle {
2417    fn from(value: MapperSynchronousProxy) -> Self {
2418        value.into_channel().into()
2419    }
2420}
2421
2422#[cfg(target_os = "fuchsia")]
2423impl From<fidl::Channel> for MapperSynchronousProxy {
2424    fn from(value: fidl::Channel) -> Self {
2425        Self::new(value)
2426    }
2427}
2428
2429#[cfg(target_os = "fuchsia")]
2430impl fidl::endpoints::FromClient for MapperSynchronousProxy {
2431    type Protocol = MapperMarker;
2432
2433    fn from_client(value: fidl::endpoints::ClientEnd<MapperMarker>) -> Self {
2434        Self::new(value.into_channel())
2435    }
2436}
2437
2438#[derive(Debug, Clone)]
2439pub struct MapperProxy {
2440    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2441}
2442
2443impl fidl::endpoints::Proxy for MapperProxy {
2444    type Protocol = MapperMarker;
2445
2446    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2447        Self::new(inner)
2448    }
2449
2450    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2451        self.client.into_channel().map_err(|client| Self { client })
2452    }
2453
2454    fn as_channel(&self) -> &::fidl::AsyncChannel {
2455        self.client.as_channel()
2456    }
2457}
2458
2459impl MapperProxy {
2460    /// Create a new Proxy for fuchsia.storage.block/Mapper.
2461    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2462        let protocol_name = <MapperMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2463        Self { client: fidl::client::Client::new(channel, protocol_name) }
2464    }
2465
2466    /// Get a Stream of events from the remote end of the protocol.
2467    ///
2468    /// # Panics
2469    ///
2470    /// Panics if the event stream was already taken.
2471    pub fn take_event_stream(&self) -> MapperEventStream {
2472        MapperEventStream { event_receiver: self.client.take_event_receiver() }
2473    }
2474
2475    /// Bootstraps the driver mapper with the mapping VMO and verifier handles.
2476    pub fn r#open_session(
2477        &self,
2478        mut session: fidl::endpoints::ServerEnd<MapperSessionMarker>,
2479        mut mapping_vmo: fidl::Vmo,
2480        mut port: Option<fidl::Port>,
2481        mut delivery_queue: Option<fidl::Vmo>,
2482    ) -> fidl::client::QueryResponseFut<
2483        MapperOpenSessionResult,
2484        fidl::encoding::DefaultFuchsiaResourceDialect,
2485    > {
2486        MapperProxyInterface::r#open_session(self, session, mapping_vmo, port, delivery_queue)
2487    }
2488}
2489
2490impl MapperProxyInterface for MapperProxy {
2491    type OpenSessionResponseFut = fidl::client::QueryResponseFut<
2492        MapperOpenSessionResult,
2493        fidl::encoding::DefaultFuchsiaResourceDialect,
2494    >;
2495    fn r#open_session(
2496        &self,
2497        mut session: fidl::endpoints::ServerEnd<MapperSessionMarker>,
2498        mut mapping_vmo: fidl::Vmo,
2499        mut port: Option<fidl::Port>,
2500        mut delivery_queue: Option<fidl::Vmo>,
2501    ) -> Self::OpenSessionResponseFut {
2502        fn _decode(
2503            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2504        ) -> Result<MapperOpenSessionResult, fidl::Error> {
2505            let _response = fidl::client::decode_transaction_body::<
2506                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2507                fidl::encoding::DefaultFuchsiaResourceDialect,
2508                0x638c49dbdff13a9c,
2509            >(_buf?)?
2510            .into_result::<MapperMarker>("open_session")?;
2511            Ok(_response.map(|x| x))
2512        }
2513        self.client.send_query_and_decode::<MapperOpenSessionRequest, MapperOpenSessionResult>(
2514            (session, mapping_vmo, port, delivery_queue),
2515            0x638c49dbdff13a9c,
2516            fidl::encoding::DynamicFlags::FLEXIBLE,
2517            _decode,
2518        )
2519    }
2520}
2521
2522pub struct MapperEventStream {
2523    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2524}
2525
2526impl std::marker::Unpin for MapperEventStream {}
2527
2528impl futures::stream::FusedStream for MapperEventStream {
2529    fn is_terminated(&self) -> bool {
2530        self.event_receiver.is_terminated()
2531    }
2532}
2533
2534impl futures::Stream for MapperEventStream {
2535    type Item = Result<MapperEvent, fidl::Error>;
2536
2537    fn poll_next(
2538        mut self: std::pin::Pin<&mut Self>,
2539        cx: &mut std::task::Context<'_>,
2540    ) -> std::task::Poll<Option<Self::Item>> {
2541        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2542            &mut self.event_receiver,
2543            cx
2544        )?) {
2545            Some(buf) => std::task::Poll::Ready(Some(MapperEvent::decode(buf))),
2546            None => std::task::Poll::Ready(None),
2547        }
2548    }
2549}
2550
2551#[derive(Debug)]
2552pub enum MapperEvent {
2553    #[non_exhaustive]
2554    _UnknownEvent {
2555        /// Ordinal of the event that was sent.
2556        ordinal: u64,
2557    },
2558}
2559
2560impl MapperEvent {
2561    /// Decodes a message buffer as a [`MapperEvent`].
2562    fn decode(
2563        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2564    ) -> Result<MapperEvent, fidl::Error> {
2565        let (bytes, _handles) = buf.split_mut();
2566        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2567        debug_assert_eq!(tx_header.tx_id, 0);
2568        match tx_header.ordinal {
2569            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2570                Ok(MapperEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2571            }
2572            _ => Err(fidl::Error::UnknownOrdinal {
2573                ordinal: tx_header.ordinal,
2574                protocol_name: <MapperMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2575            }),
2576        }
2577    }
2578}
2579
2580/// A Stream of incoming requests for fuchsia.storage.block/Mapper.
2581pub struct MapperRequestStream {
2582    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2583    is_terminated: bool,
2584}
2585
2586impl std::marker::Unpin for MapperRequestStream {}
2587
2588impl futures::stream::FusedStream for MapperRequestStream {
2589    fn is_terminated(&self) -> bool {
2590        self.is_terminated
2591    }
2592}
2593
2594impl fidl::endpoints::RequestStream for MapperRequestStream {
2595    type Protocol = MapperMarker;
2596    type ControlHandle = MapperControlHandle;
2597
2598    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2599        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2600    }
2601
2602    fn control_handle(&self) -> Self::ControlHandle {
2603        MapperControlHandle { inner: self.inner.clone() }
2604    }
2605
2606    fn into_inner(
2607        self,
2608    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2609    {
2610        (self.inner, self.is_terminated)
2611    }
2612
2613    fn from_inner(
2614        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2615        is_terminated: bool,
2616    ) -> Self {
2617        Self { inner, is_terminated }
2618    }
2619}
2620
2621impl futures::Stream for MapperRequestStream {
2622    type Item = Result<MapperRequest, fidl::Error>;
2623
2624    fn poll_next(
2625        mut self: std::pin::Pin<&mut Self>,
2626        cx: &mut std::task::Context<'_>,
2627    ) -> std::task::Poll<Option<Self::Item>> {
2628        let this = &mut *self;
2629        if this.inner.check_shutdown(cx) {
2630            this.is_terminated = true;
2631            return std::task::Poll::Ready(None);
2632        }
2633        if this.is_terminated {
2634            panic!("polled MapperRequestStream after completion");
2635        }
2636        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2637            |bytes, handles| {
2638                match this.inner.channel().read_etc(cx, bytes, handles) {
2639                    std::task::Poll::Ready(Ok(())) => {}
2640                    std::task::Poll::Pending => return std::task::Poll::Pending,
2641                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2642                        this.is_terminated = true;
2643                        return std::task::Poll::Ready(None);
2644                    }
2645                    std::task::Poll::Ready(Err(e)) => {
2646                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2647                            e.into(),
2648                        ))));
2649                    }
2650                }
2651
2652                // A message has been received from the channel
2653                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2654
2655                std::task::Poll::Ready(Some(match header.ordinal {
2656                    0x638c49dbdff13a9c => {
2657                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2658                        let mut req = fidl::new_empty!(
2659                            MapperOpenSessionRequest,
2660                            fidl::encoding::DefaultFuchsiaResourceDialect
2661                        );
2662                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MapperOpenSessionRequest>(&header, _body_bytes, handles, &mut req)?;
2663                        let control_handle = MapperControlHandle { inner: this.inner.clone() };
2664                        Ok(MapperRequest::OpenSession {
2665                            session: req.session,
2666                            mapping_vmo: req.mapping_vmo,
2667                            port: req.port,
2668                            delivery_queue: req.delivery_queue,
2669
2670                            responder: MapperOpenSessionResponder {
2671                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2672                                tx_id: header.tx_id,
2673                            },
2674                        })
2675                    }
2676                    _ if header.tx_id == 0
2677                        && header
2678                            .dynamic_flags()
2679                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2680                    {
2681                        Ok(MapperRequest::_UnknownMethod {
2682                            ordinal: header.ordinal,
2683                            control_handle: MapperControlHandle { inner: this.inner.clone() },
2684                            method_type: fidl::MethodType::OneWay,
2685                        })
2686                    }
2687                    _ if header
2688                        .dynamic_flags()
2689                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2690                    {
2691                        this.inner.send_framework_err(
2692                            fidl::encoding::FrameworkErr::UnknownMethod,
2693                            header.tx_id,
2694                            header.ordinal,
2695                            header.dynamic_flags(),
2696                            (bytes, handles),
2697                        )?;
2698                        Ok(MapperRequest::_UnknownMethod {
2699                            ordinal: header.ordinal,
2700                            control_handle: MapperControlHandle { inner: this.inner.clone() },
2701                            method_type: fidl::MethodType::TwoWay,
2702                        })
2703                    }
2704                    _ => Err(fidl::Error::UnknownOrdinal {
2705                        ordinal: header.ordinal,
2706                        protocol_name:
2707                            <MapperMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2708                    }),
2709                }))
2710            },
2711        )
2712    }
2713}
2714
2715/// Exposed by the block driver, routed via fshost to pkg-cache.
2716#[derive(Debug)]
2717pub enum MapperRequest {
2718    /// Bootstraps the driver mapper with the mapping VMO and verifier handles.
2719    OpenSession {
2720        session: fidl::endpoints::ServerEnd<MapperSessionMarker>,
2721        mapping_vmo: fidl::Vmo,
2722        port: Option<fidl::Port>,
2723        delivery_queue: Option<fidl::Vmo>,
2724        responder: MapperOpenSessionResponder,
2725    },
2726    /// An interaction was received which does not match any known method.
2727    #[non_exhaustive]
2728    _UnknownMethod {
2729        /// Ordinal of the method that was called.
2730        ordinal: u64,
2731        control_handle: MapperControlHandle,
2732        method_type: fidl::MethodType,
2733    },
2734}
2735
2736impl MapperRequest {
2737    #[allow(irrefutable_let_patterns)]
2738    pub fn into_open_session(
2739        self,
2740    ) -> Option<(
2741        fidl::endpoints::ServerEnd<MapperSessionMarker>,
2742        fidl::Vmo,
2743        Option<fidl::Port>,
2744        Option<fidl::Vmo>,
2745        MapperOpenSessionResponder,
2746    )> {
2747        if let MapperRequest::OpenSession {
2748            session,
2749            mapping_vmo,
2750            port,
2751            delivery_queue,
2752            responder,
2753        } = self
2754        {
2755            Some((session, mapping_vmo, port, delivery_queue, responder))
2756        } else {
2757            None
2758        }
2759    }
2760
2761    /// Name of the method defined in FIDL
2762    pub fn method_name(&self) -> &'static str {
2763        match *self {
2764            MapperRequest::OpenSession { .. } => "open_session",
2765            MapperRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2766                "unknown one-way method"
2767            }
2768            MapperRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2769                "unknown two-way method"
2770            }
2771        }
2772    }
2773}
2774
2775#[derive(Debug, Clone)]
2776pub struct MapperControlHandle {
2777    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2778}
2779
2780impl MapperControlHandle {
2781    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2782        self.inner.shutdown_with_epitaph(status.into())
2783    }
2784}
2785
2786impl fidl::endpoints::ControlHandle for MapperControlHandle {
2787    fn shutdown(&self) {
2788        self.inner.shutdown()
2789    }
2790
2791    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2792        self.inner.shutdown_with_epitaph(status)
2793    }
2794
2795    fn is_closed(&self) -> bool {
2796        self.inner.channel().is_closed()
2797    }
2798    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2799        self.inner.channel().on_closed()
2800    }
2801
2802    #[cfg(target_os = "fuchsia")]
2803    fn signal_peer(
2804        &self,
2805        clear_mask: zx::Signals,
2806        set_mask: zx::Signals,
2807    ) -> Result<(), zx_status::Status> {
2808        use fidl::Peered;
2809        self.inner.channel().signal_peer(clear_mask, set_mask)
2810    }
2811}
2812
2813impl MapperControlHandle {}
2814
2815#[must_use = "FIDL methods require a response to be sent"]
2816#[derive(Debug)]
2817pub struct MapperOpenSessionResponder {
2818    control_handle: std::mem::ManuallyDrop<MapperControlHandle>,
2819    tx_id: u32,
2820}
2821
2822/// Set the the channel to be shutdown (see [`MapperControlHandle::shutdown`])
2823/// if the responder is dropped without sending a response, so that the client
2824/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2825impl std::ops::Drop for MapperOpenSessionResponder {
2826    fn drop(&mut self) {
2827        self.control_handle.shutdown();
2828        // Safety: drops once, never accessed again
2829        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2830    }
2831}
2832
2833impl fidl::endpoints::Responder for MapperOpenSessionResponder {
2834    type ControlHandle = MapperControlHandle;
2835
2836    fn control_handle(&self) -> &MapperControlHandle {
2837        &self.control_handle
2838    }
2839
2840    fn drop_without_shutdown(mut self) {
2841        // Safety: drops once, never accessed again due to mem::forget
2842        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2843        // Prevent Drop from running (which would shut down the channel)
2844        std::mem::forget(self);
2845    }
2846}
2847
2848impl MapperOpenSessionResponder {
2849    /// Sends a response to the FIDL transaction.
2850    ///
2851    /// Sets the channel to shutdown if an error occurs.
2852    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2853        let _result = self.send_raw(result);
2854        if _result.is_err() {
2855            self.control_handle.shutdown();
2856        }
2857        self.drop_without_shutdown();
2858        _result
2859    }
2860
2861    /// Similar to "send" but does not shutdown the channel if an error occurs.
2862    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2863        let _result = self.send_raw(result);
2864        self.drop_without_shutdown();
2865        _result
2866    }
2867
2868    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2869        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2870            fidl::encoding::EmptyStruct,
2871            i32,
2872        >>(
2873            fidl::encoding::FlexibleResult::new(result),
2874            self.tx_id,
2875            0x638c49dbdff13a9c,
2876            fidl::encoding::DynamicFlags::FLEXIBLE,
2877        )
2878    }
2879}
2880
2881#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2882pub struct MapperSessionMarker;
2883
2884impl fidl::endpoints::ProtocolMarker for MapperSessionMarker {
2885    type Proxy = MapperSessionProxy;
2886    type RequestStream = MapperSessionRequestStream;
2887    #[cfg(target_os = "fuchsia")]
2888    type SynchronousProxy = MapperSessionSynchronousProxy;
2889
2890    const DEBUG_NAME: &'static str = "(anonymous) MapperSession";
2891}
2892pub type MapperSessionCreateVmoResult = Result<fidl::Vmo, i32>;
2893pub type MapperSessionOpenChildSessionResult = Result<(), i32>;
2894pub type MapperSessionRecordProfileResult = Result<(), i32>;
2895
2896pub trait MapperSessionProxyInterface: Send + Sync {
2897    type CloseResponseFut: std::future::Future<
2898            Output = Result<fidl_fuchsia_unknown::CloseableCloseResult, fidl::Error>,
2899        > + Send;
2900    fn r#close(&self) -> Self::CloseResponseFut;
2901    type CreateVmoResponseFut: std::future::Future<Output = Result<MapperSessionCreateVmoResult, fidl::Error>>
2902        + Send;
2903    fn r#create_vmo(
2904        &self,
2905        key: u64,
2906        size: u64,
2907        options: CreateVmoOptions,
2908    ) -> Self::CreateVmoResponseFut;
2909    type OpenChildSessionResponseFut: std::future::Future<Output = Result<MapperSessionOpenChildSessionResult, fidl::Error>>
2910        + Send;
2911    fn r#open_child_session(
2912        &self,
2913        session: fidl::endpoints::ServerEnd<MapperSessionMarker>,
2914        mapping_vmo: fidl::Vmo,
2915        parent_key: u64,
2916        port: Option<fidl::Port>,
2917        delivery_queue: Option<fidl::Vmo>,
2918    ) -> Self::OpenChildSessionResponseFut;
2919    type RecordProfileResponseFut: std::future::Future<Output = Result<MapperSessionRecordProfileResult, fidl::Error>>
2920        + Send;
2921    fn r#record_profile(
2922        &self,
2923        recording: fidl::endpoints::ServerEnd<RecordingMarker>,
2924    ) -> Self::RecordProfileResponseFut;
2925}
2926#[derive(Debug)]
2927#[cfg(target_os = "fuchsia")]
2928pub struct MapperSessionSynchronousProxy {
2929    client: fidl::client::sync::Client,
2930}
2931
2932#[cfg(target_os = "fuchsia")]
2933impl fidl::endpoints::SynchronousProxy for MapperSessionSynchronousProxy {
2934    type Proxy = MapperSessionProxy;
2935    type Protocol = MapperSessionMarker;
2936
2937    fn from_channel(inner: fidl::Channel) -> Self {
2938        Self::new(inner)
2939    }
2940
2941    fn into_channel(self) -> fidl::Channel {
2942        self.client.into_channel()
2943    }
2944
2945    fn as_channel(&self) -> &fidl::Channel {
2946        self.client.as_channel()
2947    }
2948}
2949
2950#[cfg(target_os = "fuchsia")]
2951impl MapperSessionSynchronousProxy {
2952    pub fn new(channel: fidl::Channel) -> Self {
2953        Self { client: fidl::client::sync::Client::new(channel) }
2954    }
2955
2956    pub fn into_channel(self) -> fidl::Channel {
2957        self.client.into_channel()
2958    }
2959
2960    /// Waits until an event arrives and returns it. It is safe for other
2961    /// threads to make concurrent requests while waiting for an event.
2962    pub fn wait_for_event(
2963        &self,
2964        deadline: zx::MonotonicInstant,
2965    ) -> Result<MapperSessionEvent, fidl::Error> {
2966        MapperSessionEvent::decode(self.client.wait_for_event::<MapperSessionMarker>(deadline)?)
2967    }
2968
2969    /// Terminates the connection.
2970    ///
2971    /// After calling `Close`, the client must not send any other requests.
2972    ///
2973    /// Servers, after sending the status response, should close the connection
2974    /// regardless of status and without sending an epitaph.
2975    ///
2976    /// Closing the client end of the channel should be semantically equivalent
2977    /// to calling `Close` without knowing when the close has completed or its
2978    /// status.
2979    pub fn r#close(
2980        &self,
2981        ___deadline: zx::MonotonicInstant,
2982    ) -> Result<fidl_fuchsia_unknown::CloseableCloseResult, fidl::Error> {
2983        let _response = self.client.send_query::<
2984            fidl::encoding::EmptyPayload,
2985            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2986            MapperSessionMarker,
2987        >(
2988            (),
2989            0x5ac5d459ad7f657e,
2990            fidl::encoding::DynamicFlags::empty(),
2991            ___deadline,
2992        )?;
2993        Ok(_response.map(|x| x))
2994    }
2995
2996    /// Creates a pager-backed VMO of `size` bytes associated with `key`.
2997    /// Page faults on this VMO are handled directly by the driver mapper.
2998    pub fn r#create_vmo(
2999        &self,
3000        mut key: u64,
3001        mut size: u64,
3002        mut options: CreateVmoOptions,
3003        ___deadline: zx::MonotonicInstant,
3004    ) -> Result<MapperSessionCreateVmoResult, fidl::Error> {
3005        let _response = self.client.send_query::<
3006            MapperSessionCreateVmoRequest,
3007            fidl::encoding::FlexibleResultType<MapperSessionCreateVmoResponse, i32>,
3008            MapperSessionMarker,
3009        >(
3010            (key, size, options,),
3011            0x35be1bf1bd0f9e1d,
3012            fidl::encoding::DynamicFlags::FLEXIBLE,
3013            ___deadline,
3014        )?
3015        .into_result::<MapperSessionMarker>("create_vmo")?;
3016        Ok(_response.map(|x| x.vmo))
3017    }
3018
3019    /// Opens a child mapper session whose reads map through `parent_key` in the parent session.
3020    /// When a parent session is closed, all child sessions opened from it are closed as well.
3021    pub fn r#open_child_session(
3022        &self,
3023        mut session: fidl::endpoints::ServerEnd<MapperSessionMarker>,
3024        mut mapping_vmo: fidl::Vmo,
3025        mut parent_key: u64,
3026        mut port: Option<fidl::Port>,
3027        mut delivery_queue: Option<fidl::Vmo>,
3028        ___deadline: zx::MonotonicInstant,
3029    ) -> Result<MapperSessionOpenChildSessionResult, fidl::Error> {
3030        let _response = self.client.send_query::<
3031            MapperSessionOpenChildSessionRequest,
3032            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
3033            MapperSessionMarker,
3034        >(
3035            (session, mapping_vmo, parent_key, port, delivery_queue,),
3036            0x7b80686acf9dcca3,
3037            fidl::encoding::DynamicFlags::FLEXIBLE,
3038            ___deadline,
3039        )?
3040        .into_result::<MapperSessionMarker>("open_child_session")?;
3041        Ok(_response.map(|x| x))
3042    }
3043
3044    /// Starts recording an access profile for this mapper session.
3045    pub fn r#record_profile(
3046        &self,
3047        mut recording: fidl::endpoints::ServerEnd<RecordingMarker>,
3048        ___deadline: zx::MonotonicInstant,
3049    ) -> Result<MapperSessionRecordProfileResult, fidl::Error> {
3050        let _response = self.client.send_query::<
3051            MapperSessionRecordProfileRequest,
3052            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
3053            MapperSessionMarker,
3054        >(
3055            (recording,),
3056            0x5632286dc15cd420,
3057            fidl::encoding::DynamicFlags::FLEXIBLE,
3058            ___deadline,
3059        )?
3060        .into_result::<MapperSessionMarker>("record_profile")?;
3061        Ok(_response.map(|x| x))
3062    }
3063}
3064
3065#[cfg(target_os = "fuchsia")]
3066impl From<MapperSessionSynchronousProxy> for zx::NullableHandle {
3067    fn from(value: MapperSessionSynchronousProxy) -> Self {
3068        value.into_channel().into()
3069    }
3070}
3071
3072#[cfg(target_os = "fuchsia")]
3073impl From<fidl::Channel> for MapperSessionSynchronousProxy {
3074    fn from(value: fidl::Channel) -> Self {
3075        Self::new(value)
3076    }
3077}
3078
3079#[cfg(target_os = "fuchsia")]
3080impl fidl::endpoints::FromClient for MapperSessionSynchronousProxy {
3081    type Protocol = MapperSessionMarker;
3082
3083    fn from_client(value: fidl::endpoints::ClientEnd<MapperSessionMarker>) -> Self {
3084        Self::new(value.into_channel())
3085    }
3086}
3087
3088#[derive(Debug, Clone)]
3089pub struct MapperSessionProxy {
3090    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3091}
3092
3093impl fidl::endpoints::Proxy for MapperSessionProxy {
3094    type Protocol = MapperSessionMarker;
3095
3096    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3097        Self::new(inner)
3098    }
3099
3100    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3101        self.client.into_channel().map_err(|client| Self { client })
3102    }
3103
3104    fn as_channel(&self) -> &::fidl::AsyncChannel {
3105        self.client.as_channel()
3106    }
3107}
3108
3109impl MapperSessionProxy {
3110    /// Create a new Proxy for fuchsia.storage.block/MapperSession.
3111    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3112        let protocol_name = <MapperSessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3113        Self { client: fidl::client::Client::new(channel, protocol_name) }
3114    }
3115
3116    /// Get a Stream of events from the remote end of the protocol.
3117    ///
3118    /// # Panics
3119    ///
3120    /// Panics if the event stream was already taken.
3121    pub fn take_event_stream(&self) -> MapperSessionEventStream {
3122        MapperSessionEventStream { event_receiver: self.client.take_event_receiver() }
3123    }
3124
3125    /// Terminates the connection.
3126    ///
3127    /// After calling `Close`, the client must not send any other requests.
3128    ///
3129    /// Servers, after sending the status response, should close the connection
3130    /// regardless of status and without sending an epitaph.
3131    ///
3132    /// Closing the client end of the channel should be semantically equivalent
3133    /// to calling `Close` without knowing when the close has completed or its
3134    /// status.
3135    pub fn r#close(
3136        &self,
3137    ) -> fidl::client::QueryResponseFut<
3138        fidl_fuchsia_unknown::CloseableCloseResult,
3139        fidl::encoding::DefaultFuchsiaResourceDialect,
3140    > {
3141        MapperSessionProxyInterface::r#close(self)
3142    }
3143
3144    /// Creates a pager-backed VMO of `size` bytes associated with `key`.
3145    /// Page faults on this VMO are handled directly by the driver mapper.
3146    pub fn r#create_vmo(
3147        &self,
3148        mut key: u64,
3149        mut size: u64,
3150        mut options: CreateVmoOptions,
3151    ) -> fidl::client::QueryResponseFut<
3152        MapperSessionCreateVmoResult,
3153        fidl::encoding::DefaultFuchsiaResourceDialect,
3154    > {
3155        MapperSessionProxyInterface::r#create_vmo(self, key, size, options)
3156    }
3157
3158    /// Opens a child mapper session whose reads map through `parent_key` in the parent session.
3159    /// When a parent session is closed, all child sessions opened from it are closed as well.
3160    pub fn r#open_child_session(
3161        &self,
3162        mut session: fidl::endpoints::ServerEnd<MapperSessionMarker>,
3163        mut mapping_vmo: fidl::Vmo,
3164        mut parent_key: u64,
3165        mut port: Option<fidl::Port>,
3166        mut delivery_queue: Option<fidl::Vmo>,
3167    ) -> fidl::client::QueryResponseFut<
3168        MapperSessionOpenChildSessionResult,
3169        fidl::encoding::DefaultFuchsiaResourceDialect,
3170    > {
3171        MapperSessionProxyInterface::r#open_child_session(
3172            self,
3173            session,
3174            mapping_vmo,
3175            parent_key,
3176            port,
3177            delivery_queue,
3178        )
3179    }
3180
3181    /// Starts recording an access profile for this mapper session.
3182    pub fn r#record_profile(
3183        &self,
3184        mut recording: fidl::endpoints::ServerEnd<RecordingMarker>,
3185    ) -> fidl::client::QueryResponseFut<
3186        MapperSessionRecordProfileResult,
3187        fidl::encoding::DefaultFuchsiaResourceDialect,
3188    > {
3189        MapperSessionProxyInterface::r#record_profile(self, recording)
3190    }
3191}
3192
3193impl MapperSessionProxyInterface for MapperSessionProxy {
3194    type CloseResponseFut = fidl::client::QueryResponseFut<
3195        fidl_fuchsia_unknown::CloseableCloseResult,
3196        fidl::encoding::DefaultFuchsiaResourceDialect,
3197    >;
3198    fn r#close(&self) -> Self::CloseResponseFut {
3199        fn _decode(
3200            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3201        ) -> Result<fidl_fuchsia_unknown::CloseableCloseResult, fidl::Error> {
3202            let _response = fidl::client::decode_transaction_body::<
3203                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3204                fidl::encoding::DefaultFuchsiaResourceDialect,
3205                0x5ac5d459ad7f657e,
3206            >(_buf?)?;
3207            Ok(_response.map(|x| x))
3208        }
3209        self.client.send_query_and_decode::<
3210            fidl::encoding::EmptyPayload,
3211            fidl_fuchsia_unknown::CloseableCloseResult,
3212        >(
3213            (),
3214            0x5ac5d459ad7f657e,
3215            fidl::encoding::DynamicFlags::empty(),
3216            _decode,
3217        )
3218    }
3219
3220    type CreateVmoResponseFut = fidl::client::QueryResponseFut<
3221        MapperSessionCreateVmoResult,
3222        fidl::encoding::DefaultFuchsiaResourceDialect,
3223    >;
3224    fn r#create_vmo(
3225        &self,
3226        mut key: u64,
3227        mut size: u64,
3228        mut options: CreateVmoOptions,
3229    ) -> Self::CreateVmoResponseFut {
3230        fn _decode(
3231            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3232        ) -> Result<MapperSessionCreateVmoResult, fidl::Error> {
3233            let _response = fidl::client::decode_transaction_body::<
3234                fidl::encoding::FlexibleResultType<MapperSessionCreateVmoResponse, i32>,
3235                fidl::encoding::DefaultFuchsiaResourceDialect,
3236                0x35be1bf1bd0f9e1d,
3237            >(_buf?)?
3238            .into_result::<MapperSessionMarker>("create_vmo")?;
3239            Ok(_response.map(|x| x.vmo))
3240        }
3241        self.client
3242            .send_query_and_decode::<MapperSessionCreateVmoRequest, MapperSessionCreateVmoResult>(
3243                (key, size, options),
3244                0x35be1bf1bd0f9e1d,
3245                fidl::encoding::DynamicFlags::FLEXIBLE,
3246                _decode,
3247            )
3248    }
3249
3250    type OpenChildSessionResponseFut = fidl::client::QueryResponseFut<
3251        MapperSessionOpenChildSessionResult,
3252        fidl::encoding::DefaultFuchsiaResourceDialect,
3253    >;
3254    fn r#open_child_session(
3255        &self,
3256        mut session: fidl::endpoints::ServerEnd<MapperSessionMarker>,
3257        mut mapping_vmo: fidl::Vmo,
3258        mut parent_key: u64,
3259        mut port: Option<fidl::Port>,
3260        mut delivery_queue: Option<fidl::Vmo>,
3261    ) -> Self::OpenChildSessionResponseFut {
3262        fn _decode(
3263            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3264        ) -> Result<MapperSessionOpenChildSessionResult, fidl::Error> {
3265            let _response = fidl::client::decode_transaction_body::<
3266                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
3267                fidl::encoding::DefaultFuchsiaResourceDialect,
3268                0x7b80686acf9dcca3,
3269            >(_buf?)?
3270            .into_result::<MapperSessionMarker>("open_child_session")?;
3271            Ok(_response.map(|x| x))
3272        }
3273        self.client.send_query_and_decode::<
3274            MapperSessionOpenChildSessionRequest,
3275            MapperSessionOpenChildSessionResult,
3276        >(
3277            (session, mapping_vmo, parent_key, port, delivery_queue,),
3278            0x7b80686acf9dcca3,
3279            fidl::encoding::DynamicFlags::FLEXIBLE,
3280            _decode,
3281        )
3282    }
3283
3284    type RecordProfileResponseFut = fidl::client::QueryResponseFut<
3285        MapperSessionRecordProfileResult,
3286        fidl::encoding::DefaultFuchsiaResourceDialect,
3287    >;
3288    fn r#record_profile(
3289        &self,
3290        mut recording: fidl::endpoints::ServerEnd<RecordingMarker>,
3291    ) -> Self::RecordProfileResponseFut {
3292        fn _decode(
3293            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3294        ) -> Result<MapperSessionRecordProfileResult, fidl::Error> {
3295            let _response = fidl::client::decode_transaction_body::<
3296                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
3297                fidl::encoding::DefaultFuchsiaResourceDialect,
3298                0x5632286dc15cd420,
3299            >(_buf?)?
3300            .into_result::<MapperSessionMarker>("record_profile")?;
3301            Ok(_response.map(|x| x))
3302        }
3303        self.client.send_query_and_decode::<
3304            MapperSessionRecordProfileRequest,
3305            MapperSessionRecordProfileResult,
3306        >(
3307            (recording,),
3308            0x5632286dc15cd420,
3309            fidl::encoding::DynamicFlags::FLEXIBLE,
3310            _decode,
3311        )
3312    }
3313}
3314
3315pub struct MapperSessionEventStream {
3316    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3317}
3318
3319impl std::marker::Unpin for MapperSessionEventStream {}
3320
3321impl futures::stream::FusedStream for MapperSessionEventStream {
3322    fn is_terminated(&self) -> bool {
3323        self.event_receiver.is_terminated()
3324    }
3325}
3326
3327impl futures::Stream for MapperSessionEventStream {
3328    type Item = Result<MapperSessionEvent, fidl::Error>;
3329
3330    fn poll_next(
3331        mut self: std::pin::Pin<&mut Self>,
3332        cx: &mut std::task::Context<'_>,
3333    ) -> std::task::Poll<Option<Self::Item>> {
3334        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3335            &mut self.event_receiver,
3336            cx
3337        )?) {
3338            Some(buf) => std::task::Poll::Ready(Some(MapperSessionEvent::decode(buf))),
3339            None => std::task::Poll::Ready(None),
3340        }
3341    }
3342}
3343
3344#[derive(Debug)]
3345pub enum MapperSessionEvent {
3346    #[non_exhaustive]
3347    _UnknownEvent {
3348        /// Ordinal of the event that was sent.
3349        ordinal: u64,
3350    },
3351}
3352
3353impl MapperSessionEvent {
3354    /// Decodes a message buffer as a [`MapperSessionEvent`].
3355    fn decode(
3356        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3357    ) -> Result<MapperSessionEvent, fidl::Error> {
3358        let (bytes, _handles) = buf.split_mut();
3359        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3360        debug_assert_eq!(tx_header.tx_id, 0);
3361        match tx_header.ordinal {
3362            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3363                Ok(MapperSessionEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3364            }
3365            _ => Err(fidl::Error::UnknownOrdinal {
3366                ordinal: tx_header.ordinal,
3367                protocol_name: <MapperSessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3368            }),
3369        }
3370    }
3371}
3372
3373/// A Stream of incoming requests for fuchsia.storage.block/MapperSession.
3374pub struct MapperSessionRequestStream {
3375    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3376    is_terminated: bool,
3377}
3378
3379impl std::marker::Unpin for MapperSessionRequestStream {}
3380
3381impl futures::stream::FusedStream for MapperSessionRequestStream {
3382    fn is_terminated(&self) -> bool {
3383        self.is_terminated
3384    }
3385}
3386
3387impl fidl::endpoints::RequestStream for MapperSessionRequestStream {
3388    type Protocol = MapperSessionMarker;
3389    type ControlHandle = MapperSessionControlHandle;
3390
3391    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3392        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3393    }
3394
3395    fn control_handle(&self) -> Self::ControlHandle {
3396        MapperSessionControlHandle { inner: self.inner.clone() }
3397    }
3398
3399    fn into_inner(
3400        self,
3401    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3402    {
3403        (self.inner, self.is_terminated)
3404    }
3405
3406    fn from_inner(
3407        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3408        is_terminated: bool,
3409    ) -> Self {
3410        Self { inner, is_terminated }
3411    }
3412}
3413
3414impl futures::Stream for MapperSessionRequestStream {
3415    type Item = Result<MapperSessionRequest, fidl::Error>;
3416
3417    fn poll_next(
3418        mut self: std::pin::Pin<&mut Self>,
3419        cx: &mut std::task::Context<'_>,
3420    ) -> std::task::Poll<Option<Self::Item>> {
3421        let this = &mut *self;
3422        if this.inner.check_shutdown(cx) {
3423            this.is_terminated = true;
3424            return std::task::Poll::Ready(None);
3425        }
3426        if this.is_terminated {
3427            panic!("polled MapperSessionRequestStream after completion");
3428        }
3429        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3430            |bytes, handles| {
3431                match this.inner.channel().read_etc(cx, bytes, handles) {
3432                    std::task::Poll::Ready(Ok(())) => {}
3433                    std::task::Poll::Pending => return std::task::Poll::Pending,
3434                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3435                        this.is_terminated = true;
3436                        return std::task::Poll::Ready(None);
3437                    }
3438                    std::task::Poll::Ready(Err(e)) => {
3439                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3440                            e.into(),
3441                        ))));
3442                    }
3443                }
3444
3445                // A message has been received from the channel
3446                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3447
3448                std::task::Poll::Ready(Some(match header.ordinal {
3449                    0x5ac5d459ad7f657e => {
3450                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3451                        let mut req = fidl::new_empty!(
3452                            fidl::encoding::EmptyPayload,
3453                            fidl::encoding::DefaultFuchsiaResourceDialect
3454                        );
3455                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3456                        let control_handle =
3457                            MapperSessionControlHandle { inner: this.inner.clone() };
3458                        Ok(MapperSessionRequest::Close {
3459                            responder: MapperSessionCloseResponder {
3460                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3461                                tx_id: header.tx_id,
3462                            },
3463                        })
3464                    }
3465                    0x35be1bf1bd0f9e1d => {
3466                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3467                        let mut req = fidl::new_empty!(
3468                            MapperSessionCreateVmoRequest,
3469                            fidl::encoding::DefaultFuchsiaResourceDialect
3470                        );
3471                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MapperSessionCreateVmoRequest>(&header, _body_bytes, handles, &mut req)?;
3472                        let control_handle =
3473                            MapperSessionControlHandle { inner: this.inner.clone() };
3474                        Ok(MapperSessionRequest::CreateVmo {
3475                            key: req.key,
3476                            size: req.size,
3477                            options: req.options,
3478
3479                            responder: MapperSessionCreateVmoResponder {
3480                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3481                                tx_id: header.tx_id,
3482                            },
3483                        })
3484                    }
3485                    0x7b80686acf9dcca3 => {
3486                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3487                        let mut req = fidl::new_empty!(
3488                            MapperSessionOpenChildSessionRequest,
3489                            fidl::encoding::DefaultFuchsiaResourceDialect
3490                        );
3491                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MapperSessionOpenChildSessionRequest>(&header, _body_bytes, handles, &mut req)?;
3492                        let control_handle =
3493                            MapperSessionControlHandle { inner: this.inner.clone() };
3494                        Ok(MapperSessionRequest::OpenChildSession {
3495                            session: req.session,
3496                            mapping_vmo: req.mapping_vmo,
3497                            parent_key: req.parent_key,
3498                            port: req.port,
3499                            delivery_queue: req.delivery_queue,
3500
3501                            responder: MapperSessionOpenChildSessionResponder {
3502                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3503                                tx_id: header.tx_id,
3504                            },
3505                        })
3506                    }
3507                    0x5632286dc15cd420 => {
3508                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3509                        let mut req = fidl::new_empty!(
3510                            MapperSessionRecordProfileRequest,
3511                            fidl::encoding::DefaultFuchsiaResourceDialect
3512                        );
3513                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MapperSessionRecordProfileRequest>(&header, _body_bytes, handles, &mut req)?;
3514                        let control_handle =
3515                            MapperSessionControlHandle { inner: this.inner.clone() };
3516                        Ok(MapperSessionRequest::RecordProfile {
3517                            recording: req.recording,
3518
3519                            responder: MapperSessionRecordProfileResponder {
3520                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3521                                tx_id: header.tx_id,
3522                            },
3523                        })
3524                    }
3525                    _ if header.tx_id == 0
3526                        && header
3527                            .dynamic_flags()
3528                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3529                    {
3530                        Ok(MapperSessionRequest::_UnknownMethod {
3531                            ordinal: header.ordinal,
3532                            control_handle: MapperSessionControlHandle {
3533                                inner: this.inner.clone(),
3534                            },
3535                            method_type: fidl::MethodType::OneWay,
3536                        })
3537                    }
3538                    _ if header
3539                        .dynamic_flags()
3540                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3541                    {
3542                        this.inner.send_framework_err(
3543                            fidl::encoding::FrameworkErr::UnknownMethod,
3544                            header.tx_id,
3545                            header.ordinal,
3546                            header.dynamic_flags(),
3547                            (bytes, handles),
3548                        )?;
3549                        Ok(MapperSessionRequest::_UnknownMethod {
3550                            ordinal: header.ordinal,
3551                            control_handle: MapperSessionControlHandle {
3552                                inner: this.inner.clone(),
3553                            },
3554                            method_type: fidl::MethodType::TwoWay,
3555                        })
3556                    }
3557                    _ => Err(fidl::Error::UnknownOrdinal {
3558                        ordinal: header.ordinal,
3559                        protocol_name:
3560                            <MapperSessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3561                    }),
3562                }))
3563            },
3564        )
3565    }
3566}
3567
3568/// Represents an active driver mapping session.
3569#[derive(Debug)]
3570pub enum MapperSessionRequest {
3571    /// Terminates the connection.
3572    ///
3573    /// After calling `Close`, the client must not send any other requests.
3574    ///
3575    /// Servers, after sending the status response, should close the connection
3576    /// regardless of status and without sending an epitaph.
3577    ///
3578    /// Closing the client end of the channel should be semantically equivalent
3579    /// to calling `Close` without knowing when the close has completed or its
3580    /// status.
3581    Close { responder: MapperSessionCloseResponder },
3582    /// Creates a pager-backed VMO of `size` bytes associated with `key`.
3583    /// Page faults on this VMO are handled directly by the driver mapper.
3584    CreateVmo {
3585        key: u64,
3586        size: u64,
3587        options: CreateVmoOptions,
3588        responder: MapperSessionCreateVmoResponder,
3589    },
3590    /// Opens a child mapper session whose reads map through `parent_key` in the parent session.
3591    /// When a parent session is closed, all child sessions opened from it are closed as well.
3592    OpenChildSession {
3593        session: fidl::endpoints::ServerEnd<MapperSessionMarker>,
3594        mapping_vmo: fidl::Vmo,
3595        parent_key: u64,
3596        port: Option<fidl::Port>,
3597        delivery_queue: Option<fidl::Vmo>,
3598        responder: MapperSessionOpenChildSessionResponder,
3599    },
3600    /// Starts recording an access profile for this mapper session.
3601    RecordProfile {
3602        recording: fidl::endpoints::ServerEnd<RecordingMarker>,
3603        responder: MapperSessionRecordProfileResponder,
3604    },
3605    /// An interaction was received which does not match any known method.
3606    #[non_exhaustive]
3607    _UnknownMethod {
3608        /// Ordinal of the method that was called.
3609        ordinal: u64,
3610        control_handle: MapperSessionControlHandle,
3611        method_type: fidl::MethodType,
3612    },
3613}
3614
3615impl MapperSessionRequest {
3616    #[allow(irrefutable_let_patterns)]
3617    pub fn into_close(self) -> Option<(MapperSessionCloseResponder)> {
3618        if let MapperSessionRequest::Close { responder } = self { Some((responder)) } else { None }
3619    }
3620
3621    #[allow(irrefutable_let_patterns)]
3622    pub fn into_create_vmo(
3623        self,
3624    ) -> Option<(u64, u64, CreateVmoOptions, MapperSessionCreateVmoResponder)> {
3625        if let MapperSessionRequest::CreateVmo { key, size, options, responder } = self {
3626            Some((key, size, options, responder))
3627        } else {
3628            None
3629        }
3630    }
3631
3632    #[allow(irrefutable_let_patterns)]
3633    pub fn into_open_child_session(
3634        self,
3635    ) -> Option<(
3636        fidl::endpoints::ServerEnd<MapperSessionMarker>,
3637        fidl::Vmo,
3638        u64,
3639        Option<fidl::Port>,
3640        Option<fidl::Vmo>,
3641        MapperSessionOpenChildSessionResponder,
3642    )> {
3643        if let MapperSessionRequest::OpenChildSession {
3644            session,
3645            mapping_vmo,
3646            parent_key,
3647            port,
3648            delivery_queue,
3649            responder,
3650        } = self
3651        {
3652            Some((session, mapping_vmo, parent_key, port, delivery_queue, responder))
3653        } else {
3654            None
3655        }
3656    }
3657
3658    #[allow(irrefutable_let_patterns)]
3659    pub fn into_record_profile(
3660        self,
3661    ) -> Option<(fidl::endpoints::ServerEnd<RecordingMarker>, MapperSessionRecordProfileResponder)>
3662    {
3663        if let MapperSessionRequest::RecordProfile { recording, responder } = self {
3664            Some((recording, responder))
3665        } else {
3666            None
3667        }
3668    }
3669
3670    /// Name of the method defined in FIDL
3671    pub fn method_name(&self) -> &'static str {
3672        match *self {
3673            MapperSessionRequest::Close { .. } => "close",
3674            MapperSessionRequest::CreateVmo { .. } => "create_vmo",
3675            MapperSessionRequest::OpenChildSession { .. } => "open_child_session",
3676            MapperSessionRequest::RecordProfile { .. } => "record_profile",
3677            MapperSessionRequest::_UnknownMethod {
3678                method_type: fidl::MethodType::OneWay, ..
3679            } => "unknown one-way method",
3680            MapperSessionRequest::_UnknownMethod {
3681                method_type: fidl::MethodType::TwoWay, ..
3682            } => "unknown two-way method",
3683        }
3684    }
3685}
3686
3687#[derive(Debug, Clone)]
3688pub struct MapperSessionControlHandle {
3689    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3690}
3691
3692impl MapperSessionControlHandle {
3693    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3694        self.inner.shutdown_with_epitaph(status.into())
3695    }
3696}
3697
3698impl fidl::endpoints::ControlHandle for MapperSessionControlHandle {
3699    fn shutdown(&self) {
3700        self.inner.shutdown()
3701    }
3702
3703    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3704        self.inner.shutdown_with_epitaph(status)
3705    }
3706
3707    fn is_closed(&self) -> bool {
3708        self.inner.channel().is_closed()
3709    }
3710    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3711        self.inner.channel().on_closed()
3712    }
3713
3714    #[cfg(target_os = "fuchsia")]
3715    fn signal_peer(
3716        &self,
3717        clear_mask: zx::Signals,
3718        set_mask: zx::Signals,
3719    ) -> Result<(), zx_status::Status> {
3720        use fidl::Peered;
3721        self.inner.channel().signal_peer(clear_mask, set_mask)
3722    }
3723}
3724
3725impl MapperSessionControlHandle {}
3726
3727#[must_use = "FIDL methods require a response to be sent"]
3728#[derive(Debug)]
3729pub struct MapperSessionCloseResponder {
3730    control_handle: std::mem::ManuallyDrop<MapperSessionControlHandle>,
3731    tx_id: u32,
3732}
3733
3734/// Set the the channel to be shutdown (see [`MapperSessionControlHandle::shutdown`])
3735/// if the responder is dropped without sending a response, so that the client
3736/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3737impl std::ops::Drop for MapperSessionCloseResponder {
3738    fn drop(&mut self) {
3739        self.control_handle.shutdown();
3740        // Safety: drops once, never accessed again
3741        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3742    }
3743}
3744
3745impl fidl::endpoints::Responder for MapperSessionCloseResponder {
3746    type ControlHandle = MapperSessionControlHandle;
3747
3748    fn control_handle(&self) -> &MapperSessionControlHandle {
3749        &self.control_handle
3750    }
3751
3752    fn drop_without_shutdown(mut self) {
3753        // Safety: drops once, never accessed again due to mem::forget
3754        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3755        // Prevent Drop from running (which would shut down the channel)
3756        std::mem::forget(self);
3757    }
3758}
3759
3760impl MapperSessionCloseResponder {
3761    /// Sends a response to the FIDL transaction.
3762    ///
3763    /// Sets the channel to shutdown if an error occurs.
3764    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3765        let _result = self.send_raw(result);
3766        if _result.is_err() {
3767            self.control_handle.shutdown();
3768        }
3769        self.drop_without_shutdown();
3770        _result
3771    }
3772
3773    /// Similar to "send" but does not shutdown the channel if an error occurs.
3774    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3775        let _result = self.send_raw(result);
3776        self.drop_without_shutdown();
3777        _result
3778    }
3779
3780    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3781        self.control_handle
3782            .inner
3783            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3784                result,
3785                self.tx_id,
3786                0x5ac5d459ad7f657e,
3787                fidl::encoding::DynamicFlags::empty(),
3788            )
3789    }
3790}
3791
3792#[must_use = "FIDL methods require a response to be sent"]
3793#[derive(Debug)]
3794pub struct MapperSessionCreateVmoResponder {
3795    control_handle: std::mem::ManuallyDrop<MapperSessionControlHandle>,
3796    tx_id: u32,
3797}
3798
3799/// Set the the channel to be shutdown (see [`MapperSessionControlHandle::shutdown`])
3800/// if the responder is dropped without sending a response, so that the client
3801/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3802impl std::ops::Drop for MapperSessionCreateVmoResponder {
3803    fn drop(&mut self) {
3804        self.control_handle.shutdown();
3805        // Safety: drops once, never accessed again
3806        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3807    }
3808}
3809
3810impl fidl::endpoints::Responder for MapperSessionCreateVmoResponder {
3811    type ControlHandle = MapperSessionControlHandle;
3812
3813    fn control_handle(&self) -> &MapperSessionControlHandle {
3814        &self.control_handle
3815    }
3816
3817    fn drop_without_shutdown(mut self) {
3818        // Safety: drops once, never accessed again due to mem::forget
3819        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3820        // Prevent Drop from running (which would shut down the channel)
3821        std::mem::forget(self);
3822    }
3823}
3824
3825impl MapperSessionCreateVmoResponder {
3826    /// Sends a response to the FIDL transaction.
3827    ///
3828    /// Sets the channel to shutdown if an error occurs.
3829    pub fn send(self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
3830        let _result = self.send_raw(result);
3831        if _result.is_err() {
3832            self.control_handle.shutdown();
3833        }
3834        self.drop_without_shutdown();
3835        _result
3836    }
3837
3838    /// Similar to "send" but does not shutdown the channel if an error occurs.
3839    pub fn send_no_shutdown_on_err(
3840        self,
3841        mut result: Result<fidl::Vmo, i32>,
3842    ) -> Result<(), fidl::Error> {
3843        let _result = self.send_raw(result);
3844        self.drop_without_shutdown();
3845        _result
3846    }
3847
3848    fn send_raw(&self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
3849        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3850            MapperSessionCreateVmoResponse,
3851            i32,
3852        >>(
3853            fidl::encoding::FlexibleResult::new(result.map(|vmo| (vmo,))),
3854            self.tx_id,
3855            0x35be1bf1bd0f9e1d,
3856            fidl::encoding::DynamicFlags::FLEXIBLE,
3857        )
3858    }
3859}
3860
3861#[must_use = "FIDL methods require a response to be sent"]
3862#[derive(Debug)]
3863pub struct MapperSessionOpenChildSessionResponder {
3864    control_handle: std::mem::ManuallyDrop<MapperSessionControlHandle>,
3865    tx_id: u32,
3866}
3867
3868/// Set the the channel to be shutdown (see [`MapperSessionControlHandle::shutdown`])
3869/// if the responder is dropped without sending a response, so that the client
3870/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3871impl std::ops::Drop for MapperSessionOpenChildSessionResponder {
3872    fn drop(&mut self) {
3873        self.control_handle.shutdown();
3874        // Safety: drops once, never accessed again
3875        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3876    }
3877}
3878
3879impl fidl::endpoints::Responder for MapperSessionOpenChildSessionResponder {
3880    type ControlHandle = MapperSessionControlHandle;
3881
3882    fn control_handle(&self) -> &MapperSessionControlHandle {
3883        &self.control_handle
3884    }
3885
3886    fn drop_without_shutdown(mut self) {
3887        // Safety: drops once, never accessed again due to mem::forget
3888        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3889        // Prevent Drop from running (which would shut down the channel)
3890        std::mem::forget(self);
3891    }
3892}
3893
3894impl MapperSessionOpenChildSessionResponder {
3895    /// Sends a response to the FIDL transaction.
3896    ///
3897    /// Sets the channel to shutdown if an error occurs.
3898    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3899        let _result = self.send_raw(result);
3900        if _result.is_err() {
3901            self.control_handle.shutdown();
3902        }
3903        self.drop_without_shutdown();
3904        _result
3905    }
3906
3907    /// Similar to "send" but does not shutdown the channel if an error occurs.
3908    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3909        let _result = self.send_raw(result);
3910        self.drop_without_shutdown();
3911        _result
3912    }
3913
3914    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3915        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3916            fidl::encoding::EmptyStruct,
3917            i32,
3918        >>(
3919            fidl::encoding::FlexibleResult::new(result),
3920            self.tx_id,
3921            0x7b80686acf9dcca3,
3922            fidl::encoding::DynamicFlags::FLEXIBLE,
3923        )
3924    }
3925}
3926
3927#[must_use = "FIDL methods require a response to be sent"]
3928#[derive(Debug)]
3929pub struct MapperSessionRecordProfileResponder {
3930    control_handle: std::mem::ManuallyDrop<MapperSessionControlHandle>,
3931    tx_id: u32,
3932}
3933
3934/// Set the the channel to be shutdown (see [`MapperSessionControlHandle::shutdown`])
3935/// if the responder is dropped without sending a response, so that the client
3936/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3937impl std::ops::Drop for MapperSessionRecordProfileResponder {
3938    fn drop(&mut self) {
3939        self.control_handle.shutdown();
3940        // Safety: drops once, never accessed again
3941        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3942    }
3943}
3944
3945impl fidl::endpoints::Responder for MapperSessionRecordProfileResponder {
3946    type ControlHandle = MapperSessionControlHandle;
3947
3948    fn control_handle(&self) -> &MapperSessionControlHandle {
3949        &self.control_handle
3950    }
3951
3952    fn drop_without_shutdown(mut self) {
3953        // Safety: drops once, never accessed again due to mem::forget
3954        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3955        // Prevent Drop from running (which would shut down the channel)
3956        std::mem::forget(self);
3957    }
3958}
3959
3960impl MapperSessionRecordProfileResponder {
3961    /// Sends a response to the FIDL transaction.
3962    ///
3963    /// Sets the channel to shutdown if an error occurs.
3964    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3965        let _result = self.send_raw(result);
3966        if _result.is_err() {
3967            self.control_handle.shutdown();
3968        }
3969        self.drop_without_shutdown();
3970        _result
3971    }
3972
3973    /// Similar to "send" but does not shutdown the channel if an error occurs.
3974    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3975        let _result = self.send_raw(result);
3976        self.drop_without_shutdown();
3977        _result
3978    }
3979
3980    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3981        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3982            fidl::encoding::EmptyStruct,
3983            i32,
3984        >>(
3985            fidl::encoding::FlexibleResult::new(result),
3986            self.tx_id,
3987            0x5632286dc15cd420,
3988            fidl::encoding::DynamicFlags::FLEXIBLE,
3989        )
3990    }
3991}
3992
3993#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3994pub struct RecordingMarker;
3995
3996impl fidl::endpoints::ProtocolMarker for RecordingMarker {
3997    type Proxy = RecordingProxy;
3998    type RequestStream = RecordingRequestStream;
3999    #[cfg(target_os = "fuchsia")]
4000    type SynchronousProxy = RecordingSynchronousProxy;
4001
4002    const DEBUG_NAME: &'static str = "(anonymous) Recording";
4003}
4004pub type RecordingStopResult = Result<fidl::Vmo, i32>;
4005
4006pub trait RecordingProxyInterface: Send + Sync {
4007    type StopResponseFut: std::future::Future<Output = Result<RecordingStopResult, fidl::Error>>
4008        + Send;
4009    fn r#stop(&self) -> Self::StopResponseFut;
4010}
4011#[derive(Debug)]
4012#[cfg(target_os = "fuchsia")]
4013pub struct RecordingSynchronousProxy {
4014    client: fidl::client::sync::Client,
4015}
4016
4017#[cfg(target_os = "fuchsia")]
4018impl fidl::endpoints::SynchronousProxy for RecordingSynchronousProxy {
4019    type Proxy = RecordingProxy;
4020    type Protocol = RecordingMarker;
4021
4022    fn from_channel(inner: fidl::Channel) -> Self {
4023        Self::new(inner)
4024    }
4025
4026    fn into_channel(self) -> fidl::Channel {
4027        self.client.into_channel()
4028    }
4029
4030    fn as_channel(&self) -> &fidl::Channel {
4031        self.client.as_channel()
4032    }
4033}
4034
4035#[cfg(target_os = "fuchsia")]
4036impl RecordingSynchronousProxy {
4037    pub fn new(channel: fidl::Channel) -> Self {
4038        Self { client: fidl::client::sync::Client::new(channel) }
4039    }
4040
4041    pub fn into_channel(self) -> fidl::Channel {
4042        self.client.into_channel()
4043    }
4044
4045    /// Waits until an event arrives and returns it. It is safe for other
4046    /// threads to make concurrent requests while waiting for an event.
4047    pub fn wait_for_event(
4048        &self,
4049        deadline: zx::MonotonicInstant,
4050    ) -> Result<RecordingEvent, fidl::Error> {
4051        RecordingEvent::decode(self.client.wait_for_event::<RecordingMarker>(deadline)?)
4052    }
4053
4054    /// Stops the profile recording and returns the recorded profile data in `vmo` (encoding the
4055    /// session `key` and readahead-aligned logical byte offset of each read).
4056    pub fn r#stop(
4057        &self,
4058        ___deadline: zx::MonotonicInstant,
4059    ) -> Result<RecordingStopResult, fidl::Error> {
4060        let _response = self.client.send_query::<
4061            fidl::encoding::EmptyPayload,
4062            fidl::encoding::FlexibleResultType<RecordingStopResponse, i32>,
4063            RecordingMarker,
4064        >(
4065            (),
4066            0x453cc0cfadf14ffb,
4067            fidl::encoding::DynamicFlags::FLEXIBLE,
4068            ___deadline,
4069        )?
4070        .into_result::<RecordingMarker>("stop")?;
4071        Ok(_response.map(|x| x.vmo))
4072    }
4073}
4074
4075#[cfg(target_os = "fuchsia")]
4076impl From<RecordingSynchronousProxy> for zx::NullableHandle {
4077    fn from(value: RecordingSynchronousProxy) -> Self {
4078        value.into_channel().into()
4079    }
4080}
4081
4082#[cfg(target_os = "fuchsia")]
4083impl From<fidl::Channel> for RecordingSynchronousProxy {
4084    fn from(value: fidl::Channel) -> Self {
4085        Self::new(value)
4086    }
4087}
4088
4089#[cfg(target_os = "fuchsia")]
4090impl fidl::endpoints::FromClient for RecordingSynchronousProxy {
4091    type Protocol = RecordingMarker;
4092
4093    fn from_client(value: fidl::endpoints::ClientEnd<RecordingMarker>) -> Self {
4094        Self::new(value.into_channel())
4095    }
4096}
4097
4098#[derive(Debug, Clone)]
4099pub struct RecordingProxy {
4100    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4101}
4102
4103impl fidl::endpoints::Proxy for RecordingProxy {
4104    type Protocol = RecordingMarker;
4105
4106    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4107        Self::new(inner)
4108    }
4109
4110    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4111        self.client.into_channel().map_err(|client| Self { client })
4112    }
4113
4114    fn as_channel(&self) -> &::fidl::AsyncChannel {
4115        self.client.as_channel()
4116    }
4117}
4118
4119impl RecordingProxy {
4120    /// Create a new Proxy for fuchsia.storage.block/Recording.
4121    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4122        let protocol_name = <RecordingMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4123        Self { client: fidl::client::Client::new(channel, protocol_name) }
4124    }
4125
4126    /// Get a Stream of events from the remote end of the protocol.
4127    ///
4128    /// # Panics
4129    ///
4130    /// Panics if the event stream was already taken.
4131    pub fn take_event_stream(&self) -> RecordingEventStream {
4132        RecordingEventStream { event_receiver: self.client.take_event_receiver() }
4133    }
4134
4135    /// Stops the profile recording and returns the recorded profile data in `vmo` (encoding the
4136    /// session `key` and readahead-aligned logical byte offset of each read).
4137    pub fn r#stop(
4138        &self,
4139    ) -> fidl::client::QueryResponseFut<
4140        RecordingStopResult,
4141        fidl::encoding::DefaultFuchsiaResourceDialect,
4142    > {
4143        RecordingProxyInterface::r#stop(self)
4144    }
4145}
4146
4147impl RecordingProxyInterface for RecordingProxy {
4148    type StopResponseFut = fidl::client::QueryResponseFut<
4149        RecordingStopResult,
4150        fidl::encoding::DefaultFuchsiaResourceDialect,
4151    >;
4152    fn r#stop(&self) -> Self::StopResponseFut {
4153        fn _decode(
4154            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4155        ) -> Result<RecordingStopResult, fidl::Error> {
4156            let _response = fidl::client::decode_transaction_body::<
4157                fidl::encoding::FlexibleResultType<RecordingStopResponse, i32>,
4158                fidl::encoding::DefaultFuchsiaResourceDialect,
4159                0x453cc0cfadf14ffb,
4160            >(_buf?)?
4161            .into_result::<RecordingMarker>("stop")?;
4162            Ok(_response.map(|x| x.vmo))
4163        }
4164        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, RecordingStopResult>(
4165            (),
4166            0x453cc0cfadf14ffb,
4167            fidl::encoding::DynamicFlags::FLEXIBLE,
4168            _decode,
4169        )
4170    }
4171}
4172
4173pub struct RecordingEventStream {
4174    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4175}
4176
4177impl std::marker::Unpin for RecordingEventStream {}
4178
4179impl futures::stream::FusedStream for RecordingEventStream {
4180    fn is_terminated(&self) -> bool {
4181        self.event_receiver.is_terminated()
4182    }
4183}
4184
4185impl futures::Stream for RecordingEventStream {
4186    type Item = Result<RecordingEvent, fidl::Error>;
4187
4188    fn poll_next(
4189        mut self: std::pin::Pin<&mut Self>,
4190        cx: &mut std::task::Context<'_>,
4191    ) -> std::task::Poll<Option<Self::Item>> {
4192        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4193            &mut self.event_receiver,
4194            cx
4195        )?) {
4196            Some(buf) => std::task::Poll::Ready(Some(RecordingEvent::decode(buf))),
4197            None => std::task::Poll::Ready(None),
4198        }
4199    }
4200}
4201
4202#[derive(Debug)]
4203pub enum RecordingEvent {
4204    #[non_exhaustive]
4205    _UnknownEvent {
4206        /// Ordinal of the event that was sent.
4207        ordinal: u64,
4208    },
4209}
4210
4211impl RecordingEvent {
4212    /// Decodes a message buffer as a [`RecordingEvent`].
4213    fn decode(
4214        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4215    ) -> Result<RecordingEvent, fidl::Error> {
4216        let (bytes, _handles) = buf.split_mut();
4217        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4218        debug_assert_eq!(tx_header.tx_id, 0);
4219        match tx_header.ordinal {
4220            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4221                Ok(RecordingEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4222            }
4223            _ => Err(fidl::Error::UnknownOrdinal {
4224                ordinal: tx_header.ordinal,
4225                protocol_name: <RecordingMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4226            }),
4227        }
4228    }
4229}
4230
4231/// A Stream of incoming requests for fuchsia.storage.block/Recording.
4232pub struct RecordingRequestStream {
4233    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4234    is_terminated: bool,
4235}
4236
4237impl std::marker::Unpin for RecordingRequestStream {}
4238
4239impl futures::stream::FusedStream for RecordingRequestStream {
4240    fn is_terminated(&self) -> bool {
4241        self.is_terminated
4242    }
4243}
4244
4245impl fidl::endpoints::RequestStream for RecordingRequestStream {
4246    type Protocol = RecordingMarker;
4247    type ControlHandle = RecordingControlHandle;
4248
4249    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4250        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4251    }
4252
4253    fn control_handle(&self) -> Self::ControlHandle {
4254        RecordingControlHandle { inner: self.inner.clone() }
4255    }
4256
4257    fn into_inner(
4258        self,
4259    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4260    {
4261        (self.inner, self.is_terminated)
4262    }
4263
4264    fn from_inner(
4265        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4266        is_terminated: bool,
4267    ) -> Self {
4268        Self { inner, is_terminated }
4269    }
4270}
4271
4272impl futures::Stream for RecordingRequestStream {
4273    type Item = Result<RecordingRequest, fidl::Error>;
4274
4275    fn poll_next(
4276        mut self: std::pin::Pin<&mut Self>,
4277        cx: &mut std::task::Context<'_>,
4278    ) -> std::task::Poll<Option<Self::Item>> {
4279        let this = &mut *self;
4280        if this.inner.check_shutdown(cx) {
4281            this.is_terminated = true;
4282            return std::task::Poll::Ready(None);
4283        }
4284        if this.is_terminated {
4285            panic!("polled RecordingRequestStream after completion");
4286        }
4287        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4288            |bytes, handles| {
4289                match this.inner.channel().read_etc(cx, bytes, handles) {
4290                    std::task::Poll::Ready(Ok(())) => {}
4291                    std::task::Poll::Pending => return std::task::Poll::Pending,
4292                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4293                        this.is_terminated = true;
4294                        return std::task::Poll::Ready(None);
4295                    }
4296                    std::task::Poll::Ready(Err(e)) => {
4297                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4298                            e.into(),
4299                        ))));
4300                    }
4301                }
4302
4303                // A message has been received from the channel
4304                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4305
4306                std::task::Poll::Ready(Some(match header.ordinal {
4307                    0x453cc0cfadf14ffb => {
4308                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4309                        let mut req = fidl::new_empty!(
4310                            fidl::encoding::EmptyPayload,
4311                            fidl::encoding::DefaultFuchsiaResourceDialect
4312                        );
4313                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4314                        let control_handle = RecordingControlHandle { inner: this.inner.clone() };
4315                        Ok(RecordingRequest::Stop {
4316                            responder: RecordingStopResponder {
4317                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4318                                tx_id: header.tx_id,
4319                            },
4320                        })
4321                    }
4322                    _ if header.tx_id == 0
4323                        && header
4324                            .dynamic_flags()
4325                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4326                    {
4327                        Ok(RecordingRequest::_UnknownMethod {
4328                            ordinal: header.ordinal,
4329                            control_handle: RecordingControlHandle { inner: this.inner.clone() },
4330                            method_type: fidl::MethodType::OneWay,
4331                        })
4332                    }
4333                    _ if header
4334                        .dynamic_flags()
4335                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4336                    {
4337                        this.inner.send_framework_err(
4338                            fidl::encoding::FrameworkErr::UnknownMethod,
4339                            header.tx_id,
4340                            header.ordinal,
4341                            header.dynamic_flags(),
4342                            (bytes, handles),
4343                        )?;
4344                        Ok(RecordingRequest::_UnknownMethod {
4345                            ordinal: header.ordinal,
4346                            control_handle: RecordingControlHandle { inner: this.inner.clone() },
4347                            method_type: fidl::MethodType::TwoWay,
4348                        })
4349                    }
4350                    _ => Err(fidl::Error::UnknownOrdinal {
4351                        ordinal: header.ordinal,
4352                        protocol_name:
4353                            <RecordingMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4354                    }),
4355                }))
4356            },
4357        )
4358    }
4359}
4360
4361/// Represents an active profile recording on a `MapperSession`.
4362#[derive(Debug)]
4363pub enum RecordingRequest {
4364    /// Stops the profile recording and returns the recorded profile data in `vmo` (encoding the
4365    /// session `key` and readahead-aligned logical byte offset of each read).
4366    Stop { responder: RecordingStopResponder },
4367    /// An interaction was received which does not match any known method.
4368    #[non_exhaustive]
4369    _UnknownMethod {
4370        /// Ordinal of the method that was called.
4371        ordinal: u64,
4372        control_handle: RecordingControlHandle,
4373        method_type: fidl::MethodType,
4374    },
4375}
4376
4377impl RecordingRequest {
4378    #[allow(irrefutable_let_patterns)]
4379    pub fn into_stop(self) -> Option<(RecordingStopResponder)> {
4380        if let RecordingRequest::Stop { responder } = self { Some((responder)) } else { None }
4381    }
4382
4383    /// Name of the method defined in FIDL
4384    pub fn method_name(&self) -> &'static str {
4385        match *self {
4386            RecordingRequest::Stop { .. } => "stop",
4387            RecordingRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
4388                "unknown one-way method"
4389            }
4390            RecordingRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
4391                "unknown two-way method"
4392            }
4393        }
4394    }
4395}
4396
4397#[derive(Debug, Clone)]
4398pub struct RecordingControlHandle {
4399    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4400}
4401
4402impl RecordingControlHandle {
4403    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4404        self.inner.shutdown_with_epitaph(status.into())
4405    }
4406}
4407
4408impl fidl::endpoints::ControlHandle for RecordingControlHandle {
4409    fn shutdown(&self) {
4410        self.inner.shutdown()
4411    }
4412
4413    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4414        self.inner.shutdown_with_epitaph(status)
4415    }
4416
4417    fn is_closed(&self) -> bool {
4418        self.inner.channel().is_closed()
4419    }
4420    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4421        self.inner.channel().on_closed()
4422    }
4423
4424    #[cfg(target_os = "fuchsia")]
4425    fn signal_peer(
4426        &self,
4427        clear_mask: zx::Signals,
4428        set_mask: zx::Signals,
4429    ) -> Result<(), zx_status::Status> {
4430        use fidl::Peered;
4431        self.inner.channel().signal_peer(clear_mask, set_mask)
4432    }
4433}
4434
4435impl RecordingControlHandle {}
4436
4437#[must_use = "FIDL methods require a response to be sent"]
4438#[derive(Debug)]
4439pub struct RecordingStopResponder {
4440    control_handle: std::mem::ManuallyDrop<RecordingControlHandle>,
4441    tx_id: u32,
4442}
4443
4444/// Set the the channel to be shutdown (see [`RecordingControlHandle::shutdown`])
4445/// if the responder is dropped without sending a response, so that the client
4446/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4447impl std::ops::Drop for RecordingStopResponder {
4448    fn drop(&mut self) {
4449        self.control_handle.shutdown();
4450        // Safety: drops once, never accessed again
4451        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4452    }
4453}
4454
4455impl fidl::endpoints::Responder for RecordingStopResponder {
4456    type ControlHandle = RecordingControlHandle;
4457
4458    fn control_handle(&self) -> &RecordingControlHandle {
4459        &self.control_handle
4460    }
4461
4462    fn drop_without_shutdown(mut self) {
4463        // Safety: drops once, never accessed again due to mem::forget
4464        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4465        // Prevent Drop from running (which would shut down the channel)
4466        std::mem::forget(self);
4467    }
4468}
4469
4470impl RecordingStopResponder {
4471    /// Sends a response to the FIDL transaction.
4472    ///
4473    /// Sets the channel to shutdown if an error occurs.
4474    pub fn send(self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
4475        let _result = self.send_raw(result);
4476        if _result.is_err() {
4477            self.control_handle.shutdown();
4478        }
4479        self.drop_without_shutdown();
4480        _result
4481    }
4482
4483    /// Similar to "send" but does not shutdown the channel if an error occurs.
4484    pub fn send_no_shutdown_on_err(
4485        self,
4486        mut result: Result<fidl::Vmo, i32>,
4487    ) -> Result<(), fidl::Error> {
4488        let _result = self.send_raw(result);
4489        self.drop_without_shutdown();
4490        _result
4491    }
4492
4493    fn send_raw(&self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
4494        self.control_handle
4495            .inner
4496            .send::<fidl::encoding::FlexibleResultType<RecordingStopResponse, i32>>(
4497                fidl::encoding::FlexibleResult::new(result.map(|vmo| (vmo,))),
4498                self.tx_id,
4499                0x453cc0cfadf14ffb,
4500                fidl::encoding::DynamicFlags::FLEXIBLE,
4501            )
4502    }
4503}
4504
4505#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4506pub struct SessionMarker;
4507
4508impl fidl::endpoints::ProtocolMarker for SessionMarker {
4509    type Proxy = SessionProxy;
4510    type RequestStream = SessionRequestStream;
4511    #[cfg(target_os = "fuchsia")]
4512    type SynchronousProxy = SessionSynchronousProxy;
4513
4514    const DEBUG_NAME: &'static str = "(anonymous) Session";
4515}
4516pub type SessionGetFifoResult = Result<fidl::Fifo, i32>;
4517pub type SessionAttachVmoResult = Result<VmoId, i32>;
4518pub type SessionRegisterKeyResult = Result<u8, i32>;
4519
4520pub trait SessionProxyInterface: Send + Sync {
4521    type CloseResponseFut: std::future::Future<
4522            Output = Result<fidl_fuchsia_unknown::CloseableCloseResult, fidl::Error>,
4523        > + Send;
4524    fn r#close(&self) -> Self::CloseResponseFut;
4525    type GetFifoResponseFut: std::future::Future<Output = Result<SessionGetFifoResult, fidl::Error>>
4526        + Send;
4527    fn r#get_fifo(&self) -> Self::GetFifoResponseFut;
4528    type AttachVmoResponseFut: std::future::Future<Output = Result<SessionAttachVmoResult, fidl::Error>>
4529        + Send;
4530    fn r#attach_vmo(&self, vmo: fidl::Vmo) -> Self::AttachVmoResponseFut;
4531    type RegisterKeyResponseFut: std::future::Future<Output = Result<SessionRegisterKeyResult, fidl::Error>>
4532        + Send;
4533    fn r#register_key(&self, key_token: fidl::EventPair) -> Self::RegisterKeyResponseFut;
4534}
4535#[derive(Debug)]
4536#[cfg(target_os = "fuchsia")]
4537pub struct SessionSynchronousProxy {
4538    client: fidl::client::sync::Client,
4539}
4540
4541#[cfg(target_os = "fuchsia")]
4542impl fidl::endpoints::SynchronousProxy for SessionSynchronousProxy {
4543    type Proxy = SessionProxy;
4544    type Protocol = SessionMarker;
4545
4546    fn from_channel(inner: fidl::Channel) -> Self {
4547        Self::new(inner)
4548    }
4549
4550    fn into_channel(self) -> fidl::Channel {
4551        self.client.into_channel()
4552    }
4553
4554    fn as_channel(&self) -> &fidl::Channel {
4555        self.client.as_channel()
4556    }
4557}
4558
4559#[cfg(target_os = "fuchsia")]
4560impl SessionSynchronousProxy {
4561    pub fn new(channel: fidl::Channel) -> Self {
4562        Self { client: fidl::client::sync::Client::new(channel) }
4563    }
4564
4565    pub fn into_channel(self) -> fidl::Channel {
4566        self.client.into_channel()
4567    }
4568
4569    /// Waits until an event arrives and returns it. It is safe for other
4570    /// threads to make concurrent requests while waiting for an event.
4571    pub fn wait_for_event(
4572        &self,
4573        deadline: zx::MonotonicInstant,
4574    ) -> Result<SessionEvent, fidl::Error> {
4575        SessionEvent::decode(self.client.wait_for_event::<SessionMarker>(deadline)?)
4576    }
4577
4578    /// Terminates the connection.
4579    ///
4580    /// After calling `Close`, the client must not send any other requests.
4581    ///
4582    /// Servers, after sending the status response, should close the connection
4583    /// regardless of status and without sending an epitaph.
4584    ///
4585    /// Closing the client end of the channel should be semantically equivalent
4586    /// to calling `Close` without knowing when the close has completed or its
4587    /// status.
4588    pub fn r#close(
4589        &self,
4590        ___deadline: zx::MonotonicInstant,
4591    ) -> Result<fidl_fuchsia_unknown::CloseableCloseResult, fidl::Error> {
4592        let _response = self.client.send_query::<
4593            fidl::encoding::EmptyPayload,
4594            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4595            SessionMarker,
4596        >(
4597            (),
4598            0x5ac5d459ad7f657e,
4599            fidl::encoding::DynamicFlags::empty(),
4600            ___deadline,
4601        )?;
4602        Ok(_response.map(|x| x))
4603    }
4604
4605    /// Returns a handle to the client end of the FIFO.
4606    pub fn r#get_fifo(
4607        &self,
4608        ___deadline: zx::MonotonicInstant,
4609    ) -> Result<SessionGetFifoResult, fidl::Error> {
4610        let _response = self.client.send_query::<
4611            fidl::encoding::EmptyPayload,
4612            fidl::encoding::ResultType<SessionGetFifoResponse, i32>,
4613            SessionMarker,
4614        >(
4615            (),
4616            0x7a6c7610912aaa98,
4617            fidl::encoding::DynamicFlags::empty(),
4618            ___deadline,
4619        )?;
4620        Ok(_response.map(|x| x.fifo))
4621    }
4622
4623    /// Attaches a VMO to the session. Resizable VMOs are not supported and will return
4624    /// `ZX_ERR_INVALID_ARGS`.
4625    ///
4626    /// Returns an identifier that can be used to refer to the VMO.
4627    pub fn r#attach_vmo(
4628        &self,
4629        mut vmo: fidl::Vmo,
4630        ___deadline: zx::MonotonicInstant,
4631    ) -> Result<SessionAttachVmoResult, fidl::Error> {
4632        let _response = self.client.send_query::<
4633            SessionAttachVmoRequest,
4634            fidl::encoding::ResultType<SessionAttachVmoResponse, i32>,
4635            SessionMarker,
4636        >(
4637            (vmo,),
4638            0x677a0f6fd1a370b2,
4639            fidl::encoding::DynamicFlags::empty(),
4640            ___deadline,
4641        )?;
4642        Ok(_response.map(|x| x.vmoid))
4643    }
4644
4645    /// Registers an inline encryption key handle (`key_token` returned by
4646    /// `fuchsia.hardware.inlineencryption/Device.ProgramKey`) with this session.
4647    ///
4648    /// Returns a session-scoped `slot` token that can be passed in
4649    /// `BlockFifoRequest.slot` when `BlockIoFlag.INLINE_ENCRYPTION_ENABLED` is set.
4650    ///
4651    /// * error `ZX_ERR_ACCESS_DENIED` if `key_token` is not a valid inline encryption key token
4652    ///   for this block device, or if the key has been evicted.
4653    /// * error `ZX_ERR_NOT_SUPPORTED` if the device does not support inline encryption.
4654    pub fn r#register_key(
4655        &self,
4656        mut key_token: fidl::EventPair,
4657        ___deadline: zx::MonotonicInstant,
4658    ) -> Result<SessionRegisterKeyResult, fidl::Error> {
4659        let _response = self.client.send_query::<
4660            SessionRegisterKeyRequest,
4661            fidl::encoding::ResultType<SessionRegisterKeyResponse, i32>,
4662            SessionMarker,
4663        >(
4664            (key_token,),
4665            0x38ea5528cf83d1f6,
4666            fidl::encoding::DynamicFlags::empty(),
4667            ___deadline,
4668        )?;
4669        Ok(_response.map(|x| x.slot))
4670    }
4671}
4672
4673#[cfg(target_os = "fuchsia")]
4674impl From<SessionSynchronousProxy> for zx::NullableHandle {
4675    fn from(value: SessionSynchronousProxy) -> Self {
4676        value.into_channel().into()
4677    }
4678}
4679
4680#[cfg(target_os = "fuchsia")]
4681impl From<fidl::Channel> for SessionSynchronousProxy {
4682    fn from(value: fidl::Channel) -> Self {
4683        Self::new(value)
4684    }
4685}
4686
4687#[cfg(target_os = "fuchsia")]
4688impl fidl::endpoints::FromClient for SessionSynchronousProxy {
4689    type Protocol = SessionMarker;
4690
4691    fn from_client(value: fidl::endpoints::ClientEnd<SessionMarker>) -> Self {
4692        Self::new(value.into_channel())
4693    }
4694}
4695
4696#[derive(Debug, Clone)]
4697pub struct SessionProxy {
4698    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4699}
4700
4701impl fidl::endpoints::Proxy for SessionProxy {
4702    type Protocol = SessionMarker;
4703
4704    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4705        Self::new(inner)
4706    }
4707
4708    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4709        self.client.into_channel().map_err(|client| Self { client })
4710    }
4711
4712    fn as_channel(&self) -> &::fidl::AsyncChannel {
4713        self.client.as_channel()
4714    }
4715}
4716
4717impl SessionProxy {
4718    /// Create a new Proxy for fuchsia.storage.block/Session.
4719    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4720        let protocol_name = <SessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4721        Self { client: fidl::client::Client::new(channel, protocol_name) }
4722    }
4723
4724    /// Get a Stream of events from the remote end of the protocol.
4725    ///
4726    /// # Panics
4727    ///
4728    /// Panics if the event stream was already taken.
4729    pub fn take_event_stream(&self) -> SessionEventStream {
4730        SessionEventStream { event_receiver: self.client.take_event_receiver() }
4731    }
4732
4733    /// Terminates the connection.
4734    ///
4735    /// After calling `Close`, the client must not send any other requests.
4736    ///
4737    /// Servers, after sending the status response, should close the connection
4738    /// regardless of status and without sending an epitaph.
4739    ///
4740    /// Closing the client end of the channel should be semantically equivalent
4741    /// to calling `Close` without knowing when the close has completed or its
4742    /// status.
4743    pub fn r#close(
4744        &self,
4745    ) -> fidl::client::QueryResponseFut<
4746        fidl_fuchsia_unknown::CloseableCloseResult,
4747        fidl::encoding::DefaultFuchsiaResourceDialect,
4748    > {
4749        SessionProxyInterface::r#close(self)
4750    }
4751
4752    /// Returns a handle to the client end of the FIFO.
4753    pub fn r#get_fifo(
4754        &self,
4755    ) -> fidl::client::QueryResponseFut<
4756        SessionGetFifoResult,
4757        fidl::encoding::DefaultFuchsiaResourceDialect,
4758    > {
4759        SessionProxyInterface::r#get_fifo(self)
4760    }
4761
4762    /// Attaches a VMO to the session. Resizable VMOs are not supported and will return
4763    /// `ZX_ERR_INVALID_ARGS`.
4764    ///
4765    /// Returns an identifier that can be used to refer to the VMO.
4766    pub fn r#attach_vmo(
4767        &self,
4768        mut vmo: fidl::Vmo,
4769    ) -> fidl::client::QueryResponseFut<
4770        SessionAttachVmoResult,
4771        fidl::encoding::DefaultFuchsiaResourceDialect,
4772    > {
4773        SessionProxyInterface::r#attach_vmo(self, vmo)
4774    }
4775
4776    /// Registers an inline encryption key handle (`key_token` returned by
4777    /// `fuchsia.hardware.inlineencryption/Device.ProgramKey`) with this session.
4778    ///
4779    /// Returns a session-scoped `slot` token that can be passed in
4780    /// `BlockFifoRequest.slot` when `BlockIoFlag.INLINE_ENCRYPTION_ENABLED` is set.
4781    ///
4782    /// * error `ZX_ERR_ACCESS_DENIED` if `key_token` is not a valid inline encryption key token
4783    ///   for this block device, or if the key has been evicted.
4784    /// * error `ZX_ERR_NOT_SUPPORTED` if the device does not support inline encryption.
4785    pub fn r#register_key(
4786        &self,
4787        mut key_token: fidl::EventPair,
4788    ) -> fidl::client::QueryResponseFut<
4789        SessionRegisterKeyResult,
4790        fidl::encoding::DefaultFuchsiaResourceDialect,
4791    > {
4792        SessionProxyInterface::r#register_key(self, key_token)
4793    }
4794}
4795
4796impl SessionProxyInterface for SessionProxy {
4797    type CloseResponseFut = fidl::client::QueryResponseFut<
4798        fidl_fuchsia_unknown::CloseableCloseResult,
4799        fidl::encoding::DefaultFuchsiaResourceDialect,
4800    >;
4801    fn r#close(&self) -> Self::CloseResponseFut {
4802        fn _decode(
4803            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4804        ) -> Result<fidl_fuchsia_unknown::CloseableCloseResult, fidl::Error> {
4805            let _response = fidl::client::decode_transaction_body::<
4806                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4807                fidl::encoding::DefaultFuchsiaResourceDialect,
4808                0x5ac5d459ad7f657e,
4809            >(_buf?)?;
4810            Ok(_response.map(|x| x))
4811        }
4812        self.client.send_query_and_decode::<
4813            fidl::encoding::EmptyPayload,
4814            fidl_fuchsia_unknown::CloseableCloseResult,
4815        >(
4816            (),
4817            0x5ac5d459ad7f657e,
4818            fidl::encoding::DynamicFlags::empty(),
4819            _decode,
4820        )
4821    }
4822
4823    type GetFifoResponseFut = fidl::client::QueryResponseFut<
4824        SessionGetFifoResult,
4825        fidl::encoding::DefaultFuchsiaResourceDialect,
4826    >;
4827    fn r#get_fifo(&self) -> Self::GetFifoResponseFut {
4828        fn _decode(
4829            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4830        ) -> Result<SessionGetFifoResult, fidl::Error> {
4831            let _response = fidl::client::decode_transaction_body::<
4832                fidl::encoding::ResultType<SessionGetFifoResponse, i32>,
4833                fidl::encoding::DefaultFuchsiaResourceDialect,
4834                0x7a6c7610912aaa98,
4835            >(_buf?)?;
4836            Ok(_response.map(|x| x.fifo))
4837        }
4838        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, SessionGetFifoResult>(
4839            (),
4840            0x7a6c7610912aaa98,
4841            fidl::encoding::DynamicFlags::empty(),
4842            _decode,
4843        )
4844    }
4845
4846    type AttachVmoResponseFut = fidl::client::QueryResponseFut<
4847        SessionAttachVmoResult,
4848        fidl::encoding::DefaultFuchsiaResourceDialect,
4849    >;
4850    fn r#attach_vmo(&self, mut vmo: fidl::Vmo) -> Self::AttachVmoResponseFut {
4851        fn _decode(
4852            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4853        ) -> Result<SessionAttachVmoResult, fidl::Error> {
4854            let _response = fidl::client::decode_transaction_body::<
4855                fidl::encoding::ResultType<SessionAttachVmoResponse, i32>,
4856                fidl::encoding::DefaultFuchsiaResourceDialect,
4857                0x677a0f6fd1a370b2,
4858            >(_buf?)?;
4859            Ok(_response.map(|x| x.vmoid))
4860        }
4861        self.client.send_query_and_decode::<SessionAttachVmoRequest, SessionAttachVmoResult>(
4862            (vmo,),
4863            0x677a0f6fd1a370b2,
4864            fidl::encoding::DynamicFlags::empty(),
4865            _decode,
4866        )
4867    }
4868
4869    type RegisterKeyResponseFut = fidl::client::QueryResponseFut<
4870        SessionRegisterKeyResult,
4871        fidl::encoding::DefaultFuchsiaResourceDialect,
4872    >;
4873    fn r#register_key(&self, mut key_token: fidl::EventPair) -> Self::RegisterKeyResponseFut {
4874        fn _decode(
4875            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4876        ) -> Result<SessionRegisterKeyResult, fidl::Error> {
4877            let _response = fidl::client::decode_transaction_body::<
4878                fidl::encoding::ResultType<SessionRegisterKeyResponse, i32>,
4879                fidl::encoding::DefaultFuchsiaResourceDialect,
4880                0x38ea5528cf83d1f6,
4881            >(_buf?)?;
4882            Ok(_response.map(|x| x.slot))
4883        }
4884        self.client.send_query_and_decode::<SessionRegisterKeyRequest, SessionRegisterKeyResult>(
4885            (key_token,),
4886            0x38ea5528cf83d1f6,
4887            fidl::encoding::DynamicFlags::empty(),
4888            _decode,
4889        )
4890    }
4891}
4892
4893pub struct SessionEventStream {
4894    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4895}
4896
4897impl std::marker::Unpin for SessionEventStream {}
4898
4899impl futures::stream::FusedStream for SessionEventStream {
4900    fn is_terminated(&self) -> bool {
4901        self.event_receiver.is_terminated()
4902    }
4903}
4904
4905impl futures::Stream for SessionEventStream {
4906    type Item = Result<SessionEvent, fidl::Error>;
4907
4908    fn poll_next(
4909        mut self: std::pin::Pin<&mut Self>,
4910        cx: &mut std::task::Context<'_>,
4911    ) -> std::task::Poll<Option<Self::Item>> {
4912        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4913            &mut self.event_receiver,
4914            cx
4915        )?) {
4916            Some(buf) => std::task::Poll::Ready(Some(SessionEvent::decode(buf))),
4917            None => std::task::Poll::Ready(None),
4918        }
4919    }
4920}
4921
4922#[derive(Debug)]
4923pub enum SessionEvent {}
4924
4925impl SessionEvent {
4926    /// Decodes a message buffer as a [`SessionEvent`].
4927    fn decode(
4928        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4929    ) -> Result<SessionEvent, fidl::Error> {
4930        let (bytes, _handles) = buf.split_mut();
4931        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4932        debug_assert_eq!(tx_header.tx_id, 0);
4933        match tx_header.ordinal {
4934            _ => Err(fidl::Error::UnknownOrdinal {
4935                ordinal: tx_header.ordinal,
4936                protocol_name: <SessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4937            }),
4938        }
4939    }
4940}
4941
4942/// A Stream of incoming requests for fuchsia.storage.block/Session.
4943pub struct SessionRequestStream {
4944    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4945    is_terminated: bool,
4946}
4947
4948impl std::marker::Unpin for SessionRequestStream {}
4949
4950impl futures::stream::FusedStream for SessionRequestStream {
4951    fn is_terminated(&self) -> bool {
4952        self.is_terminated
4953    }
4954}
4955
4956impl fidl::endpoints::RequestStream for SessionRequestStream {
4957    type Protocol = SessionMarker;
4958    type ControlHandle = SessionControlHandle;
4959
4960    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4961        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4962    }
4963
4964    fn control_handle(&self) -> Self::ControlHandle {
4965        SessionControlHandle { inner: self.inner.clone() }
4966    }
4967
4968    fn into_inner(
4969        self,
4970    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4971    {
4972        (self.inner, self.is_terminated)
4973    }
4974
4975    fn from_inner(
4976        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4977        is_terminated: bool,
4978    ) -> Self {
4979        Self { inner, is_terminated }
4980    }
4981}
4982
4983impl futures::Stream for SessionRequestStream {
4984    type Item = Result<SessionRequest, fidl::Error>;
4985
4986    fn poll_next(
4987        mut self: std::pin::Pin<&mut Self>,
4988        cx: &mut std::task::Context<'_>,
4989    ) -> std::task::Poll<Option<Self::Item>> {
4990        let this = &mut *self;
4991        if this.inner.check_shutdown(cx) {
4992            this.is_terminated = true;
4993            return std::task::Poll::Ready(None);
4994        }
4995        if this.is_terminated {
4996            panic!("polled SessionRequestStream after completion");
4997        }
4998        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4999            |bytes, handles| {
5000                match this.inner.channel().read_etc(cx, bytes, handles) {
5001                    std::task::Poll::Ready(Ok(())) => {}
5002                    std::task::Poll::Pending => return std::task::Poll::Pending,
5003                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5004                        this.is_terminated = true;
5005                        return std::task::Poll::Ready(None);
5006                    }
5007                    std::task::Poll::Ready(Err(e)) => {
5008                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5009                            e.into(),
5010                        ))));
5011                    }
5012                }
5013
5014                // A message has been received from the channel
5015                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5016
5017                std::task::Poll::Ready(Some(match header.ordinal {
5018                    0x5ac5d459ad7f657e => {
5019                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5020                        let mut req = fidl::new_empty!(
5021                            fidl::encoding::EmptyPayload,
5022                            fidl::encoding::DefaultFuchsiaResourceDialect
5023                        );
5024                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5025                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
5026                        Ok(SessionRequest::Close {
5027                            responder: SessionCloseResponder {
5028                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5029                                tx_id: header.tx_id,
5030                            },
5031                        })
5032                    }
5033                    0x7a6c7610912aaa98 => {
5034                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5035                        let mut req = fidl::new_empty!(
5036                            fidl::encoding::EmptyPayload,
5037                            fidl::encoding::DefaultFuchsiaResourceDialect
5038                        );
5039                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5040                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
5041                        Ok(SessionRequest::GetFifo {
5042                            responder: SessionGetFifoResponder {
5043                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5044                                tx_id: header.tx_id,
5045                            },
5046                        })
5047                    }
5048                    0x677a0f6fd1a370b2 => {
5049                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5050                        let mut req = fidl::new_empty!(
5051                            SessionAttachVmoRequest,
5052                            fidl::encoding::DefaultFuchsiaResourceDialect
5053                        );
5054                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionAttachVmoRequest>(&header, _body_bytes, handles, &mut req)?;
5055                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
5056                        Ok(SessionRequest::AttachVmo {
5057                            vmo: req.vmo,
5058
5059                            responder: SessionAttachVmoResponder {
5060                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5061                                tx_id: header.tx_id,
5062                            },
5063                        })
5064                    }
5065                    0x38ea5528cf83d1f6 => {
5066                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5067                        let mut req = fidl::new_empty!(
5068                            SessionRegisterKeyRequest,
5069                            fidl::encoding::DefaultFuchsiaResourceDialect
5070                        );
5071                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionRegisterKeyRequest>(&header, _body_bytes, handles, &mut req)?;
5072                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
5073                        Ok(SessionRequest::RegisterKey {
5074                            key_token: req.key_token,
5075
5076                            responder: SessionRegisterKeyResponder {
5077                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5078                                tx_id: header.tx_id,
5079                            },
5080                        })
5081                    }
5082                    _ => Err(fidl::Error::UnknownOrdinal {
5083                        ordinal: header.ordinal,
5084                        protocol_name:
5085                            <SessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5086                    }),
5087                }))
5088            },
5089        )
5090    }
5091}
5092
5093/// Represents a session with a block device.
5094///
5095/// This protocol encodes the underlying object's lifetime in both directions; the underlying object
5096/// is alive iff both ends of the protocol are open. That is:
5097///
5098/// - Closing the client end causes the object to be destroyed.
5099/// - Observing a closure of the server end indicates the object no longer exists.
5100///
5101/// The object can be destroyed synchronously using [`fuchsia.unknown/Closeable.Close`].
5102#[derive(Debug)]
5103pub enum SessionRequest {
5104    /// Terminates the connection.
5105    ///
5106    /// After calling `Close`, the client must not send any other requests.
5107    ///
5108    /// Servers, after sending the status response, should close the connection
5109    /// regardless of status and without sending an epitaph.
5110    ///
5111    /// Closing the client end of the channel should be semantically equivalent
5112    /// to calling `Close` without knowing when the close has completed or its
5113    /// status.
5114    Close { responder: SessionCloseResponder },
5115    /// Returns a handle to the client end of the FIFO.
5116    GetFifo { responder: SessionGetFifoResponder },
5117    /// Attaches a VMO to the session. Resizable VMOs are not supported and will return
5118    /// `ZX_ERR_INVALID_ARGS`.
5119    ///
5120    /// Returns an identifier that can be used to refer to the VMO.
5121    AttachVmo { vmo: fidl::Vmo, responder: SessionAttachVmoResponder },
5122    /// Registers an inline encryption key handle (`key_token` returned by
5123    /// `fuchsia.hardware.inlineencryption/Device.ProgramKey`) with this session.
5124    ///
5125    /// Returns a session-scoped `slot` token that can be passed in
5126    /// `BlockFifoRequest.slot` when `BlockIoFlag.INLINE_ENCRYPTION_ENABLED` is set.
5127    ///
5128    /// * error `ZX_ERR_ACCESS_DENIED` if `key_token` is not a valid inline encryption key token
5129    ///   for this block device, or if the key has been evicted.
5130    /// * error `ZX_ERR_NOT_SUPPORTED` if the device does not support inline encryption.
5131    RegisterKey { key_token: fidl::EventPair, responder: SessionRegisterKeyResponder },
5132}
5133
5134impl SessionRequest {
5135    #[allow(irrefutable_let_patterns)]
5136    pub fn into_close(self) -> Option<(SessionCloseResponder)> {
5137        if let SessionRequest::Close { responder } = self { Some((responder)) } else { None }
5138    }
5139
5140    #[allow(irrefutable_let_patterns)]
5141    pub fn into_get_fifo(self) -> Option<(SessionGetFifoResponder)> {
5142        if let SessionRequest::GetFifo { responder } = self { Some((responder)) } else { None }
5143    }
5144
5145    #[allow(irrefutable_let_patterns)]
5146    pub fn into_attach_vmo(self) -> Option<(fidl::Vmo, SessionAttachVmoResponder)> {
5147        if let SessionRequest::AttachVmo { vmo, responder } = self {
5148            Some((vmo, responder))
5149        } else {
5150            None
5151        }
5152    }
5153
5154    #[allow(irrefutable_let_patterns)]
5155    pub fn into_register_key(self) -> Option<(fidl::EventPair, SessionRegisterKeyResponder)> {
5156        if let SessionRequest::RegisterKey { key_token, responder } = self {
5157            Some((key_token, responder))
5158        } else {
5159            None
5160        }
5161    }
5162
5163    /// Name of the method defined in FIDL
5164    pub fn method_name(&self) -> &'static str {
5165        match *self {
5166            SessionRequest::Close { .. } => "close",
5167            SessionRequest::GetFifo { .. } => "get_fifo",
5168            SessionRequest::AttachVmo { .. } => "attach_vmo",
5169            SessionRequest::RegisterKey { .. } => "register_key",
5170        }
5171    }
5172}
5173
5174#[derive(Debug, Clone)]
5175pub struct SessionControlHandle {
5176    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5177}
5178
5179impl SessionControlHandle {
5180    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
5181        self.inner.shutdown_with_epitaph(status.into())
5182    }
5183}
5184
5185impl fidl::endpoints::ControlHandle for SessionControlHandle {
5186    fn shutdown(&self) {
5187        self.inner.shutdown()
5188    }
5189
5190    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
5191        self.inner.shutdown_with_epitaph(status)
5192    }
5193
5194    fn is_closed(&self) -> bool {
5195        self.inner.channel().is_closed()
5196    }
5197    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5198        self.inner.channel().on_closed()
5199    }
5200
5201    #[cfg(target_os = "fuchsia")]
5202    fn signal_peer(
5203        &self,
5204        clear_mask: zx::Signals,
5205        set_mask: zx::Signals,
5206    ) -> Result<(), zx_status::Status> {
5207        use fidl::Peered;
5208        self.inner.channel().signal_peer(clear_mask, set_mask)
5209    }
5210}
5211
5212impl SessionControlHandle {}
5213
5214#[must_use = "FIDL methods require a response to be sent"]
5215#[derive(Debug)]
5216pub struct SessionCloseResponder {
5217    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
5218    tx_id: u32,
5219}
5220
5221/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
5222/// if the responder is dropped without sending a response, so that the client
5223/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5224impl std::ops::Drop for SessionCloseResponder {
5225    fn drop(&mut self) {
5226        self.control_handle.shutdown();
5227        // Safety: drops once, never accessed again
5228        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5229    }
5230}
5231
5232impl fidl::endpoints::Responder for SessionCloseResponder {
5233    type ControlHandle = SessionControlHandle;
5234
5235    fn control_handle(&self) -> &SessionControlHandle {
5236        &self.control_handle
5237    }
5238
5239    fn drop_without_shutdown(mut self) {
5240        // Safety: drops once, never accessed again due to mem::forget
5241        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5242        // Prevent Drop from running (which would shut down the channel)
5243        std::mem::forget(self);
5244    }
5245}
5246
5247impl SessionCloseResponder {
5248    /// Sends a response to the FIDL transaction.
5249    ///
5250    /// Sets the channel to shutdown if an error occurs.
5251    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5252        let _result = self.send_raw(result);
5253        if _result.is_err() {
5254            self.control_handle.shutdown();
5255        }
5256        self.drop_without_shutdown();
5257        _result
5258    }
5259
5260    /// Similar to "send" but does not shutdown the channel if an error occurs.
5261    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5262        let _result = self.send_raw(result);
5263        self.drop_without_shutdown();
5264        _result
5265    }
5266
5267    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
5268        self.control_handle
5269            .inner
5270            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
5271                result,
5272                self.tx_id,
5273                0x5ac5d459ad7f657e,
5274                fidl::encoding::DynamicFlags::empty(),
5275            )
5276    }
5277}
5278
5279#[must_use = "FIDL methods require a response to be sent"]
5280#[derive(Debug)]
5281pub struct SessionGetFifoResponder {
5282    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
5283    tx_id: u32,
5284}
5285
5286/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
5287/// if the responder is dropped without sending a response, so that the client
5288/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5289impl std::ops::Drop for SessionGetFifoResponder {
5290    fn drop(&mut self) {
5291        self.control_handle.shutdown();
5292        // Safety: drops once, never accessed again
5293        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5294    }
5295}
5296
5297impl fidl::endpoints::Responder for SessionGetFifoResponder {
5298    type ControlHandle = SessionControlHandle;
5299
5300    fn control_handle(&self) -> &SessionControlHandle {
5301        &self.control_handle
5302    }
5303
5304    fn drop_without_shutdown(mut self) {
5305        // Safety: drops once, never accessed again due to mem::forget
5306        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5307        // Prevent Drop from running (which would shut down the channel)
5308        std::mem::forget(self);
5309    }
5310}
5311
5312impl SessionGetFifoResponder {
5313    /// Sends a response to the FIDL transaction.
5314    ///
5315    /// Sets the channel to shutdown if an error occurs.
5316    pub fn send(self, mut result: Result<fidl::Fifo, i32>) -> Result<(), fidl::Error> {
5317        let _result = self.send_raw(result);
5318        if _result.is_err() {
5319            self.control_handle.shutdown();
5320        }
5321        self.drop_without_shutdown();
5322        _result
5323    }
5324
5325    /// Similar to "send" but does not shutdown the channel if an error occurs.
5326    pub fn send_no_shutdown_on_err(
5327        self,
5328        mut result: Result<fidl::Fifo, i32>,
5329    ) -> Result<(), fidl::Error> {
5330        let _result = self.send_raw(result);
5331        self.drop_without_shutdown();
5332        _result
5333    }
5334
5335    fn send_raw(&self, mut result: Result<fidl::Fifo, i32>) -> Result<(), fidl::Error> {
5336        self.control_handle.inner.send::<fidl::encoding::ResultType<SessionGetFifoResponse, i32>>(
5337            result.map(|fifo| (fifo,)),
5338            self.tx_id,
5339            0x7a6c7610912aaa98,
5340            fidl::encoding::DynamicFlags::empty(),
5341        )
5342    }
5343}
5344
5345#[must_use = "FIDL methods require a response to be sent"]
5346#[derive(Debug)]
5347pub struct SessionAttachVmoResponder {
5348    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
5349    tx_id: u32,
5350}
5351
5352/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
5353/// if the responder is dropped without sending a response, so that the client
5354/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5355impl std::ops::Drop for SessionAttachVmoResponder {
5356    fn drop(&mut self) {
5357        self.control_handle.shutdown();
5358        // Safety: drops once, never accessed again
5359        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5360    }
5361}
5362
5363impl fidl::endpoints::Responder for SessionAttachVmoResponder {
5364    type ControlHandle = SessionControlHandle;
5365
5366    fn control_handle(&self) -> &SessionControlHandle {
5367        &self.control_handle
5368    }
5369
5370    fn drop_without_shutdown(mut self) {
5371        // Safety: drops once, never accessed again due to mem::forget
5372        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5373        // Prevent Drop from running (which would shut down the channel)
5374        std::mem::forget(self);
5375    }
5376}
5377
5378impl SessionAttachVmoResponder {
5379    /// Sends a response to the FIDL transaction.
5380    ///
5381    /// Sets the channel to shutdown if an error occurs.
5382    pub fn send(self, mut result: Result<&VmoId, i32>) -> Result<(), fidl::Error> {
5383        let _result = self.send_raw(result);
5384        if _result.is_err() {
5385            self.control_handle.shutdown();
5386        }
5387        self.drop_without_shutdown();
5388        _result
5389    }
5390
5391    /// Similar to "send" but does not shutdown the channel if an error occurs.
5392    pub fn send_no_shutdown_on_err(
5393        self,
5394        mut result: Result<&VmoId, i32>,
5395    ) -> Result<(), fidl::Error> {
5396        let _result = self.send_raw(result);
5397        self.drop_without_shutdown();
5398        _result
5399    }
5400
5401    fn send_raw(&self, mut result: Result<&VmoId, i32>) -> Result<(), fidl::Error> {
5402        self.control_handle.inner.send::<fidl::encoding::ResultType<SessionAttachVmoResponse, i32>>(
5403            result.map(|vmoid| (vmoid,)),
5404            self.tx_id,
5405            0x677a0f6fd1a370b2,
5406            fidl::encoding::DynamicFlags::empty(),
5407        )
5408    }
5409}
5410
5411#[must_use = "FIDL methods require a response to be sent"]
5412#[derive(Debug)]
5413pub struct SessionRegisterKeyResponder {
5414    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
5415    tx_id: u32,
5416}
5417
5418/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
5419/// if the responder is dropped without sending a response, so that the client
5420/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5421impl std::ops::Drop for SessionRegisterKeyResponder {
5422    fn drop(&mut self) {
5423        self.control_handle.shutdown();
5424        // Safety: drops once, never accessed again
5425        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5426    }
5427}
5428
5429impl fidl::endpoints::Responder for SessionRegisterKeyResponder {
5430    type ControlHandle = SessionControlHandle;
5431
5432    fn control_handle(&self) -> &SessionControlHandle {
5433        &self.control_handle
5434    }
5435
5436    fn drop_without_shutdown(mut self) {
5437        // Safety: drops once, never accessed again due to mem::forget
5438        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5439        // Prevent Drop from running (which would shut down the channel)
5440        std::mem::forget(self);
5441    }
5442}
5443
5444impl SessionRegisterKeyResponder {
5445    /// Sends a response to the FIDL transaction.
5446    ///
5447    /// Sets the channel to shutdown if an error occurs.
5448    pub fn send(self, mut result: Result<u8, i32>) -> Result<(), fidl::Error> {
5449        let _result = self.send_raw(result);
5450        if _result.is_err() {
5451            self.control_handle.shutdown();
5452        }
5453        self.drop_without_shutdown();
5454        _result
5455    }
5456
5457    /// Similar to "send" but does not shutdown the channel if an error occurs.
5458    pub fn send_no_shutdown_on_err(self, mut result: Result<u8, i32>) -> Result<(), fidl::Error> {
5459        let _result = self.send_raw(result);
5460        self.drop_without_shutdown();
5461        _result
5462    }
5463
5464    fn send_raw(&self, mut result: Result<u8, i32>) -> Result<(), fidl::Error> {
5465        self.control_handle
5466            .inner
5467            .send::<fidl::encoding::ResultType<SessionRegisterKeyResponse, i32>>(
5468                result.map(|slot| (slot,)),
5469                self.tx_id,
5470                0x38ea5528cf83d1f6,
5471                fidl::encoding::DynamicFlags::empty(),
5472            )
5473    }
5474}
5475
5476#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5477pub struct VolumeManagerMarker;
5478
5479impl fidl::endpoints::ProtocolMarker for VolumeManagerMarker {
5480    type Proxy = VolumeManagerProxy;
5481    type RequestStream = VolumeManagerRequestStream;
5482    #[cfg(target_os = "fuchsia")]
5483    type SynchronousProxy = VolumeManagerSynchronousProxy;
5484
5485    const DEBUG_NAME: &'static str = "(anonymous) VolumeManager";
5486}
5487pub type VolumeManagerSetPartitionNameResult = Result<(), i32>;
5488
5489pub trait VolumeManagerProxyInterface: Send + Sync {
5490    type AllocatePartitionResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
5491    fn r#allocate_partition(
5492        &self,
5493        slice_count: u64,
5494        type_: &Guid,
5495        instance: &Guid,
5496        name: &str,
5497        flags: u32,
5498    ) -> Self::AllocatePartitionResponseFut;
5499    type GetInfoResponseFut: std::future::Future<Output = Result<(i32, Option<Box<VolumeManagerInfo>>), fidl::Error>>
5500        + Send;
5501    fn r#get_info(&self) -> Self::GetInfoResponseFut;
5502    type ActivateResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
5503    fn r#activate(&self, old_guid: &Guid, new_guid: &Guid) -> Self::ActivateResponseFut;
5504    type GetPartitionLimitResponseFut: std::future::Future<Output = Result<(i32, u64), fidl::Error>>
5505        + Send;
5506    fn r#get_partition_limit(&self, guid: &Guid) -> Self::GetPartitionLimitResponseFut;
5507    type SetPartitionLimitResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
5508    fn r#set_partition_limit(
5509        &self,
5510        guid: &Guid,
5511        slice_count: u64,
5512    ) -> Self::SetPartitionLimitResponseFut;
5513    type SetPartitionNameResponseFut: std::future::Future<Output = Result<VolumeManagerSetPartitionNameResult, fidl::Error>>
5514        + Send;
5515    fn r#set_partition_name(&self, guid: &Guid, name: &str) -> Self::SetPartitionNameResponseFut;
5516}
5517#[derive(Debug)]
5518#[cfg(target_os = "fuchsia")]
5519pub struct VolumeManagerSynchronousProxy {
5520    client: fidl::client::sync::Client,
5521}
5522
5523#[cfg(target_os = "fuchsia")]
5524impl fidl::endpoints::SynchronousProxy for VolumeManagerSynchronousProxy {
5525    type Proxy = VolumeManagerProxy;
5526    type Protocol = VolumeManagerMarker;
5527
5528    fn from_channel(inner: fidl::Channel) -> Self {
5529        Self::new(inner)
5530    }
5531
5532    fn into_channel(self) -> fidl::Channel {
5533        self.client.into_channel()
5534    }
5535
5536    fn as_channel(&self) -> &fidl::Channel {
5537        self.client.as_channel()
5538    }
5539}
5540
5541#[cfg(target_os = "fuchsia")]
5542impl VolumeManagerSynchronousProxy {
5543    pub fn new(channel: fidl::Channel) -> Self {
5544        Self { client: fidl::client::sync::Client::new(channel) }
5545    }
5546
5547    pub fn into_channel(self) -> fidl::Channel {
5548        self.client.into_channel()
5549    }
5550
5551    /// Waits until an event arrives and returns it. It is safe for other
5552    /// threads to make concurrent requests while waiting for an event.
5553    pub fn wait_for_event(
5554        &self,
5555        deadline: zx::MonotonicInstant,
5556    ) -> Result<VolumeManagerEvent, fidl::Error> {
5557        VolumeManagerEvent::decode(self.client.wait_for_event::<VolumeManagerMarker>(deadline)?)
5558    }
5559
5560    /// Allocates a virtual partition with the requested features.
5561    ///
5562    /// `slice_count` is the number of slices initially allocated to the partition, at
5563    /// offset zero. The number of slices allocated to a new partition must be at least one.
5564    /// `type` and `value` indicate type and instance GUIDs for the partition, respectively.
5565    /// `name` indicates the name of the new partition.
5566    pub fn r#allocate_partition(
5567        &self,
5568        mut slice_count: u64,
5569        mut type_: &Guid,
5570        mut instance: &Guid,
5571        mut name: &str,
5572        mut flags: u32,
5573        ___deadline: zx::MonotonicInstant,
5574    ) -> Result<i32, fidl::Error> {
5575        let _response = self.client.send_query::<
5576            VolumeManagerAllocatePartitionRequest,
5577            VolumeManagerAllocatePartitionResponse,
5578            VolumeManagerMarker,
5579        >(
5580            (slice_count, type_, instance, name, flags,),
5581            0x5db528bfc287b696,
5582            fidl::encoding::DynamicFlags::empty(),
5583            ___deadline,
5584        )?;
5585        Ok(_response.status)
5586    }
5587
5588    /// Gets the VolumeManagerInfo describing this instance of the `VolumeManager`.
5589    ///
5590    /// **NOTE**: GetInfo() is used to synchronize child partition device visibility with devfs.
5591    /// Implementations must only respond once all child partitions of `VolumeManager` have been
5592    /// added to devfs, to guarantee clients can safely enumerate them.
5593    ///
5594    /// See https://fxbug.dev/42077585 for more information.
5595    pub fn r#get_info(
5596        &self,
5597        ___deadline: zx::MonotonicInstant,
5598    ) -> Result<(i32, Option<Box<VolumeManagerInfo>>), fidl::Error> {
5599        let _response = self.client.send_query::<
5600            fidl::encoding::EmptyPayload,
5601            VolumeManagerGetInfoResponse,
5602            VolumeManagerMarker,
5603        >(
5604            (),
5605            0x2611214dcca5b064,
5606            fidl::encoding::DynamicFlags::empty(),
5607            ___deadline,
5608        )?;
5609        Ok((_response.status, _response.info))
5610    }
5611
5612    /// Atomically marks a vpartition (by instance GUID) as inactive, while finding
5613    /// another partition (by instance GUID) and marking it as active.
5614    ///
5615    /// If the "old" partition does not exist, the GUID is ignored.
5616    /// If the "old" partition is the same as the "new" partition, the "old"
5617    /// GUID is ignored.
5618    /// If the "new" partition does not exist, `ZX_ERR_NOT_FOUND` is returned.
5619    ///
5620    /// This function does not destroy the "old" partition, it just marks it as
5621    /// inactive -- to reclaim that space, the "old" partition must be explicitly
5622    /// destroyed.  This destruction can also occur automatically when the FVM driver
5623    /// is rebound (i.e., on reboot).
5624    ///
5625    /// This function may be useful for A/B updates within the FVM,
5626    /// since it will allow activating updated partitions.
5627    pub fn r#activate(
5628        &self,
5629        mut old_guid: &Guid,
5630        mut new_guid: &Guid,
5631        ___deadline: zx::MonotonicInstant,
5632    ) -> Result<i32, fidl::Error> {
5633        let _response = self.client.send_query::<
5634            VolumeManagerActivateRequest,
5635            VolumeManagerActivateResponse,
5636            VolumeManagerMarker,
5637        >(
5638            (old_guid, new_guid,),
5639            0x182238d40c275be,
5640            fidl::encoding::DynamicFlags::empty(),
5641            ___deadline,
5642        )?;
5643        Ok(_response.status)
5644    }
5645
5646    /// Retrieves the allocation limit for the partition. A return value of 0 indicates that there
5647    /// is no limit and the partition can be extended as long as there is available space on the
5648    /// device.
5649    ///
5650    /// The partition may be larger than this limit if a smaller limit was applied after the
5651    /// partition had already grown to the current size.
5652    ///
5653    /// Currently the partition limit is not persisted across reboots but this may change in the
5654    /// future.
5655    pub fn r#get_partition_limit(
5656        &self,
5657        mut guid: &Guid,
5658        ___deadline: zx::MonotonicInstant,
5659    ) -> Result<(i32, u64), fidl::Error> {
5660        let _response = self.client.send_query::<
5661            VolumeManagerGetPartitionLimitRequest,
5662            VolumeManagerGetPartitionLimitResponse,
5663            VolumeManagerMarker,
5664        >(
5665            (guid,),
5666            0x5bc9d21ea8bd52db,
5667            fidl::encoding::DynamicFlags::empty(),
5668            ___deadline,
5669        )?;
5670        Ok((_response.status, _response.slice_count))
5671    }
5672
5673    /// Sets the allocation limit for the partition. Partitions can not be extended beyond their
5674    /// allocation limit. The partition limit will never shrink partitions so if this value is
5675    /// less than the current partition size, it will keep the current size but prevent further
5676    /// growth.
5677    ///
5678    /// The allocation limits are on the VolumeManager API rather than on the partition because
5679    /// they represent a higher capability level. These limits are designed to put guards on
5680    /// users of the block device (and hence the Volume API).
5681    ///
5682    /// Currently the partition limit is not persisted across reboots but this may change in the
5683    /// future.
5684    pub fn r#set_partition_limit(
5685        &self,
5686        mut guid: &Guid,
5687        mut slice_count: u64,
5688        ___deadline: zx::MonotonicInstant,
5689    ) -> Result<i32, fidl::Error> {
5690        let _response = self.client.send_query::<
5691            VolumeManagerSetPartitionLimitRequest,
5692            VolumeManagerSetPartitionLimitResponse,
5693            VolumeManagerMarker,
5694        >(
5695            (guid, slice_count,),
5696            0x3a4903076534c093,
5697            fidl::encoding::DynamicFlags::empty(),
5698            ___deadline,
5699        )?;
5700        Ok(_response.status)
5701    }
5702
5703    /// Renames the specified partition. Any existing devices that include the name of the partition
5704    /// in their topological path might *not* reflect the name change until the next time that the
5705    /// device is instantiated.
5706    pub fn r#set_partition_name(
5707        &self,
5708        mut guid: &Guid,
5709        mut name: &str,
5710        ___deadline: zx::MonotonicInstant,
5711    ) -> Result<VolumeManagerSetPartitionNameResult, fidl::Error> {
5712        let _response = self.client.send_query::<
5713            VolumeManagerSetPartitionNameRequest,
5714            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5715            VolumeManagerMarker,
5716        >(
5717            (guid, name,),
5718            0x26afb07b9d70ff1a,
5719            fidl::encoding::DynamicFlags::empty(),
5720            ___deadline,
5721        )?;
5722        Ok(_response.map(|x| x))
5723    }
5724}
5725
5726#[cfg(target_os = "fuchsia")]
5727impl From<VolumeManagerSynchronousProxy> for zx::NullableHandle {
5728    fn from(value: VolumeManagerSynchronousProxy) -> Self {
5729        value.into_channel().into()
5730    }
5731}
5732
5733#[cfg(target_os = "fuchsia")]
5734impl From<fidl::Channel> for VolumeManagerSynchronousProxy {
5735    fn from(value: fidl::Channel) -> Self {
5736        Self::new(value)
5737    }
5738}
5739
5740#[cfg(target_os = "fuchsia")]
5741impl fidl::endpoints::FromClient for VolumeManagerSynchronousProxy {
5742    type Protocol = VolumeManagerMarker;
5743
5744    fn from_client(value: fidl::endpoints::ClientEnd<VolumeManagerMarker>) -> Self {
5745        Self::new(value.into_channel())
5746    }
5747}
5748
5749#[derive(Debug, Clone)]
5750pub struct VolumeManagerProxy {
5751    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5752}
5753
5754impl fidl::endpoints::Proxy for VolumeManagerProxy {
5755    type Protocol = VolumeManagerMarker;
5756
5757    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5758        Self::new(inner)
5759    }
5760
5761    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5762        self.client.into_channel().map_err(|client| Self { client })
5763    }
5764
5765    fn as_channel(&self) -> &::fidl::AsyncChannel {
5766        self.client.as_channel()
5767    }
5768}
5769
5770impl VolumeManagerProxy {
5771    /// Create a new Proxy for fuchsia.storage.block/VolumeManager.
5772    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5773        let protocol_name = <VolumeManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5774        Self { client: fidl::client::Client::new(channel, protocol_name) }
5775    }
5776
5777    /// Get a Stream of events from the remote end of the protocol.
5778    ///
5779    /// # Panics
5780    ///
5781    /// Panics if the event stream was already taken.
5782    pub fn take_event_stream(&self) -> VolumeManagerEventStream {
5783        VolumeManagerEventStream { event_receiver: self.client.take_event_receiver() }
5784    }
5785
5786    /// Allocates a virtual partition with the requested features.
5787    ///
5788    /// `slice_count` is the number of slices initially allocated to the partition, at
5789    /// offset zero. The number of slices allocated to a new partition must be at least one.
5790    /// `type` and `value` indicate type and instance GUIDs for the partition, respectively.
5791    /// `name` indicates the name of the new partition.
5792    pub fn r#allocate_partition(
5793        &self,
5794        mut slice_count: u64,
5795        mut type_: &Guid,
5796        mut instance: &Guid,
5797        mut name: &str,
5798        mut flags: u32,
5799    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5800        VolumeManagerProxyInterface::r#allocate_partition(
5801            self,
5802            slice_count,
5803            type_,
5804            instance,
5805            name,
5806            flags,
5807        )
5808    }
5809
5810    /// Gets the VolumeManagerInfo describing this instance of the `VolumeManager`.
5811    ///
5812    /// **NOTE**: GetInfo() is used to synchronize child partition device visibility with devfs.
5813    /// Implementations must only respond once all child partitions of `VolumeManager` have been
5814    /// added to devfs, to guarantee clients can safely enumerate them.
5815    ///
5816    /// See https://fxbug.dev/42077585 for more information.
5817    pub fn r#get_info(
5818        &self,
5819    ) -> fidl::client::QueryResponseFut<
5820        (i32, Option<Box<VolumeManagerInfo>>),
5821        fidl::encoding::DefaultFuchsiaResourceDialect,
5822    > {
5823        VolumeManagerProxyInterface::r#get_info(self)
5824    }
5825
5826    /// Atomically marks a vpartition (by instance GUID) as inactive, while finding
5827    /// another partition (by instance GUID) and marking it as active.
5828    ///
5829    /// If the "old" partition does not exist, the GUID is ignored.
5830    /// If the "old" partition is the same as the "new" partition, the "old"
5831    /// GUID is ignored.
5832    /// If the "new" partition does not exist, `ZX_ERR_NOT_FOUND` is returned.
5833    ///
5834    /// This function does not destroy the "old" partition, it just marks it as
5835    /// inactive -- to reclaim that space, the "old" partition must be explicitly
5836    /// destroyed.  This destruction can also occur automatically when the FVM driver
5837    /// is rebound (i.e., on reboot).
5838    ///
5839    /// This function may be useful for A/B updates within the FVM,
5840    /// since it will allow activating updated partitions.
5841    pub fn r#activate(
5842        &self,
5843        mut old_guid: &Guid,
5844        mut new_guid: &Guid,
5845    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5846        VolumeManagerProxyInterface::r#activate(self, old_guid, new_guid)
5847    }
5848
5849    /// Retrieves the allocation limit for the partition. A return value of 0 indicates that there
5850    /// is no limit and the partition can be extended as long as there is available space on the
5851    /// device.
5852    ///
5853    /// The partition may be larger than this limit if a smaller limit was applied after the
5854    /// partition had already grown to the current size.
5855    ///
5856    /// Currently the partition limit is not persisted across reboots but this may change in the
5857    /// future.
5858    pub fn r#get_partition_limit(
5859        &self,
5860        mut guid: &Guid,
5861    ) -> fidl::client::QueryResponseFut<(i32, u64), fidl::encoding::DefaultFuchsiaResourceDialect>
5862    {
5863        VolumeManagerProxyInterface::r#get_partition_limit(self, guid)
5864    }
5865
5866    /// Sets the allocation limit for the partition. Partitions can not be extended beyond their
5867    /// allocation limit. The partition limit will never shrink partitions so if this value is
5868    /// less than the current partition size, it will keep the current size but prevent further
5869    /// growth.
5870    ///
5871    /// The allocation limits are on the VolumeManager API rather than on the partition because
5872    /// they represent a higher capability level. These limits are designed to put guards on
5873    /// users of the block device (and hence the Volume API).
5874    ///
5875    /// Currently the partition limit is not persisted across reboots but this may change in the
5876    /// future.
5877    pub fn r#set_partition_limit(
5878        &self,
5879        mut guid: &Guid,
5880        mut slice_count: u64,
5881    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5882        VolumeManagerProxyInterface::r#set_partition_limit(self, guid, slice_count)
5883    }
5884
5885    /// Renames the specified partition. Any existing devices that include the name of the partition
5886    /// in their topological path might *not* reflect the name change until the next time that the
5887    /// device is instantiated.
5888    pub fn r#set_partition_name(
5889        &self,
5890        mut guid: &Guid,
5891        mut name: &str,
5892    ) -> fidl::client::QueryResponseFut<
5893        VolumeManagerSetPartitionNameResult,
5894        fidl::encoding::DefaultFuchsiaResourceDialect,
5895    > {
5896        VolumeManagerProxyInterface::r#set_partition_name(self, guid, name)
5897    }
5898}
5899
5900impl VolumeManagerProxyInterface for VolumeManagerProxy {
5901    type AllocatePartitionResponseFut =
5902        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5903    fn r#allocate_partition(
5904        &self,
5905        mut slice_count: u64,
5906        mut type_: &Guid,
5907        mut instance: &Guid,
5908        mut name: &str,
5909        mut flags: u32,
5910    ) -> Self::AllocatePartitionResponseFut {
5911        fn _decode(
5912            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5913        ) -> Result<i32, fidl::Error> {
5914            let _response = fidl::client::decode_transaction_body::<
5915                VolumeManagerAllocatePartitionResponse,
5916                fidl::encoding::DefaultFuchsiaResourceDialect,
5917                0x5db528bfc287b696,
5918            >(_buf?)?;
5919            Ok(_response.status)
5920        }
5921        self.client.send_query_and_decode::<VolumeManagerAllocatePartitionRequest, i32>(
5922            (slice_count, type_, instance, name, flags),
5923            0x5db528bfc287b696,
5924            fidl::encoding::DynamicFlags::empty(),
5925            _decode,
5926        )
5927    }
5928
5929    type GetInfoResponseFut = fidl::client::QueryResponseFut<
5930        (i32, Option<Box<VolumeManagerInfo>>),
5931        fidl::encoding::DefaultFuchsiaResourceDialect,
5932    >;
5933    fn r#get_info(&self) -> Self::GetInfoResponseFut {
5934        fn _decode(
5935            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5936        ) -> Result<(i32, Option<Box<VolumeManagerInfo>>), fidl::Error> {
5937            let _response = fidl::client::decode_transaction_body::<
5938                VolumeManagerGetInfoResponse,
5939                fidl::encoding::DefaultFuchsiaResourceDialect,
5940                0x2611214dcca5b064,
5941            >(_buf?)?;
5942            Ok((_response.status, _response.info))
5943        }
5944        self.client.send_query_and_decode::<
5945            fidl::encoding::EmptyPayload,
5946            (i32, Option<Box<VolumeManagerInfo>>),
5947        >(
5948            (),
5949            0x2611214dcca5b064,
5950            fidl::encoding::DynamicFlags::empty(),
5951            _decode,
5952        )
5953    }
5954
5955    type ActivateResponseFut =
5956        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5957    fn r#activate(&self, mut old_guid: &Guid, mut new_guid: &Guid) -> Self::ActivateResponseFut {
5958        fn _decode(
5959            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5960        ) -> Result<i32, fidl::Error> {
5961            let _response = fidl::client::decode_transaction_body::<
5962                VolumeManagerActivateResponse,
5963                fidl::encoding::DefaultFuchsiaResourceDialect,
5964                0x182238d40c275be,
5965            >(_buf?)?;
5966            Ok(_response.status)
5967        }
5968        self.client.send_query_and_decode::<VolumeManagerActivateRequest, i32>(
5969            (old_guid, new_guid),
5970            0x182238d40c275be,
5971            fidl::encoding::DynamicFlags::empty(),
5972            _decode,
5973        )
5974    }
5975
5976    type GetPartitionLimitResponseFut =
5977        fidl::client::QueryResponseFut<(i32, u64), fidl::encoding::DefaultFuchsiaResourceDialect>;
5978    fn r#get_partition_limit(&self, mut guid: &Guid) -> Self::GetPartitionLimitResponseFut {
5979        fn _decode(
5980            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5981        ) -> Result<(i32, u64), fidl::Error> {
5982            let _response = fidl::client::decode_transaction_body::<
5983                VolumeManagerGetPartitionLimitResponse,
5984                fidl::encoding::DefaultFuchsiaResourceDialect,
5985                0x5bc9d21ea8bd52db,
5986            >(_buf?)?;
5987            Ok((_response.status, _response.slice_count))
5988        }
5989        self.client.send_query_and_decode::<VolumeManagerGetPartitionLimitRequest, (i32, u64)>(
5990            (guid,),
5991            0x5bc9d21ea8bd52db,
5992            fidl::encoding::DynamicFlags::empty(),
5993            _decode,
5994        )
5995    }
5996
5997    type SetPartitionLimitResponseFut =
5998        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5999    fn r#set_partition_limit(
6000        &self,
6001        mut guid: &Guid,
6002        mut slice_count: u64,
6003    ) -> Self::SetPartitionLimitResponseFut {
6004        fn _decode(
6005            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6006        ) -> Result<i32, fidl::Error> {
6007            let _response = fidl::client::decode_transaction_body::<
6008                VolumeManagerSetPartitionLimitResponse,
6009                fidl::encoding::DefaultFuchsiaResourceDialect,
6010                0x3a4903076534c093,
6011            >(_buf?)?;
6012            Ok(_response.status)
6013        }
6014        self.client.send_query_and_decode::<VolumeManagerSetPartitionLimitRequest, i32>(
6015            (guid, slice_count),
6016            0x3a4903076534c093,
6017            fidl::encoding::DynamicFlags::empty(),
6018            _decode,
6019        )
6020    }
6021
6022    type SetPartitionNameResponseFut = fidl::client::QueryResponseFut<
6023        VolumeManagerSetPartitionNameResult,
6024        fidl::encoding::DefaultFuchsiaResourceDialect,
6025    >;
6026    fn r#set_partition_name(
6027        &self,
6028        mut guid: &Guid,
6029        mut name: &str,
6030    ) -> Self::SetPartitionNameResponseFut {
6031        fn _decode(
6032            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6033        ) -> Result<VolumeManagerSetPartitionNameResult, fidl::Error> {
6034            let _response = fidl::client::decode_transaction_body::<
6035                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6036                fidl::encoding::DefaultFuchsiaResourceDialect,
6037                0x26afb07b9d70ff1a,
6038            >(_buf?)?;
6039            Ok(_response.map(|x| x))
6040        }
6041        self.client.send_query_and_decode::<
6042            VolumeManagerSetPartitionNameRequest,
6043            VolumeManagerSetPartitionNameResult,
6044        >(
6045            (guid, name,),
6046            0x26afb07b9d70ff1a,
6047            fidl::encoding::DynamicFlags::empty(),
6048            _decode,
6049        )
6050    }
6051}
6052
6053pub struct VolumeManagerEventStream {
6054    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6055}
6056
6057impl std::marker::Unpin for VolumeManagerEventStream {}
6058
6059impl futures::stream::FusedStream for VolumeManagerEventStream {
6060    fn is_terminated(&self) -> bool {
6061        self.event_receiver.is_terminated()
6062    }
6063}
6064
6065impl futures::Stream for VolumeManagerEventStream {
6066    type Item = Result<VolumeManagerEvent, fidl::Error>;
6067
6068    fn poll_next(
6069        mut self: std::pin::Pin<&mut Self>,
6070        cx: &mut std::task::Context<'_>,
6071    ) -> std::task::Poll<Option<Self::Item>> {
6072        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6073            &mut self.event_receiver,
6074            cx
6075        )?) {
6076            Some(buf) => std::task::Poll::Ready(Some(VolumeManagerEvent::decode(buf))),
6077            None => std::task::Poll::Ready(None),
6078        }
6079    }
6080}
6081
6082#[derive(Debug)]
6083pub enum VolumeManagerEvent {}
6084
6085impl VolumeManagerEvent {
6086    /// Decodes a message buffer as a [`VolumeManagerEvent`].
6087    fn decode(
6088        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6089    ) -> Result<VolumeManagerEvent, fidl::Error> {
6090        let (bytes, _handles) = buf.split_mut();
6091        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6092        debug_assert_eq!(tx_header.tx_id, 0);
6093        match tx_header.ordinal {
6094            _ => Err(fidl::Error::UnknownOrdinal {
6095                ordinal: tx_header.ordinal,
6096                protocol_name: <VolumeManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6097            }),
6098        }
6099    }
6100}
6101
6102/// A Stream of incoming requests for fuchsia.storage.block/VolumeManager.
6103pub struct VolumeManagerRequestStream {
6104    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6105    is_terminated: bool,
6106}
6107
6108impl std::marker::Unpin for VolumeManagerRequestStream {}
6109
6110impl futures::stream::FusedStream for VolumeManagerRequestStream {
6111    fn is_terminated(&self) -> bool {
6112        self.is_terminated
6113    }
6114}
6115
6116impl fidl::endpoints::RequestStream for VolumeManagerRequestStream {
6117    type Protocol = VolumeManagerMarker;
6118    type ControlHandle = VolumeManagerControlHandle;
6119
6120    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6121        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6122    }
6123
6124    fn control_handle(&self) -> Self::ControlHandle {
6125        VolumeManagerControlHandle { inner: self.inner.clone() }
6126    }
6127
6128    fn into_inner(
6129        self,
6130    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6131    {
6132        (self.inner, self.is_terminated)
6133    }
6134
6135    fn from_inner(
6136        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6137        is_terminated: bool,
6138    ) -> Self {
6139        Self { inner, is_terminated }
6140    }
6141}
6142
6143impl futures::Stream for VolumeManagerRequestStream {
6144    type Item = Result<VolumeManagerRequest, fidl::Error>;
6145
6146    fn poll_next(
6147        mut self: std::pin::Pin<&mut Self>,
6148        cx: &mut std::task::Context<'_>,
6149    ) -> std::task::Poll<Option<Self::Item>> {
6150        let this = &mut *self;
6151        if this.inner.check_shutdown(cx) {
6152            this.is_terminated = true;
6153            return std::task::Poll::Ready(None);
6154        }
6155        if this.is_terminated {
6156            panic!("polled VolumeManagerRequestStream after completion");
6157        }
6158        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6159            |bytes, handles| {
6160                match this.inner.channel().read_etc(cx, bytes, handles) {
6161                    std::task::Poll::Ready(Ok(())) => {}
6162                    std::task::Poll::Pending => return std::task::Poll::Pending,
6163                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6164                        this.is_terminated = true;
6165                        return std::task::Poll::Ready(None);
6166                    }
6167                    std::task::Poll::Ready(Err(e)) => {
6168                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6169                            e.into(),
6170                        ))));
6171                    }
6172                }
6173
6174                // A message has been received from the channel
6175                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6176
6177                std::task::Poll::Ready(Some(match header.ordinal {
6178                    0x5db528bfc287b696 => {
6179                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6180                        let mut req = fidl::new_empty!(
6181                            VolumeManagerAllocatePartitionRequest,
6182                            fidl::encoding::DefaultFuchsiaResourceDialect
6183                        );
6184                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VolumeManagerAllocatePartitionRequest>(&header, _body_bytes, handles, &mut req)?;
6185                        let control_handle =
6186                            VolumeManagerControlHandle { inner: this.inner.clone() };
6187                        Ok(VolumeManagerRequest::AllocatePartition {
6188                            slice_count: req.slice_count,
6189                            type_: req.type_,
6190                            instance: req.instance,
6191                            name: req.name,
6192                            flags: req.flags,
6193
6194                            responder: VolumeManagerAllocatePartitionResponder {
6195                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6196                                tx_id: header.tx_id,
6197                            },
6198                        })
6199                    }
6200                    0x2611214dcca5b064 => {
6201                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6202                        let mut req = fidl::new_empty!(
6203                            fidl::encoding::EmptyPayload,
6204                            fidl::encoding::DefaultFuchsiaResourceDialect
6205                        );
6206                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6207                        let control_handle =
6208                            VolumeManagerControlHandle { inner: this.inner.clone() };
6209                        Ok(VolumeManagerRequest::GetInfo {
6210                            responder: VolumeManagerGetInfoResponder {
6211                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6212                                tx_id: header.tx_id,
6213                            },
6214                        })
6215                    }
6216                    0x182238d40c275be => {
6217                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6218                        let mut req = fidl::new_empty!(
6219                            VolumeManagerActivateRequest,
6220                            fidl::encoding::DefaultFuchsiaResourceDialect
6221                        );
6222                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VolumeManagerActivateRequest>(&header, _body_bytes, handles, &mut req)?;
6223                        let control_handle =
6224                            VolumeManagerControlHandle { inner: this.inner.clone() };
6225                        Ok(VolumeManagerRequest::Activate {
6226                            old_guid: req.old_guid,
6227                            new_guid: req.new_guid,
6228
6229                            responder: VolumeManagerActivateResponder {
6230                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6231                                tx_id: header.tx_id,
6232                            },
6233                        })
6234                    }
6235                    0x5bc9d21ea8bd52db => {
6236                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6237                        let mut req = fidl::new_empty!(
6238                            VolumeManagerGetPartitionLimitRequest,
6239                            fidl::encoding::DefaultFuchsiaResourceDialect
6240                        );
6241                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VolumeManagerGetPartitionLimitRequest>(&header, _body_bytes, handles, &mut req)?;
6242                        let control_handle =
6243                            VolumeManagerControlHandle { inner: this.inner.clone() };
6244                        Ok(VolumeManagerRequest::GetPartitionLimit {
6245                            guid: req.guid,
6246
6247                            responder: VolumeManagerGetPartitionLimitResponder {
6248                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6249                                tx_id: header.tx_id,
6250                            },
6251                        })
6252                    }
6253                    0x3a4903076534c093 => {
6254                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6255                        let mut req = fidl::new_empty!(
6256                            VolumeManagerSetPartitionLimitRequest,
6257                            fidl::encoding::DefaultFuchsiaResourceDialect
6258                        );
6259                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VolumeManagerSetPartitionLimitRequest>(&header, _body_bytes, handles, &mut req)?;
6260                        let control_handle =
6261                            VolumeManagerControlHandle { inner: this.inner.clone() };
6262                        Ok(VolumeManagerRequest::SetPartitionLimit {
6263                            guid: req.guid,
6264                            slice_count: req.slice_count,
6265
6266                            responder: VolumeManagerSetPartitionLimitResponder {
6267                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6268                                tx_id: header.tx_id,
6269                            },
6270                        })
6271                    }
6272                    0x26afb07b9d70ff1a => {
6273                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6274                        let mut req = fidl::new_empty!(
6275                            VolumeManagerSetPartitionNameRequest,
6276                            fidl::encoding::DefaultFuchsiaResourceDialect
6277                        );
6278                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VolumeManagerSetPartitionNameRequest>(&header, _body_bytes, handles, &mut req)?;
6279                        let control_handle =
6280                            VolumeManagerControlHandle { inner: this.inner.clone() };
6281                        Ok(VolumeManagerRequest::SetPartitionName {
6282                            guid: req.guid,
6283                            name: req.name,
6284
6285                            responder: VolumeManagerSetPartitionNameResponder {
6286                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6287                                tx_id: header.tx_id,
6288                            },
6289                        })
6290                    }
6291                    _ => Err(fidl::Error::UnknownOrdinal {
6292                        ordinal: header.ordinal,
6293                        protocol_name:
6294                            <VolumeManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6295                    }),
6296                }))
6297            },
6298        )
6299    }
6300}
6301
6302/// VolumeManager controls a collection of Volumes.
6303#[derive(Debug)]
6304pub enum VolumeManagerRequest {
6305    /// Allocates a virtual partition with the requested features.
6306    ///
6307    /// `slice_count` is the number of slices initially allocated to the partition, at
6308    /// offset zero. The number of slices allocated to a new partition must be at least one.
6309    /// `type` and `value` indicate type and instance GUIDs for the partition, respectively.
6310    /// `name` indicates the name of the new partition.
6311    AllocatePartition {
6312        slice_count: u64,
6313        type_: Guid,
6314        instance: Guid,
6315        name: String,
6316        flags: u32,
6317        responder: VolumeManagerAllocatePartitionResponder,
6318    },
6319    /// Gets the VolumeManagerInfo describing this instance of the `VolumeManager`.
6320    ///
6321    /// **NOTE**: GetInfo() is used to synchronize child partition device visibility with devfs.
6322    /// Implementations must only respond once all child partitions of `VolumeManager` have been
6323    /// added to devfs, to guarantee clients can safely enumerate them.
6324    ///
6325    /// See https://fxbug.dev/42077585 for more information.
6326    GetInfo { responder: VolumeManagerGetInfoResponder },
6327    /// Atomically marks a vpartition (by instance GUID) as inactive, while finding
6328    /// another partition (by instance GUID) and marking it as active.
6329    ///
6330    /// If the "old" partition does not exist, the GUID is ignored.
6331    /// If the "old" partition is the same as the "new" partition, the "old"
6332    /// GUID is ignored.
6333    /// If the "new" partition does not exist, `ZX_ERR_NOT_FOUND` is returned.
6334    ///
6335    /// This function does not destroy the "old" partition, it just marks it as
6336    /// inactive -- to reclaim that space, the "old" partition must be explicitly
6337    /// destroyed.  This destruction can also occur automatically when the FVM driver
6338    /// is rebound (i.e., on reboot).
6339    ///
6340    /// This function may be useful for A/B updates within the FVM,
6341    /// since it will allow activating updated partitions.
6342    Activate { old_guid: Guid, new_guid: Guid, responder: VolumeManagerActivateResponder },
6343    /// Retrieves the allocation limit for the partition. A return value of 0 indicates that there
6344    /// is no limit and the partition can be extended as long as there is available space on the
6345    /// device.
6346    ///
6347    /// The partition may be larger than this limit if a smaller limit was applied after the
6348    /// partition had already grown to the current size.
6349    ///
6350    /// Currently the partition limit is not persisted across reboots but this may change in the
6351    /// future.
6352    GetPartitionLimit { guid: Guid, responder: VolumeManagerGetPartitionLimitResponder },
6353    /// Sets the allocation limit for the partition. Partitions can not be extended beyond their
6354    /// allocation limit. The partition limit will never shrink partitions so if this value is
6355    /// less than the current partition size, it will keep the current size but prevent further
6356    /// growth.
6357    ///
6358    /// The allocation limits are on the VolumeManager API rather than on the partition because
6359    /// they represent a higher capability level. These limits are designed to put guards on
6360    /// users of the block device (and hence the Volume API).
6361    ///
6362    /// Currently the partition limit is not persisted across reboots but this may change in the
6363    /// future.
6364    SetPartitionLimit {
6365        guid: Guid,
6366        slice_count: u64,
6367        responder: VolumeManagerSetPartitionLimitResponder,
6368    },
6369    /// Renames the specified partition. Any existing devices that include the name of the partition
6370    /// in their topological path might *not* reflect the name change until the next time that the
6371    /// device is instantiated.
6372    SetPartitionName { guid: Guid, name: String, responder: VolumeManagerSetPartitionNameResponder },
6373}
6374
6375impl VolumeManagerRequest {
6376    #[allow(irrefutable_let_patterns)]
6377    pub fn into_allocate_partition(
6378        self,
6379    ) -> Option<(u64, Guid, Guid, String, u32, VolumeManagerAllocatePartitionResponder)> {
6380        if let VolumeManagerRequest::AllocatePartition {
6381            slice_count,
6382            type_,
6383            instance,
6384            name,
6385            flags,
6386            responder,
6387        } = self
6388        {
6389            Some((slice_count, type_, instance, name, flags, responder))
6390        } else {
6391            None
6392        }
6393    }
6394
6395    #[allow(irrefutable_let_patterns)]
6396    pub fn into_get_info(self) -> Option<(VolumeManagerGetInfoResponder)> {
6397        if let VolumeManagerRequest::GetInfo { responder } = self {
6398            Some((responder))
6399        } else {
6400            None
6401        }
6402    }
6403
6404    #[allow(irrefutable_let_patterns)]
6405    pub fn into_activate(self) -> Option<(Guid, Guid, VolumeManagerActivateResponder)> {
6406        if let VolumeManagerRequest::Activate { old_guid, new_guid, responder } = self {
6407            Some((old_guid, new_guid, responder))
6408        } else {
6409            None
6410        }
6411    }
6412
6413    #[allow(irrefutable_let_patterns)]
6414    pub fn into_get_partition_limit(
6415        self,
6416    ) -> Option<(Guid, VolumeManagerGetPartitionLimitResponder)> {
6417        if let VolumeManagerRequest::GetPartitionLimit { guid, responder } = self {
6418            Some((guid, responder))
6419        } else {
6420            None
6421        }
6422    }
6423
6424    #[allow(irrefutable_let_patterns)]
6425    pub fn into_set_partition_limit(
6426        self,
6427    ) -> Option<(Guid, u64, VolumeManagerSetPartitionLimitResponder)> {
6428        if let VolumeManagerRequest::SetPartitionLimit { guid, slice_count, responder } = self {
6429            Some((guid, slice_count, responder))
6430        } else {
6431            None
6432        }
6433    }
6434
6435    #[allow(irrefutable_let_patterns)]
6436    pub fn into_set_partition_name(
6437        self,
6438    ) -> Option<(Guid, String, VolumeManagerSetPartitionNameResponder)> {
6439        if let VolumeManagerRequest::SetPartitionName { guid, name, responder } = self {
6440            Some((guid, name, responder))
6441        } else {
6442            None
6443        }
6444    }
6445
6446    /// Name of the method defined in FIDL
6447    pub fn method_name(&self) -> &'static str {
6448        match *self {
6449            VolumeManagerRequest::AllocatePartition { .. } => "allocate_partition",
6450            VolumeManagerRequest::GetInfo { .. } => "get_info",
6451            VolumeManagerRequest::Activate { .. } => "activate",
6452            VolumeManagerRequest::GetPartitionLimit { .. } => "get_partition_limit",
6453            VolumeManagerRequest::SetPartitionLimit { .. } => "set_partition_limit",
6454            VolumeManagerRequest::SetPartitionName { .. } => "set_partition_name",
6455        }
6456    }
6457}
6458
6459#[derive(Debug, Clone)]
6460pub struct VolumeManagerControlHandle {
6461    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6462}
6463
6464impl VolumeManagerControlHandle {
6465    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
6466        self.inner.shutdown_with_epitaph(status.into())
6467    }
6468}
6469
6470impl fidl::endpoints::ControlHandle for VolumeManagerControlHandle {
6471    fn shutdown(&self) {
6472        self.inner.shutdown()
6473    }
6474
6475    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
6476        self.inner.shutdown_with_epitaph(status)
6477    }
6478
6479    fn is_closed(&self) -> bool {
6480        self.inner.channel().is_closed()
6481    }
6482    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6483        self.inner.channel().on_closed()
6484    }
6485
6486    #[cfg(target_os = "fuchsia")]
6487    fn signal_peer(
6488        &self,
6489        clear_mask: zx::Signals,
6490        set_mask: zx::Signals,
6491    ) -> Result<(), zx_status::Status> {
6492        use fidl::Peered;
6493        self.inner.channel().signal_peer(clear_mask, set_mask)
6494    }
6495}
6496
6497impl VolumeManagerControlHandle {}
6498
6499#[must_use = "FIDL methods require a response to be sent"]
6500#[derive(Debug)]
6501pub struct VolumeManagerAllocatePartitionResponder {
6502    control_handle: std::mem::ManuallyDrop<VolumeManagerControlHandle>,
6503    tx_id: u32,
6504}
6505
6506/// Set the the channel to be shutdown (see [`VolumeManagerControlHandle::shutdown`])
6507/// if the responder is dropped without sending a response, so that the client
6508/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6509impl std::ops::Drop for VolumeManagerAllocatePartitionResponder {
6510    fn drop(&mut self) {
6511        self.control_handle.shutdown();
6512        // Safety: drops once, never accessed again
6513        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6514    }
6515}
6516
6517impl fidl::endpoints::Responder for VolumeManagerAllocatePartitionResponder {
6518    type ControlHandle = VolumeManagerControlHandle;
6519
6520    fn control_handle(&self) -> &VolumeManagerControlHandle {
6521        &self.control_handle
6522    }
6523
6524    fn drop_without_shutdown(mut self) {
6525        // Safety: drops once, never accessed again due to mem::forget
6526        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6527        // Prevent Drop from running (which would shut down the channel)
6528        std::mem::forget(self);
6529    }
6530}
6531
6532impl VolumeManagerAllocatePartitionResponder {
6533    /// Sends a response to the FIDL transaction.
6534    ///
6535    /// Sets the channel to shutdown if an error occurs.
6536    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
6537        let _result = self.send_raw(status);
6538        if _result.is_err() {
6539            self.control_handle.shutdown();
6540        }
6541        self.drop_without_shutdown();
6542        _result
6543    }
6544
6545    /// Similar to "send" but does not shutdown the channel if an error occurs.
6546    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
6547        let _result = self.send_raw(status);
6548        self.drop_without_shutdown();
6549        _result
6550    }
6551
6552    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
6553        self.control_handle.inner.send::<VolumeManagerAllocatePartitionResponse>(
6554            (status,),
6555            self.tx_id,
6556            0x5db528bfc287b696,
6557            fidl::encoding::DynamicFlags::empty(),
6558        )
6559    }
6560}
6561
6562#[must_use = "FIDL methods require a response to be sent"]
6563#[derive(Debug)]
6564pub struct VolumeManagerGetInfoResponder {
6565    control_handle: std::mem::ManuallyDrop<VolumeManagerControlHandle>,
6566    tx_id: u32,
6567}
6568
6569/// Set the the channel to be shutdown (see [`VolumeManagerControlHandle::shutdown`])
6570/// if the responder is dropped without sending a response, so that the client
6571/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6572impl std::ops::Drop for VolumeManagerGetInfoResponder {
6573    fn drop(&mut self) {
6574        self.control_handle.shutdown();
6575        // Safety: drops once, never accessed again
6576        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6577    }
6578}
6579
6580impl fidl::endpoints::Responder for VolumeManagerGetInfoResponder {
6581    type ControlHandle = VolumeManagerControlHandle;
6582
6583    fn control_handle(&self) -> &VolumeManagerControlHandle {
6584        &self.control_handle
6585    }
6586
6587    fn drop_without_shutdown(mut self) {
6588        // Safety: drops once, never accessed again due to mem::forget
6589        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6590        // Prevent Drop from running (which would shut down the channel)
6591        std::mem::forget(self);
6592    }
6593}
6594
6595impl VolumeManagerGetInfoResponder {
6596    /// Sends a response to the FIDL transaction.
6597    ///
6598    /// Sets the channel to shutdown if an error occurs.
6599    pub fn send(
6600        self,
6601        mut status: i32,
6602        mut info: Option<&VolumeManagerInfo>,
6603    ) -> Result<(), fidl::Error> {
6604        let _result = self.send_raw(status, info);
6605        if _result.is_err() {
6606            self.control_handle.shutdown();
6607        }
6608        self.drop_without_shutdown();
6609        _result
6610    }
6611
6612    /// Similar to "send" but does not shutdown the channel if an error occurs.
6613    pub fn send_no_shutdown_on_err(
6614        self,
6615        mut status: i32,
6616        mut info: Option<&VolumeManagerInfo>,
6617    ) -> Result<(), fidl::Error> {
6618        let _result = self.send_raw(status, info);
6619        self.drop_without_shutdown();
6620        _result
6621    }
6622
6623    fn send_raw(
6624        &self,
6625        mut status: i32,
6626        mut info: Option<&VolumeManagerInfo>,
6627    ) -> Result<(), fidl::Error> {
6628        self.control_handle.inner.send::<VolumeManagerGetInfoResponse>(
6629            (status, info),
6630            self.tx_id,
6631            0x2611214dcca5b064,
6632            fidl::encoding::DynamicFlags::empty(),
6633        )
6634    }
6635}
6636
6637#[must_use = "FIDL methods require a response to be sent"]
6638#[derive(Debug)]
6639pub struct VolumeManagerActivateResponder {
6640    control_handle: std::mem::ManuallyDrop<VolumeManagerControlHandle>,
6641    tx_id: u32,
6642}
6643
6644/// Set the the channel to be shutdown (see [`VolumeManagerControlHandle::shutdown`])
6645/// if the responder is dropped without sending a response, so that the client
6646/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6647impl std::ops::Drop for VolumeManagerActivateResponder {
6648    fn drop(&mut self) {
6649        self.control_handle.shutdown();
6650        // Safety: drops once, never accessed again
6651        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6652    }
6653}
6654
6655impl fidl::endpoints::Responder for VolumeManagerActivateResponder {
6656    type ControlHandle = VolumeManagerControlHandle;
6657
6658    fn control_handle(&self) -> &VolumeManagerControlHandle {
6659        &self.control_handle
6660    }
6661
6662    fn drop_without_shutdown(mut self) {
6663        // Safety: drops once, never accessed again due to mem::forget
6664        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6665        // Prevent Drop from running (which would shut down the channel)
6666        std::mem::forget(self);
6667    }
6668}
6669
6670impl VolumeManagerActivateResponder {
6671    /// Sends a response to the FIDL transaction.
6672    ///
6673    /// Sets the channel to shutdown if an error occurs.
6674    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
6675        let _result = self.send_raw(status);
6676        if _result.is_err() {
6677            self.control_handle.shutdown();
6678        }
6679        self.drop_without_shutdown();
6680        _result
6681    }
6682
6683    /// Similar to "send" but does not shutdown the channel if an error occurs.
6684    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
6685        let _result = self.send_raw(status);
6686        self.drop_without_shutdown();
6687        _result
6688    }
6689
6690    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
6691        self.control_handle.inner.send::<VolumeManagerActivateResponse>(
6692            (status,),
6693            self.tx_id,
6694            0x182238d40c275be,
6695            fidl::encoding::DynamicFlags::empty(),
6696        )
6697    }
6698}
6699
6700#[must_use = "FIDL methods require a response to be sent"]
6701#[derive(Debug)]
6702pub struct VolumeManagerGetPartitionLimitResponder {
6703    control_handle: std::mem::ManuallyDrop<VolumeManagerControlHandle>,
6704    tx_id: u32,
6705}
6706
6707/// Set the the channel to be shutdown (see [`VolumeManagerControlHandle::shutdown`])
6708/// if the responder is dropped without sending a response, so that the client
6709/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6710impl std::ops::Drop for VolumeManagerGetPartitionLimitResponder {
6711    fn drop(&mut self) {
6712        self.control_handle.shutdown();
6713        // Safety: drops once, never accessed again
6714        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6715    }
6716}
6717
6718impl fidl::endpoints::Responder for VolumeManagerGetPartitionLimitResponder {
6719    type ControlHandle = VolumeManagerControlHandle;
6720
6721    fn control_handle(&self) -> &VolumeManagerControlHandle {
6722        &self.control_handle
6723    }
6724
6725    fn drop_without_shutdown(mut self) {
6726        // Safety: drops once, never accessed again due to mem::forget
6727        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6728        // Prevent Drop from running (which would shut down the channel)
6729        std::mem::forget(self);
6730    }
6731}
6732
6733impl VolumeManagerGetPartitionLimitResponder {
6734    /// Sends a response to the FIDL transaction.
6735    ///
6736    /// Sets the channel to shutdown if an error occurs.
6737    pub fn send(self, mut status: i32, mut slice_count: u64) -> Result<(), fidl::Error> {
6738        let _result = self.send_raw(status, slice_count);
6739        if _result.is_err() {
6740            self.control_handle.shutdown();
6741        }
6742        self.drop_without_shutdown();
6743        _result
6744    }
6745
6746    /// Similar to "send" but does not shutdown the channel if an error occurs.
6747    pub fn send_no_shutdown_on_err(
6748        self,
6749        mut status: i32,
6750        mut slice_count: u64,
6751    ) -> Result<(), fidl::Error> {
6752        let _result = self.send_raw(status, slice_count);
6753        self.drop_without_shutdown();
6754        _result
6755    }
6756
6757    fn send_raw(&self, mut status: i32, mut slice_count: u64) -> Result<(), fidl::Error> {
6758        self.control_handle.inner.send::<VolumeManagerGetPartitionLimitResponse>(
6759            (status, slice_count),
6760            self.tx_id,
6761            0x5bc9d21ea8bd52db,
6762            fidl::encoding::DynamicFlags::empty(),
6763        )
6764    }
6765}
6766
6767#[must_use = "FIDL methods require a response to be sent"]
6768#[derive(Debug)]
6769pub struct VolumeManagerSetPartitionLimitResponder {
6770    control_handle: std::mem::ManuallyDrop<VolumeManagerControlHandle>,
6771    tx_id: u32,
6772}
6773
6774/// Set the the channel to be shutdown (see [`VolumeManagerControlHandle::shutdown`])
6775/// if the responder is dropped without sending a response, so that the client
6776/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6777impl std::ops::Drop for VolumeManagerSetPartitionLimitResponder {
6778    fn drop(&mut self) {
6779        self.control_handle.shutdown();
6780        // Safety: drops once, never accessed again
6781        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6782    }
6783}
6784
6785impl fidl::endpoints::Responder for VolumeManagerSetPartitionLimitResponder {
6786    type ControlHandle = VolumeManagerControlHandle;
6787
6788    fn control_handle(&self) -> &VolumeManagerControlHandle {
6789        &self.control_handle
6790    }
6791
6792    fn drop_without_shutdown(mut self) {
6793        // Safety: drops once, never accessed again due to mem::forget
6794        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6795        // Prevent Drop from running (which would shut down the channel)
6796        std::mem::forget(self);
6797    }
6798}
6799
6800impl VolumeManagerSetPartitionLimitResponder {
6801    /// Sends a response to the FIDL transaction.
6802    ///
6803    /// Sets the channel to shutdown if an error occurs.
6804    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
6805        let _result = self.send_raw(status);
6806        if _result.is_err() {
6807            self.control_handle.shutdown();
6808        }
6809        self.drop_without_shutdown();
6810        _result
6811    }
6812
6813    /// Similar to "send" but does not shutdown the channel if an error occurs.
6814    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
6815        let _result = self.send_raw(status);
6816        self.drop_without_shutdown();
6817        _result
6818    }
6819
6820    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
6821        self.control_handle.inner.send::<VolumeManagerSetPartitionLimitResponse>(
6822            (status,),
6823            self.tx_id,
6824            0x3a4903076534c093,
6825            fidl::encoding::DynamicFlags::empty(),
6826        )
6827    }
6828}
6829
6830#[must_use = "FIDL methods require a response to be sent"]
6831#[derive(Debug)]
6832pub struct VolumeManagerSetPartitionNameResponder {
6833    control_handle: std::mem::ManuallyDrop<VolumeManagerControlHandle>,
6834    tx_id: u32,
6835}
6836
6837/// Set the the channel to be shutdown (see [`VolumeManagerControlHandle::shutdown`])
6838/// if the responder is dropped without sending a response, so that the client
6839/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6840impl std::ops::Drop for VolumeManagerSetPartitionNameResponder {
6841    fn drop(&mut self) {
6842        self.control_handle.shutdown();
6843        // Safety: drops once, never accessed again
6844        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6845    }
6846}
6847
6848impl fidl::endpoints::Responder for VolumeManagerSetPartitionNameResponder {
6849    type ControlHandle = VolumeManagerControlHandle;
6850
6851    fn control_handle(&self) -> &VolumeManagerControlHandle {
6852        &self.control_handle
6853    }
6854
6855    fn drop_without_shutdown(mut self) {
6856        // Safety: drops once, never accessed again due to mem::forget
6857        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6858        // Prevent Drop from running (which would shut down the channel)
6859        std::mem::forget(self);
6860    }
6861}
6862
6863impl VolumeManagerSetPartitionNameResponder {
6864    /// Sends a response to the FIDL transaction.
6865    ///
6866    /// Sets the channel to shutdown if an error occurs.
6867    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6868        let _result = self.send_raw(result);
6869        if _result.is_err() {
6870            self.control_handle.shutdown();
6871        }
6872        self.drop_without_shutdown();
6873        _result
6874    }
6875
6876    /// Similar to "send" but does not shutdown the channel if an error occurs.
6877    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6878        let _result = self.send_raw(result);
6879        self.drop_without_shutdown();
6880        _result
6881    }
6882
6883    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6884        self.control_handle
6885            .inner
6886            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
6887                result,
6888                self.tx_id,
6889                0x26afb07b9d70ff1a,
6890                fidl::encoding::DynamicFlags::empty(),
6891            )
6892    }
6893}
6894
6895mod internal {
6896    use super::*;
6897
6898    impl fidl::encoding::ResourceTypeMarker for BlockConnectMapperRequest {
6899        type Borrowed<'a> = &'a mut Self;
6900        fn take_or_borrow<'a>(
6901            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6902        ) -> Self::Borrowed<'a> {
6903            value
6904        }
6905    }
6906
6907    unsafe impl fidl::encoding::TypeMarker for BlockConnectMapperRequest {
6908        type Owned = Self;
6909
6910        #[inline(always)]
6911        fn inline_align(_context: fidl::encoding::Context) -> usize {
6912            4
6913        }
6914
6915        #[inline(always)]
6916        fn inline_size(_context: fidl::encoding::Context) -> usize {
6917            4
6918        }
6919    }
6920
6921    unsafe impl
6922        fidl::encoding::Encode<
6923            BlockConnectMapperRequest,
6924            fidl::encoding::DefaultFuchsiaResourceDialect,
6925        > for &mut BlockConnectMapperRequest
6926    {
6927        #[inline]
6928        unsafe fn encode(
6929            self,
6930            encoder: &mut fidl::encoding::Encoder<
6931                '_,
6932                fidl::encoding::DefaultFuchsiaResourceDialect,
6933            >,
6934            offset: usize,
6935            _depth: fidl::encoding::Depth,
6936        ) -> fidl::Result<()> {
6937            encoder.debug_check_bounds::<BlockConnectMapperRequest>(offset);
6938            // Delegate to tuple encoding.
6939            fidl::encoding::Encode::<BlockConnectMapperRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6940                (
6941                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MapperMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.server_end),
6942                ),
6943                encoder, offset, _depth
6944            )
6945        }
6946    }
6947    unsafe impl<
6948        T0: fidl::encoding::Encode<
6949                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MapperMarker>>,
6950                fidl::encoding::DefaultFuchsiaResourceDialect,
6951            >,
6952    >
6953        fidl::encoding::Encode<
6954            BlockConnectMapperRequest,
6955            fidl::encoding::DefaultFuchsiaResourceDialect,
6956        > for (T0,)
6957    {
6958        #[inline]
6959        unsafe fn encode(
6960            self,
6961            encoder: &mut fidl::encoding::Encoder<
6962                '_,
6963                fidl::encoding::DefaultFuchsiaResourceDialect,
6964            >,
6965            offset: usize,
6966            depth: fidl::encoding::Depth,
6967        ) -> fidl::Result<()> {
6968            encoder.debug_check_bounds::<BlockConnectMapperRequest>(offset);
6969            // Zero out padding regions. There's no need to apply masks
6970            // because the unmasked parts will be overwritten by fields.
6971            // Write the fields.
6972            self.0.encode(encoder, offset + 0, depth)?;
6973            Ok(())
6974        }
6975    }
6976
6977    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6978        for BlockConnectMapperRequest
6979    {
6980        #[inline(always)]
6981        fn new_empty() -> Self {
6982            Self {
6983                server_end: fidl::new_empty!(
6984                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MapperMarker>>,
6985                    fidl::encoding::DefaultFuchsiaResourceDialect
6986                ),
6987            }
6988        }
6989
6990        #[inline]
6991        unsafe fn decode(
6992            &mut self,
6993            decoder: &mut fidl::encoding::Decoder<
6994                '_,
6995                fidl::encoding::DefaultFuchsiaResourceDialect,
6996            >,
6997            offset: usize,
6998            _depth: fidl::encoding::Depth,
6999        ) -> fidl::Result<()> {
7000            decoder.debug_check_bounds::<Self>(offset);
7001            // Verify that padding bytes are zero.
7002            fidl::decode!(
7003                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MapperMarker>>,
7004                fidl::encoding::DefaultFuchsiaResourceDialect,
7005                &mut self.server_end,
7006                decoder,
7007                offset + 0,
7008                _depth
7009            )?;
7010            Ok(())
7011        }
7012    }
7013
7014    impl fidl::encoding::ResourceTypeMarker for BlockOpenSessionRequest {
7015        type Borrowed<'a> = &'a mut Self;
7016        fn take_or_borrow<'a>(
7017            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7018        ) -> Self::Borrowed<'a> {
7019            value
7020        }
7021    }
7022
7023    unsafe impl fidl::encoding::TypeMarker for BlockOpenSessionRequest {
7024        type Owned = Self;
7025
7026        #[inline(always)]
7027        fn inline_align(_context: fidl::encoding::Context) -> usize {
7028            4
7029        }
7030
7031        #[inline(always)]
7032        fn inline_size(_context: fidl::encoding::Context) -> usize {
7033            4
7034        }
7035    }
7036
7037    unsafe impl
7038        fidl::encoding::Encode<
7039            BlockOpenSessionRequest,
7040            fidl::encoding::DefaultFuchsiaResourceDialect,
7041        > for &mut BlockOpenSessionRequest
7042    {
7043        #[inline]
7044        unsafe fn encode(
7045            self,
7046            encoder: &mut fidl::encoding::Encoder<
7047                '_,
7048                fidl::encoding::DefaultFuchsiaResourceDialect,
7049            >,
7050            offset: usize,
7051            _depth: fidl::encoding::Depth,
7052        ) -> fidl::Result<()> {
7053            encoder.debug_check_bounds::<BlockOpenSessionRequest>(offset);
7054            // Delegate to tuple encoding.
7055            fidl::encoding::Encode::<BlockOpenSessionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7056                (
7057                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session),
7058                ),
7059                encoder, offset, _depth
7060            )
7061        }
7062    }
7063    unsafe impl<
7064        T0: fidl::encoding::Encode<
7065                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>>,
7066                fidl::encoding::DefaultFuchsiaResourceDialect,
7067            >,
7068    >
7069        fidl::encoding::Encode<
7070            BlockOpenSessionRequest,
7071            fidl::encoding::DefaultFuchsiaResourceDialect,
7072        > for (T0,)
7073    {
7074        #[inline]
7075        unsafe fn encode(
7076            self,
7077            encoder: &mut fidl::encoding::Encoder<
7078                '_,
7079                fidl::encoding::DefaultFuchsiaResourceDialect,
7080            >,
7081            offset: usize,
7082            depth: fidl::encoding::Depth,
7083        ) -> fidl::Result<()> {
7084            encoder.debug_check_bounds::<BlockOpenSessionRequest>(offset);
7085            // Zero out padding regions. There's no need to apply masks
7086            // because the unmasked parts will be overwritten by fields.
7087            // Write the fields.
7088            self.0.encode(encoder, offset + 0, depth)?;
7089            Ok(())
7090        }
7091    }
7092
7093    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7094        for BlockOpenSessionRequest
7095    {
7096        #[inline(always)]
7097        fn new_empty() -> Self {
7098            Self {
7099                session: fidl::new_empty!(
7100                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>>,
7101                    fidl::encoding::DefaultFuchsiaResourceDialect
7102                ),
7103            }
7104        }
7105
7106        #[inline]
7107        unsafe fn decode(
7108            &mut self,
7109            decoder: &mut fidl::encoding::Decoder<
7110                '_,
7111                fidl::encoding::DefaultFuchsiaResourceDialect,
7112            >,
7113            offset: usize,
7114            _depth: fidl::encoding::Depth,
7115        ) -> fidl::Result<()> {
7116            decoder.debug_check_bounds::<Self>(offset);
7117            // Verify that padding bytes are zero.
7118            fidl::decode!(
7119                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>>,
7120                fidl::encoding::DefaultFuchsiaResourceDialect,
7121                &mut self.session,
7122                decoder,
7123                offset + 0,
7124                _depth
7125            )?;
7126            Ok(())
7127        }
7128    }
7129
7130    impl fidl::encoding::ResourceTypeMarker for BlockOpenSessionWithOptionsRequest {
7131        type Borrowed<'a> = &'a mut Self;
7132        fn take_or_borrow<'a>(
7133            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7134        ) -> Self::Borrowed<'a> {
7135            value
7136        }
7137    }
7138
7139    unsafe impl fidl::encoding::TypeMarker for BlockOpenSessionWithOptionsRequest {
7140        type Owned = Self;
7141
7142        #[inline(always)]
7143        fn inline_align(_context: fidl::encoding::Context) -> usize {
7144            8
7145        }
7146
7147        #[inline(always)]
7148        fn inline_size(_context: fidl::encoding::Context) -> usize {
7149            24
7150        }
7151    }
7152
7153    unsafe impl
7154        fidl::encoding::Encode<
7155            BlockOpenSessionWithOptionsRequest,
7156            fidl::encoding::DefaultFuchsiaResourceDialect,
7157        > for &mut BlockOpenSessionWithOptionsRequest
7158    {
7159        #[inline]
7160        unsafe fn encode(
7161            self,
7162            encoder: &mut fidl::encoding::Encoder<
7163                '_,
7164                fidl::encoding::DefaultFuchsiaResourceDialect,
7165            >,
7166            offset: usize,
7167            _depth: fidl::encoding::Depth,
7168        ) -> fidl::Result<()> {
7169            encoder.debug_check_bounds::<BlockOpenSessionWithOptionsRequest>(offset);
7170            // Delegate to tuple encoding.
7171            fidl::encoding::Encode::<BlockOpenSessionWithOptionsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7172                (
7173                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session),
7174                    <fidl::encoding::Vector<BlockOffsetMapping, 4> as fidl::encoding::ValueTypeMarker>::borrow(&self.mappings),
7175                ),
7176                encoder, offset, _depth
7177            )
7178        }
7179    }
7180    unsafe impl<
7181        T0: fidl::encoding::Encode<
7182                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>>,
7183                fidl::encoding::DefaultFuchsiaResourceDialect,
7184            >,
7185        T1: fidl::encoding::Encode<
7186                fidl::encoding::Vector<BlockOffsetMapping, 4>,
7187                fidl::encoding::DefaultFuchsiaResourceDialect,
7188            >,
7189    >
7190        fidl::encoding::Encode<
7191            BlockOpenSessionWithOptionsRequest,
7192            fidl::encoding::DefaultFuchsiaResourceDialect,
7193        > for (T0, T1)
7194    {
7195        #[inline]
7196        unsafe fn encode(
7197            self,
7198            encoder: &mut fidl::encoding::Encoder<
7199                '_,
7200                fidl::encoding::DefaultFuchsiaResourceDialect,
7201            >,
7202            offset: usize,
7203            depth: fidl::encoding::Depth,
7204        ) -> fidl::Result<()> {
7205            encoder.debug_check_bounds::<BlockOpenSessionWithOptionsRequest>(offset);
7206            // Zero out padding regions. There's no need to apply masks
7207            // because the unmasked parts will be overwritten by fields.
7208            unsafe {
7209                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
7210                (ptr as *mut u64).write_unaligned(0);
7211            }
7212            // Write the fields.
7213            self.0.encode(encoder, offset + 0, depth)?;
7214            self.1.encode(encoder, offset + 8, depth)?;
7215            Ok(())
7216        }
7217    }
7218
7219    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7220        for BlockOpenSessionWithOptionsRequest
7221    {
7222        #[inline(always)]
7223        fn new_empty() -> Self {
7224            Self {
7225                session: fidl::new_empty!(
7226                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>>,
7227                    fidl::encoding::DefaultFuchsiaResourceDialect
7228                ),
7229                mappings: fidl::new_empty!(fidl::encoding::Vector<BlockOffsetMapping, 4>, fidl::encoding::DefaultFuchsiaResourceDialect),
7230            }
7231        }
7232
7233        #[inline]
7234        unsafe fn decode(
7235            &mut self,
7236            decoder: &mut fidl::encoding::Decoder<
7237                '_,
7238                fidl::encoding::DefaultFuchsiaResourceDialect,
7239            >,
7240            offset: usize,
7241            _depth: fidl::encoding::Depth,
7242        ) -> fidl::Result<()> {
7243            decoder.debug_check_bounds::<Self>(offset);
7244            // Verify that padding bytes are zero.
7245            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
7246            let padval = unsafe { (ptr as *const u64).read_unaligned() };
7247            let mask = 0xffffffff00000000u64;
7248            let maskedval = padval & mask;
7249            if maskedval != 0 {
7250                return Err(fidl::Error::NonZeroPadding {
7251                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
7252                });
7253            }
7254            fidl::decode!(
7255                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>>,
7256                fidl::encoding::DefaultFuchsiaResourceDialect,
7257                &mut self.session,
7258                decoder,
7259                offset + 0,
7260                _depth
7261            )?;
7262            fidl::decode!(fidl::encoding::Vector<BlockOffsetMapping, 4>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.mappings, decoder, offset + 8, _depth)?;
7263            Ok(())
7264        }
7265    }
7266
7267    impl fidl::encoding::ResourceTypeMarker for MapperOpenSessionRequest {
7268        type Borrowed<'a> = &'a mut Self;
7269        fn take_or_borrow<'a>(
7270            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7271        ) -> Self::Borrowed<'a> {
7272            value
7273        }
7274    }
7275
7276    unsafe impl fidl::encoding::TypeMarker for MapperOpenSessionRequest {
7277        type Owned = Self;
7278
7279        #[inline(always)]
7280        fn inline_align(_context: fidl::encoding::Context) -> usize {
7281            4
7282        }
7283
7284        #[inline(always)]
7285        fn inline_size(_context: fidl::encoding::Context) -> usize {
7286            16
7287        }
7288    }
7289
7290    unsafe impl
7291        fidl::encoding::Encode<
7292            MapperOpenSessionRequest,
7293            fidl::encoding::DefaultFuchsiaResourceDialect,
7294        > for &mut MapperOpenSessionRequest
7295    {
7296        #[inline]
7297        unsafe fn encode(
7298            self,
7299            encoder: &mut fidl::encoding::Encoder<
7300                '_,
7301                fidl::encoding::DefaultFuchsiaResourceDialect,
7302            >,
7303            offset: usize,
7304            _depth: fidl::encoding::Depth,
7305        ) -> fidl::Result<()> {
7306            encoder.debug_check_bounds::<MapperOpenSessionRequest>(offset);
7307            // Delegate to tuple encoding.
7308            fidl::encoding::Encode::<MapperOpenSessionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7309                (
7310                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MapperSessionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session),
7311                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.mapping_vmo),
7312                    <fidl::encoding::Optional<fidl::encoding::HandleType<fidl::Port, { fidl::ObjectType::PORT.into_raw() }, 2147483648>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.port),
7313                    <fidl::encoding::Optional<fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.delivery_queue),
7314                ),
7315                encoder, offset, _depth
7316            )
7317        }
7318    }
7319    unsafe impl<
7320        T0: fidl::encoding::Encode<
7321                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MapperSessionMarker>>,
7322                fidl::encoding::DefaultFuchsiaResourceDialect,
7323            >,
7324        T1: fidl::encoding::Encode<
7325                fidl::encoding::HandleType<
7326                    fidl::Vmo,
7327                    { fidl::ObjectType::VMO.into_raw() },
7328                    2147483648,
7329                >,
7330                fidl::encoding::DefaultFuchsiaResourceDialect,
7331            >,
7332        T2: fidl::encoding::Encode<
7333                fidl::encoding::Optional<
7334                    fidl::encoding::HandleType<
7335                        fidl::Port,
7336                        { fidl::ObjectType::PORT.into_raw() },
7337                        2147483648,
7338                    >,
7339                >,
7340                fidl::encoding::DefaultFuchsiaResourceDialect,
7341            >,
7342        T3: fidl::encoding::Encode<
7343                fidl::encoding::Optional<
7344                    fidl::encoding::HandleType<
7345                        fidl::Vmo,
7346                        { fidl::ObjectType::VMO.into_raw() },
7347                        2147483648,
7348                    >,
7349                >,
7350                fidl::encoding::DefaultFuchsiaResourceDialect,
7351            >,
7352    >
7353        fidl::encoding::Encode<
7354            MapperOpenSessionRequest,
7355            fidl::encoding::DefaultFuchsiaResourceDialect,
7356        > for (T0, T1, T2, T3)
7357    {
7358        #[inline]
7359        unsafe fn encode(
7360            self,
7361            encoder: &mut fidl::encoding::Encoder<
7362                '_,
7363                fidl::encoding::DefaultFuchsiaResourceDialect,
7364            >,
7365            offset: usize,
7366            depth: fidl::encoding::Depth,
7367        ) -> fidl::Result<()> {
7368            encoder.debug_check_bounds::<MapperOpenSessionRequest>(offset);
7369            // Zero out padding regions. There's no need to apply masks
7370            // because the unmasked parts will be overwritten by fields.
7371            // Write the fields.
7372            self.0.encode(encoder, offset + 0, depth)?;
7373            self.1.encode(encoder, offset + 4, depth)?;
7374            self.2.encode(encoder, offset + 8, depth)?;
7375            self.3.encode(encoder, offset + 12, depth)?;
7376            Ok(())
7377        }
7378    }
7379
7380    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7381        for MapperOpenSessionRequest
7382    {
7383        #[inline(always)]
7384        fn new_empty() -> Self {
7385            Self {
7386                session: fidl::new_empty!(
7387                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MapperSessionMarker>>,
7388                    fidl::encoding::DefaultFuchsiaResourceDialect
7389                ),
7390                mapping_vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
7391                port: fidl::new_empty!(
7392                    fidl::encoding::Optional<
7393                        fidl::encoding::HandleType<
7394                            fidl::Port,
7395                            { fidl::ObjectType::PORT.into_raw() },
7396                            2147483648,
7397                        >,
7398                    >,
7399                    fidl::encoding::DefaultFuchsiaResourceDialect
7400                ),
7401                delivery_queue: fidl::new_empty!(
7402                    fidl::encoding::Optional<
7403                        fidl::encoding::HandleType<
7404                            fidl::Vmo,
7405                            { fidl::ObjectType::VMO.into_raw() },
7406                            2147483648,
7407                        >,
7408                    >,
7409                    fidl::encoding::DefaultFuchsiaResourceDialect
7410                ),
7411            }
7412        }
7413
7414        #[inline]
7415        unsafe fn decode(
7416            &mut self,
7417            decoder: &mut fidl::encoding::Decoder<
7418                '_,
7419                fidl::encoding::DefaultFuchsiaResourceDialect,
7420            >,
7421            offset: usize,
7422            _depth: fidl::encoding::Depth,
7423        ) -> fidl::Result<()> {
7424            decoder.debug_check_bounds::<Self>(offset);
7425            // Verify that padding bytes are zero.
7426            fidl::decode!(
7427                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MapperSessionMarker>>,
7428                fidl::encoding::DefaultFuchsiaResourceDialect,
7429                &mut self.session,
7430                decoder,
7431                offset + 0,
7432                _depth
7433            )?;
7434            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.mapping_vmo, decoder, offset + 4, _depth)?;
7435            fidl::decode!(
7436                fidl::encoding::Optional<
7437                    fidl::encoding::HandleType<
7438                        fidl::Port,
7439                        { fidl::ObjectType::PORT.into_raw() },
7440                        2147483648,
7441                    >,
7442                >,
7443                fidl::encoding::DefaultFuchsiaResourceDialect,
7444                &mut self.port,
7445                decoder,
7446                offset + 8,
7447                _depth
7448            )?;
7449            fidl::decode!(
7450                fidl::encoding::Optional<
7451                    fidl::encoding::HandleType<
7452                        fidl::Vmo,
7453                        { fidl::ObjectType::VMO.into_raw() },
7454                        2147483648,
7455                    >,
7456                >,
7457                fidl::encoding::DefaultFuchsiaResourceDialect,
7458                &mut self.delivery_queue,
7459                decoder,
7460                offset + 12,
7461                _depth
7462            )?;
7463            Ok(())
7464        }
7465    }
7466
7467    impl fidl::encoding::ResourceTypeMarker for MapperSessionOpenChildSessionRequest {
7468        type Borrowed<'a> = &'a mut Self;
7469        fn take_or_borrow<'a>(
7470            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7471        ) -> Self::Borrowed<'a> {
7472            value
7473        }
7474    }
7475
7476    unsafe impl fidl::encoding::TypeMarker for MapperSessionOpenChildSessionRequest {
7477        type Owned = Self;
7478
7479        #[inline(always)]
7480        fn inline_align(_context: fidl::encoding::Context) -> usize {
7481            8
7482        }
7483
7484        #[inline(always)]
7485        fn inline_size(_context: fidl::encoding::Context) -> usize {
7486            24
7487        }
7488    }
7489
7490    unsafe impl
7491        fidl::encoding::Encode<
7492            MapperSessionOpenChildSessionRequest,
7493            fidl::encoding::DefaultFuchsiaResourceDialect,
7494        > for &mut MapperSessionOpenChildSessionRequest
7495    {
7496        #[inline]
7497        unsafe fn encode(
7498            self,
7499            encoder: &mut fidl::encoding::Encoder<
7500                '_,
7501                fidl::encoding::DefaultFuchsiaResourceDialect,
7502            >,
7503            offset: usize,
7504            _depth: fidl::encoding::Depth,
7505        ) -> fidl::Result<()> {
7506            encoder.debug_check_bounds::<MapperSessionOpenChildSessionRequest>(offset);
7507            // Delegate to tuple encoding.
7508            fidl::encoding::Encode::<MapperSessionOpenChildSessionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7509                (
7510                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MapperSessionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session),
7511                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.mapping_vmo),
7512                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.parent_key),
7513                    <fidl::encoding::Optional<fidl::encoding::HandleType<fidl::Port, { fidl::ObjectType::PORT.into_raw() }, 2147483648>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.port),
7514                    <fidl::encoding::Optional<fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.delivery_queue),
7515                ),
7516                encoder, offset, _depth
7517            )
7518        }
7519    }
7520    unsafe impl<
7521        T0: fidl::encoding::Encode<
7522                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MapperSessionMarker>>,
7523                fidl::encoding::DefaultFuchsiaResourceDialect,
7524            >,
7525        T1: fidl::encoding::Encode<
7526                fidl::encoding::HandleType<
7527                    fidl::Vmo,
7528                    { fidl::ObjectType::VMO.into_raw() },
7529                    2147483648,
7530                >,
7531                fidl::encoding::DefaultFuchsiaResourceDialect,
7532            >,
7533        T2: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
7534        T3: fidl::encoding::Encode<
7535                fidl::encoding::Optional<
7536                    fidl::encoding::HandleType<
7537                        fidl::Port,
7538                        { fidl::ObjectType::PORT.into_raw() },
7539                        2147483648,
7540                    >,
7541                >,
7542                fidl::encoding::DefaultFuchsiaResourceDialect,
7543            >,
7544        T4: fidl::encoding::Encode<
7545                fidl::encoding::Optional<
7546                    fidl::encoding::HandleType<
7547                        fidl::Vmo,
7548                        { fidl::ObjectType::VMO.into_raw() },
7549                        2147483648,
7550                    >,
7551                >,
7552                fidl::encoding::DefaultFuchsiaResourceDialect,
7553            >,
7554    >
7555        fidl::encoding::Encode<
7556            MapperSessionOpenChildSessionRequest,
7557            fidl::encoding::DefaultFuchsiaResourceDialect,
7558        > for (T0, T1, T2, T3, T4)
7559    {
7560        #[inline]
7561        unsafe fn encode(
7562            self,
7563            encoder: &mut fidl::encoding::Encoder<
7564                '_,
7565                fidl::encoding::DefaultFuchsiaResourceDialect,
7566            >,
7567            offset: usize,
7568            depth: fidl::encoding::Depth,
7569        ) -> fidl::Result<()> {
7570            encoder.debug_check_bounds::<MapperSessionOpenChildSessionRequest>(offset);
7571            // Zero out padding regions. There's no need to apply masks
7572            // because the unmasked parts will be overwritten by fields.
7573            // Write the fields.
7574            self.0.encode(encoder, offset + 0, depth)?;
7575            self.1.encode(encoder, offset + 4, depth)?;
7576            self.2.encode(encoder, offset + 8, depth)?;
7577            self.3.encode(encoder, offset + 16, depth)?;
7578            self.4.encode(encoder, offset + 20, depth)?;
7579            Ok(())
7580        }
7581    }
7582
7583    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7584        for MapperSessionOpenChildSessionRequest
7585    {
7586        #[inline(always)]
7587        fn new_empty() -> Self {
7588            Self {
7589                session: fidl::new_empty!(
7590                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MapperSessionMarker>>,
7591                    fidl::encoding::DefaultFuchsiaResourceDialect
7592                ),
7593                mapping_vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
7594                parent_key: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
7595                port: fidl::new_empty!(
7596                    fidl::encoding::Optional<
7597                        fidl::encoding::HandleType<
7598                            fidl::Port,
7599                            { fidl::ObjectType::PORT.into_raw() },
7600                            2147483648,
7601                        >,
7602                    >,
7603                    fidl::encoding::DefaultFuchsiaResourceDialect
7604                ),
7605                delivery_queue: fidl::new_empty!(
7606                    fidl::encoding::Optional<
7607                        fidl::encoding::HandleType<
7608                            fidl::Vmo,
7609                            { fidl::ObjectType::VMO.into_raw() },
7610                            2147483648,
7611                        >,
7612                    >,
7613                    fidl::encoding::DefaultFuchsiaResourceDialect
7614                ),
7615            }
7616        }
7617
7618        #[inline]
7619        unsafe fn decode(
7620            &mut self,
7621            decoder: &mut fidl::encoding::Decoder<
7622                '_,
7623                fidl::encoding::DefaultFuchsiaResourceDialect,
7624            >,
7625            offset: usize,
7626            _depth: fidl::encoding::Depth,
7627        ) -> fidl::Result<()> {
7628            decoder.debug_check_bounds::<Self>(offset);
7629            // Verify that padding bytes are zero.
7630            fidl::decode!(
7631                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<MapperSessionMarker>>,
7632                fidl::encoding::DefaultFuchsiaResourceDialect,
7633                &mut self.session,
7634                decoder,
7635                offset + 0,
7636                _depth
7637            )?;
7638            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.mapping_vmo, decoder, offset + 4, _depth)?;
7639            fidl::decode!(
7640                u64,
7641                fidl::encoding::DefaultFuchsiaResourceDialect,
7642                &mut self.parent_key,
7643                decoder,
7644                offset + 8,
7645                _depth
7646            )?;
7647            fidl::decode!(
7648                fidl::encoding::Optional<
7649                    fidl::encoding::HandleType<
7650                        fidl::Port,
7651                        { fidl::ObjectType::PORT.into_raw() },
7652                        2147483648,
7653                    >,
7654                >,
7655                fidl::encoding::DefaultFuchsiaResourceDialect,
7656                &mut self.port,
7657                decoder,
7658                offset + 16,
7659                _depth
7660            )?;
7661            fidl::decode!(
7662                fidl::encoding::Optional<
7663                    fidl::encoding::HandleType<
7664                        fidl::Vmo,
7665                        { fidl::ObjectType::VMO.into_raw() },
7666                        2147483648,
7667                    >,
7668                >,
7669                fidl::encoding::DefaultFuchsiaResourceDialect,
7670                &mut self.delivery_queue,
7671                decoder,
7672                offset + 20,
7673                _depth
7674            )?;
7675            Ok(())
7676        }
7677    }
7678
7679    impl fidl::encoding::ResourceTypeMarker for MapperSessionRecordProfileRequest {
7680        type Borrowed<'a> = &'a mut Self;
7681        fn take_or_borrow<'a>(
7682            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7683        ) -> Self::Borrowed<'a> {
7684            value
7685        }
7686    }
7687
7688    unsafe impl fidl::encoding::TypeMarker for MapperSessionRecordProfileRequest {
7689        type Owned = Self;
7690
7691        #[inline(always)]
7692        fn inline_align(_context: fidl::encoding::Context) -> usize {
7693            4
7694        }
7695
7696        #[inline(always)]
7697        fn inline_size(_context: fidl::encoding::Context) -> usize {
7698            4
7699        }
7700    }
7701
7702    unsafe impl
7703        fidl::encoding::Encode<
7704            MapperSessionRecordProfileRequest,
7705            fidl::encoding::DefaultFuchsiaResourceDialect,
7706        > for &mut MapperSessionRecordProfileRequest
7707    {
7708        #[inline]
7709        unsafe fn encode(
7710            self,
7711            encoder: &mut fidl::encoding::Encoder<
7712                '_,
7713                fidl::encoding::DefaultFuchsiaResourceDialect,
7714            >,
7715            offset: usize,
7716            _depth: fidl::encoding::Depth,
7717        ) -> fidl::Result<()> {
7718            encoder.debug_check_bounds::<MapperSessionRecordProfileRequest>(offset);
7719            // Delegate to tuple encoding.
7720            fidl::encoding::Encode::<MapperSessionRecordProfileRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7721                (
7722                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RecordingMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.recording),
7723                ),
7724                encoder, offset, _depth
7725            )
7726        }
7727    }
7728    unsafe impl<
7729        T0: fidl::encoding::Encode<
7730                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RecordingMarker>>,
7731                fidl::encoding::DefaultFuchsiaResourceDialect,
7732            >,
7733    >
7734        fidl::encoding::Encode<
7735            MapperSessionRecordProfileRequest,
7736            fidl::encoding::DefaultFuchsiaResourceDialect,
7737        > for (T0,)
7738    {
7739        #[inline]
7740        unsafe fn encode(
7741            self,
7742            encoder: &mut fidl::encoding::Encoder<
7743                '_,
7744                fidl::encoding::DefaultFuchsiaResourceDialect,
7745            >,
7746            offset: usize,
7747            depth: fidl::encoding::Depth,
7748        ) -> fidl::Result<()> {
7749            encoder.debug_check_bounds::<MapperSessionRecordProfileRequest>(offset);
7750            // Zero out padding regions. There's no need to apply masks
7751            // because the unmasked parts will be overwritten by fields.
7752            // Write the fields.
7753            self.0.encode(encoder, offset + 0, depth)?;
7754            Ok(())
7755        }
7756    }
7757
7758    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7759        for MapperSessionRecordProfileRequest
7760    {
7761        #[inline(always)]
7762        fn new_empty() -> Self {
7763            Self {
7764                recording: fidl::new_empty!(
7765                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RecordingMarker>>,
7766                    fidl::encoding::DefaultFuchsiaResourceDialect
7767                ),
7768            }
7769        }
7770
7771        #[inline]
7772        unsafe fn decode(
7773            &mut self,
7774            decoder: &mut fidl::encoding::Decoder<
7775                '_,
7776                fidl::encoding::DefaultFuchsiaResourceDialect,
7777            >,
7778            offset: usize,
7779            _depth: fidl::encoding::Depth,
7780        ) -> fidl::Result<()> {
7781            decoder.debug_check_bounds::<Self>(offset);
7782            // Verify that padding bytes are zero.
7783            fidl::decode!(
7784                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RecordingMarker>>,
7785                fidl::encoding::DefaultFuchsiaResourceDialect,
7786                &mut self.recording,
7787                decoder,
7788                offset + 0,
7789                _depth
7790            )?;
7791            Ok(())
7792        }
7793    }
7794
7795    impl fidl::encoding::ResourceTypeMarker for MapperSessionCreateVmoResponse {
7796        type Borrowed<'a> = &'a mut Self;
7797        fn take_or_borrow<'a>(
7798            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7799        ) -> Self::Borrowed<'a> {
7800            value
7801        }
7802    }
7803
7804    unsafe impl fidl::encoding::TypeMarker for MapperSessionCreateVmoResponse {
7805        type Owned = Self;
7806
7807        #[inline(always)]
7808        fn inline_align(_context: fidl::encoding::Context) -> usize {
7809            4
7810        }
7811
7812        #[inline(always)]
7813        fn inline_size(_context: fidl::encoding::Context) -> usize {
7814            4
7815        }
7816    }
7817
7818    unsafe impl
7819        fidl::encoding::Encode<
7820            MapperSessionCreateVmoResponse,
7821            fidl::encoding::DefaultFuchsiaResourceDialect,
7822        > for &mut MapperSessionCreateVmoResponse
7823    {
7824        #[inline]
7825        unsafe fn encode(
7826            self,
7827            encoder: &mut fidl::encoding::Encoder<
7828                '_,
7829                fidl::encoding::DefaultFuchsiaResourceDialect,
7830            >,
7831            offset: usize,
7832            _depth: fidl::encoding::Depth,
7833        ) -> fidl::Result<()> {
7834            encoder.debug_check_bounds::<MapperSessionCreateVmoResponse>(offset);
7835            // Delegate to tuple encoding.
7836            fidl::encoding::Encode::<
7837                MapperSessionCreateVmoResponse,
7838                fidl::encoding::DefaultFuchsiaResourceDialect,
7839            >::encode(
7840                (<fidl::encoding::HandleType<
7841                    fidl::Vmo,
7842                    { fidl::ObjectType::VMO.into_raw() },
7843                    2147483648,
7844                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7845                    &mut self.vmo
7846                ),),
7847                encoder,
7848                offset,
7849                _depth,
7850            )
7851        }
7852    }
7853    unsafe impl<
7854        T0: fidl::encoding::Encode<
7855                fidl::encoding::HandleType<
7856                    fidl::Vmo,
7857                    { fidl::ObjectType::VMO.into_raw() },
7858                    2147483648,
7859                >,
7860                fidl::encoding::DefaultFuchsiaResourceDialect,
7861            >,
7862    >
7863        fidl::encoding::Encode<
7864            MapperSessionCreateVmoResponse,
7865            fidl::encoding::DefaultFuchsiaResourceDialect,
7866        > for (T0,)
7867    {
7868        #[inline]
7869        unsafe fn encode(
7870            self,
7871            encoder: &mut fidl::encoding::Encoder<
7872                '_,
7873                fidl::encoding::DefaultFuchsiaResourceDialect,
7874            >,
7875            offset: usize,
7876            depth: fidl::encoding::Depth,
7877        ) -> fidl::Result<()> {
7878            encoder.debug_check_bounds::<MapperSessionCreateVmoResponse>(offset);
7879            // Zero out padding regions. There's no need to apply masks
7880            // because the unmasked parts will be overwritten by fields.
7881            // Write the fields.
7882            self.0.encode(encoder, offset + 0, depth)?;
7883            Ok(())
7884        }
7885    }
7886
7887    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7888        for MapperSessionCreateVmoResponse
7889    {
7890        #[inline(always)]
7891        fn new_empty() -> Self {
7892            Self {
7893                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
7894            }
7895        }
7896
7897        #[inline]
7898        unsafe fn decode(
7899            &mut self,
7900            decoder: &mut fidl::encoding::Decoder<
7901                '_,
7902                fidl::encoding::DefaultFuchsiaResourceDialect,
7903            >,
7904            offset: usize,
7905            _depth: fidl::encoding::Depth,
7906        ) -> fidl::Result<()> {
7907            decoder.debug_check_bounds::<Self>(offset);
7908            // Verify that padding bytes are zero.
7909            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
7910            Ok(())
7911        }
7912    }
7913
7914    impl fidl::encoding::ResourceTypeMarker for RecordingStopResponse {
7915        type Borrowed<'a> = &'a mut Self;
7916        fn take_or_borrow<'a>(
7917            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7918        ) -> Self::Borrowed<'a> {
7919            value
7920        }
7921    }
7922
7923    unsafe impl fidl::encoding::TypeMarker for RecordingStopResponse {
7924        type Owned = Self;
7925
7926        #[inline(always)]
7927        fn inline_align(_context: fidl::encoding::Context) -> usize {
7928            4
7929        }
7930
7931        #[inline(always)]
7932        fn inline_size(_context: fidl::encoding::Context) -> usize {
7933            4
7934        }
7935    }
7936
7937    unsafe impl
7938        fidl::encoding::Encode<RecordingStopResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
7939        for &mut RecordingStopResponse
7940    {
7941        #[inline]
7942        unsafe fn encode(
7943            self,
7944            encoder: &mut fidl::encoding::Encoder<
7945                '_,
7946                fidl::encoding::DefaultFuchsiaResourceDialect,
7947            >,
7948            offset: usize,
7949            _depth: fidl::encoding::Depth,
7950        ) -> fidl::Result<()> {
7951            encoder.debug_check_bounds::<RecordingStopResponse>(offset);
7952            // Delegate to tuple encoding.
7953            fidl::encoding::Encode::<
7954                RecordingStopResponse,
7955                fidl::encoding::DefaultFuchsiaResourceDialect,
7956            >::encode(
7957                (<fidl::encoding::HandleType<
7958                    fidl::Vmo,
7959                    { fidl::ObjectType::VMO.into_raw() },
7960                    2147483648,
7961                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7962                    &mut self.vmo
7963                ),),
7964                encoder,
7965                offset,
7966                _depth,
7967            )
7968        }
7969    }
7970    unsafe impl<
7971        T0: fidl::encoding::Encode<
7972                fidl::encoding::HandleType<
7973                    fidl::Vmo,
7974                    { fidl::ObjectType::VMO.into_raw() },
7975                    2147483648,
7976                >,
7977                fidl::encoding::DefaultFuchsiaResourceDialect,
7978            >,
7979    >
7980        fidl::encoding::Encode<RecordingStopResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
7981        for (T0,)
7982    {
7983        #[inline]
7984        unsafe fn encode(
7985            self,
7986            encoder: &mut fidl::encoding::Encoder<
7987                '_,
7988                fidl::encoding::DefaultFuchsiaResourceDialect,
7989            >,
7990            offset: usize,
7991            depth: fidl::encoding::Depth,
7992        ) -> fidl::Result<()> {
7993            encoder.debug_check_bounds::<RecordingStopResponse>(offset);
7994            // Zero out padding regions. There's no need to apply masks
7995            // because the unmasked parts will be overwritten by fields.
7996            // Write the fields.
7997            self.0.encode(encoder, offset + 0, depth)?;
7998            Ok(())
7999        }
8000    }
8001
8002    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8003        for RecordingStopResponse
8004    {
8005        #[inline(always)]
8006        fn new_empty() -> Self {
8007            Self {
8008                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8009            }
8010        }
8011
8012        #[inline]
8013        unsafe fn decode(
8014            &mut self,
8015            decoder: &mut fidl::encoding::Decoder<
8016                '_,
8017                fidl::encoding::DefaultFuchsiaResourceDialect,
8018            >,
8019            offset: usize,
8020            _depth: fidl::encoding::Depth,
8021        ) -> fidl::Result<()> {
8022            decoder.debug_check_bounds::<Self>(offset);
8023            // Verify that padding bytes are zero.
8024            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
8025            Ok(())
8026        }
8027    }
8028
8029    impl fidl::encoding::ResourceTypeMarker for SessionAttachVmoRequest {
8030        type Borrowed<'a> = &'a mut Self;
8031        fn take_or_borrow<'a>(
8032            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8033        ) -> Self::Borrowed<'a> {
8034            value
8035        }
8036    }
8037
8038    unsafe impl fidl::encoding::TypeMarker for SessionAttachVmoRequest {
8039        type Owned = Self;
8040
8041        #[inline(always)]
8042        fn inline_align(_context: fidl::encoding::Context) -> usize {
8043            4
8044        }
8045
8046        #[inline(always)]
8047        fn inline_size(_context: fidl::encoding::Context) -> usize {
8048            4
8049        }
8050    }
8051
8052    unsafe impl
8053        fidl::encoding::Encode<
8054            SessionAttachVmoRequest,
8055            fidl::encoding::DefaultFuchsiaResourceDialect,
8056        > for &mut SessionAttachVmoRequest
8057    {
8058        #[inline]
8059        unsafe fn encode(
8060            self,
8061            encoder: &mut fidl::encoding::Encoder<
8062                '_,
8063                fidl::encoding::DefaultFuchsiaResourceDialect,
8064            >,
8065            offset: usize,
8066            _depth: fidl::encoding::Depth,
8067        ) -> fidl::Result<()> {
8068            encoder.debug_check_bounds::<SessionAttachVmoRequest>(offset);
8069            // Delegate to tuple encoding.
8070            fidl::encoding::Encode::<
8071                SessionAttachVmoRequest,
8072                fidl::encoding::DefaultFuchsiaResourceDialect,
8073            >::encode(
8074                (<fidl::encoding::HandleType<
8075                    fidl::Vmo,
8076                    { fidl::ObjectType::VMO.into_raw() },
8077                    2147483648,
8078                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8079                    &mut self.vmo
8080                ),),
8081                encoder,
8082                offset,
8083                _depth,
8084            )
8085        }
8086    }
8087    unsafe impl<
8088        T0: fidl::encoding::Encode<
8089                fidl::encoding::HandleType<
8090                    fidl::Vmo,
8091                    { fidl::ObjectType::VMO.into_raw() },
8092                    2147483648,
8093                >,
8094                fidl::encoding::DefaultFuchsiaResourceDialect,
8095            >,
8096    >
8097        fidl::encoding::Encode<
8098            SessionAttachVmoRequest,
8099            fidl::encoding::DefaultFuchsiaResourceDialect,
8100        > for (T0,)
8101    {
8102        #[inline]
8103        unsafe fn encode(
8104            self,
8105            encoder: &mut fidl::encoding::Encoder<
8106                '_,
8107                fidl::encoding::DefaultFuchsiaResourceDialect,
8108            >,
8109            offset: usize,
8110            depth: fidl::encoding::Depth,
8111        ) -> fidl::Result<()> {
8112            encoder.debug_check_bounds::<SessionAttachVmoRequest>(offset);
8113            // Zero out padding regions. There's no need to apply masks
8114            // because the unmasked parts will be overwritten by fields.
8115            // Write the fields.
8116            self.0.encode(encoder, offset + 0, depth)?;
8117            Ok(())
8118        }
8119    }
8120
8121    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8122        for SessionAttachVmoRequest
8123    {
8124        #[inline(always)]
8125        fn new_empty() -> Self {
8126            Self {
8127                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8128            }
8129        }
8130
8131        #[inline]
8132        unsafe fn decode(
8133            &mut self,
8134            decoder: &mut fidl::encoding::Decoder<
8135                '_,
8136                fidl::encoding::DefaultFuchsiaResourceDialect,
8137            >,
8138            offset: usize,
8139            _depth: fidl::encoding::Depth,
8140        ) -> fidl::Result<()> {
8141            decoder.debug_check_bounds::<Self>(offset);
8142            // Verify that padding bytes are zero.
8143            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
8144            Ok(())
8145        }
8146    }
8147
8148    impl fidl::encoding::ResourceTypeMarker for SessionRegisterKeyRequest {
8149        type Borrowed<'a> = &'a mut Self;
8150        fn take_or_borrow<'a>(
8151            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8152        ) -> Self::Borrowed<'a> {
8153            value
8154        }
8155    }
8156
8157    unsafe impl fidl::encoding::TypeMarker for SessionRegisterKeyRequest {
8158        type Owned = Self;
8159
8160        #[inline(always)]
8161        fn inline_align(_context: fidl::encoding::Context) -> usize {
8162            4
8163        }
8164
8165        #[inline(always)]
8166        fn inline_size(_context: fidl::encoding::Context) -> usize {
8167            4
8168        }
8169    }
8170
8171    unsafe impl
8172        fidl::encoding::Encode<
8173            SessionRegisterKeyRequest,
8174            fidl::encoding::DefaultFuchsiaResourceDialect,
8175        > for &mut SessionRegisterKeyRequest
8176    {
8177        #[inline]
8178        unsafe fn encode(
8179            self,
8180            encoder: &mut fidl::encoding::Encoder<
8181                '_,
8182                fidl::encoding::DefaultFuchsiaResourceDialect,
8183            >,
8184            offset: usize,
8185            _depth: fidl::encoding::Depth,
8186        ) -> fidl::Result<()> {
8187            encoder.debug_check_bounds::<SessionRegisterKeyRequest>(offset);
8188            // Delegate to tuple encoding.
8189            fidl::encoding::Encode::<
8190                SessionRegisterKeyRequest,
8191                fidl::encoding::DefaultFuchsiaResourceDialect,
8192            >::encode(
8193                (<fidl::encoding::HandleType<
8194                    fidl::EventPair,
8195                    { fidl::ObjectType::EVENTPAIR.into_raw() },
8196                    2147483648,
8197                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8198                    &mut self.key_token
8199                ),),
8200                encoder,
8201                offset,
8202                _depth,
8203            )
8204        }
8205    }
8206    unsafe impl<
8207        T0: fidl::encoding::Encode<
8208                fidl::encoding::HandleType<
8209                    fidl::EventPair,
8210                    { fidl::ObjectType::EVENTPAIR.into_raw() },
8211                    2147483648,
8212                >,
8213                fidl::encoding::DefaultFuchsiaResourceDialect,
8214            >,
8215    >
8216        fidl::encoding::Encode<
8217            SessionRegisterKeyRequest,
8218            fidl::encoding::DefaultFuchsiaResourceDialect,
8219        > for (T0,)
8220    {
8221        #[inline]
8222        unsafe fn encode(
8223            self,
8224            encoder: &mut fidl::encoding::Encoder<
8225                '_,
8226                fidl::encoding::DefaultFuchsiaResourceDialect,
8227            >,
8228            offset: usize,
8229            depth: fidl::encoding::Depth,
8230        ) -> fidl::Result<()> {
8231            encoder.debug_check_bounds::<SessionRegisterKeyRequest>(offset);
8232            // Zero out padding regions. There's no need to apply masks
8233            // because the unmasked parts will be overwritten by fields.
8234            // Write the fields.
8235            self.0.encode(encoder, offset + 0, depth)?;
8236            Ok(())
8237        }
8238    }
8239
8240    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8241        for SessionRegisterKeyRequest
8242    {
8243        #[inline(always)]
8244        fn new_empty() -> Self {
8245            Self {
8246                key_token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8247            }
8248        }
8249
8250        #[inline]
8251        unsafe fn decode(
8252            &mut self,
8253            decoder: &mut fidl::encoding::Decoder<
8254                '_,
8255                fidl::encoding::DefaultFuchsiaResourceDialect,
8256            >,
8257            offset: usize,
8258            _depth: fidl::encoding::Depth,
8259        ) -> fidl::Result<()> {
8260            decoder.debug_check_bounds::<Self>(offset);
8261            // Verify that padding bytes are zero.
8262            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.key_token, decoder, offset + 0, _depth)?;
8263            Ok(())
8264        }
8265    }
8266
8267    impl fidl::encoding::ResourceTypeMarker for SessionGetFifoResponse {
8268        type Borrowed<'a> = &'a mut Self;
8269        fn take_or_borrow<'a>(
8270            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8271        ) -> Self::Borrowed<'a> {
8272            value
8273        }
8274    }
8275
8276    unsafe impl fidl::encoding::TypeMarker for SessionGetFifoResponse {
8277        type Owned = Self;
8278
8279        #[inline(always)]
8280        fn inline_align(_context: fidl::encoding::Context) -> usize {
8281            4
8282        }
8283
8284        #[inline(always)]
8285        fn inline_size(_context: fidl::encoding::Context) -> usize {
8286            4
8287        }
8288    }
8289
8290    unsafe impl
8291        fidl::encoding::Encode<
8292            SessionGetFifoResponse,
8293            fidl::encoding::DefaultFuchsiaResourceDialect,
8294        > for &mut SessionGetFifoResponse
8295    {
8296        #[inline]
8297        unsafe fn encode(
8298            self,
8299            encoder: &mut fidl::encoding::Encoder<
8300                '_,
8301                fidl::encoding::DefaultFuchsiaResourceDialect,
8302            >,
8303            offset: usize,
8304            _depth: fidl::encoding::Depth,
8305        ) -> fidl::Result<()> {
8306            encoder.debug_check_bounds::<SessionGetFifoResponse>(offset);
8307            // Delegate to tuple encoding.
8308            fidl::encoding::Encode::<
8309                SessionGetFifoResponse,
8310                fidl::encoding::DefaultFuchsiaResourceDialect,
8311            >::encode(
8312                (<fidl::encoding::HandleType<
8313                    fidl::Fifo,
8314                    { fidl::ObjectType::FIFO.into_raw() },
8315                    2147483648,
8316                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8317                    &mut self.fifo
8318                ),),
8319                encoder,
8320                offset,
8321                _depth,
8322            )
8323        }
8324    }
8325    unsafe impl<
8326        T0: fidl::encoding::Encode<
8327                fidl::encoding::HandleType<
8328                    fidl::Fifo,
8329                    { fidl::ObjectType::FIFO.into_raw() },
8330                    2147483648,
8331                >,
8332                fidl::encoding::DefaultFuchsiaResourceDialect,
8333            >,
8334    >
8335        fidl::encoding::Encode<
8336            SessionGetFifoResponse,
8337            fidl::encoding::DefaultFuchsiaResourceDialect,
8338        > for (T0,)
8339    {
8340        #[inline]
8341        unsafe fn encode(
8342            self,
8343            encoder: &mut fidl::encoding::Encoder<
8344                '_,
8345                fidl::encoding::DefaultFuchsiaResourceDialect,
8346            >,
8347            offset: usize,
8348            depth: fidl::encoding::Depth,
8349        ) -> fidl::Result<()> {
8350            encoder.debug_check_bounds::<SessionGetFifoResponse>(offset);
8351            // Zero out padding regions. There's no need to apply masks
8352            // because the unmasked parts will be overwritten by fields.
8353            // Write the fields.
8354            self.0.encode(encoder, offset + 0, depth)?;
8355            Ok(())
8356        }
8357    }
8358
8359    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8360        for SessionGetFifoResponse
8361    {
8362        #[inline(always)]
8363        fn new_empty() -> Self {
8364            Self {
8365                fifo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8366            }
8367        }
8368
8369        #[inline]
8370        unsafe fn decode(
8371            &mut self,
8372            decoder: &mut fidl::encoding::Decoder<
8373                '_,
8374                fidl::encoding::DefaultFuchsiaResourceDialect,
8375            >,
8376            offset: usize,
8377            _depth: fidl::encoding::Depth,
8378        ) -> fidl::Result<()> {
8379            decoder.debug_check_bounds::<Self>(offset);
8380            // Verify that padding bytes are zero.
8381            fidl::decode!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.fifo, decoder, offset + 0, _depth)?;
8382            Ok(())
8383        }
8384    }
8385}