fidl_fuchsia_storage_partitions/
fidl_fuchsia_storage_partitions.rs

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