1#![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#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
16pub struct BlockReadWrite {
17 pub command: BlockCommand,
19 pub extra: u32,
21 pub vmo: fidl::Vmo,
23 pub length: u32,
25 pub offset_dev: u64,
27 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 Command(BlockCommand),
52 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 #[deprecated = "Strict unions should not use `is_unknown`"]
68 #[inline]
69 pub fn is_unknown(&self) -> bool {
70 false
71 }
72}
73
74impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlockOp {}
75
76#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
77pub struct CommonMarker;
78
79impl fidl::endpoints::ProtocolMarker for CommonMarker {
80 type Proxy = CommonProxy;
81 type RequestStream = CommonRequestStream;
82 #[cfg(target_os = "fuchsia")]
83 type SynchronousProxy = CommonSynchronousProxy;
84
85 const DEBUG_NAME: &'static str = "(anonymous) Common";
86}
87
88pub trait CommonProxyInterface: Send + Sync {
89 type QueryResponseFut: std::future::Future<
90 Output = Result<(fidl_fuchsia_hardware_block::BlockInfo, u64), fidl::Error>,
91 > + Send;
92 fn r#query(&self) -> Self::QueryResponseFut;
93 type QueueResponseFut: std::future::Future<Output = Result<(i32, BlockOp), fidl::Error>> + Send;
94 fn r#queue(&self, txn: BlockOp) -> Self::QueueResponseFut;
95}
96#[derive(Debug)]
97#[cfg(target_os = "fuchsia")]
98pub struct CommonSynchronousProxy {
99 client: fidl::client::sync::Client,
100}
101
102#[cfg(target_os = "fuchsia")]
103impl fidl::endpoints::SynchronousProxy for CommonSynchronousProxy {
104 type Proxy = CommonProxy;
105 type Protocol = CommonMarker;
106
107 fn from_channel(inner: fidl::Channel) -> Self {
108 Self::new(inner)
109 }
110
111 fn into_channel(self) -> fidl::Channel {
112 self.client.into_channel()
113 }
114
115 fn as_channel(&self) -> &fidl::Channel {
116 self.client.as_channel()
117 }
118}
119
120#[cfg(target_os = "fuchsia")]
121impl CommonSynchronousProxy {
122 pub fn new(channel: fidl::Channel) -> Self {
123 let protocol_name = <CommonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
124 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
125 }
126
127 pub fn into_channel(self) -> fidl::Channel {
128 self.client.into_channel()
129 }
130
131 pub fn wait_for_event(
134 &self,
135 deadline: zx::MonotonicInstant,
136 ) -> Result<CommonEvent, fidl::Error> {
137 CommonEvent::decode(self.client.wait_for_event(deadline)?)
138 }
139
140 pub fn r#query(
145 &self,
146 ___deadline: zx::MonotonicInstant,
147 ) -> Result<(fidl_fuchsia_hardware_block::BlockInfo, u64), fidl::Error> {
148 let _response =
149 self.client.send_query::<fidl::encoding::EmptyPayload, CommonQueryResponse>(
150 (),
151 0x1551192b715c20b0,
152 fidl::encoding::DynamicFlags::empty(),
153 ___deadline,
154 )?;
155 Ok((_response.info, _response.block_op_size))
156 }
157
158 pub fn r#queue(
163 &self,
164 mut txn: BlockOp,
165 ___deadline: zx::MonotonicInstant,
166 ) -> Result<(i32, BlockOp), fidl::Error> {
167 let _response = self.client.send_query::<CommonQueueRequest, CommonQueueResponse>(
168 (&mut txn,),
169 0x4d57f58df2b01c6a,
170 fidl::encoding::DynamicFlags::empty(),
171 ___deadline,
172 )?;
173 Ok((_response.status, _response.op))
174 }
175}
176
177#[cfg(target_os = "fuchsia")]
178impl From<CommonSynchronousProxy> for zx::Handle {
179 fn from(value: CommonSynchronousProxy) -> Self {
180 value.into_channel().into()
181 }
182}
183
184#[cfg(target_os = "fuchsia")]
185impl From<fidl::Channel> for CommonSynchronousProxy {
186 fn from(value: fidl::Channel) -> Self {
187 Self::new(value)
188 }
189}
190
191#[derive(Debug, Clone)]
192pub struct CommonProxy {
193 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
194}
195
196impl fidl::endpoints::Proxy for CommonProxy {
197 type Protocol = CommonMarker;
198
199 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
200 Self::new(inner)
201 }
202
203 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
204 self.client.into_channel().map_err(|client| Self { client })
205 }
206
207 fn as_channel(&self) -> &::fidl::AsyncChannel {
208 self.client.as_channel()
209 }
210}
211
212impl CommonProxy {
213 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
215 let protocol_name = <CommonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
216 Self { client: fidl::client::Client::new(channel, protocol_name) }
217 }
218
219 pub fn take_event_stream(&self) -> CommonEventStream {
225 CommonEventStream { event_receiver: self.client.take_event_receiver() }
226 }
227
228 pub fn r#query(
233 &self,
234 ) -> fidl::client::QueryResponseFut<
235 (fidl_fuchsia_hardware_block::BlockInfo, u64),
236 fidl::encoding::DefaultFuchsiaResourceDialect,
237 > {
238 CommonProxyInterface::r#query(self)
239 }
240
241 pub fn r#queue(
246 &self,
247 mut txn: BlockOp,
248 ) -> fidl::client::QueryResponseFut<(i32, BlockOp), fidl::encoding::DefaultFuchsiaResourceDialect>
249 {
250 CommonProxyInterface::r#queue(self, txn)
251 }
252}
253
254impl CommonProxyInterface for CommonProxy {
255 type QueryResponseFut = fidl::client::QueryResponseFut<
256 (fidl_fuchsia_hardware_block::BlockInfo, u64),
257 fidl::encoding::DefaultFuchsiaResourceDialect,
258 >;
259 fn r#query(&self) -> Self::QueryResponseFut {
260 fn _decode(
261 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
262 ) -> Result<(fidl_fuchsia_hardware_block::BlockInfo, u64), fidl::Error> {
263 let _response = fidl::client::decode_transaction_body::<
264 CommonQueryResponse,
265 fidl::encoding::DefaultFuchsiaResourceDialect,
266 0x1551192b715c20b0,
267 >(_buf?)?;
268 Ok((_response.info, _response.block_op_size))
269 }
270 self.client.send_query_and_decode::<
271 fidl::encoding::EmptyPayload,
272 (fidl_fuchsia_hardware_block::BlockInfo, u64),
273 >(
274 (),
275 0x1551192b715c20b0,
276 fidl::encoding::DynamicFlags::empty(),
277 _decode,
278 )
279 }
280
281 type QueueResponseFut = fidl::client::QueryResponseFut<
282 (i32, BlockOp),
283 fidl::encoding::DefaultFuchsiaResourceDialect,
284 >;
285 fn r#queue(&self, mut txn: BlockOp) -> Self::QueueResponseFut {
286 fn _decode(
287 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
288 ) -> Result<(i32, BlockOp), fidl::Error> {
289 let _response = fidl::client::decode_transaction_body::<
290 CommonQueueResponse,
291 fidl::encoding::DefaultFuchsiaResourceDialect,
292 0x4d57f58df2b01c6a,
293 >(_buf?)?;
294 Ok((_response.status, _response.op))
295 }
296 self.client.send_query_and_decode::<CommonQueueRequest, (i32, BlockOp)>(
297 (&mut txn,),
298 0x4d57f58df2b01c6a,
299 fidl::encoding::DynamicFlags::empty(),
300 _decode,
301 )
302 }
303}
304
305pub struct CommonEventStream {
306 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
307}
308
309impl std::marker::Unpin for CommonEventStream {}
310
311impl futures::stream::FusedStream for CommonEventStream {
312 fn is_terminated(&self) -> bool {
313 self.event_receiver.is_terminated()
314 }
315}
316
317impl futures::Stream for CommonEventStream {
318 type Item = Result<CommonEvent, fidl::Error>;
319
320 fn poll_next(
321 mut self: std::pin::Pin<&mut Self>,
322 cx: &mut std::task::Context<'_>,
323 ) -> std::task::Poll<Option<Self::Item>> {
324 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
325 &mut self.event_receiver,
326 cx
327 )?) {
328 Some(buf) => std::task::Poll::Ready(Some(CommonEvent::decode(buf))),
329 None => std::task::Poll::Ready(None),
330 }
331 }
332}
333
334#[derive(Debug)]
335pub enum CommonEvent {}
336
337impl CommonEvent {
338 fn decode(
340 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
341 ) -> Result<CommonEvent, fidl::Error> {
342 let (bytes, _handles) = buf.split_mut();
343 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
344 debug_assert_eq!(tx_header.tx_id, 0);
345 match tx_header.ordinal {
346 _ => Err(fidl::Error::UnknownOrdinal {
347 ordinal: tx_header.ordinal,
348 protocol_name: <CommonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
349 }),
350 }
351 }
352}
353
354pub struct CommonRequestStream {
356 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
357 is_terminated: bool,
358}
359
360impl std::marker::Unpin for CommonRequestStream {}
361
362impl futures::stream::FusedStream for CommonRequestStream {
363 fn is_terminated(&self) -> bool {
364 self.is_terminated
365 }
366}
367
368impl fidl::endpoints::RequestStream for CommonRequestStream {
369 type Protocol = CommonMarker;
370 type ControlHandle = CommonControlHandle;
371
372 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
373 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
374 }
375
376 fn control_handle(&self) -> Self::ControlHandle {
377 CommonControlHandle { inner: self.inner.clone() }
378 }
379
380 fn into_inner(
381 self,
382 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
383 {
384 (self.inner, self.is_terminated)
385 }
386
387 fn from_inner(
388 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
389 is_terminated: bool,
390 ) -> Self {
391 Self { inner, is_terminated }
392 }
393}
394
395impl futures::Stream for CommonRequestStream {
396 type Item = Result<CommonRequest, fidl::Error>;
397
398 fn poll_next(
399 mut self: std::pin::Pin<&mut Self>,
400 cx: &mut std::task::Context<'_>,
401 ) -> std::task::Poll<Option<Self::Item>> {
402 let this = &mut *self;
403 if this.inner.check_shutdown(cx) {
404 this.is_terminated = true;
405 return std::task::Poll::Ready(None);
406 }
407 if this.is_terminated {
408 panic!("polled CommonRequestStream after completion");
409 }
410 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
411 |bytes, handles| {
412 match this.inner.channel().read_etc(cx, bytes, handles) {
413 std::task::Poll::Ready(Ok(())) => {}
414 std::task::Poll::Pending => return std::task::Poll::Pending,
415 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
416 this.is_terminated = true;
417 return std::task::Poll::Ready(None);
418 }
419 std::task::Poll::Ready(Err(e)) => {
420 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
421 e.into(),
422 ))))
423 }
424 }
425
426 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
428
429 std::task::Poll::Ready(Some(match header.ordinal {
430 0x1551192b715c20b0 => {
431 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
432 let mut req = fidl::new_empty!(
433 fidl::encoding::EmptyPayload,
434 fidl::encoding::DefaultFuchsiaResourceDialect
435 );
436 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
437 let control_handle = CommonControlHandle { inner: this.inner.clone() };
438 Ok(CommonRequest::Query {
439 responder: CommonQueryResponder {
440 control_handle: std::mem::ManuallyDrop::new(control_handle),
441 tx_id: header.tx_id,
442 },
443 })
444 }
445 0x4d57f58df2b01c6a => {
446 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
447 let mut req = fidl::new_empty!(
448 CommonQueueRequest,
449 fidl::encoding::DefaultFuchsiaResourceDialect
450 );
451 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CommonQueueRequest>(&header, _body_bytes, handles, &mut req)?;
452 let control_handle = CommonControlHandle { inner: this.inner.clone() };
453 Ok(CommonRequest::Queue {
454 txn: req.txn,
455
456 responder: CommonQueueResponder {
457 control_handle: std::mem::ManuallyDrop::new(control_handle),
458 tx_id: header.tx_id,
459 },
460 })
461 }
462 _ => Err(fidl::Error::UnknownOrdinal {
463 ordinal: header.ordinal,
464 protocol_name:
465 <CommonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
466 }),
467 }))
468 },
469 )
470 }
471}
472
473#[derive(Debug)]
474pub enum CommonRequest {
475 Query { responder: CommonQueryResponder },
480 Queue { txn: BlockOp, responder: CommonQueueResponder },
485}
486
487impl CommonRequest {
488 #[allow(irrefutable_let_patterns)]
489 pub fn into_query(self) -> Option<(CommonQueryResponder)> {
490 if let CommonRequest::Query { responder } = self {
491 Some((responder))
492 } else {
493 None
494 }
495 }
496
497 #[allow(irrefutable_let_patterns)]
498 pub fn into_queue(self) -> Option<(BlockOp, CommonQueueResponder)> {
499 if let CommonRequest::Queue { txn, responder } = self {
500 Some((txn, responder))
501 } else {
502 None
503 }
504 }
505
506 pub fn method_name(&self) -> &'static str {
508 match *self {
509 CommonRequest::Query { .. } => "query",
510 CommonRequest::Queue { .. } => "queue",
511 }
512 }
513}
514
515#[derive(Debug, Clone)]
516pub struct CommonControlHandle {
517 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
518}
519
520impl fidl::endpoints::ControlHandle for CommonControlHandle {
521 fn shutdown(&self) {
522 self.inner.shutdown()
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
555impl std::ops::Drop for CommonQueryResponder {
559 fn drop(&mut self) {
560 self.control_handle.shutdown();
561 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 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
576 std::mem::forget(self);
578 }
579}
580
581impl CommonQueryResponder {
582 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 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
630impl std::ops::Drop for CommonQueueResponder {
634 fn drop(&mut self) {
635 self.control_handle.shutdown();
636 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 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
651 std::mem::forget(self);
653 }
654}
655
656impl CommonQueueResponder {
657 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 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 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 unsafe {
776 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
777 (ptr as *mut u64).write_unaligned(0);
778 }
779 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 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 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 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 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 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 >
1036 fidl::encoding::Encode<CommonQueueResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
1037 for (T0, T1)
1038 {
1039 #[inline]
1040 unsafe fn encode(
1041 self,
1042 encoder: &mut fidl::encoding::Encoder<
1043 '_,
1044 fidl::encoding::DefaultFuchsiaResourceDialect,
1045 >,
1046 offset: usize,
1047 depth: fidl::encoding::Depth,
1048 ) -> fidl::Result<()> {
1049 encoder.debug_check_bounds::<CommonQueueResponse>(offset);
1050 unsafe {
1053 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1054 (ptr as *mut u64).write_unaligned(0);
1055 }
1056 self.0.encode(encoder, offset + 0, depth)?;
1058 self.1.encode(encoder, offset + 8, depth)?;
1059 Ok(())
1060 }
1061 }
1062
1063 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1064 for CommonQueueResponse
1065 {
1066 #[inline(always)]
1067 fn new_empty() -> Self {
1068 Self {
1069 status: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
1070 op: fidl::new_empty!(BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect),
1071 }
1072 }
1073
1074 #[inline]
1075 unsafe fn decode(
1076 &mut self,
1077 decoder: &mut fidl::encoding::Decoder<
1078 '_,
1079 fidl::encoding::DefaultFuchsiaResourceDialect,
1080 >,
1081 offset: usize,
1082 _depth: fidl::encoding::Depth,
1083 ) -> fidl::Result<()> {
1084 decoder.debug_check_bounds::<Self>(offset);
1085 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1087 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1088 let mask = 0xffffffff00000000u64;
1089 let maskedval = padval & mask;
1090 if maskedval != 0 {
1091 return Err(fidl::Error::NonZeroPadding {
1092 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1093 });
1094 }
1095 fidl::decode!(
1096 i32,
1097 fidl::encoding::DefaultFuchsiaResourceDialect,
1098 &mut self.status,
1099 decoder,
1100 offset + 0,
1101 _depth
1102 )?;
1103 fidl::decode!(
1104 BlockOp,
1105 fidl::encoding::DefaultFuchsiaResourceDialect,
1106 &mut self.op,
1107 decoder,
1108 offset + 8,
1109 _depth
1110 )?;
1111 Ok(())
1112 }
1113 }
1114
1115 impl fidl::encoding::ResourceTypeMarker for BlockOp {
1116 type Borrowed<'a> = &'a mut Self;
1117 fn take_or_borrow<'a>(
1118 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1119 ) -> Self::Borrowed<'a> {
1120 value
1121 }
1122 }
1123
1124 unsafe impl fidl::encoding::TypeMarker for BlockOp {
1125 type Owned = Self;
1126
1127 #[inline(always)]
1128 fn inline_align(_context: fidl::encoding::Context) -> usize {
1129 8
1130 }
1131
1132 #[inline(always)]
1133 fn inline_size(_context: fidl::encoding::Context) -> usize {
1134 16
1135 }
1136 }
1137
1138 unsafe impl fidl::encoding::Encode<BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect>
1139 for &mut BlockOp
1140 {
1141 #[inline]
1142 unsafe fn encode(
1143 self,
1144 encoder: &mut fidl::encoding::Encoder<
1145 '_,
1146 fidl::encoding::DefaultFuchsiaResourceDialect,
1147 >,
1148 offset: usize,
1149 _depth: fidl::encoding::Depth,
1150 ) -> fidl::Result<()> {
1151 encoder.debug_check_bounds::<BlockOp>(offset);
1152 encoder.write_num::<u64>(self.ordinal(), offset);
1153 match self {
1154 BlockOp::Command(ref val) => fidl::encoding::encode_in_envelope::<
1155 BlockCommand,
1156 fidl::encoding::DefaultFuchsiaResourceDialect,
1157 >(
1158 <BlockCommand as fidl::encoding::ValueTypeMarker>::borrow(val),
1159 encoder,
1160 offset + 8,
1161 _depth,
1162 ),
1163 BlockOp::Rw(ref mut val) => fidl::encoding::encode_in_envelope::<
1164 BlockReadWrite,
1165 fidl::encoding::DefaultFuchsiaResourceDialect,
1166 >(
1167 <BlockReadWrite as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
1168 encoder,
1169 offset + 8,
1170 _depth,
1171 ),
1172 BlockOp::Trim(ref val) => fidl::encoding::encode_in_envelope::<
1173 BlockTrim,
1174 fidl::encoding::DefaultFuchsiaResourceDialect,
1175 >(
1176 <BlockTrim as fidl::encoding::ValueTypeMarker>::borrow(val),
1177 encoder,
1178 offset + 8,
1179 _depth,
1180 ),
1181 }
1182 }
1183 }
1184
1185 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlockOp {
1186 #[inline(always)]
1187 fn new_empty() -> Self {
1188 Self::Command(fidl::new_empty!(
1189 BlockCommand,
1190 fidl::encoding::DefaultFuchsiaResourceDialect
1191 ))
1192 }
1193
1194 #[inline]
1195 unsafe fn decode(
1196 &mut self,
1197 decoder: &mut fidl::encoding::Decoder<
1198 '_,
1199 fidl::encoding::DefaultFuchsiaResourceDialect,
1200 >,
1201 offset: usize,
1202 mut depth: fidl::encoding::Depth,
1203 ) -> fidl::Result<()> {
1204 decoder.debug_check_bounds::<Self>(offset);
1205 #[allow(unused_variables)]
1206 let next_out_of_line = decoder.next_out_of_line();
1207 let handles_before = decoder.remaining_handles();
1208 let (ordinal, inlined, num_bytes, num_handles) =
1209 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1210
1211 let member_inline_size = match ordinal {
1212 1 => <BlockCommand as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1213 2 => <BlockReadWrite as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1214 3 => <BlockTrim as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1215 _ => return Err(fidl::Error::UnknownUnionTag),
1216 };
1217
1218 if inlined != (member_inline_size <= 4) {
1219 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1220 }
1221 let _inner_offset;
1222 if inlined {
1223 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1224 _inner_offset = offset + 8;
1225 } else {
1226 depth.increment()?;
1227 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1228 }
1229 match ordinal {
1230 1 => {
1231 #[allow(irrefutable_let_patterns)]
1232 if let BlockOp::Command(_) = self {
1233 } else {
1235 *self = BlockOp::Command(fidl::new_empty!(
1237 BlockCommand,
1238 fidl::encoding::DefaultFuchsiaResourceDialect
1239 ));
1240 }
1241 #[allow(irrefutable_let_patterns)]
1242 if let BlockOp::Command(ref mut val) = self {
1243 fidl::decode!(
1244 BlockCommand,
1245 fidl::encoding::DefaultFuchsiaResourceDialect,
1246 val,
1247 decoder,
1248 _inner_offset,
1249 depth
1250 )?;
1251 } else {
1252 unreachable!()
1253 }
1254 }
1255 2 => {
1256 #[allow(irrefutable_let_patterns)]
1257 if let BlockOp::Rw(_) = self {
1258 } else {
1260 *self = BlockOp::Rw(fidl::new_empty!(
1262 BlockReadWrite,
1263 fidl::encoding::DefaultFuchsiaResourceDialect
1264 ));
1265 }
1266 #[allow(irrefutable_let_patterns)]
1267 if let BlockOp::Rw(ref mut val) = self {
1268 fidl::decode!(
1269 BlockReadWrite,
1270 fidl::encoding::DefaultFuchsiaResourceDialect,
1271 val,
1272 decoder,
1273 _inner_offset,
1274 depth
1275 )?;
1276 } else {
1277 unreachable!()
1278 }
1279 }
1280 3 => {
1281 #[allow(irrefutable_let_patterns)]
1282 if let BlockOp::Trim(_) = self {
1283 } else {
1285 *self = BlockOp::Trim(fidl::new_empty!(
1287 BlockTrim,
1288 fidl::encoding::DefaultFuchsiaResourceDialect
1289 ));
1290 }
1291 #[allow(irrefutable_let_patterns)]
1292 if let BlockOp::Trim(ref mut val) = self {
1293 fidl::decode!(
1294 BlockTrim,
1295 fidl::encoding::DefaultFuchsiaResourceDialect,
1296 val,
1297 decoder,
1298 _inner_offset,
1299 depth
1300 )?;
1301 } else {
1302 unreachable!()
1303 }
1304 }
1305 ordinal => panic!("unexpected ordinal {:?}", ordinal),
1306 }
1307 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1308 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1309 }
1310 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1311 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1312 }
1313 Ok(())
1314 }
1315 }
1316}