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 { Some((responder)) } else { None }
494    }
495
496    #[allow(irrefutable_let_patterns)]
497    pub fn into_queue(self) -> Option<(BlockOp, CommonQueueResponder)> {
498        if let CommonRequest::Queue { txn, responder } = self {
499            Some((txn, responder))
500        } else {
501            None
502        }
503    }
504
505    /// Name of the method defined in FIDL
506    pub fn method_name(&self) -> &'static str {
507        match *self {
508            CommonRequest::Query { .. } => "query",
509            CommonRequest::Queue { .. } => "queue",
510        }
511    }
512}
513
514#[derive(Debug, Clone)]
515pub struct CommonControlHandle {
516    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
517}
518
519impl fidl::endpoints::ControlHandle for CommonControlHandle {
520    fn shutdown(&self) {
521        self.inner.shutdown()
522    }
523    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
524        self.inner.shutdown_with_epitaph(status)
525    }
526
527    fn is_closed(&self) -> bool {
528        self.inner.channel().is_closed()
529    }
530    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
531        self.inner.channel().on_closed()
532    }
533
534    #[cfg(target_os = "fuchsia")]
535    fn signal_peer(
536        &self,
537        clear_mask: zx::Signals,
538        set_mask: zx::Signals,
539    ) -> Result<(), zx_status::Status> {
540        use fidl::Peered;
541        self.inner.channel().signal_peer(clear_mask, set_mask)
542    }
543}
544
545impl CommonControlHandle {}
546
547#[must_use = "FIDL methods require a response to be sent"]
548#[derive(Debug)]
549pub struct CommonQueryResponder {
550    control_handle: std::mem::ManuallyDrop<CommonControlHandle>,
551    tx_id: u32,
552}
553
554/// Set the the channel to be shutdown (see [`CommonControlHandle::shutdown`])
555/// if the responder is dropped without sending a response, so that the client
556/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
557impl std::ops::Drop for CommonQueryResponder {
558    fn drop(&mut self) {
559        self.control_handle.shutdown();
560        // Safety: drops once, never accessed again
561        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
562    }
563}
564
565impl fidl::endpoints::Responder for CommonQueryResponder {
566    type ControlHandle = CommonControlHandle;
567
568    fn control_handle(&self) -> &CommonControlHandle {
569        &self.control_handle
570    }
571
572    fn drop_without_shutdown(mut self) {
573        // Safety: drops once, never accessed again due to mem::forget
574        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
575        // Prevent Drop from running (which would shut down the channel)
576        std::mem::forget(self);
577    }
578}
579
580impl CommonQueryResponder {
581    /// Sends a response to the FIDL transaction.
582    ///
583    /// Sets the channel to shutdown if an error occurs.
584    pub fn send(
585        self,
586        mut info: &fidl_fuchsia_hardware_block::BlockInfo,
587        mut block_op_size: u64,
588    ) -> Result<(), fidl::Error> {
589        let _result = self.send_raw(info, block_op_size);
590        if _result.is_err() {
591            self.control_handle.shutdown();
592        }
593        self.drop_without_shutdown();
594        _result
595    }
596
597    /// Similar to "send" but does not shutdown the channel if an error occurs.
598    pub fn send_no_shutdown_on_err(
599        self,
600        mut info: &fidl_fuchsia_hardware_block::BlockInfo,
601        mut block_op_size: u64,
602    ) -> Result<(), fidl::Error> {
603        let _result = self.send_raw(info, block_op_size);
604        self.drop_without_shutdown();
605        _result
606    }
607
608    fn send_raw(
609        &self,
610        mut info: &fidl_fuchsia_hardware_block::BlockInfo,
611        mut block_op_size: u64,
612    ) -> Result<(), fidl::Error> {
613        self.control_handle.inner.send::<CommonQueryResponse>(
614            (info, block_op_size),
615            self.tx_id,
616            0x1551192b715c20b0,
617            fidl::encoding::DynamicFlags::empty(),
618        )
619    }
620}
621
622#[must_use = "FIDL methods require a response to be sent"]
623#[derive(Debug)]
624pub struct CommonQueueResponder {
625    control_handle: std::mem::ManuallyDrop<CommonControlHandle>,
626    tx_id: u32,
627}
628
629/// Set the the channel to be shutdown (see [`CommonControlHandle::shutdown`])
630/// if the responder is dropped without sending a response, so that the client
631/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
632impl std::ops::Drop for CommonQueueResponder {
633    fn drop(&mut self) {
634        self.control_handle.shutdown();
635        // Safety: drops once, never accessed again
636        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
637    }
638}
639
640impl fidl::endpoints::Responder for CommonQueueResponder {
641    type ControlHandle = CommonControlHandle;
642
643    fn control_handle(&self) -> &CommonControlHandle {
644        &self.control_handle
645    }
646
647    fn drop_without_shutdown(mut self) {
648        // Safety: drops once, never accessed again due to mem::forget
649        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
650        // Prevent Drop from running (which would shut down the channel)
651        std::mem::forget(self);
652    }
653}
654
655impl CommonQueueResponder {
656    /// Sends a response to the FIDL transaction.
657    ///
658    /// Sets the channel to shutdown if an error occurs.
659    pub fn send(self, mut status: i32, mut op: BlockOp) -> Result<(), fidl::Error> {
660        let _result = self.send_raw(status, op);
661        if _result.is_err() {
662            self.control_handle.shutdown();
663        }
664        self.drop_without_shutdown();
665        _result
666    }
667
668    /// Similar to "send" but does not shutdown the channel if an error occurs.
669    pub fn send_no_shutdown_on_err(
670        self,
671        mut status: i32,
672        mut op: BlockOp,
673    ) -> Result<(), fidl::Error> {
674        let _result = self.send_raw(status, op);
675        self.drop_without_shutdown();
676        _result
677    }
678
679    fn send_raw(&self, mut status: i32, mut op: BlockOp) -> Result<(), fidl::Error> {
680        self.control_handle.inner.send::<CommonQueueResponse>(
681            (status, &mut op),
682            self.tx_id,
683            0x4d57f58df2b01c6a,
684            fidl::encoding::DynamicFlags::empty(),
685        )
686    }
687}
688
689mod internal {
690    use super::*;
691
692    impl fidl::encoding::ResourceTypeMarker for BlockReadWrite {
693        type Borrowed<'a> = &'a mut Self;
694        fn take_or_borrow<'a>(
695            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
696        ) -> Self::Borrowed<'a> {
697            value
698        }
699    }
700
701    unsafe impl fidl::encoding::TypeMarker for BlockReadWrite {
702        type Owned = Self;
703
704        #[inline(always)]
705        fn inline_align(_context: fidl::encoding::Context) -> usize {
706            8
707        }
708
709        #[inline(always)]
710        fn inline_size(_context: fidl::encoding::Context) -> usize {
711            40
712        }
713    }
714
715    unsafe impl
716        fidl::encoding::Encode<BlockReadWrite, fidl::encoding::DefaultFuchsiaResourceDialect>
717        for &mut BlockReadWrite
718    {
719        #[inline]
720        unsafe fn encode(
721            self,
722            encoder: &mut fidl::encoding::Encoder<
723                '_,
724                fidl::encoding::DefaultFuchsiaResourceDialect,
725            >,
726            offset: usize,
727            _depth: fidl::encoding::Depth,
728        ) -> fidl::Result<()> {
729            encoder.debug_check_bounds::<BlockReadWrite>(offset);
730            // Delegate to tuple encoding.
731            fidl::encoding::Encode::<BlockReadWrite, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
732                (
733                    <BlockCommand as fidl::encoding::ValueTypeMarker>::borrow(&self.command),
734                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.extra),
735                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
736                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.length),
737                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.offset_dev),
738                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.offset_vmo),
739                ),
740                encoder, offset, _depth
741            )
742        }
743    }
744    unsafe impl<
745        T0: fidl::encoding::Encode<BlockCommand, fidl::encoding::DefaultFuchsiaResourceDialect>,
746        T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
747        T2: fidl::encoding::Encode<
748                fidl::encoding::HandleType<
749                    fidl::Vmo,
750                    { fidl::ObjectType::VMO.into_raw() },
751                    2147483648,
752                >,
753                fidl::encoding::DefaultFuchsiaResourceDialect,
754            >,
755        T3: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
756        T4: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
757        T5: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
758    > fidl::encoding::Encode<BlockReadWrite, fidl::encoding::DefaultFuchsiaResourceDialect>
759        for (T0, T1, T2, T3, T4, T5)
760    {
761        #[inline]
762        unsafe fn encode(
763            self,
764            encoder: &mut fidl::encoding::Encoder<
765                '_,
766                fidl::encoding::DefaultFuchsiaResourceDialect,
767            >,
768            offset: usize,
769            depth: fidl::encoding::Depth,
770        ) -> fidl::Result<()> {
771            encoder.debug_check_bounds::<BlockReadWrite>(offset);
772            // Zero out padding regions. There's no need to apply masks
773            // because the unmasked parts will be overwritten by fields.
774            unsafe {
775                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
776                (ptr as *mut u64).write_unaligned(0);
777            }
778            // Write the fields.
779            self.0.encode(encoder, offset + 0, depth)?;
780            self.1.encode(encoder, offset + 8, depth)?;
781            self.2.encode(encoder, offset + 12, depth)?;
782            self.3.encode(encoder, offset + 16, depth)?;
783            self.4.encode(encoder, offset + 24, depth)?;
784            self.5.encode(encoder, offset + 32, depth)?;
785            Ok(())
786        }
787    }
788
789    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
790        for BlockReadWrite
791    {
792        #[inline(always)]
793        fn new_empty() -> Self {
794            Self {
795                command: fidl::new_empty!(
796                    BlockCommand,
797                    fidl::encoding::DefaultFuchsiaResourceDialect
798                ),
799                extra: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
800                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
801                length: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
802                offset_dev: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
803                offset_vmo: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
804            }
805        }
806
807        #[inline]
808        unsafe fn decode(
809            &mut self,
810            decoder: &mut fidl::encoding::Decoder<
811                '_,
812                fidl::encoding::DefaultFuchsiaResourceDialect,
813            >,
814            offset: usize,
815            _depth: fidl::encoding::Depth,
816        ) -> fidl::Result<()> {
817            decoder.debug_check_bounds::<Self>(offset);
818            // Verify that padding bytes are zero.
819            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
820            let padval = unsafe { (ptr as *const u64).read_unaligned() };
821            let mask = 0xffffffff00000000u64;
822            let maskedval = padval & mask;
823            if maskedval != 0 {
824                return Err(fidl::Error::NonZeroPadding {
825                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
826                });
827            }
828            fidl::decode!(
829                BlockCommand,
830                fidl::encoding::DefaultFuchsiaResourceDialect,
831                &mut self.command,
832                decoder,
833                offset + 0,
834                _depth
835            )?;
836            fidl::decode!(
837                u32,
838                fidl::encoding::DefaultFuchsiaResourceDialect,
839                &mut self.extra,
840                decoder,
841                offset + 8,
842                _depth
843            )?;
844            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 12, _depth)?;
845            fidl::decode!(
846                u32,
847                fidl::encoding::DefaultFuchsiaResourceDialect,
848                &mut self.length,
849                decoder,
850                offset + 16,
851                _depth
852            )?;
853            fidl::decode!(
854                u64,
855                fidl::encoding::DefaultFuchsiaResourceDialect,
856                &mut self.offset_dev,
857                decoder,
858                offset + 24,
859                _depth
860            )?;
861            fidl::decode!(
862                u64,
863                fidl::encoding::DefaultFuchsiaResourceDialect,
864                &mut self.offset_vmo,
865                decoder,
866                offset + 32,
867                _depth
868            )?;
869            Ok(())
870        }
871    }
872
873    impl fidl::encoding::ResourceTypeMarker for CommonQueueRequest {
874        type Borrowed<'a> = &'a mut Self;
875        fn take_or_borrow<'a>(
876            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
877        ) -> Self::Borrowed<'a> {
878            value
879        }
880    }
881
882    unsafe impl fidl::encoding::TypeMarker for CommonQueueRequest {
883        type Owned = Self;
884
885        #[inline(always)]
886        fn inline_align(_context: fidl::encoding::Context) -> usize {
887            8
888        }
889
890        #[inline(always)]
891        fn inline_size(_context: fidl::encoding::Context) -> usize {
892            16
893        }
894    }
895
896    unsafe impl
897        fidl::encoding::Encode<CommonQueueRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
898        for &mut CommonQueueRequest
899    {
900        #[inline]
901        unsafe fn encode(
902            self,
903            encoder: &mut fidl::encoding::Encoder<
904                '_,
905                fidl::encoding::DefaultFuchsiaResourceDialect,
906            >,
907            offset: usize,
908            _depth: fidl::encoding::Depth,
909        ) -> fidl::Result<()> {
910            encoder.debug_check_bounds::<CommonQueueRequest>(offset);
911            // Delegate to tuple encoding.
912            fidl::encoding::Encode::<
913                CommonQueueRequest,
914                fidl::encoding::DefaultFuchsiaResourceDialect,
915            >::encode(
916                (<BlockOp as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.txn),),
917                encoder,
918                offset,
919                _depth,
920            )
921        }
922    }
923    unsafe impl<T0: fidl::encoding::Encode<BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect>>
924        fidl::encoding::Encode<CommonQueueRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
925        for (T0,)
926    {
927        #[inline]
928        unsafe fn encode(
929            self,
930            encoder: &mut fidl::encoding::Encoder<
931                '_,
932                fidl::encoding::DefaultFuchsiaResourceDialect,
933            >,
934            offset: usize,
935            depth: fidl::encoding::Depth,
936        ) -> fidl::Result<()> {
937            encoder.debug_check_bounds::<CommonQueueRequest>(offset);
938            // Zero out padding regions. There's no need to apply masks
939            // because the unmasked parts will be overwritten by fields.
940            // Write the fields.
941            self.0.encode(encoder, offset + 0, depth)?;
942            Ok(())
943        }
944    }
945
946    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
947        for CommonQueueRequest
948    {
949        #[inline(always)]
950        fn new_empty() -> Self {
951            Self { txn: fidl::new_empty!(BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect) }
952        }
953
954        #[inline]
955        unsafe fn decode(
956            &mut self,
957            decoder: &mut fidl::encoding::Decoder<
958                '_,
959                fidl::encoding::DefaultFuchsiaResourceDialect,
960            >,
961            offset: usize,
962            _depth: fidl::encoding::Depth,
963        ) -> fidl::Result<()> {
964            decoder.debug_check_bounds::<Self>(offset);
965            // Verify that padding bytes are zero.
966            fidl::decode!(
967                BlockOp,
968                fidl::encoding::DefaultFuchsiaResourceDialect,
969                &mut self.txn,
970                decoder,
971                offset + 0,
972                _depth
973            )?;
974            Ok(())
975        }
976    }
977
978    impl fidl::encoding::ResourceTypeMarker for CommonQueueResponse {
979        type Borrowed<'a> = &'a mut Self;
980        fn take_or_borrow<'a>(
981            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
982        ) -> Self::Borrowed<'a> {
983            value
984        }
985    }
986
987    unsafe impl fidl::encoding::TypeMarker for CommonQueueResponse {
988        type Owned = Self;
989
990        #[inline(always)]
991        fn inline_align(_context: fidl::encoding::Context) -> usize {
992            8
993        }
994
995        #[inline(always)]
996        fn inline_size(_context: fidl::encoding::Context) -> usize {
997            24
998        }
999    }
1000
1001    unsafe impl
1002        fidl::encoding::Encode<CommonQueueResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
1003        for &mut CommonQueueResponse
1004    {
1005        #[inline]
1006        unsafe fn encode(
1007            self,
1008            encoder: &mut fidl::encoding::Encoder<
1009                '_,
1010                fidl::encoding::DefaultFuchsiaResourceDialect,
1011            >,
1012            offset: usize,
1013            _depth: fidl::encoding::Depth,
1014        ) -> fidl::Result<()> {
1015            encoder.debug_check_bounds::<CommonQueueResponse>(offset);
1016            // Delegate to tuple encoding.
1017            fidl::encoding::Encode::<
1018                CommonQueueResponse,
1019                fidl::encoding::DefaultFuchsiaResourceDialect,
1020            >::encode(
1021                (
1022                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
1023                    <BlockOp as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.op),
1024                ),
1025                encoder,
1026                offset,
1027                _depth,
1028            )
1029        }
1030    }
1031    unsafe impl<
1032        T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
1033        T1: fidl::encoding::Encode<BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect>,
1034    > fidl::encoding::Encode<CommonQueueResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
1035        for (T0, T1)
1036    {
1037        #[inline]
1038        unsafe fn encode(
1039            self,
1040            encoder: &mut fidl::encoding::Encoder<
1041                '_,
1042                fidl::encoding::DefaultFuchsiaResourceDialect,
1043            >,
1044            offset: usize,
1045            depth: fidl::encoding::Depth,
1046        ) -> fidl::Result<()> {
1047            encoder.debug_check_bounds::<CommonQueueResponse>(offset);
1048            // Zero out padding regions. There's no need to apply masks
1049            // because the unmasked parts will be overwritten by fields.
1050            unsafe {
1051                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1052                (ptr as *mut u64).write_unaligned(0);
1053            }
1054            // Write the fields.
1055            self.0.encode(encoder, offset + 0, depth)?;
1056            self.1.encode(encoder, offset + 8, depth)?;
1057            Ok(())
1058        }
1059    }
1060
1061    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1062        for CommonQueueResponse
1063    {
1064        #[inline(always)]
1065        fn new_empty() -> Self {
1066            Self {
1067                status: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
1068                op: fidl::new_empty!(BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect),
1069            }
1070        }
1071
1072        #[inline]
1073        unsafe fn decode(
1074            &mut self,
1075            decoder: &mut fidl::encoding::Decoder<
1076                '_,
1077                fidl::encoding::DefaultFuchsiaResourceDialect,
1078            >,
1079            offset: usize,
1080            _depth: fidl::encoding::Depth,
1081        ) -> fidl::Result<()> {
1082            decoder.debug_check_bounds::<Self>(offset);
1083            // Verify that padding bytes are zero.
1084            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1085            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1086            let mask = 0xffffffff00000000u64;
1087            let maskedval = padval & mask;
1088            if maskedval != 0 {
1089                return Err(fidl::Error::NonZeroPadding {
1090                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1091                });
1092            }
1093            fidl::decode!(
1094                i32,
1095                fidl::encoding::DefaultFuchsiaResourceDialect,
1096                &mut self.status,
1097                decoder,
1098                offset + 0,
1099                _depth
1100            )?;
1101            fidl::decode!(
1102                BlockOp,
1103                fidl::encoding::DefaultFuchsiaResourceDialect,
1104                &mut self.op,
1105                decoder,
1106                offset + 8,
1107                _depth
1108            )?;
1109            Ok(())
1110        }
1111    }
1112
1113    impl fidl::encoding::ResourceTypeMarker for BlockOp {
1114        type Borrowed<'a> = &'a mut Self;
1115        fn take_or_borrow<'a>(
1116            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1117        ) -> Self::Borrowed<'a> {
1118            value
1119        }
1120    }
1121
1122    unsafe impl fidl::encoding::TypeMarker for BlockOp {
1123        type Owned = Self;
1124
1125        #[inline(always)]
1126        fn inline_align(_context: fidl::encoding::Context) -> usize {
1127            8
1128        }
1129
1130        #[inline(always)]
1131        fn inline_size(_context: fidl::encoding::Context) -> usize {
1132            16
1133        }
1134    }
1135
1136    unsafe impl fidl::encoding::Encode<BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect>
1137        for &mut BlockOp
1138    {
1139        #[inline]
1140        unsafe fn encode(
1141            self,
1142            encoder: &mut fidl::encoding::Encoder<
1143                '_,
1144                fidl::encoding::DefaultFuchsiaResourceDialect,
1145            >,
1146            offset: usize,
1147            _depth: fidl::encoding::Depth,
1148        ) -> fidl::Result<()> {
1149            encoder.debug_check_bounds::<BlockOp>(offset);
1150            encoder.write_num::<u64>(self.ordinal(), offset);
1151            match self {
1152                BlockOp::Command(ref val) => fidl::encoding::encode_in_envelope::<
1153                    BlockCommand,
1154                    fidl::encoding::DefaultFuchsiaResourceDialect,
1155                >(
1156                    <BlockCommand as fidl::encoding::ValueTypeMarker>::borrow(val),
1157                    encoder,
1158                    offset + 8,
1159                    _depth,
1160                ),
1161                BlockOp::Rw(ref mut val) => fidl::encoding::encode_in_envelope::<
1162                    BlockReadWrite,
1163                    fidl::encoding::DefaultFuchsiaResourceDialect,
1164                >(
1165                    <BlockReadWrite as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
1166                    encoder,
1167                    offset + 8,
1168                    _depth,
1169                ),
1170                BlockOp::Trim(ref val) => fidl::encoding::encode_in_envelope::<
1171                    BlockTrim,
1172                    fidl::encoding::DefaultFuchsiaResourceDialect,
1173                >(
1174                    <BlockTrim as fidl::encoding::ValueTypeMarker>::borrow(val),
1175                    encoder,
1176                    offset + 8,
1177                    _depth,
1178                ),
1179            }
1180        }
1181    }
1182
1183    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlockOp {
1184        #[inline(always)]
1185        fn new_empty() -> Self {
1186            Self::Command(fidl::new_empty!(
1187                BlockCommand,
1188                fidl::encoding::DefaultFuchsiaResourceDialect
1189            ))
1190        }
1191
1192        #[inline]
1193        unsafe fn decode(
1194            &mut self,
1195            decoder: &mut fidl::encoding::Decoder<
1196                '_,
1197                fidl::encoding::DefaultFuchsiaResourceDialect,
1198            >,
1199            offset: usize,
1200            mut depth: fidl::encoding::Depth,
1201        ) -> fidl::Result<()> {
1202            decoder.debug_check_bounds::<Self>(offset);
1203            #[allow(unused_variables)]
1204            let next_out_of_line = decoder.next_out_of_line();
1205            let handles_before = decoder.remaining_handles();
1206            let (ordinal, inlined, num_bytes, num_handles) =
1207                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1208
1209            let member_inline_size = match ordinal {
1210                1 => <BlockCommand as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1211                2 => <BlockReadWrite as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1212                3 => <BlockTrim as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1213                _ => return Err(fidl::Error::UnknownUnionTag),
1214            };
1215
1216            if inlined != (member_inline_size <= 4) {
1217                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1218            }
1219            let _inner_offset;
1220            if inlined {
1221                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1222                _inner_offset = offset + 8;
1223            } else {
1224                depth.increment()?;
1225                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1226            }
1227            match ordinal {
1228                1 => {
1229                    #[allow(irrefutable_let_patterns)]
1230                    if let BlockOp::Command(_) = self {
1231                        // Do nothing, read the value into the object
1232                    } else {
1233                        // Initialize `self` to the right variant
1234                        *self = BlockOp::Command(fidl::new_empty!(
1235                            BlockCommand,
1236                            fidl::encoding::DefaultFuchsiaResourceDialect
1237                        ));
1238                    }
1239                    #[allow(irrefutable_let_patterns)]
1240                    if let BlockOp::Command(ref mut val) = self {
1241                        fidl::decode!(
1242                            BlockCommand,
1243                            fidl::encoding::DefaultFuchsiaResourceDialect,
1244                            val,
1245                            decoder,
1246                            _inner_offset,
1247                            depth
1248                        )?;
1249                    } else {
1250                        unreachable!()
1251                    }
1252                }
1253                2 => {
1254                    #[allow(irrefutable_let_patterns)]
1255                    if let BlockOp::Rw(_) = self {
1256                        // Do nothing, read the value into the object
1257                    } else {
1258                        // Initialize `self` to the right variant
1259                        *self = BlockOp::Rw(fidl::new_empty!(
1260                            BlockReadWrite,
1261                            fidl::encoding::DefaultFuchsiaResourceDialect
1262                        ));
1263                    }
1264                    #[allow(irrefutable_let_patterns)]
1265                    if let BlockOp::Rw(ref mut val) = self {
1266                        fidl::decode!(
1267                            BlockReadWrite,
1268                            fidl::encoding::DefaultFuchsiaResourceDialect,
1269                            val,
1270                            decoder,
1271                            _inner_offset,
1272                            depth
1273                        )?;
1274                    } else {
1275                        unreachable!()
1276                    }
1277                }
1278                3 => {
1279                    #[allow(irrefutable_let_patterns)]
1280                    if let BlockOp::Trim(_) = self {
1281                        // Do nothing, read the value into the object
1282                    } else {
1283                        // Initialize `self` to the right variant
1284                        *self = BlockOp::Trim(fidl::new_empty!(
1285                            BlockTrim,
1286                            fidl::encoding::DefaultFuchsiaResourceDialect
1287                        ));
1288                    }
1289                    #[allow(irrefutable_let_patterns)]
1290                    if let BlockOp::Trim(ref mut val) = self {
1291                        fidl::decode!(
1292                            BlockTrim,
1293                            fidl::encoding::DefaultFuchsiaResourceDialect,
1294                            val,
1295                            decoder,
1296                            _inner_offset,
1297                            depth
1298                        )?;
1299                    } else {
1300                        unreachable!()
1301                    }
1302                }
1303                ordinal => panic!("unexpected ordinal {:?}", ordinal),
1304            }
1305            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1306                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1307            }
1308            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1309                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1310            }
1311            Ok(())
1312        }
1313    }
1314}