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