Skip to main content

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