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