fidl_fuchsia_hardware_block_partition/
fidl_fuchsia_hardware_block_partition.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_hardware_block_partition_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct PartitionMarker;
16
17impl fidl::endpoints::ProtocolMarker for PartitionMarker {
18    type Proxy = PartitionProxy;
19    type RequestStream = PartitionRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = PartitionSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "(anonymous) Partition";
24}
25pub type PartitionGetMetadataResult = Result<PartitionGetMetadataResponse, i32>;
26
27pub trait PartitionProxyInterface: Send + Sync {
28    type GetInfoResponseFut: std::future::Future<
29            Output = Result<fidl_fuchsia_hardware_block::BlockGetInfoResult, fidl::Error>,
30        > + Send;
31    fn r#get_info(&self) -> Self::GetInfoResponseFut;
32    type GetStatsResponseFut: std::future::Future<
33            Output = Result<fidl_fuchsia_hardware_block::BlockGetStatsResult, fidl::Error>,
34        > + Send;
35    fn r#get_stats(&self, clear: bool) -> Self::GetStatsResponseFut;
36    fn r#open_session(
37        &self,
38        session: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block::SessionMarker>,
39    ) -> Result<(), fidl::Error>;
40    fn r#open_session_with_offset_map(
41        &self,
42        session: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block::SessionMarker>,
43        offset_map: Option<
44            fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::OffsetMapMarker>,
45        >,
46        initial_mappings: Option<&[fidl_fuchsia_hardware_block::BlockOffsetMapping]>,
47    ) -> Result<(), fidl::Error>;
48    type GetTypeGuidResponseFut: std::future::Future<Output = Result<(i32, Option<Box<Guid>>), fidl::Error>>
49        + Send;
50    fn r#get_type_guid(&self) -> Self::GetTypeGuidResponseFut;
51    type GetInstanceGuidResponseFut: std::future::Future<Output = Result<(i32, Option<Box<Guid>>), fidl::Error>>
52        + Send;
53    fn r#get_instance_guid(&self) -> Self::GetInstanceGuidResponseFut;
54    type GetNameResponseFut: std::future::Future<Output = Result<(i32, Option<String>), fidl::Error>>
55        + Send;
56    fn r#get_name(&self) -> Self::GetNameResponseFut;
57    type GetMetadataResponseFut: std::future::Future<Output = Result<PartitionGetMetadataResult, fidl::Error>>
58        + Send;
59    fn r#get_metadata(&self) -> Self::GetMetadataResponseFut;
60}
61#[derive(Debug)]
62#[cfg(target_os = "fuchsia")]
63pub struct PartitionSynchronousProxy {
64    client: fidl::client::sync::Client,
65}
66
67#[cfg(target_os = "fuchsia")]
68impl fidl::endpoints::SynchronousProxy for PartitionSynchronousProxy {
69    type Proxy = PartitionProxy;
70    type Protocol = PartitionMarker;
71
72    fn from_channel(inner: fidl::Channel) -> Self {
73        Self::new(inner)
74    }
75
76    fn into_channel(self) -> fidl::Channel {
77        self.client.into_channel()
78    }
79
80    fn as_channel(&self) -> &fidl::Channel {
81        self.client.as_channel()
82    }
83}
84
85#[cfg(target_os = "fuchsia")]
86impl PartitionSynchronousProxy {
87    pub fn new(channel: fidl::Channel) -> Self {
88        let protocol_name = <PartitionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
89        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
90    }
91
92    pub fn into_channel(self) -> fidl::Channel {
93        self.client.into_channel()
94    }
95
96    /// Waits until an event arrives and returns it. It is safe for other
97    /// threads to make concurrent requests while waiting for an event.
98    pub fn wait_for_event(
99        &self,
100        deadline: zx::MonotonicInstant,
101    ) -> Result<PartitionEvent, fidl::Error> {
102        PartitionEvent::decode(self.client.wait_for_event(deadline)?)
103    }
104
105    /// Get information about the underlying block device.
106    pub fn r#get_info(
107        &self,
108        ___deadline: zx::MonotonicInstant,
109    ) -> Result<fidl_fuchsia_hardware_block::BlockGetInfoResult, fidl::Error> {
110        let _response =
111            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
112                fidl_fuchsia_hardware_block::BlockGetInfoResponse,
113                i32,
114            >>(
115                (),
116                0x79df1a5cdb6cc6a3,
117                fidl::encoding::DynamicFlags::empty(),
118                ___deadline,
119            )?;
120        Ok(_response.map(|x| x.info))
121    }
122
123    /// Returns stats about block device operations. Setting `clear` will reset stats counters.
124    pub fn r#get_stats(
125        &self,
126        mut clear: bool,
127        ___deadline: zx::MonotonicInstant,
128    ) -> Result<fidl_fuchsia_hardware_block::BlockGetStatsResult, fidl::Error> {
129        let _response = self.client.send_query::<
130            fidl_fuchsia_hardware_block::BlockGetStatsRequest,
131            fidl::encoding::ResultType<fidl_fuchsia_hardware_block::BlockGetStatsResponse, i32>,
132        >(
133            (clear,),
134            0x53d9542a778385ae,
135            fidl::encoding::DynamicFlags::empty(),
136            ___deadline,
137        )?;
138        Ok(_response.map(|x| x.stats))
139    }
140
141    /// Opens a new FIFO-based session on the block device.
142    pub fn r#open_session(
143        &self,
144        mut session: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block::SessionMarker>,
145    ) -> Result<(), fidl::Error> {
146        self.client.send::<fidl_fuchsia_hardware_block::BlockOpenSessionRequest>(
147            (session,),
148            0x7241c68d17614a31,
149            fidl::encoding::DynamicFlags::empty(),
150        )
151    }
152
153    /// Opens a new FIFO-based session on the block device, providing an offset lookup map which
154    /// transparently translates device offsets in block FIFO requests.
155    ///
156    /// `initial_mappings` is a static set of mappings which the server can immediately use.  If
157    /// `offset_map` is not provided, this must be non-empty, and requests that fall outside of the
158    /// mapped range will fail.
159    ///
160    /// If `offset_map` is provided, whenever the server receives a request with a dev_offset that
161    /// falls outside of the known range, it will consult `offset_map` to attempt to resolve the
162    /// offset.  Because these offset mappings must be stable for the duration of the session, the
163    /// server may cache any mappings.
164    ///
165    /// This interface is intended to be used internally between nested Block implementations, in
166    /// order to provide passthrough I/O.  For example, a fixed partition map (e.g. GPT) will serve
167    /// a Block protocol for each partition, and will respond to OpenSession requests by calling
168    /// OpenSessionWithOffsetMap on the underlying block device, establishing itself as the source
169    /// for translating client block offsets (relative to the partition start) to absolute offsets.
170    /// The client can then communicate directly with the underlying block device, and the partition
171    /// offsets can be transparently applied to requests.
172    pub fn r#open_session_with_offset_map(
173        &self,
174        mut session: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block::SessionMarker>,
175        mut offset_map: Option<
176            fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::OffsetMapMarker>,
177        >,
178        mut initial_mappings: Option<&[fidl_fuchsia_hardware_block::BlockOffsetMapping]>,
179    ) -> Result<(), fidl::Error> {
180        self.client.send::<fidl_fuchsia_hardware_block::BlockOpenSessionWithOffsetMapRequest>(
181            (session, offset_map, initial_mappings),
182            0x7a8d3ba3d8bfa10f,
183            fidl::encoding::DynamicFlags::empty(),
184        )
185    }
186
187    /// Gets the type GUID of the partition (if one exists).
188    /// If the partition has no type GUID, ZX_ERR_NOT_SUPPORTED is returned.
189    pub fn r#get_type_guid(
190        &self,
191        ___deadline: zx::MonotonicInstant,
192    ) -> Result<(i32, Option<Box<Guid>>), fidl::Error> {
193        let _response =
194            self.client.send_query::<fidl::encoding::EmptyPayload, PartitionGetTypeGuidResponse>(
195                (),
196                0x111843d737a9b847,
197                fidl::encoding::DynamicFlags::empty(),
198                ___deadline,
199            )?;
200        Ok((_response.status, _response.guid))
201    }
202
203    /// Gets the instance GUID of the partition (if one exists).
204    /// If the partition has no instance GUID, ZX_ERR_NOT_SUPPORTED is returned.
205    pub fn r#get_instance_guid(
206        &self,
207        ___deadline: zx::MonotonicInstant,
208    ) -> Result<(i32, Option<Box<Guid>>), fidl::Error> {
209        let _response = self
210            .client
211            .send_query::<fidl::encoding::EmptyPayload, PartitionGetInstanceGuidResponse>(
212                (),
213                0x14a5a573b275d435,
214                fidl::encoding::DynamicFlags::empty(),
215                ___deadline,
216            )?;
217        Ok((_response.status, _response.guid))
218    }
219
220    /// Gets the name of the partition (if one exists).
221    /// If the partition has no name, ZX_ERR_NOT_SUPPORTED is returned.
222    pub fn r#get_name(
223        &self,
224        ___deadline: zx::MonotonicInstant,
225    ) -> Result<(i32, Option<String>), fidl::Error> {
226        let _response =
227            self.client.send_query::<fidl::encoding::EmptyPayload, PartitionGetNameResponse>(
228                (),
229                0x7e3c6f0b0937fc02,
230                fidl::encoding::DynamicFlags::empty(),
231                ___deadline,
232            )?;
233        Ok((_response.status, _response.name))
234    }
235
236    /// Gets the metadata for the partition.
237    ///
238    /// Fields may be absent if the partition doesn't have the given metadata.
239    pub fn r#get_metadata(
240        &self,
241        ___deadline: zx::MonotonicInstant,
242    ) -> Result<PartitionGetMetadataResult, fidl::Error> {
243        let _response = self.client.send_query::<
244            fidl::encoding::EmptyPayload,
245            fidl::encoding::ResultType<PartitionGetMetadataResponse, i32>,
246        >(
247            (),
248            0x42d1464c96c3f3ff,
249            fidl::encoding::DynamicFlags::empty(),
250            ___deadline,
251        )?;
252        Ok(_response.map(|x| x))
253    }
254}
255
256#[derive(Debug, Clone)]
257pub struct PartitionProxy {
258    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
259}
260
261impl fidl::endpoints::Proxy for PartitionProxy {
262    type Protocol = PartitionMarker;
263
264    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
265        Self::new(inner)
266    }
267
268    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
269        self.client.into_channel().map_err(|client| Self { client })
270    }
271
272    fn as_channel(&self) -> &::fidl::AsyncChannel {
273        self.client.as_channel()
274    }
275}
276
277impl PartitionProxy {
278    /// Create a new Proxy for fuchsia.hardware.block.partition/Partition.
279    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
280        let protocol_name = <PartitionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
281        Self { client: fidl::client::Client::new(channel, protocol_name) }
282    }
283
284    /// Get a Stream of events from the remote end of the protocol.
285    ///
286    /// # Panics
287    ///
288    /// Panics if the event stream was already taken.
289    pub fn take_event_stream(&self) -> PartitionEventStream {
290        PartitionEventStream { event_receiver: self.client.take_event_receiver() }
291    }
292
293    /// Get information about the underlying block device.
294    pub fn r#get_info(
295        &self,
296    ) -> fidl::client::QueryResponseFut<
297        fidl_fuchsia_hardware_block::BlockGetInfoResult,
298        fidl::encoding::DefaultFuchsiaResourceDialect,
299    > {
300        PartitionProxyInterface::r#get_info(self)
301    }
302
303    /// Returns stats about block device operations. Setting `clear` will reset stats counters.
304    pub fn r#get_stats(
305        &self,
306        mut clear: bool,
307    ) -> fidl::client::QueryResponseFut<
308        fidl_fuchsia_hardware_block::BlockGetStatsResult,
309        fidl::encoding::DefaultFuchsiaResourceDialect,
310    > {
311        PartitionProxyInterface::r#get_stats(self, clear)
312    }
313
314    /// Opens a new FIFO-based session on the block device.
315    pub fn r#open_session(
316        &self,
317        mut session: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block::SessionMarker>,
318    ) -> Result<(), fidl::Error> {
319        PartitionProxyInterface::r#open_session(self, session)
320    }
321
322    /// Opens a new FIFO-based session on the block device, providing an offset lookup map which
323    /// transparently translates device offsets in block FIFO requests.
324    ///
325    /// `initial_mappings` is a static set of mappings which the server can immediately use.  If
326    /// `offset_map` is not provided, this must be non-empty, and requests that fall outside of the
327    /// mapped range will fail.
328    ///
329    /// If `offset_map` is provided, whenever the server receives a request with a dev_offset that
330    /// falls outside of the known range, it will consult `offset_map` to attempt to resolve the
331    /// offset.  Because these offset mappings must be stable for the duration of the session, the
332    /// server may cache any mappings.
333    ///
334    /// This interface is intended to be used internally between nested Block implementations, in
335    /// order to provide passthrough I/O.  For example, a fixed partition map (e.g. GPT) will serve
336    /// a Block protocol for each partition, and will respond to OpenSession requests by calling
337    /// OpenSessionWithOffsetMap on the underlying block device, establishing itself as the source
338    /// for translating client block offsets (relative to the partition start) to absolute offsets.
339    /// The client can then communicate directly with the underlying block device, and the partition
340    /// offsets can be transparently applied to requests.
341    pub fn r#open_session_with_offset_map(
342        &self,
343        mut session: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block::SessionMarker>,
344        mut offset_map: Option<
345            fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::OffsetMapMarker>,
346        >,
347        mut initial_mappings: Option<&[fidl_fuchsia_hardware_block::BlockOffsetMapping]>,
348    ) -> Result<(), fidl::Error> {
349        PartitionProxyInterface::r#open_session_with_offset_map(
350            self,
351            session,
352            offset_map,
353            initial_mappings,
354        )
355    }
356
357    /// Gets the type GUID of the partition (if one exists).
358    /// If the partition has no type GUID, ZX_ERR_NOT_SUPPORTED is returned.
359    pub fn r#get_type_guid(
360        &self,
361    ) -> fidl::client::QueryResponseFut<
362        (i32, Option<Box<Guid>>),
363        fidl::encoding::DefaultFuchsiaResourceDialect,
364    > {
365        PartitionProxyInterface::r#get_type_guid(self)
366    }
367
368    /// Gets the instance GUID of the partition (if one exists).
369    /// If the partition has no instance GUID, ZX_ERR_NOT_SUPPORTED is returned.
370    pub fn r#get_instance_guid(
371        &self,
372    ) -> fidl::client::QueryResponseFut<
373        (i32, Option<Box<Guid>>),
374        fidl::encoding::DefaultFuchsiaResourceDialect,
375    > {
376        PartitionProxyInterface::r#get_instance_guid(self)
377    }
378
379    /// Gets the name of the partition (if one exists).
380    /// If the partition has no name, ZX_ERR_NOT_SUPPORTED is returned.
381    pub fn r#get_name(
382        &self,
383    ) -> fidl::client::QueryResponseFut<
384        (i32, Option<String>),
385        fidl::encoding::DefaultFuchsiaResourceDialect,
386    > {
387        PartitionProxyInterface::r#get_name(self)
388    }
389
390    /// Gets the metadata for the partition.
391    ///
392    /// Fields may be absent if the partition doesn't have the given metadata.
393    pub fn r#get_metadata(
394        &self,
395    ) -> fidl::client::QueryResponseFut<
396        PartitionGetMetadataResult,
397        fidl::encoding::DefaultFuchsiaResourceDialect,
398    > {
399        PartitionProxyInterface::r#get_metadata(self)
400    }
401}
402
403impl PartitionProxyInterface for PartitionProxy {
404    type GetInfoResponseFut = fidl::client::QueryResponseFut<
405        fidl_fuchsia_hardware_block::BlockGetInfoResult,
406        fidl::encoding::DefaultFuchsiaResourceDialect,
407    >;
408    fn r#get_info(&self) -> Self::GetInfoResponseFut {
409        fn _decode(
410            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
411        ) -> Result<fidl_fuchsia_hardware_block::BlockGetInfoResult, fidl::Error> {
412            let _response = fidl::client::decode_transaction_body::<
413                fidl::encoding::ResultType<fidl_fuchsia_hardware_block::BlockGetInfoResponse, i32>,
414                fidl::encoding::DefaultFuchsiaResourceDialect,
415                0x79df1a5cdb6cc6a3,
416            >(_buf?)?;
417            Ok(_response.map(|x| x.info))
418        }
419        self.client.send_query_and_decode::<
420            fidl::encoding::EmptyPayload,
421            fidl_fuchsia_hardware_block::BlockGetInfoResult,
422        >(
423            (),
424            0x79df1a5cdb6cc6a3,
425            fidl::encoding::DynamicFlags::empty(),
426            _decode,
427        )
428    }
429
430    type GetStatsResponseFut = fidl::client::QueryResponseFut<
431        fidl_fuchsia_hardware_block::BlockGetStatsResult,
432        fidl::encoding::DefaultFuchsiaResourceDialect,
433    >;
434    fn r#get_stats(&self, mut clear: bool) -> Self::GetStatsResponseFut {
435        fn _decode(
436            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
437        ) -> Result<fidl_fuchsia_hardware_block::BlockGetStatsResult, fidl::Error> {
438            let _response = fidl::client::decode_transaction_body::<
439                fidl::encoding::ResultType<fidl_fuchsia_hardware_block::BlockGetStatsResponse, i32>,
440                fidl::encoding::DefaultFuchsiaResourceDialect,
441                0x53d9542a778385ae,
442            >(_buf?)?;
443            Ok(_response.map(|x| x.stats))
444        }
445        self.client.send_query_and_decode::<
446            fidl_fuchsia_hardware_block::BlockGetStatsRequest,
447            fidl_fuchsia_hardware_block::BlockGetStatsResult,
448        >(
449            (clear,),
450            0x53d9542a778385ae,
451            fidl::encoding::DynamicFlags::empty(),
452            _decode,
453        )
454    }
455
456    fn r#open_session(
457        &self,
458        mut session: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block::SessionMarker>,
459    ) -> Result<(), fidl::Error> {
460        self.client.send::<fidl_fuchsia_hardware_block::BlockOpenSessionRequest>(
461            (session,),
462            0x7241c68d17614a31,
463            fidl::encoding::DynamicFlags::empty(),
464        )
465    }
466
467    fn r#open_session_with_offset_map(
468        &self,
469        mut session: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block::SessionMarker>,
470        mut offset_map: Option<
471            fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::OffsetMapMarker>,
472        >,
473        mut initial_mappings: Option<&[fidl_fuchsia_hardware_block::BlockOffsetMapping]>,
474    ) -> Result<(), fidl::Error> {
475        self.client.send::<fidl_fuchsia_hardware_block::BlockOpenSessionWithOffsetMapRequest>(
476            (session, offset_map, initial_mappings),
477            0x7a8d3ba3d8bfa10f,
478            fidl::encoding::DynamicFlags::empty(),
479        )
480    }
481
482    type GetTypeGuidResponseFut = fidl::client::QueryResponseFut<
483        (i32, Option<Box<Guid>>),
484        fidl::encoding::DefaultFuchsiaResourceDialect,
485    >;
486    fn r#get_type_guid(&self) -> Self::GetTypeGuidResponseFut {
487        fn _decode(
488            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
489        ) -> Result<(i32, Option<Box<Guid>>), fidl::Error> {
490            let _response = fidl::client::decode_transaction_body::<
491                PartitionGetTypeGuidResponse,
492                fidl::encoding::DefaultFuchsiaResourceDialect,
493                0x111843d737a9b847,
494            >(_buf?)?;
495            Ok((_response.status, _response.guid))
496        }
497        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, Option<Box<Guid>>)>(
498            (),
499            0x111843d737a9b847,
500            fidl::encoding::DynamicFlags::empty(),
501            _decode,
502        )
503    }
504
505    type GetInstanceGuidResponseFut = fidl::client::QueryResponseFut<
506        (i32, Option<Box<Guid>>),
507        fidl::encoding::DefaultFuchsiaResourceDialect,
508    >;
509    fn r#get_instance_guid(&self) -> Self::GetInstanceGuidResponseFut {
510        fn _decode(
511            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
512        ) -> Result<(i32, Option<Box<Guid>>), fidl::Error> {
513            let _response = fidl::client::decode_transaction_body::<
514                PartitionGetInstanceGuidResponse,
515                fidl::encoding::DefaultFuchsiaResourceDialect,
516                0x14a5a573b275d435,
517            >(_buf?)?;
518            Ok((_response.status, _response.guid))
519        }
520        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, Option<Box<Guid>>)>(
521            (),
522            0x14a5a573b275d435,
523            fidl::encoding::DynamicFlags::empty(),
524            _decode,
525        )
526    }
527
528    type GetNameResponseFut = fidl::client::QueryResponseFut<
529        (i32, Option<String>),
530        fidl::encoding::DefaultFuchsiaResourceDialect,
531    >;
532    fn r#get_name(&self) -> Self::GetNameResponseFut {
533        fn _decode(
534            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
535        ) -> Result<(i32, Option<String>), fidl::Error> {
536            let _response = fidl::client::decode_transaction_body::<
537                PartitionGetNameResponse,
538                fidl::encoding::DefaultFuchsiaResourceDialect,
539                0x7e3c6f0b0937fc02,
540            >(_buf?)?;
541            Ok((_response.status, _response.name))
542        }
543        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, Option<String>)>(
544            (),
545            0x7e3c6f0b0937fc02,
546            fidl::encoding::DynamicFlags::empty(),
547            _decode,
548        )
549    }
550
551    type GetMetadataResponseFut = fidl::client::QueryResponseFut<
552        PartitionGetMetadataResult,
553        fidl::encoding::DefaultFuchsiaResourceDialect,
554    >;
555    fn r#get_metadata(&self) -> Self::GetMetadataResponseFut {
556        fn _decode(
557            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
558        ) -> Result<PartitionGetMetadataResult, fidl::Error> {
559            let _response = fidl::client::decode_transaction_body::<
560                fidl::encoding::ResultType<PartitionGetMetadataResponse, i32>,
561                fidl::encoding::DefaultFuchsiaResourceDialect,
562                0x42d1464c96c3f3ff,
563            >(_buf?)?;
564            Ok(_response.map(|x| x))
565        }
566        self.client
567            .send_query_and_decode::<fidl::encoding::EmptyPayload, PartitionGetMetadataResult>(
568                (),
569                0x42d1464c96c3f3ff,
570                fidl::encoding::DynamicFlags::empty(),
571                _decode,
572            )
573    }
574}
575
576pub struct PartitionEventStream {
577    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
578}
579
580impl std::marker::Unpin for PartitionEventStream {}
581
582impl futures::stream::FusedStream for PartitionEventStream {
583    fn is_terminated(&self) -> bool {
584        self.event_receiver.is_terminated()
585    }
586}
587
588impl futures::Stream for PartitionEventStream {
589    type Item = Result<PartitionEvent, fidl::Error>;
590
591    fn poll_next(
592        mut self: std::pin::Pin<&mut Self>,
593        cx: &mut std::task::Context<'_>,
594    ) -> std::task::Poll<Option<Self::Item>> {
595        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
596            &mut self.event_receiver,
597            cx
598        )?) {
599            Some(buf) => std::task::Poll::Ready(Some(PartitionEvent::decode(buf))),
600            None => std::task::Poll::Ready(None),
601        }
602    }
603}
604
605#[derive(Debug)]
606pub enum PartitionEvent {}
607
608impl PartitionEvent {
609    /// Decodes a message buffer as a [`PartitionEvent`].
610    fn decode(
611        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
612    ) -> Result<PartitionEvent, fidl::Error> {
613        let (bytes, _handles) = buf.split_mut();
614        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
615        debug_assert_eq!(tx_header.tx_id, 0);
616        match tx_header.ordinal {
617            _ => Err(fidl::Error::UnknownOrdinal {
618                ordinal: tx_header.ordinal,
619                protocol_name: <PartitionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
620            }),
621        }
622    }
623}
624
625/// A Stream of incoming requests for fuchsia.hardware.block.partition/Partition.
626pub struct PartitionRequestStream {
627    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
628    is_terminated: bool,
629}
630
631impl std::marker::Unpin for PartitionRequestStream {}
632
633impl futures::stream::FusedStream for PartitionRequestStream {
634    fn is_terminated(&self) -> bool {
635        self.is_terminated
636    }
637}
638
639impl fidl::endpoints::RequestStream for PartitionRequestStream {
640    type Protocol = PartitionMarker;
641    type ControlHandle = PartitionControlHandle;
642
643    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
644        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
645    }
646
647    fn control_handle(&self) -> Self::ControlHandle {
648        PartitionControlHandle { inner: self.inner.clone() }
649    }
650
651    fn into_inner(
652        self,
653    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
654    {
655        (self.inner, self.is_terminated)
656    }
657
658    fn from_inner(
659        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
660        is_terminated: bool,
661    ) -> Self {
662        Self { inner, is_terminated }
663    }
664}
665
666impl futures::Stream for PartitionRequestStream {
667    type Item = Result<PartitionRequest, fidl::Error>;
668
669    fn poll_next(
670        mut self: std::pin::Pin<&mut Self>,
671        cx: &mut std::task::Context<'_>,
672    ) -> std::task::Poll<Option<Self::Item>> {
673        let this = &mut *self;
674        if this.inner.check_shutdown(cx) {
675            this.is_terminated = true;
676            return std::task::Poll::Ready(None);
677        }
678        if this.is_terminated {
679            panic!("polled PartitionRequestStream after completion");
680        }
681        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
682            |bytes, handles| {
683                match this.inner.channel().read_etc(cx, bytes, handles) {
684                    std::task::Poll::Ready(Ok(())) => {}
685                    std::task::Poll::Pending => return std::task::Poll::Pending,
686                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
687                        this.is_terminated = true;
688                        return std::task::Poll::Ready(None);
689                    }
690                    std::task::Poll::Ready(Err(e)) => {
691                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
692                            e.into(),
693                        ))))
694                    }
695                }
696
697                // A message has been received from the channel
698                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
699
700                std::task::Poll::Ready(Some(match header.ordinal {
701                    0x79df1a5cdb6cc6a3 => {
702                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
703                        let mut req = fidl::new_empty!(
704                            fidl::encoding::EmptyPayload,
705                            fidl::encoding::DefaultFuchsiaResourceDialect
706                        );
707                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
708                        let control_handle = PartitionControlHandle { inner: this.inner.clone() };
709                        Ok(PartitionRequest::GetInfo {
710                            responder: PartitionGetInfoResponder {
711                                control_handle: std::mem::ManuallyDrop::new(control_handle),
712                                tx_id: header.tx_id,
713                            },
714                        })
715                    }
716                    0x53d9542a778385ae => {
717                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
718                        let mut req = fidl::new_empty!(
719                            fidl_fuchsia_hardware_block::BlockGetStatsRequest,
720                            fidl::encoding::DefaultFuchsiaResourceDialect
721                        );
722                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_block::BlockGetStatsRequest>(&header, _body_bytes, handles, &mut req)?;
723                        let control_handle = PartitionControlHandle { inner: this.inner.clone() };
724                        Ok(PartitionRequest::GetStats {
725                            clear: req.clear,
726
727                            responder: PartitionGetStatsResponder {
728                                control_handle: std::mem::ManuallyDrop::new(control_handle),
729                                tx_id: header.tx_id,
730                            },
731                        })
732                    }
733                    0x7241c68d17614a31 => {
734                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
735                        let mut req = fidl::new_empty!(
736                            fidl_fuchsia_hardware_block::BlockOpenSessionRequest,
737                            fidl::encoding::DefaultFuchsiaResourceDialect
738                        );
739                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_block::BlockOpenSessionRequest>(&header, _body_bytes, handles, &mut req)?;
740                        let control_handle = PartitionControlHandle { inner: this.inner.clone() };
741                        Ok(PartitionRequest::OpenSession { session: req.session, control_handle })
742                    }
743                    0x7a8d3ba3d8bfa10f => {
744                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
745                        let mut req = fidl::new_empty!(
746                            fidl_fuchsia_hardware_block::BlockOpenSessionWithOffsetMapRequest,
747                            fidl::encoding::DefaultFuchsiaResourceDialect
748                        );
749                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_block::BlockOpenSessionWithOffsetMapRequest>(&header, _body_bytes, handles, &mut req)?;
750                        let control_handle = PartitionControlHandle { inner: this.inner.clone() };
751                        Ok(PartitionRequest::OpenSessionWithOffsetMap {
752                            session: req.session,
753                            offset_map: req.offset_map,
754                            initial_mappings: req.initial_mappings,
755
756                            control_handle,
757                        })
758                    }
759                    0x111843d737a9b847 => {
760                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
761                        let mut req = fidl::new_empty!(
762                            fidl::encoding::EmptyPayload,
763                            fidl::encoding::DefaultFuchsiaResourceDialect
764                        );
765                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
766                        let control_handle = PartitionControlHandle { inner: this.inner.clone() };
767                        Ok(PartitionRequest::GetTypeGuid {
768                            responder: PartitionGetTypeGuidResponder {
769                                control_handle: std::mem::ManuallyDrop::new(control_handle),
770                                tx_id: header.tx_id,
771                            },
772                        })
773                    }
774                    0x14a5a573b275d435 => {
775                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
776                        let mut req = fidl::new_empty!(
777                            fidl::encoding::EmptyPayload,
778                            fidl::encoding::DefaultFuchsiaResourceDialect
779                        );
780                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
781                        let control_handle = PartitionControlHandle { inner: this.inner.clone() };
782                        Ok(PartitionRequest::GetInstanceGuid {
783                            responder: PartitionGetInstanceGuidResponder {
784                                control_handle: std::mem::ManuallyDrop::new(control_handle),
785                                tx_id: header.tx_id,
786                            },
787                        })
788                    }
789                    0x7e3c6f0b0937fc02 => {
790                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
791                        let mut req = fidl::new_empty!(
792                            fidl::encoding::EmptyPayload,
793                            fidl::encoding::DefaultFuchsiaResourceDialect
794                        );
795                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
796                        let control_handle = PartitionControlHandle { inner: this.inner.clone() };
797                        Ok(PartitionRequest::GetName {
798                            responder: PartitionGetNameResponder {
799                                control_handle: std::mem::ManuallyDrop::new(control_handle),
800                                tx_id: header.tx_id,
801                            },
802                        })
803                    }
804                    0x42d1464c96c3f3ff => {
805                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
806                        let mut req = fidl::new_empty!(
807                            fidl::encoding::EmptyPayload,
808                            fidl::encoding::DefaultFuchsiaResourceDialect
809                        );
810                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
811                        let control_handle = PartitionControlHandle { inner: this.inner.clone() };
812                        Ok(PartitionRequest::GetMetadata {
813                            responder: PartitionGetMetadataResponder {
814                                control_handle: std::mem::ManuallyDrop::new(control_handle),
815                                tx_id: header.tx_id,
816                            },
817                        })
818                    }
819                    _ => Err(fidl::Error::UnknownOrdinal {
820                        ordinal: header.ordinal,
821                        protocol_name:
822                            <PartitionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
823                    }),
824                }))
825            },
826        )
827    }
828}
829
830/// Partition describes a region of one or more block devices, labelled
831/// with distinguishing identifiers.
832#[derive(Debug)]
833pub enum PartitionRequest {
834    /// Get information about the underlying block device.
835    GetInfo { responder: PartitionGetInfoResponder },
836    /// Returns stats about block device operations. Setting `clear` will reset stats counters.
837    GetStats { clear: bool, responder: PartitionGetStatsResponder },
838    /// Opens a new FIFO-based session on the block device.
839    OpenSession {
840        session: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block::SessionMarker>,
841        control_handle: PartitionControlHandle,
842    },
843    /// Opens a new FIFO-based session on the block device, providing an offset lookup map which
844    /// transparently translates device offsets in block FIFO requests.
845    ///
846    /// `initial_mappings` is a static set of mappings which the server can immediately use.  If
847    /// `offset_map` is not provided, this must be non-empty, and requests that fall outside of the
848    /// mapped range will fail.
849    ///
850    /// If `offset_map` is provided, whenever the server receives a request with a dev_offset that
851    /// falls outside of the known range, it will consult `offset_map` to attempt to resolve the
852    /// offset.  Because these offset mappings must be stable for the duration of the session, the
853    /// server may cache any mappings.
854    ///
855    /// This interface is intended to be used internally between nested Block implementations, in
856    /// order to provide passthrough I/O.  For example, a fixed partition map (e.g. GPT) will serve
857    /// a Block protocol for each partition, and will respond to OpenSession requests by calling
858    /// OpenSessionWithOffsetMap on the underlying block device, establishing itself as the source
859    /// for translating client block offsets (relative to the partition start) to absolute offsets.
860    /// The client can then communicate directly with the underlying block device, and the partition
861    /// offsets can be transparently applied to requests.
862    OpenSessionWithOffsetMap {
863        session: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block::SessionMarker>,
864        offset_map:
865            Option<fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::OffsetMapMarker>>,
866        initial_mappings: Option<Vec<fidl_fuchsia_hardware_block::BlockOffsetMapping>>,
867        control_handle: PartitionControlHandle,
868    },
869    /// Gets the type GUID of the partition (if one exists).
870    /// If the partition has no type GUID, ZX_ERR_NOT_SUPPORTED is returned.
871    GetTypeGuid { responder: PartitionGetTypeGuidResponder },
872    /// Gets the instance GUID of the partition (if one exists).
873    /// If the partition has no instance GUID, ZX_ERR_NOT_SUPPORTED is returned.
874    GetInstanceGuid { responder: PartitionGetInstanceGuidResponder },
875    /// Gets the name of the partition (if one exists).
876    /// If the partition has no name, ZX_ERR_NOT_SUPPORTED is returned.
877    GetName { responder: PartitionGetNameResponder },
878    /// Gets the metadata for the partition.
879    ///
880    /// Fields may be absent if the partition doesn't have the given metadata.
881    GetMetadata { responder: PartitionGetMetadataResponder },
882}
883
884impl PartitionRequest {
885    #[allow(irrefutable_let_patterns)]
886    pub fn into_get_info(self) -> Option<(PartitionGetInfoResponder)> {
887        if let PartitionRequest::GetInfo { responder } = self {
888            Some((responder))
889        } else {
890            None
891        }
892    }
893
894    #[allow(irrefutable_let_patterns)]
895    pub fn into_get_stats(self) -> Option<(bool, PartitionGetStatsResponder)> {
896        if let PartitionRequest::GetStats { clear, responder } = self {
897            Some((clear, responder))
898        } else {
899            None
900        }
901    }
902
903    #[allow(irrefutable_let_patterns)]
904    pub fn into_open_session(
905        self,
906    ) -> Option<(
907        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block::SessionMarker>,
908        PartitionControlHandle,
909    )> {
910        if let PartitionRequest::OpenSession { session, control_handle } = self {
911            Some((session, control_handle))
912        } else {
913            None
914        }
915    }
916
917    #[allow(irrefutable_let_patterns)]
918    pub fn into_open_session_with_offset_map(
919        self,
920    ) -> Option<(
921        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_block::SessionMarker>,
922        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_block::OffsetMapMarker>>,
923        Option<Vec<fidl_fuchsia_hardware_block::BlockOffsetMapping>>,
924        PartitionControlHandle,
925    )> {
926        if let PartitionRequest::OpenSessionWithOffsetMap {
927            session,
928            offset_map,
929            initial_mappings,
930            control_handle,
931        } = self
932        {
933            Some((session, offset_map, initial_mappings, control_handle))
934        } else {
935            None
936        }
937    }
938
939    #[allow(irrefutable_let_patterns)]
940    pub fn into_get_type_guid(self) -> Option<(PartitionGetTypeGuidResponder)> {
941        if let PartitionRequest::GetTypeGuid { responder } = self {
942            Some((responder))
943        } else {
944            None
945        }
946    }
947
948    #[allow(irrefutable_let_patterns)]
949    pub fn into_get_instance_guid(self) -> Option<(PartitionGetInstanceGuidResponder)> {
950        if let PartitionRequest::GetInstanceGuid { responder } = self {
951            Some((responder))
952        } else {
953            None
954        }
955    }
956
957    #[allow(irrefutable_let_patterns)]
958    pub fn into_get_name(self) -> Option<(PartitionGetNameResponder)> {
959        if let PartitionRequest::GetName { responder } = self {
960            Some((responder))
961        } else {
962            None
963        }
964    }
965
966    #[allow(irrefutable_let_patterns)]
967    pub fn into_get_metadata(self) -> Option<(PartitionGetMetadataResponder)> {
968        if let PartitionRequest::GetMetadata { responder } = self {
969            Some((responder))
970        } else {
971            None
972        }
973    }
974
975    /// Name of the method defined in FIDL
976    pub fn method_name(&self) -> &'static str {
977        match *self {
978            PartitionRequest::GetInfo { .. } => "get_info",
979            PartitionRequest::GetStats { .. } => "get_stats",
980            PartitionRequest::OpenSession { .. } => "open_session",
981            PartitionRequest::OpenSessionWithOffsetMap { .. } => "open_session_with_offset_map",
982            PartitionRequest::GetTypeGuid { .. } => "get_type_guid",
983            PartitionRequest::GetInstanceGuid { .. } => "get_instance_guid",
984            PartitionRequest::GetName { .. } => "get_name",
985            PartitionRequest::GetMetadata { .. } => "get_metadata",
986        }
987    }
988}
989
990#[derive(Debug, Clone)]
991pub struct PartitionControlHandle {
992    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
993}
994
995impl fidl::endpoints::ControlHandle for PartitionControlHandle {
996    fn shutdown(&self) {
997        self.inner.shutdown()
998    }
999    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1000        self.inner.shutdown_with_epitaph(status)
1001    }
1002
1003    fn is_closed(&self) -> bool {
1004        self.inner.channel().is_closed()
1005    }
1006    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1007        self.inner.channel().on_closed()
1008    }
1009
1010    #[cfg(target_os = "fuchsia")]
1011    fn signal_peer(
1012        &self,
1013        clear_mask: zx::Signals,
1014        set_mask: zx::Signals,
1015    ) -> Result<(), zx_status::Status> {
1016        use fidl::Peered;
1017        self.inner.channel().signal_peer(clear_mask, set_mask)
1018    }
1019}
1020
1021impl PartitionControlHandle {}
1022
1023#[must_use = "FIDL methods require a response to be sent"]
1024#[derive(Debug)]
1025pub struct PartitionGetInfoResponder {
1026    control_handle: std::mem::ManuallyDrop<PartitionControlHandle>,
1027    tx_id: u32,
1028}
1029
1030/// Set the the channel to be shutdown (see [`PartitionControlHandle::shutdown`])
1031/// if the responder is dropped without sending a response, so that the client
1032/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1033impl std::ops::Drop for PartitionGetInfoResponder {
1034    fn drop(&mut self) {
1035        self.control_handle.shutdown();
1036        // Safety: drops once, never accessed again
1037        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1038    }
1039}
1040
1041impl fidl::endpoints::Responder for PartitionGetInfoResponder {
1042    type ControlHandle = PartitionControlHandle;
1043
1044    fn control_handle(&self) -> &PartitionControlHandle {
1045        &self.control_handle
1046    }
1047
1048    fn drop_without_shutdown(mut self) {
1049        // Safety: drops once, never accessed again due to mem::forget
1050        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1051        // Prevent Drop from running (which would shut down the channel)
1052        std::mem::forget(self);
1053    }
1054}
1055
1056impl PartitionGetInfoResponder {
1057    /// Sends a response to the FIDL transaction.
1058    ///
1059    /// Sets the channel to shutdown if an error occurs.
1060    pub fn send(
1061        self,
1062        mut result: Result<&fidl_fuchsia_hardware_block::BlockInfo, i32>,
1063    ) -> Result<(), fidl::Error> {
1064        let _result = self.send_raw(result);
1065        if _result.is_err() {
1066            self.control_handle.shutdown();
1067        }
1068        self.drop_without_shutdown();
1069        _result
1070    }
1071
1072    /// Similar to "send" but does not shutdown the channel if an error occurs.
1073    pub fn send_no_shutdown_on_err(
1074        self,
1075        mut result: Result<&fidl_fuchsia_hardware_block::BlockInfo, i32>,
1076    ) -> Result<(), fidl::Error> {
1077        let _result = self.send_raw(result);
1078        self.drop_without_shutdown();
1079        _result
1080    }
1081
1082    fn send_raw(
1083        &self,
1084        mut result: Result<&fidl_fuchsia_hardware_block::BlockInfo, i32>,
1085    ) -> Result<(), fidl::Error> {
1086        self.control_handle.inner.send::<fidl::encoding::ResultType<
1087            fidl_fuchsia_hardware_block::BlockGetInfoResponse,
1088            i32,
1089        >>(
1090            result.map(|info| (info,)),
1091            self.tx_id,
1092            0x79df1a5cdb6cc6a3,
1093            fidl::encoding::DynamicFlags::empty(),
1094        )
1095    }
1096}
1097
1098#[must_use = "FIDL methods require a response to be sent"]
1099#[derive(Debug)]
1100pub struct PartitionGetStatsResponder {
1101    control_handle: std::mem::ManuallyDrop<PartitionControlHandle>,
1102    tx_id: u32,
1103}
1104
1105/// Set the the channel to be shutdown (see [`PartitionControlHandle::shutdown`])
1106/// if the responder is dropped without sending a response, so that the client
1107/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1108impl std::ops::Drop for PartitionGetStatsResponder {
1109    fn drop(&mut self) {
1110        self.control_handle.shutdown();
1111        // Safety: drops once, never accessed again
1112        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1113    }
1114}
1115
1116impl fidl::endpoints::Responder for PartitionGetStatsResponder {
1117    type ControlHandle = PartitionControlHandle;
1118
1119    fn control_handle(&self) -> &PartitionControlHandle {
1120        &self.control_handle
1121    }
1122
1123    fn drop_without_shutdown(mut self) {
1124        // Safety: drops once, never accessed again due to mem::forget
1125        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1126        // Prevent Drop from running (which would shut down the channel)
1127        std::mem::forget(self);
1128    }
1129}
1130
1131impl PartitionGetStatsResponder {
1132    /// Sends a response to the FIDL transaction.
1133    ///
1134    /// Sets the channel to shutdown if an error occurs.
1135    pub fn send(
1136        self,
1137        mut result: Result<&fidl_fuchsia_hardware_block::BlockStats, i32>,
1138    ) -> Result<(), fidl::Error> {
1139        let _result = self.send_raw(result);
1140        if _result.is_err() {
1141            self.control_handle.shutdown();
1142        }
1143        self.drop_without_shutdown();
1144        _result
1145    }
1146
1147    /// Similar to "send" but does not shutdown the channel if an error occurs.
1148    pub fn send_no_shutdown_on_err(
1149        self,
1150        mut result: Result<&fidl_fuchsia_hardware_block::BlockStats, i32>,
1151    ) -> Result<(), fidl::Error> {
1152        let _result = self.send_raw(result);
1153        self.drop_without_shutdown();
1154        _result
1155    }
1156
1157    fn send_raw(
1158        &self,
1159        mut result: Result<&fidl_fuchsia_hardware_block::BlockStats, i32>,
1160    ) -> Result<(), fidl::Error> {
1161        self.control_handle.inner.send::<fidl::encoding::ResultType<
1162            fidl_fuchsia_hardware_block::BlockGetStatsResponse,
1163            i32,
1164        >>(
1165            result.map(|stats| (stats,)),
1166            self.tx_id,
1167            0x53d9542a778385ae,
1168            fidl::encoding::DynamicFlags::empty(),
1169        )
1170    }
1171}
1172
1173#[must_use = "FIDL methods require a response to be sent"]
1174#[derive(Debug)]
1175pub struct PartitionGetTypeGuidResponder {
1176    control_handle: std::mem::ManuallyDrop<PartitionControlHandle>,
1177    tx_id: u32,
1178}
1179
1180/// Set the the channel to be shutdown (see [`PartitionControlHandle::shutdown`])
1181/// if the responder is dropped without sending a response, so that the client
1182/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1183impl std::ops::Drop for PartitionGetTypeGuidResponder {
1184    fn drop(&mut self) {
1185        self.control_handle.shutdown();
1186        // Safety: drops once, never accessed again
1187        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1188    }
1189}
1190
1191impl fidl::endpoints::Responder for PartitionGetTypeGuidResponder {
1192    type ControlHandle = PartitionControlHandle;
1193
1194    fn control_handle(&self) -> &PartitionControlHandle {
1195        &self.control_handle
1196    }
1197
1198    fn drop_without_shutdown(mut self) {
1199        // Safety: drops once, never accessed again due to mem::forget
1200        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1201        // Prevent Drop from running (which would shut down the channel)
1202        std::mem::forget(self);
1203    }
1204}
1205
1206impl PartitionGetTypeGuidResponder {
1207    /// Sends a response to the FIDL transaction.
1208    ///
1209    /// Sets the channel to shutdown if an error occurs.
1210    pub fn send(self, mut status: i32, mut guid: Option<&Guid>) -> Result<(), fidl::Error> {
1211        let _result = self.send_raw(status, guid);
1212        if _result.is_err() {
1213            self.control_handle.shutdown();
1214        }
1215        self.drop_without_shutdown();
1216        _result
1217    }
1218
1219    /// Similar to "send" but does not shutdown the channel if an error occurs.
1220    pub fn send_no_shutdown_on_err(
1221        self,
1222        mut status: i32,
1223        mut guid: Option<&Guid>,
1224    ) -> Result<(), fidl::Error> {
1225        let _result = self.send_raw(status, guid);
1226        self.drop_without_shutdown();
1227        _result
1228    }
1229
1230    fn send_raw(&self, mut status: i32, mut guid: Option<&Guid>) -> Result<(), fidl::Error> {
1231        self.control_handle.inner.send::<PartitionGetTypeGuidResponse>(
1232            (status, guid),
1233            self.tx_id,
1234            0x111843d737a9b847,
1235            fidl::encoding::DynamicFlags::empty(),
1236        )
1237    }
1238}
1239
1240#[must_use = "FIDL methods require a response to be sent"]
1241#[derive(Debug)]
1242pub struct PartitionGetInstanceGuidResponder {
1243    control_handle: std::mem::ManuallyDrop<PartitionControlHandle>,
1244    tx_id: u32,
1245}
1246
1247/// Set the the channel to be shutdown (see [`PartitionControlHandle::shutdown`])
1248/// if the responder is dropped without sending a response, so that the client
1249/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1250impl std::ops::Drop for PartitionGetInstanceGuidResponder {
1251    fn drop(&mut self) {
1252        self.control_handle.shutdown();
1253        // Safety: drops once, never accessed again
1254        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1255    }
1256}
1257
1258impl fidl::endpoints::Responder for PartitionGetInstanceGuidResponder {
1259    type ControlHandle = PartitionControlHandle;
1260
1261    fn control_handle(&self) -> &PartitionControlHandle {
1262        &self.control_handle
1263    }
1264
1265    fn drop_without_shutdown(mut self) {
1266        // Safety: drops once, never accessed again due to mem::forget
1267        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1268        // Prevent Drop from running (which would shut down the channel)
1269        std::mem::forget(self);
1270    }
1271}
1272
1273impl PartitionGetInstanceGuidResponder {
1274    /// Sends a response to the FIDL transaction.
1275    ///
1276    /// Sets the channel to shutdown if an error occurs.
1277    pub fn send(self, mut status: i32, mut guid: Option<&Guid>) -> Result<(), fidl::Error> {
1278        let _result = self.send_raw(status, guid);
1279        if _result.is_err() {
1280            self.control_handle.shutdown();
1281        }
1282        self.drop_without_shutdown();
1283        _result
1284    }
1285
1286    /// Similar to "send" but does not shutdown the channel if an error occurs.
1287    pub fn send_no_shutdown_on_err(
1288        self,
1289        mut status: i32,
1290        mut guid: Option<&Guid>,
1291    ) -> Result<(), fidl::Error> {
1292        let _result = self.send_raw(status, guid);
1293        self.drop_without_shutdown();
1294        _result
1295    }
1296
1297    fn send_raw(&self, mut status: i32, mut guid: Option<&Guid>) -> Result<(), fidl::Error> {
1298        self.control_handle.inner.send::<PartitionGetInstanceGuidResponse>(
1299            (status, guid),
1300            self.tx_id,
1301            0x14a5a573b275d435,
1302            fidl::encoding::DynamicFlags::empty(),
1303        )
1304    }
1305}
1306
1307#[must_use = "FIDL methods require a response to be sent"]
1308#[derive(Debug)]
1309pub struct PartitionGetNameResponder {
1310    control_handle: std::mem::ManuallyDrop<PartitionControlHandle>,
1311    tx_id: u32,
1312}
1313
1314/// Set the the channel to be shutdown (see [`PartitionControlHandle::shutdown`])
1315/// if the responder is dropped without sending a response, so that the client
1316/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1317impl std::ops::Drop for PartitionGetNameResponder {
1318    fn drop(&mut self) {
1319        self.control_handle.shutdown();
1320        // Safety: drops once, never accessed again
1321        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1322    }
1323}
1324
1325impl fidl::endpoints::Responder for PartitionGetNameResponder {
1326    type ControlHandle = PartitionControlHandle;
1327
1328    fn control_handle(&self) -> &PartitionControlHandle {
1329        &self.control_handle
1330    }
1331
1332    fn drop_without_shutdown(mut self) {
1333        // Safety: drops once, never accessed again due to mem::forget
1334        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1335        // Prevent Drop from running (which would shut down the channel)
1336        std::mem::forget(self);
1337    }
1338}
1339
1340impl PartitionGetNameResponder {
1341    /// Sends a response to the FIDL transaction.
1342    ///
1343    /// Sets the channel to shutdown if an error occurs.
1344    pub fn send(self, mut status: i32, mut name: Option<&str>) -> Result<(), fidl::Error> {
1345        let _result = self.send_raw(status, name);
1346        if _result.is_err() {
1347            self.control_handle.shutdown();
1348        }
1349        self.drop_without_shutdown();
1350        _result
1351    }
1352
1353    /// Similar to "send" but does not shutdown the channel if an error occurs.
1354    pub fn send_no_shutdown_on_err(
1355        self,
1356        mut status: i32,
1357        mut name: Option<&str>,
1358    ) -> Result<(), fidl::Error> {
1359        let _result = self.send_raw(status, name);
1360        self.drop_without_shutdown();
1361        _result
1362    }
1363
1364    fn send_raw(&self, mut status: i32, mut name: Option<&str>) -> Result<(), fidl::Error> {
1365        self.control_handle.inner.send::<PartitionGetNameResponse>(
1366            (status, name),
1367            self.tx_id,
1368            0x7e3c6f0b0937fc02,
1369            fidl::encoding::DynamicFlags::empty(),
1370        )
1371    }
1372}
1373
1374#[must_use = "FIDL methods require a response to be sent"]
1375#[derive(Debug)]
1376pub struct PartitionGetMetadataResponder {
1377    control_handle: std::mem::ManuallyDrop<PartitionControlHandle>,
1378    tx_id: u32,
1379}
1380
1381/// Set the the channel to be shutdown (see [`PartitionControlHandle::shutdown`])
1382/// if the responder is dropped without sending a response, so that the client
1383/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1384impl std::ops::Drop for PartitionGetMetadataResponder {
1385    fn drop(&mut self) {
1386        self.control_handle.shutdown();
1387        // Safety: drops once, never accessed again
1388        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1389    }
1390}
1391
1392impl fidl::endpoints::Responder for PartitionGetMetadataResponder {
1393    type ControlHandle = PartitionControlHandle;
1394
1395    fn control_handle(&self) -> &PartitionControlHandle {
1396        &self.control_handle
1397    }
1398
1399    fn drop_without_shutdown(mut self) {
1400        // Safety: drops once, never accessed again due to mem::forget
1401        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1402        // Prevent Drop from running (which would shut down the channel)
1403        std::mem::forget(self);
1404    }
1405}
1406
1407impl PartitionGetMetadataResponder {
1408    /// Sends a response to the FIDL transaction.
1409    ///
1410    /// Sets the channel to shutdown if an error occurs.
1411    pub fn send(
1412        self,
1413        mut result: Result<&PartitionGetMetadataResponse, i32>,
1414    ) -> Result<(), fidl::Error> {
1415        let _result = self.send_raw(result);
1416        if _result.is_err() {
1417            self.control_handle.shutdown();
1418        }
1419        self.drop_without_shutdown();
1420        _result
1421    }
1422
1423    /// Similar to "send" but does not shutdown the channel if an error occurs.
1424    pub fn send_no_shutdown_on_err(
1425        self,
1426        mut result: Result<&PartitionGetMetadataResponse, i32>,
1427    ) -> Result<(), fidl::Error> {
1428        let _result = self.send_raw(result);
1429        self.drop_without_shutdown();
1430        _result
1431    }
1432
1433    fn send_raw(
1434        &self,
1435        mut result: Result<&PartitionGetMetadataResponse, i32>,
1436    ) -> Result<(), fidl::Error> {
1437        self.control_handle
1438            .inner
1439            .send::<fidl::encoding::ResultType<PartitionGetMetadataResponse, i32>>(
1440                result,
1441                self.tx_id,
1442                0x42d1464c96c3f3ff,
1443                fidl::encoding::DynamicFlags::empty(),
1444            )
1445    }
1446}
1447
1448mod internal {
1449    use super::*;
1450}