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