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