fidl_fuchsia_hardware_block_driver/
fidl_fuchsia_hardware_block_driver.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_hardware_block_driver__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14/// `READ`, `WRITE`
15#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
16pub struct BlockReadWrite {
17    /// Opcode and flags.
18    pub command: BlockCommand,
19    /// Available for temporary use.
20    pub extra: u32,
21    /// VMO of data to read or write.
22    pub vmo: fidl::Vmo,
23    /// Transfer length in blocks (0 is invalid).
24    pub length: u32,
25    /// Device offset in blocks.
26    pub offset_dev: u64,
27    /// VMO offset in blocks.
28    pub offset_vmo: u64,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlockReadWrite {}
32
33#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
34pub struct CommonQueueRequest {
35    pub txn: BlockOp,
36}
37
38impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CommonQueueRequest {}
39
40#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
41pub struct CommonQueueResponse {
42    pub status: i32,
43    pub op: BlockOp,
44}
45
46impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CommonQueueResponse {}
47
48#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
49pub enum BlockOp {
50    /// All Commands
51    Command(BlockCommand),
52    /// Read and Write ops use rw for parameters.
53    Rw(BlockReadWrite),
54    Trim(BlockTrim),
55}
56
57impl BlockOp {
58    #[inline]
59    pub fn ordinal(&self) -> u64 {
60        match *self {
61            Self::Command(_) => 1,
62            Self::Rw(_) => 2,
63            Self::Trim(_) => 3,
64        }
65    }
66}
67
68impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlockOp {}
69
70#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
71pub struct CommonMarker;
72
73impl fidl::endpoints::ProtocolMarker for CommonMarker {
74    type Proxy = CommonProxy;
75    type RequestStream = CommonRequestStream;
76    #[cfg(target_os = "fuchsia")]
77    type SynchronousProxy = CommonSynchronousProxy;
78
79    const DEBUG_NAME: &'static str = "(anonymous) Common";
80}
81
82pub trait CommonProxyInterface: Send + Sync {
83    type QueryResponseFut: std::future::Future<
84            Output = Result<(fidl_fuchsia_hardware_block::BlockInfo, u64), fidl::Error>,
85        > + Send;
86    fn r#query(&self) -> Self::QueryResponseFut;
87    type QueueResponseFut: std::future::Future<Output = Result<(i32, BlockOp), fidl::Error>> + Send;
88    fn r#queue(&self, txn: BlockOp) -> Self::QueueResponseFut;
89}
90#[derive(Debug)]
91#[cfg(target_os = "fuchsia")]
92pub struct CommonSynchronousProxy {
93    client: fidl::client::sync::Client,
94}
95
96#[cfg(target_os = "fuchsia")]
97impl fidl::endpoints::SynchronousProxy for CommonSynchronousProxy {
98    type Proxy = CommonProxy;
99    type Protocol = CommonMarker;
100
101    fn from_channel(inner: fidl::Channel) -> Self {
102        Self::new(inner)
103    }
104
105    fn into_channel(self) -> fidl::Channel {
106        self.client.into_channel()
107    }
108
109    fn as_channel(&self) -> &fidl::Channel {
110        self.client.as_channel()
111    }
112}
113
114#[cfg(target_os = "fuchsia")]
115impl CommonSynchronousProxy {
116    pub fn new(channel: fidl::Channel) -> Self {
117        let protocol_name = <CommonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
118        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
119    }
120
121    pub fn into_channel(self) -> fidl::Channel {
122        self.client.into_channel()
123    }
124
125    /// Waits until an event arrives and returns it. It is safe for other
126    /// threads to make concurrent requests while waiting for an event.
127    pub fn wait_for_event(
128        &self,
129        deadline: zx::MonotonicInstant,
130    ) -> Result<CommonEvent, fidl::Error> {
131        CommonEvent::decode(self.client.wait_for_event(deadline)?)
132    }
133
134    /// Obtains the parameters of the block device (`block_info_t`) and the
135    /// required size of `block_txn_t`. The `block_txn_t`s submitted via
136    /// `Queue()` must have `block_op_size_out - sizeof(block_op_t)` bytes
137    /// available at the end of the structure for the use of the driver.
138    pub fn r#query(
139        &self,
140        ___deadline: zx::MonotonicInstant,
141    ) -> Result<(fidl_fuchsia_hardware_block::BlockInfo, u64), fidl::Error> {
142        let _response =
143            self.client.send_query::<fidl::encoding::EmptyPayload, CommonQueryResponse>(
144                (),
145                0x1551192b715c20b0,
146                fidl::encoding::DynamicFlags::empty(),
147                ___deadline,
148            )?;
149        Ok((_response.info, _response.block_op_size))
150    }
151
152    /// Submits an I/O request for processing. Ownership of `op` is transferred
153    /// to callee until `completion_cb` is invoked. Success or failure will be
154    /// reported via the `completion_cb`. This callback may be called before the
155    /// `Queue()` method returns.
156    pub fn r#queue(
157        &self,
158        mut txn: BlockOp,
159        ___deadline: zx::MonotonicInstant,
160    ) -> Result<(i32, BlockOp), fidl::Error> {
161        let _response = self.client.send_query::<CommonQueueRequest, CommonQueueResponse>(
162            (&mut txn,),
163            0x4d57f58df2b01c6a,
164            fidl::encoding::DynamicFlags::empty(),
165            ___deadline,
166        )?;
167        Ok((_response.status, _response.op))
168    }
169}
170
171#[cfg(target_os = "fuchsia")]
172impl From<CommonSynchronousProxy> for zx::Handle {
173    fn from(value: CommonSynchronousProxy) -> Self {
174        value.into_channel().into()
175    }
176}
177
178#[cfg(target_os = "fuchsia")]
179impl From<fidl::Channel> for CommonSynchronousProxy {
180    fn from(value: fidl::Channel) -> Self {
181        Self::new(value)
182    }
183}
184
185#[cfg(target_os = "fuchsia")]
186impl fidl::endpoints::FromClient for CommonSynchronousProxy {
187    type Protocol = CommonMarker;
188
189    fn from_client(value: fidl::endpoints::ClientEnd<CommonMarker>) -> Self {
190        Self::new(value.into_channel())
191    }
192}
193
194#[derive(Debug, Clone)]
195pub struct CommonProxy {
196    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
197}
198
199impl fidl::endpoints::Proxy for CommonProxy {
200    type Protocol = CommonMarker;
201
202    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
203        Self::new(inner)
204    }
205
206    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
207        self.client.into_channel().map_err(|client| Self { client })
208    }
209
210    fn as_channel(&self) -> &::fidl::AsyncChannel {
211        self.client.as_channel()
212    }
213}
214
215impl CommonProxy {
216    /// Create a new Proxy for fuchsia.hardware.block.driver/Common.
217    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
218        let protocol_name = <CommonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
219        Self { client: fidl::client::Client::new(channel, protocol_name) }
220    }
221
222    /// Get a Stream of events from the remote end of the protocol.
223    ///
224    /// # Panics
225    ///
226    /// Panics if the event stream was already taken.
227    pub fn take_event_stream(&self) -> CommonEventStream {
228        CommonEventStream { event_receiver: self.client.take_event_receiver() }
229    }
230
231    /// Obtains the parameters of the block device (`block_info_t`) and the
232    /// required size of `block_txn_t`. The `block_txn_t`s submitted via
233    /// `Queue()` must have `block_op_size_out - sizeof(block_op_t)` bytes
234    /// available at the end of the structure for the use of the driver.
235    pub fn r#query(
236        &self,
237    ) -> fidl::client::QueryResponseFut<
238        (fidl_fuchsia_hardware_block::BlockInfo, u64),
239        fidl::encoding::DefaultFuchsiaResourceDialect,
240    > {
241        CommonProxyInterface::r#query(self)
242    }
243
244    /// Submits an I/O request for processing. Ownership of `op` is transferred
245    /// to callee until `completion_cb` is invoked. Success or failure will be
246    /// reported via the `completion_cb`. This callback may be called before the
247    /// `Queue()` method returns.
248    pub fn r#queue(
249        &self,
250        mut txn: BlockOp,
251    ) -> fidl::client::QueryResponseFut<(i32, BlockOp), fidl::encoding::DefaultFuchsiaResourceDialect>
252    {
253        CommonProxyInterface::r#queue(self, txn)
254    }
255}
256
257impl CommonProxyInterface for CommonProxy {
258    type QueryResponseFut = fidl::client::QueryResponseFut<
259        (fidl_fuchsia_hardware_block::BlockInfo, u64),
260        fidl::encoding::DefaultFuchsiaResourceDialect,
261    >;
262    fn r#query(&self) -> Self::QueryResponseFut {
263        fn _decode(
264            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
265        ) -> Result<(fidl_fuchsia_hardware_block::BlockInfo, u64), fidl::Error> {
266            let _response = fidl::client::decode_transaction_body::<
267                CommonQueryResponse,
268                fidl::encoding::DefaultFuchsiaResourceDialect,
269                0x1551192b715c20b0,
270            >(_buf?)?;
271            Ok((_response.info, _response.block_op_size))
272        }
273        self.client.send_query_and_decode::<
274            fidl::encoding::EmptyPayload,
275            (fidl_fuchsia_hardware_block::BlockInfo, u64),
276        >(
277            (),
278            0x1551192b715c20b0,
279            fidl::encoding::DynamicFlags::empty(),
280            _decode,
281        )
282    }
283
284    type QueueResponseFut = fidl::client::QueryResponseFut<
285        (i32, BlockOp),
286        fidl::encoding::DefaultFuchsiaResourceDialect,
287    >;
288    fn r#queue(&self, mut txn: BlockOp) -> Self::QueueResponseFut {
289        fn _decode(
290            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
291        ) -> Result<(i32, BlockOp), fidl::Error> {
292            let _response = fidl::client::decode_transaction_body::<
293                CommonQueueResponse,
294                fidl::encoding::DefaultFuchsiaResourceDialect,
295                0x4d57f58df2b01c6a,
296            >(_buf?)?;
297            Ok((_response.status, _response.op))
298        }
299        self.client.send_query_and_decode::<CommonQueueRequest, (i32, BlockOp)>(
300            (&mut txn,),
301            0x4d57f58df2b01c6a,
302            fidl::encoding::DynamicFlags::empty(),
303            _decode,
304        )
305    }
306}
307
308pub struct CommonEventStream {
309    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
310}
311
312impl std::marker::Unpin for CommonEventStream {}
313
314impl futures::stream::FusedStream for CommonEventStream {
315    fn is_terminated(&self) -> bool {
316        self.event_receiver.is_terminated()
317    }
318}
319
320impl futures::Stream for CommonEventStream {
321    type Item = Result<CommonEvent, fidl::Error>;
322
323    fn poll_next(
324        mut self: std::pin::Pin<&mut Self>,
325        cx: &mut std::task::Context<'_>,
326    ) -> std::task::Poll<Option<Self::Item>> {
327        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
328            &mut self.event_receiver,
329            cx
330        )?) {
331            Some(buf) => std::task::Poll::Ready(Some(CommonEvent::decode(buf))),
332            None => std::task::Poll::Ready(None),
333        }
334    }
335}
336
337#[derive(Debug)]
338pub enum CommonEvent {}
339
340impl CommonEvent {
341    /// Decodes a message buffer as a [`CommonEvent`].
342    fn decode(
343        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
344    ) -> Result<CommonEvent, fidl::Error> {
345        let (bytes, _handles) = buf.split_mut();
346        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
347        debug_assert_eq!(tx_header.tx_id, 0);
348        match tx_header.ordinal {
349            _ => Err(fidl::Error::UnknownOrdinal {
350                ordinal: tx_header.ordinal,
351                protocol_name: <CommonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
352            }),
353        }
354    }
355}
356
357/// A Stream of incoming requests for fuchsia.hardware.block.driver/Common.
358pub struct CommonRequestStream {
359    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
360    is_terminated: bool,
361}
362
363impl std::marker::Unpin for CommonRequestStream {}
364
365impl futures::stream::FusedStream for CommonRequestStream {
366    fn is_terminated(&self) -> bool {
367        self.is_terminated
368    }
369}
370
371impl fidl::endpoints::RequestStream for CommonRequestStream {
372    type Protocol = CommonMarker;
373    type ControlHandle = CommonControlHandle;
374
375    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
376        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
377    }
378
379    fn control_handle(&self) -> Self::ControlHandle {
380        CommonControlHandle { inner: self.inner.clone() }
381    }
382
383    fn into_inner(
384        self,
385    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
386    {
387        (self.inner, self.is_terminated)
388    }
389
390    fn from_inner(
391        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
392        is_terminated: bool,
393    ) -> Self {
394        Self { inner, is_terminated }
395    }
396}
397
398impl futures::Stream for CommonRequestStream {
399    type Item = Result<CommonRequest, fidl::Error>;
400
401    fn poll_next(
402        mut self: std::pin::Pin<&mut Self>,
403        cx: &mut std::task::Context<'_>,
404    ) -> std::task::Poll<Option<Self::Item>> {
405        let this = &mut *self;
406        if this.inner.check_shutdown(cx) {
407            this.is_terminated = true;
408            return std::task::Poll::Ready(None);
409        }
410        if this.is_terminated {
411            panic!("polled CommonRequestStream after completion");
412        }
413        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
414            |bytes, handles| {
415                match this.inner.channel().read_etc(cx, bytes, handles) {
416                    std::task::Poll::Ready(Ok(())) => {}
417                    std::task::Poll::Pending => return std::task::Poll::Pending,
418                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
419                        this.is_terminated = true;
420                        return std::task::Poll::Ready(None);
421                    }
422                    std::task::Poll::Ready(Err(e)) => {
423                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
424                            e.into(),
425                        ))))
426                    }
427                }
428
429                // A message has been received from the channel
430                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
431
432                std::task::Poll::Ready(Some(match header.ordinal {
433                    0x1551192b715c20b0 => {
434                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
435                        let mut req = fidl::new_empty!(
436                            fidl::encoding::EmptyPayload,
437                            fidl::encoding::DefaultFuchsiaResourceDialect
438                        );
439                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
440                        let control_handle = CommonControlHandle { inner: this.inner.clone() };
441                        Ok(CommonRequest::Query {
442                            responder: CommonQueryResponder {
443                                control_handle: std::mem::ManuallyDrop::new(control_handle),
444                                tx_id: header.tx_id,
445                            },
446                        })
447                    }
448                    0x4d57f58df2b01c6a => {
449                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
450                        let mut req = fidl::new_empty!(
451                            CommonQueueRequest,
452                            fidl::encoding::DefaultFuchsiaResourceDialect
453                        );
454                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CommonQueueRequest>(&header, _body_bytes, handles, &mut req)?;
455                        let control_handle = CommonControlHandle { inner: this.inner.clone() };
456                        Ok(CommonRequest::Queue {
457                            txn: req.txn,
458
459                            responder: CommonQueueResponder {
460                                control_handle: std::mem::ManuallyDrop::new(control_handle),
461                                tx_id: header.tx_id,
462                            },
463                        })
464                    }
465                    _ => Err(fidl::Error::UnknownOrdinal {
466                        ordinal: header.ordinal,
467                        protocol_name:
468                            <CommonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
469                    }),
470                }))
471            },
472        )
473    }
474}
475
476#[derive(Debug)]
477pub enum CommonRequest {
478    /// Obtains the parameters of the block device (`block_info_t`) and the
479    /// required size of `block_txn_t`. The `block_txn_t`s submitted via
480    /// `Queue()` must have `block_op_size_out - sizeof(block_op_t)` bytes
481    /// available at the end of the structure for the use of the driver.
482    Query { responder: CommonQueryResponder },
483    /// Submits an I/O request for processing. Ownership of `op` is transferred
484    /// to callee until `completion_cb` is invoked. Success or failure will be
485    /// reported via the `completion_cb`. This callback may be called before the
486    /// `Queue()` method returns.
487    Queue { txn: BlockOp, responder: CommonQueueResponder },
488}
489
490impl CommonRequest {
491    #[allow(irrefutable_let_patterns)]
492    pub fn into_query(self) -> Option<(CommonQueryResponder)> {
493        if let CommonRequest::Query { responder } = self {
494            Some((responder))
495        } else {
496            None
497        }
498    }
499
500    #[allow(irrefutable_let_patterns)]
501    pub fn into_queue(self) -> Option<(BlockOp, CommonQueueResponder)> {
502        if let CommonRequest::Queue { txn, responder } = self {
503            Some((txn, responder))
504        } else {
505            None
506        }
507    }
508
509    /// Name of the method defined in FIDL
510    pub fn method_name(&self) -> &'static str {
511        match *self {
512            CommonRequest::Query { .. } => "query",
513            CommonRequest::Queue { .. } => "queue",
514        }
515    }
516}
517
518#[derive(Debug, Clone)]
519pub struct CommonControlHandle {
520    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
521}
522
523impl fidl::endpoints::ControlHandle for CommonControlHandle {
524    fn shutdown(&self) {
525        self.inner.shutdown()
526    }
527    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
528        self.inner.shutdown_with_epitaph(status)
529    }
530
531    fn is_closed(&self) -> bool {
532        self.inner.channel().is_closed()
533    }
534    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
535        self.inner.channel().on_closed()
536    }
537
538    #[cfg(target_os = "fuchsia")]
539    fn signal_peer(
540        &self,
541        clear_mask: zx::Signals,
542        set_mask: zx::Signals,
543    ) -> Result<(), zx_status::Status> {
544        use fidl::Peered;
545        self.inner.channel().signal_peer(clear_mask, set_mask)
546    }
547}
548
549impl CommonControlHandle {}
550
551#[must_use = "FIDL methods require a response to be sent"]
552#[derive(Debug)]
553pub struct CommonQueryResponder {
554    control_handle: std::mem::ManuallyDrop<CommonControlHandle>,
555    tx_id: u32,
556}
557
558/// Set the the channel to be shutdown (see [`CommonControlHandle::shutdown`])
559/// if the responder is dropped without sending a response, so that the client
560/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
561impl std::ops::Drop for CommonQueryResponder {
562    fn drop(&mut self) {
563        self.control_handle.shutdown();
564        // Safety: drops once, never accessed again
565        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
566    }
567}
568
569impl fidl::endpoints::Responder for CommonQueryResponder {
570    type ControlHandle = CommonControlHandle;
571
572    fn control_handle(&self) -> &CommonControlHandle {
573        &self.control_handle
574    }
575
576    fn drop_without_shutdown(mut self) {
577        // Safety: drops once, never accessed again due to mem::forget
578        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
579        // Prevent Drop from running (which would shut down the channel)
580        std::mem::forget(self);
581    }
582}
583
584impl CommonQueryResponder {
585    /// Sends a response to the FIDL transaction.
586    ///
587    /// Sets the channel to shutdown if an error occurs.
588    pub fn send(
589        self,
590        mut info: &fidl_fuchsia_hardware_block::BlockInfo,
591        mut block_op_size: u64,
592    ) -> Result<(), fidl::Error> {
593        let _result = self.send_raw(info, block_op_size);
594        if _result.is_err() {
595            self.control_handle.shutdown();
596        }
597        self.drop_without_shutdown();
598        _result
599    }
600
601    /// Similar to "send" but does not shutdown the channel if an error occurs.
602    pub fn send_no_shutdown_on_err(
603        self,
604        mut info: &fidl_fuchsia_hardware_block::BlockInfo,
605        mut block_op_size: u64,
606    ) -> Result<(), fidl::Error> {
607        let _result = self.send_raw(info, block_op_size);
608        self.drop_without_shutdown();
609        _result
610    }
611
612    fn send_raw(
613        &self,
614        mut info: &fidl_fuchsia_hardware_block::BlockInfo,
615        mut block_op_size: u64,
616    ) -> Result<(), fidl::Error> {
617        self.control_handle.inner.send::<CommonQueryResponse>(
618            (info, block_op_size),
619            self.tx_id,
620            0x1551192b715c20b0,
621            fidl::encoding::DynamicFlags::empty(),
622        )
623    }
624}
625
626#[must_use = "FIDL methods require a response to be sent"]
627#[derive(Debug)]
628pub struct CommonQueueResponder {
629    control_handle: std::mem::ManuallyDrop<CommonControlHandle>,
630    tx_id: u32,
631}
632
633/// Set the the channel to be shutdown (see [`CommonControlHandle::shutdown`])
634/// if the responder is dropped without sending a response, so that the client
635/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
636impl std::ops::Drop for CommonQueueResponder {
637    fn drop(&mut self) {
638        self.control_handle.shutdown();
639        // Safety: drops once, never accessed again
640        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
641    }
642}
643
644impl fidl::endpoints::Responder for CommonQueueResponder {
645    type ControlHandle = CommonControlHandle;
646
647    fn control_handle(&self) -> &CommonControlHandle {
648        &self.control_handle
649    }
650
651    fn drop_without_shutdown(mut self) {
652        // Safety: drops once, never accessed again due to mem::forget
653        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
654        // Prevent Drop from running (which would shut down the channel)
655        std::mem::forget(self);
656    }
657}
658
659impl CommonQueueResponder {
660    /// Sends a response to the FIDL transaction.
661    ///
662    /// Sets the channel to shutdown if an error occurs.
663    pub fn send(self, mut status: i32, mut op: BlockOp) -> Result<(), fidl::Error> {
664        let _result = self.send_raw(status, op);
665        if _result.is_err() {
666            self.control_handle.shutdown();
667        }
668        self.drop_without_shutdown();
669        _result
670    }
671
672    /// Similar to "send" but does not shutdown the channel if an error occurs.
673    pub fn send_no_shutdown_on_err(
674        self,
675        mut status: i32,
676        mut op: BlockOp,
677    ) -> Result<(), fidl::Error> {
678        let _result = self.send_raw(status, op);
679        self.drop_without_shutdown();
680        _result
681    }
682
683    fn send_raw(&self, mut status: i32, mut op: BlockOp) -> Result<(), fidl::Error> {
684        self.control_handle.inner.send::<CommonQueueResponse>(
685            (status, &mut op),
686            self.tx_id,
687            0x4d57f58df2b01c6a,
688            fidl::encoding::DynamicFlags::empty(),
689        )
690    }
691}
692
693mod internal {
694    use super::*;
695
696    impl fidl::encoding::ResourceTypeMarker for BlockReadWrite {
697        type Borrowed<'a> = &'a mut Self;
698        fn take_or_borrow<'a>(
699            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
700        ) -> Self::Borrowed<'a> {
701            value
702        }
703    }
704
705    unsafe impl fidl::encoding::TypeMarker for BlockReadWrite {
706        type Owned = Self;
707
708        #[inline(always)]
709        fn inline_align(_context: fidl::encoding::Context) -> usize {
710            8
711        }
712
713        #[inline(always)]
714        fn inline_size(_context: fidl::encoding::Context) -> usize {
715            40
716        }
717    }
718
719    unsafe impl
720        fidl::encoding::Encode<BlockReadWrite, fidl::encoding::DefaultFuchsiaResourceDialect>
721        for &mut BlockReadWrite
722    {
723        #[inline]
724        unsafe fn encode(
725            self,
726            encoder: &mut fidl::encoding::Encoder<
727                '_,
728                fidl::encoding::DefaultFuchsiaResourceDialect,
729            >,
730            offset: usize,
731            _depth: fidl::encoding::Depth,
732        ) -> fidl::Result<()> {
733            encoder.debug_check_bounds::<BlockReadWrite>(offset);
734            // Delegate to tuple encoding.
735            fidl::encoding::Encode::<BlockReadWrite, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
736                (
737                    <BlockCommand as fidl::encoding::ValueTypeMarker>::borrow(&self.command),
738                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.extra),
739                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
740                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.length),
741                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.offset_dev),
742                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.offset_vmo),
743                ),
744                encoder, offset, _depth
745            )
746        }
747    }
748    unsafe impl<
749            T0: fidl::encoding::Encode<BlockCommand, fidl::encoding::DefaultFuchsiaResourceDialect>,
750            T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
751            T2: fidl::encoding::Encode<
752                fidl::encoding::HandleType<
753                    fidl::Vmo,
754                    { fidl::ObjectType::VMO.into_raw() },
755                    2147483648,
756                >,
757                fidl::encoding::DefaultFuchsiaResourceDialect,
758            >,
759            T3: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
760            T4: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
761            T5: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
762        > fidl::encoding::Encode<BlockReadWrite, fidl::encoding::DefaultFuchsiaResourceDialect>
763        for (T0, T1, T2, T3, T4, T5)
764    {
765        #[inline]
766        unsafe fn encode(
767            self,
768            encoder: &mut fidl::encoding::Encoder<
769                '_,
770                fidl::encoding::DefaultFuchsiaResourceDialect,
771            >,
772            offset: usize,
773            depth: fidl::encoding::Depth,
774        ) -> fidl::Result<()> {
775            encoder.debug_check_bounds::<BlockReadWrite>(offset);
776            // Zero out padding regions. There's no need to apply masks
777            // because the unmasked parts will be overwritten by fields.
778            unsafe {
779                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
780                (ptr as *mut u64).write_unaligned(0);
781            }
782            // Write the fields.
783            self.0.encode(encoder, offset + 0, depth)?;
784            self.1.encode(encoder, offset + 8, depth)?;
785            self.2.encode(encoder, offset + 12, depth)?;
786            self.3.encode(encoder, offset + 16, depth)?;
787            self.4.encode(encoder, offset + 24, depth)?;
788            self.5.encode(encoder, offset + 32, depth)?;
789            Ok(())
790        }
791    }
792
793    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
794        for BlockReadWrite
795    {
796        #[inline(always)]
797        fn new_empty() -> Self {
798            Self {
799                command: fidl::new_empty!(
800                    BlockCommand,
801                    fidl::encoding::DefaultFuchsiaResourceDialect
802                ),
803                extra: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
804                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
805                length: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
806                offset_dev: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
807                offset_vmo: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
808            }
809        }
810
811        #[inline]
812        unsafe fn decode(
813            &mut self,
814            decoder: &mut fidl::encoding::Decoder<
815                '_,
816                fidl::encoding::DefaultFuchsiaResourceDialect,
817            >,
818            offset: usize,
819            _depth: fidl::encoding::Depth,
820        ) -> fidl::Result<()> {
821            decoder.debug_check_bounds::<Self>(offset);
822            // Verify that padding bytes are zero.
823            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
824            let padval = unsafe { (ptr as *const u64).read_unaligned() };
825            let mask = 0xffffffff00000000u64;
826            let maskedval = padval & mask;
827            if maskedval != 0 {
828                return Err(fidl::Error::NonZeroPadding {
829                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
830                });
831            }
832            fidl::decode!(
833                BlockCommand,
834                fidl::encoding::DefaultFuchsiaResourceDialect,
835                &mut self.command,
836                decoder,
837                offset + 0,
838                _depth
839            )?;
840            fidl::decode!(
841                u32,
842                fidl::encoding::DefaultFuchsiaResourceDialect,
843                &mut self.extra,
844                decoder,
845                offset + 8,
846                _depth
847            )?;
848            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 12, _depth)?;
849            fidl::decode!(
850                u32,
851                fidl::encoding::DefaultFuchsiaResourceDialect,
852                &mut self.length,
853                decoder,
854                offset + 16,
855                _depth
856            )?;
857            fidl::decode!(
858                u64,
859                fidl::encoding::DefaultFuchsiaResourceDialect,
860                &mut self.offset_dev,
861                decoder,
862                offset + 24,
863                _depth
864            )?;
865            fidl::decode!(
866                u64,
867                fidl::encoding::DefaultFuchsiaResourceDialect,
868                &mut self.offset_vmo,
869                decoder,
870                offset + 32,
871                _depth
872            )?;
873            Ok(())
874        }
875    }
876
877    impl fidl::encoding::ResourceTypeMarker for CommonQueueRequest {
878        type Borrowed<'a> = &'a mut Self;
879        fn take_or_borrow<'a>(
880            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
881        ) -> Self::Borrowed<'a> {
882            value
883        }
884    }
885
886    unsafe impl fidl::encoding::TypeMarker for CommonQueueRequest {
887        type Owned = Self;
888
889        #[inline(always)]
890        fn inline_align(_context: fidl::encoding::Context) -> usize {
891            8
892        }
893
894        #[inline(always)]
895        fn inline_size(_context: fidl::encoding::Context) -> usize {
896            16
897        }
898    }
899
900    unsafe impl
901        fidl::encoding::Encode<CommonQueueRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
902        for &mut CommonQueueRequest
903    {
904        #[inline]
905        unsafe fn encode(
906            self,
907            encoder: &mut fidl::encoding::Encoder<
908                '_,
909                fidl::encoding::DefaultFuchsiaResourceDialect,
910            >,
911            offset: usize,
912            _depth: fidl::encoding::Depth,
913        ) -> fidl::Result<()> {
914            encoder.debug_check_bounds::<CommonQueueRequest>(offset);
915            // Delegate to tuple encoding.
916            fidl::encoding::Encode::<
917                CommonQueueRequest,
918                fidl::encoding::DefaultFuchsiaResourceDialect,
919            >::encode(
920                (<BlockOp as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.txn),),
921                encoder,
922                offset,
923                _depth,
924            )
925        }
926    }
927    unsafe impl<T0: fidl::encoding::Encode<BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect>>
928        fidl::encoding::Encode<CommonQueueRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
929        for (T0,)
930    {
931        #[inline]
932        unsafe fn encode(
933            self,
934            encoder: &mut fidl::encoding::Encoder<
935                '_,
936                fidl::encoding::DefaultFuchsiaResourceDialect,
937            >,
938            offset: usize,
939            depth: fidl::encoding::Depth,
940        ) -> fidl::Result<()> {
941            encoder.debug_check_bounds::<CommonQueueRequest>(offset);
942            // Zero out padding regions. There's no need to apply masks
943            // because the unmasked parts will be overwritten by fields.
944            // Write the fields.
945            self.0.encode(encoder, offset + 0, depth)?;
946            Ok(())
947        }
948    }
949
950    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
951        for CommonQueueRequest
952    {
953        #[inline(always)]
954        fn new_empty() -> Self {
955            Self { txn: fidl::new_empty!(BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect) }
956        }
957
958        #[inline]
959        unsafe fn decode(
960            &mut self,
961            decoder: &mut fidl::encoding::Decoder<
962                '_,
963                fidl::encoding::DefaultFuchsiaResourceDialect,
964            >,
965            offset: usize,
966            _depth: fidl::encoding::Depth,
967        ) -> fidl::Result<()> {
968            decoder.debug_check_bounds::<Self>(offset);
969            // Verify that padding bytes are zero.
970            fidl::decode!(
971                BlockOp,
972                fidl::encoding::DefaultFuchsiaResourceDialect,
973                &mut self.txn,
974                decoder,
975                offset + 0,
976                _depth
977            )?;
978            Ok(())
979        }
980    }
981
982    impl fidl::encoding::ResourceTypeMarker for CommonQueueResponse {
983        type Borrowed<'a> = &'a mut Self;
984        fn take_or_borrow<'a>(
985            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
986        ) -> Self::Borrowed<'a> {
987            value
988        }
989    }
990
991    unsafe impl fidl::encoding::TypeMarker for CommonQueueResponse {
992        type Owned = Self;
993
994        #[inline(always)]
995        fn inline_align(_context: fidl::encoding::Context) -> usize {
996            8
997        }
998
999        #[inline(always)]
1000        fn inline_size(_context: fidl::encoding::Context) -> usize {
1001            24
1002        }
1003    }
1004
1005    unsafe impl
1006        fidl::encoding::Encode<CommonQueueResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
1007        for &mut CommonQueueResponse
1008    {
1009        #[inline]
1010        unsafe fn encode(
1011            self,
1012            encoder: &mut fidl::encoding::Encoder<
1013                '_,
1014                fidl::encoding::DefaultFuchsiaResourceDialect,
1015            >,
1016            offset: usize,
1017            _depth: fidl::encoding::Depth,
1018        ) -> fidl::Result<()> {
1019            encoder.debug_check_bounds::<CommonQueueResponse>(offset);
1020            // Delegate to tuple encoding.
1021            fidl::encoding::Encode::<
1022                CommonQueueResponse,
1023                fidl::encoding::DefaultFuchsiaResourceDialect,
1024            >::encode(
1025                (
1026                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
1027                    <BlockOp as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.op),
1028                ),
1029                encoder,
1030                offset,
1031                _depth,
1032            )
1033        }
1034    }
1035    unsafe impl<
1036            T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
1037            T1: fidl::encoding::Encode<BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect>,
1038        >
1039        fidl::encoding::Encode<CommonQueueResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
1040        for (T0, T1)
1041    {
1042        #[inline]
1043        unsafe fn encode(
1044            self,
1045            encoder: &mut fidl::encoding::Encoder<
1046                '_,
1047                fidl::encoding::DefaultFuchsiaResourceDialect,
1048            >,
1049            offset: usize,
1050            depth: fidl::encoding::Depth,
1051        ) -> fidl::Result<()> {
1052            encoder.debug_check_bounds::<CommonQueueResponse>(offset);
1053            // Zero out padding regions. There's no need to apply masks
1054            // because the unmasked parts will be overwritten by fields.
1055            unsafe {
1056                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1057                (ptr as *mut u64).write_unaligned(0);
1058            }
1059            // Write the fields.
1060            self.0.encode(encoder, offset + 0, depth)?;
1061            self.1.encode(encoder, offset + 8, depth)?;
1062            Ok(())
1063        }
1064    }
1065
1066    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1067        for CommonQueueResponse
1068    {
1069        #[inline(always)]
1070        fn new_empty() -> Self {
1071            Self {
1072                status: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
1073                op: fidl::new_empty!(BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect),
1074            }
1075        }
1076
1077        #[inline]
1078        unsafe fn decode(
1079            &mut self,
1080            decoder: &mut fidl::encoding::Decoder<
1081                '_,
1082                fidl::encoding::DefaultFuchsiaResourceDialect,
1083            >,
1084            offset: usize,
1085            _depth: fidl::encoding::Depth,
1086        ) -> fidl::Result<()> {
1087            decoder.debug_check_bounds::<Self>(offset);
1088            // Verify that padding bytes are zero.
1089            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1090            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1091            let mask = 0xffffffff00000000u64;
1092            let maskedval = padval & mask;
1093            if maskedval != 0 {
1094                return Err(fidl::Error::NonZeroPadding {
1095                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1096                });
1097            }
1098            fidl::decode!(
1099                i32,
1100                fidl::encoding::DefaultFuchsiaResourceDialect,
1101                &mut self.status,
1102                decoder,
1103                offset + 0,
1104                _depth
1105            )?;
1106            fidl::decode!(
1107                BlockOp,
1108                fidl::encoding::DefaultFuchsiaResourceDialect,
1109                &mut self.op,
1110                decoder,
1111                offset + 8,
1112                _depth
1113            )?;
1114            Ok(())
1115        }
1116    }
1117
1118    impl fidl::encoding::ResourceTypeMarker for BlockOp {
1119        type Borrowed<'a> = &'a mut Self;
1120        fn take_or_borrow<'a>(
1121            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1122        ) -> Self::Borrowed<'a> {
1123            value
1124        }
1125    }
1126
1127    unsafe impl fidl::encoding::TypeMarker for BlockOp {
1128        type Owned = Self;
1129
1130        #[inline(always)]
1131        fn inline_align(_context: fidl::encoding::Context) -> usize {
1132            8
1133        }
1134
1135        #[inline(always)]
1136        fn inline_size(_context: fidl::encoding::Context) -> usize {
1137            16
1138        }
1139    }
1140
1141    unsafe impl fidl::encoding::Encode<BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect>
1142        for &mut BlockOp
1143    {
1144        #[inline]
1145        unsafe fn encode(
1146            self,
1147            encoder: &mut fidl::encoding::Encoder<
1148                '_,
1149                fidl::encoding::DefaultFuchsiaResourceDialect,
1150            >,
1151            offset: usize,
1152            _depth: fidl::encoding::Depth,
1153        ) -> fidl::Result<()> {
1154            encoder.debug_check_bounds::<BlockOp>(offset);
1155            encoder.write_num::<u64>(self.ordinal(), offset);
1156            match self {
1157                BlockOp::Command(ref val) => fidl::encoding::encode_in_envelope::<
1158                    BlockCommand,
1159                    fidl::encoding::DefaultFuchsiaResourceDialect,
1160                >(
1161                    <BlockCommand as fidl::encoding::ValueTypeMarker>::borrow(val),
1162                    encoder,
1163                    offset + 8,
1164                    _depth,
1165                ),
1166                BlockOp::Rw(ref mut val) => fidl::encoding::encode_in_envelope::<
1167                    BlockReadWrite,
1168                    fidl::encoding::DefaultFuchsiaResourceDialect,
1169                >(
1170                    <BlockReadWrite as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
1171                    encoder,
1172                    offset + 8,
1173                    _depth,
1174                ),
1175                BlockOp::Trim(ref val) => fidl::encoding::encode_in_envelope::<
1176                    BlockTrim,
1177                    fidl::encoding::DefaultFuchsiaResourceDialect,
1178                >(
1179                    <BlockTrim as fidl::encoding::ValueTypeMarker>::borrow(val),
1180                    encoder,
1181                    offset + 8,
1182                    _depth,
1183                ),
1184            }
1185        }
1186    }
1187
1188    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlockOp {
1189        #[inline(always)]
1190        fn new_empty() -> Self {
1191            Self::Command(fidl::new_empty!(
1192                BlockCommand,
1193                fidl::encoding::DefaultFuchsiaResourceDialect
1194            ))
1195        }
1196
1197        #[inline]
1198        unsafe fn decode(
1199            &mut self,
1200            decoder: &mut fidl::encoding::Decoder<
1201                '_,
1202                fidl::encoding::DefaultFuchsiaResourceDialect,
1203            >,
1204            offset: usize,
1205            mut depth: fidl::encoding::Depth,
1206        ) -> fidl::Result<()> {
1207            decoder.debug_check_bounds::<Self>(offset);
1208            #[allow(unused_variables)]
1209            let next_out_of_line = decoder.next_out_of_line();
1210            let handles_before = decoder.remaining_handles();
1211            let (ordinal, inlined, num_bytes, num_handles) =
1212                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1213
1214            let member_inline_size = match ordinal {
1215                1 => <BlockCommand as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1216                2 => <BlockReadWrite as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1217                3 => <BlockTrim as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1218                _ => return Err(fidl::Error::UnknownUnionTag),
1219            };
1220
1221            if inlined != (member_inline_size <= 4) {
1222                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1223            }
1224            let _inner_offset;
1225            if inlined {
1226                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1227                _inner_offset = offset + 8;
1228            } else {
1229                depth.increment()?;
1230                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1231            }
1232            match ordinal {
1233                1 => {
1234                    #[allow(irrefutable_let_patterns)]
1235                    if let BlockOp::Command(_) = self {
1236                        // Do nothing, read the value into the object
1237                    } else {
1238                        // Initialize `self` to the right variant
1239                        *self = BlockOp::Command(fidl::new_empty!(
1240                            BlockCommand,
1241                            fidl::encoding::DefaultFuchsiaResourceDialect
1242                        ));
1243                    }
1244                    #[allow(irrefutable_let_patterns)]
1245                    if let BlockOp::Command(ref mut val) = self {
1246                        fidl::decode!(
1247                            BlockCommand,
1248                            fidl::encoding::DefaultFuchsiaResourceDialect,
1249                            val,
1250                            decoder,
1251                            _inner_offset,
1252                            depth
1253                        )?;
1254                    } else {
1255                        unreachable!()
1256                    }
1257                }
1258                2 => {
1259                    #[allow(irrefutable_let_patterns)]
1260                    if let BlockOp::Rw(_) = self {
1261                        // Do nothing, read the value into the object
1262                    } else {
1263                        // Initialize `self` to the right variant
1264                        *self = BlockOp::Rw(fidl::new_empty!(
1265                            BlockReadWrite,
1266                            fidl::encoding::DefaultFuchsiaResourceDialect
1267                        ));
1268                    }
1269                    #[allow(irrefutable_let_patterns)]
1270                    if let BlockOp::Rw(ref mut val) = self {
1271                        fidl::decode!(
1272                            BlockReadWrite,
1273                            fidl::encoding::DefaultFuchsiaResourceDialect,
1274                            val,
1275                            decoder,
1276                            _inner_offset,
1277                            depth
1278                        )?;
1279                    } else {
1280                        unreachable!()
1281                    }
1282                }
1283                3 => {
1284                    #[allow(irrefutable_let_patterns)]
1285                    if let BlockOp::Trim(_) = self {
1286                        // Do nothing, read the value into the object
1287                    } else {
1288                        // Initialize `self` to the right variant
1289                        *self = BlockOp::Trim(fidl::new_empty!(
1290                            BlockTrim,
1291                            fidl::encoding::DefaultFuchsiaResourceDialect
1292                        ));
1293                    }
1294                    #[allow(irrefutable_let_patterns)]
1295                    if let BlockOp::Trim(ref mut val) = self {
1296                        fidl::decode!(
1297                            BlockTrim,
1298                            fidl::encoding::DefaultFuchsiaResourceDialect,
1299                            val,
1300                            decoder,
1301                            _inner_offset,
1302                            depth
1303                        )?;
1304                    } else {
1305                        unreachable!()
1306                    }
1307                }
1308                ordinal => panic!("unexpected ordinal {:?}", ordinal),
1309            }
1310            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1311                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1312            }
1313            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1314                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1315            }
1316            Ok(())
1317        }
1318    }
1319}