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