#![warn(clippy::all)]
#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
use bitflags::bitflags;
use fidl::client::QueryResponseFut;
use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
use fidl::endpoints::{ControlHandle as _, Responder as _};
use futures::future::{self, MaybeDone, TryFutureExt};
use zx_status;
pub type Vmoid = u16;
pub const BLOCK_GUID_LEN: u32 = 16;
pub const BLOCK_VMOID_INVALID: u16 = 0;
pub const MAX_TXN_GROUP_COUNT: u32 = 8;
bitflags! {
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct BlockIoFlag: u32 {
const GROUP_ITEM = 1;
const GROUP_LAST = 2;
const FORCE_ACCESS = 4;
}
}
impl BlockIoFlag {
#[deprecated = "Strict bits should not use `has_unknown_bits`"]
#[inline(always)]
pub fn has_unknown_bits(&self) -> bool {
false
}
#[deprecated = "Strict bits should not use `get_unknown_bits`"]
#[inline(always)]
pub fn get_unknown_bits(&self) -> u32 {
0
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u8)]
pub enum BlockOpcode {
Read = 1,
Write = 2,
Flush = 3,
Trim = 4,
CloseVmo = 5,
}
impl BlockOpcode {
#[inline]
pub fn from_primitive(prim: u8) -> Option<Self> {
match prim {
1 => Some(Self::Read),
2 => Some(Self::Write),
3 => Some(Self::Flush),
4 => Some(Self::Trim),
5 => Some(Self::CloseVmo),
_ => None,
}
}
#[inline]
pub const fn into_primitive(self) -> u8 {
self as u8
}
#[deprecated = "Strict enums should not use `is_unknown`"]
#[inline]
pub fn is_unknown(&self) -> bool {
false
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct BlockCommand {
pub opcode: BlockOpcode,
pub flags: BlockIoFlag,
}
impl fidl::Persistable for BlockCommand {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct BlockReadWrite {
pub command: BlockCommand,
pub extra: u32,
pub vmo: fidl::Vmo,
pub length: u32,
pub offset_dev: u64,
pub offset_vmo: u64,
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlockReadWrite {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct BlockTrim {
pub command: BlockCommand,
pub length: u32,
pub offset_dev: u64,
}
impl fidl::Persistable for BlockTrim {}
#[derive(Clone, Debug, PartialEq)]
pub struct CommonQueryResponse {
pub info: fidl_fuchsia_hardware_block::BlockInfo,
pub block_op_size: u64,
}
impl fidl::Persistable for CommonQueryResponse {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct CommonQueueRequest {
pub txn: BlockOp,
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CommonQueueRequest {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct CommonQueueResponse {
pub status: i32,
pub op: BlockOp,
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CommonQueueResponse {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum BlockOp {
Command(BlockCommand),
Rw(BlockReadWrite),
Trim(BlockTrim),
}
impl BlockOp {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::Command(_) => 1,
Self::Rw(_) => 2,
Self::Trim(_) => 3,
}
}
#[deprecated = "Strict unions should not use `is_unknown`"]
#[inline]
pub fn is_unknown(&self) -> bool {
false
}
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlockOp {}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct CommonMarker;
impl fidl::endpoints::ProtocolMarker for CommonMarker {
type Proxy = CommonProxy;
type RequestStream = CommonRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = CommonSynchronousProxy;
const DEBUG_NAME: &'static str = "(anonymous) Common";
}
pub trait CommonProxyInterface: Send + Sync {
type QueryResponseFut: std::future::Future<
Output = Result<(fidl_fuchsia_hardware_block::BlockInfo, u64), fidl::Error>,
> + Send;
fn r#query(&self) -> Self::QueryResponseFut;
type QueueResponseFut: std::future::Future<Output = Result<(i32, BlockOp), fidl::Error>> + Send;
fn r#queue(&self, txn: BlockOp) -> Self::QueueResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct CommonSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for CommonSynchronousProxy {
type Proxy = CommonProxy;
type Protocol = CommonMarker;
fn from_channel(inner: fidl::Channel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
fn as_channel(&self) -> &fidl::Channel {
self.client.as_channel()
}
}
#[cfg(target_os = "fuchsia")]
impl CommonSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <CommonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
}
pub fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
pub fn wait_for_event(
&self,
deadline: zx::MonotonicInstant,
) -> Result<CommonEvent, fidl::Error> {
CommonEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#query(
&self,
___deadline: zx::MonotonicInstant,
) -> Result<(fidl_fuchsia_hardware_block::BlockInfo, u64), fidl::Error> {
let _response =
self.client.send_query::<fidl::encoding::EmptyPayload, CommonQueryResponse>(
(),
0x1551192b715c20b0,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok((_response.info, _response.block_op_size))
}
pub fn r#queue(
&self,
mut txn: BlockOp,
___deadline: zx::MonotonicInstant,
) -> Result<(i32, BlockOp), fidl::Error> {
let _response = self.client.send_query::<CommonQueueRequest, CommonQueueResponse>(
(&mut txn,),
0x4d57f58df2b01c6a,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok((_response.status, _response.op))
}
}
#[derive(Debug, Clone)]
pub struct CommonProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for CommonProxy {
type Protocol = CommonMarker;
fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
self.client.into_channel().map_err(|client| Self { client })
}
fn as_channel(&self) -> &::fidl::AsyncChannel {
self.client.as_channel()
}
}
impl CommonProxy {
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name = <CommonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> CommonEventStream {
CommonEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#query(
&self,
) -> fidl::client::QueryResponseFut<
(fidl_fuchsia_hardware_block::BlockInfo, u64),
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
CommonProxyInterface::r#query(self)
}
pub fn r#queue(
&self,
mut txn: BlockOp,
) -> fidl::client::QueryResponseFut<(i32, BlockOp), fidl::encoding::DefaultFuchsiaResourceDialect>
{
CommonProxyInterface::r#queue(self, txn)
}
}
impl CommonProxyInterface for CommonProxy {
type QueryResponseFut = fidl::client::QueryResponseFut<
(fidl_fuchsia_hardware_block::BlockInfo, u64),
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#query(&self) -> Self::QueryResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<(fidl_fuchsia_hardware_block::BlockInfo, u64), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
CommonQueryResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x1551192b715c20b0,
>(_buf?)?;
Ok((_response.info, _response.block_op_size))
}
self.client.send_query_and_decode::<
fidl::encoding::EmptyPayload,
(fidl_fuchsia_hardware_block::BlockInfo, u64),
>(
(),
0x1551192b715c20b0,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type QueueResponseFut = fidl::client::QueryResponseFut<
(i32, BlockOp),
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#queue(&self, mut txn: BlockOp) -> Self::QueueResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<(i32, BlockOp), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
CommonQueueResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x4d57f58df2b01c6a,
>(_buf?)?;
Ok((_response.status, _response.op))
}
self.client.send_query_and_decode::<CommonQueueRequest, (i32, BlockOp)>(
(&mut txn,),
0x4d57f58df2b01c6a,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct CommonEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for CommonEventStream {}
impl futures::stream::FusedStream for CommonEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for CommonEventStream {
type Item = Result<CommonEvent, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
&mut self.event_receiver,
cx
)?) {
Some(buf) => std::task::Poll::Ready(Some(CommonEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum CommonEvent {}
impl CommonEvent {
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<CommonEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
debug_assert_eq!(tx_header.tx_id, 0);
match tx_header.ordinal {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <CommonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct CommonRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for CommonRequestStream {}
impl futures::stream::FusedStream for CommonRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for CommonRequestStream {
type Protocol = CommonMarker;
type ControlHandle = CommonControlHandle;
fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
}
fn control_handle(&self) -> Self::ControlHandle {
CommonControlHandle { inner: self.inner.clone() }
}
fn into_inner(
self,
) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
{
(self.inner, self.is_terminated)
}
fn from_inner(
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
) -> Self {
Self { inner, is_terminated }
}
}
impl futures::Stream for CommonRequestStream {
type Item = Result<CommonRequest, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let this = &mut *self;
if this.inner.check_shutdown(cx) {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
if this.is_terminated {
panic!("polled CommonRequestStream after completion");
}
fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
|bytes, handles| {
match this.inner.channel().read_etc(cx, bytes, handles) {
std::task::Poll::Ready(Ok(())) => {}
std::task::Poll::Pending => return std::task::Poll::Pending,
std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
std::task::Poll::Ready(Err(e)) => {
return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
e.into(),
))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0x1551192b715c20b0 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
fidl::encoding::EmptyPayload,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
let control_handle = CommonControlHandle { inner: this.inner.clone() };
Ok(CommonRequest::Query {
responder: CommonQueryResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x4d57f58df2b01c6a => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
CommonQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CommonQueueRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = CommonControlHandle { inner: this.inner.clone() };
Ok(CommonRequest::Queue {
txn: req.txn,
responder: CommonQueueResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<CommonMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum CommonRequest {
Query { responder: CommonQueryResponder },
Queue { txn: BlockOp, responder: CommonQueueResponder },
}
impl CommonRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_query(self) -> Option<(CommonQueryResponder)> {
if let CommonRequest::Query { responder } = self {
Some((responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_queue(self) -> Option<(BlockOp, CommonQueueResponder)> {
if let CommonRequest::Queue { txn, responder } = self {
Some((txn, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
CommonRequest::Query { .. } => "query",
CommonRequest::Queue { .. } => "queue",
}
}
}
#[derive(Debug, Clone)]
pub struct CommonControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for CommonControlHandle {
fn shutdown(&self) {
self.inner.shutdown()
}
fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
fn is_closed(&self) -> bool {
self.inner.channel().is_closed()
}
fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
self.inner.channel().on_closed()
}
#[cfg(target_os = "fuchsia")]
fn signal_peer(
&self,
clear_mask: zx::Signals,
set_mask: zx::Signals,
) -> Result<(), zx_status::Status> {
use fidl::Peered;
self.inner.channel().signal_peer(clear_mask, set_mask)
}
}
impl CommonControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct CommonQueryResponder {
control_handle: std::mem::ManuallyDrop<CommonControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for CommonQueryResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for CommonQueryResponder {
type ControlHandle = CommonControlHandle;
fn control_handle(&self) -> &CommonControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl CommonQueryResponder {
pub fn send(
self,
mut info: &fidl_fuchsia_hardware_block::BlockInfo,
mut block_op_size: u64,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(info, block_op_size);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut info: &fidl_fuchsia_hardware_block::BlockInfo,
mut block_op_size: u64,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(info, block_op_size);
self.drop_without_shutdown();
_result
}
fn send_raw(
&self,
mut info: &fidl_fuchsia_hardware_block::BlockInfo,
mut block_op_size: u64,
) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<CommonQueryResponse>(
(info, block_op_size),
self.tx_id,
0x1551192b715c20b0,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct CommonQueueResponder {
control_handle: std::mem::ManuallyDrop<CommonControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for CommonQueueResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for CommonQueueResponder {
type ControlHandle = CommonControlHandle;
fn control_handle(&self) -> &CommonControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl CommonQueueResponder {
pub fn send(self, mut status: i32, mut op: BlockOp) -> Result<(), fidl::Error> {
let _result = self.send_raw(status, op);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut status: i32,
mut op: BlockOp,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(status, op);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut status: i32, mut op: BlockOp) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<CommonQueueResponse>(
(status, &mut op),
self.tx_id,
0x4d57f58df2b01c6a,
fidl::encoding::DynamicFlags::empty(),
)
}
}
mod internal {
use super::*;
unsafe impl fidl::encoding::TypeMarker for BlockIoFlag {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
4
}
}
impl fidl::encoding::ValueTypeMarker for BlockIoFlag {
type Borrowed<'a> = Self;
#[inline(always)]
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
*value
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for BlockIoFlag {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Self>(offset);
if self.bits() & Self::all().bits() != self.bits() {
return Err(fidl::Error::InvalidBitsValue);
}
encoder.write_num(self.bits(), offset);
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BlockIoFlag {
#[inline(always)]
fn new_empty() -> Self {
Self::empty()
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let prim = decoder.read_num::<u32>(offset);
*self = Self::from_bits(prim).ok_or(fidl::Error::InvalidBitsValue)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for BlockOpcode {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
std::mem::align_of::<u8>()
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
std::mem::size_of::<u8>()
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
false
}
}
impl fidl::encoding::ValueTypeMarker for BlockOpcode {
type Borrowed<'a> = Self;
#[inline(always)]
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
*value
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for BlockOpcode {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Self>(offset);
encoder.write_num(self.into_primitive(), offset);
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BlockOpcode {
#[inline(always)]
fn new_empty() -> Self {
Self::Read
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let prim = decoder.read_num::<u8>(offset);
*self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for BlockCommand {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BlockCommand {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
8
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BlockCommand, D>
for &BlockCommand
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BlockCommand>(offset);
fidl::encoding::Encode::<BlockCommand, D>::encode(
(
<BlockOpcode as fidl::encoding::ValueTypeMarker>::borrow(&self.opcode),
<BlockIoFlag as fidl::encoding::ValueTypeMarker>::borrow(&self.flags),
),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<BlockOpcode, D>,
T1: fidl::encoding::Encode<BlockIoFlag, D>,
> fidl::encoding::Encode<BlockCommand, D> for (T0, T1)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BlockCommand>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
(ptr as *mut u32).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 4, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BlockCommand {
#[inline(always)]
fn new_empty() -> Self {
Self {
opcode: fidl::new_empty!(BlockOpcode, D),
flags: fidl::new_empty!(BlockIoFlag, D),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
let padval = unsafe { (ptr as *const u32).read_unaligned() };
let mask = 0xffffff00u32;
let maskedval = padval & mask;
if maskedval != 0 {
return Err(fidl::Error::NonZeroPadding {
padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(BlockOpcode, D, &mut self.opcode, decoder, offset + 0, _depth)?;
fidl::decode!(BlockIoFlag, D, &mut self.flags, decoder, offset + 4, _depth)?;
Ok(())
}
}
impl fidl::encoding::ResourceTypeMarker for BlockReadWrite {
type Borrowed<'a> = &'a mut Self;
fn take_or_borrow<'a>(
value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BlockReadWrite {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
40
}
}
unsafe impl
fidl::encoding::Encode<BlockReadWrite, fidl::encoding::DefaultFuchsiaResourceDialect>
for &mut BlockReadWrite
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BlockReadWrite>(offset);
fidl::encoding::Encode::<BlockReadWrite, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
(
<BlockCommand as fidl::encoding::ValueTypeMarker>::borrow(&self.command),
<u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.extra),
<fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
<u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.length),
<u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.offset_dev),
<u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.offset_vmo),
),
encoder, offset, _depth
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<BlockCommand, fidl::encoding::DefaultFuchsiaResourceDialect>,
T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
T2: fidl::encoding::Encode<
fidl::encoding::HandleType<
fidl::Vmo,
{ fidl::ObjectType::VMO.into_raw() },
2147483648,
>,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
T3: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
T4: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
T5: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
> fidl::encoding::Encode<BlockReadWrite, fidl::encoding::DefaultFuchsiaResourceDialect>
for (T0, T1, T2, T3, T4, T5)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BlockReadWrite>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
(ptr as *mut u64).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 8, depth)?;
self.2.encode(encoder, offset + 12, depth)?;
self.3.encode(encoder, offset + 16, depth)?;
self.4.encode(encoder, offset + 24, depth)?;
self.5.encode(encoder, offset + 32, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
for BlockReadWrite
{
#[inline(always)]
fn new_empty() -> Self {
Self {
command: fidl::new_empty!(
BlockCommand,
fidl::encoding::DefaultFuchsiaResourceDialect
),
extra: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
length: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
offset_dev: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
offset_vmo: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
let padval = unsafe { (ptr as *const u64).read_unaligned() };
let mask = 0xffffffff00000000u64;
let maskedval = padval & mask;
if maskedval != 0 {
return Err(fidl::Error::NonZeroPadding {
padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(
BlockCommand,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.command,
decoder,
offset + 0,
_depth
)?;
fidl::decode!(
u32,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.extra,
decoder,
offset + 8,
_depth
)?;
fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 12, _depth)?;
fidl::decode!(
u32,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.length,
decoder,
offset + 16,
_depth
)?;
fidl::decode!(
u64,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.offset_dev,
decoder,
offset + 24,
_depth
)?;
fidl::decode!(
u64,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.offset_vmo,
decoder,
offset + 32,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for BlockTrim {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BlockTrim {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
24
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BlockTrim, D>
for &BlockTrim
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BlockTrim>(offset);
fidl::encoding::Encode::<BlockTrim, D>::encode(
(
<BlockCommand as fidl::encoding::ValueTypeMarker>::borrow(&self.command),
<u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.length),
<u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.offset_dev),
),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<BlockCommand, D>,
T1: fidl::encoding::Encode<u32, D>,
T2: fidl::encoding::Encode<u64, D>,
> fidl::encoding::Encode<BlockTrim, D> for (T0, T1, T2)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BlockTrim>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
(ptr as *mut u64).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 8, depth)?;
self.2.encode(encoder, offset + 16, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BlockTrim {
#[inline(always)]
fn new_empty() -> Self {
Self {
command: fidl::new_empty!(BlockCommand, D),
length: fidl::new_empty!(u32, D),
offset_dev: fidl::new_empty!(u64, D),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
let padval = unsafe { (ptr as *const u64).read_unaligned() };
let mask = 0xffffffff00000000u64;
let maskedval = padval & mask;
if maskedval != 0 {
return Err(fidl::Error::NonZeroPadding {
padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(BlockCommand, D, &mut self.command, decoder, offset + 0, _depth)?;
fidl::decode!(u32, D, &mut self.length, decoder, offset + 8, _depth)?;
fidl::decode!(u64, D, &mut self.offset_dev, decoder, offset + 16, _depth)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for CommonQueryResponse {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for CommonQueryResponse {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
32
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CommonQueryResponse, D>
for &CommonQueryResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<CommonQueryResponse>(offset);
fidl::encoding::Encode::<CommonQueryResponse, D>::encode(
(
<fidl_fuchsia_hardware_block::BlockInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.info),
<u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.block_op_size),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl_fuchsia_hardware_block::BlockInfo, D>,
T1: fidl::encoding::Encode<u64, D>,
> fidl::encoding::Encode<CommonQueryResponse, D> for (T0, T1)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<CommonQueryResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 24, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CommonQueryResponse {
#[inline(always)]
fn new_empty() -> Self {
Self {
info: fidl::new_empty!(fidl_fuchsia_hardware_block::BlockInfo, D),
block_op_size: fidl::new_empty!(u64, D),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(
fidl_fuchsia_hardware_block::BlockInfo,
D,
&mut self.info,
decoder,
offset + 0,
_depth
)?;
fidl::decode!(u64, D, &mut self.block_op_size, decoder, offset + 24, _depth)?;
Ok(())
}
}
impl fidl::encoding::ResourceTypeMarker for CommonQueueRequest {
type Borrowed<'a> = &'a mut Self;
fn take_or_borrow<'a>(
value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for CommonQueueRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
16
}
}
unsafe impl
fidl::encoding::Encode<CommonQueueRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
for &mut CommonQueueRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<CommonQueueRequest>(offset);
fidl::encoding::Encode::<
CommonQueueRequest,
fidl::encoding::DefaultFuchsiaResourceDialect,
>::encode(
(<BlockOp as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.txn),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<T0: fidl::encoding::Encode<BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect>>
fidl::encoding::Encode<CommonQueueRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<CommonQueueRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
for CommonQueueRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { txn: fidl::new_empty!(BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(
BlockOp,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.txn,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ResourceTypeMarker for CommonQueueResponse {
type Borrowed<'a> = &'a mut Self;
fn take_or_borrow<'a>(
value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for CommonQueueResponse {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
24
}
}
unsafe impl
fidl::encoding::Encode<CommonQueueResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
for &mut CommonQueueResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<CommonQueueResponse>(offset);
fidl::encoding::Encode::<
CommonQueueResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
>::encode(
(
<i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
<BlockOp as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.op),
),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
T1: fidl::encoding::Encode<BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect>,
>
fidl::encoding::Encode<CommonQueueResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
for (T0, T1)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<CommonQueueResponse>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
(ptr as *mut u64).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 8, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
for CommonQueueResponse
{
#[inline(always)]
fn new_empty() -> Self {
Self {
status: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
op: fidl::new_empty!(BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
let padval = unsafe { (ptr as *const u64).read_unaligned() };
let mask = 0xffffffff00000000u64;
let maskedval = padval & mask;
if maskedval != 0 {
return Err(fidl::Error::NonZeroPadding {
padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(
i32,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.status,
decoder,
offset + 0,
_depth
)?;
fidl::decode!(
BlockOp,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.op,
decoder,
offset + 8,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ResourceTypeMarker for BlockOp {
type Borrowed<'a> = &'a mut Self;
fn take_or_borrow<'a>(
value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BlockOp {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
16
}
}
unsafe impl fidl::encoding::Encode<BlockOp, fidl::encoding::DefaultFuchsiaResourceDialect>
for &mut BlockOp
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BlockOp>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
BlockOp::Command(ref val) => fidl::encoding::encode_in_envelope::<
BlockCommand,
fidl::encoding::DefaultFuchsiaResourceDialect,
>(
<BlockCommand as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
BlockOp::Rw(ref mut val) => fidl::encoding::encode_in_envelope::<
BlockReadWrite,
fidl::encoding::DefaultFuchsiaResourceDialect,
>(
<BlockReadWrite as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
encoder,
offset + 8,
_depth,
),
BlockOp::Trim(ref val) => fidl::encoding::encode_in_envelope::<
BlockTrim,
fidl::encoding::DefaultFuchsiaResourceDialect,
>(
<BlockTrim as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
}
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for BlockOp {
#[inline(always)]
fn new_empty() -> Self {
Self::Command(fidl::new_empty!(
BlockCommand,
fidl::encoding::DefaultFuchsiaResourceDialect
))
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
#[allow(unused_variables)]
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
let (ordinal, inlined, num_bytes, num_handles) =
fidl::encoding::decode_union_inline_portion(decoder, offset)?;
let member_inline_size = match ordinal {
1 => <BlockCommand as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2 => <BlockReadWrite as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3 => <BlockTrim as fidl::encoding::TypeMarker>::inline_size(decoder.context),
_ => return Err(fidl::Error::UnknownUnionTag),
};
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let _inner_offset;
if inlined {
decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
_inner_offset = offset + 8;
} else {
depth.increment()?;
_inner_offset = decoder.out_of_line_offset(member_inline_size)?;
}
match ordinal {
1 => {
#[allow(irrefutable_let_patterns)]
if let BlockOp::Command(_) = self {
} else {
*self = BlockOp::Command(fidl::new_empty!(
BlockCommand,
fidl::encoding::DefaultFuchsiaResourceDialect
));
}
#[allow(irrefutable_let_patterns)]
if let BlockOp::Command(ref mut val) = self {
fidl::decode!(
BlockCommand,
fidl::encoding::DefaultFuchsiaResourceDialect,
val,
decoder,
_inner_offset,
depth
)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let BlockOp::Rw(_) = self {
} else {
*self = BlockOp::Rw(fidl::new_empty!(
BlockReadWrite,
fidl::encoding::DefaultFuchsiaResourceDialect
));
}
#[allow(irrefutable_let_patterns)]
if let BlockOp::Rw(ref mut val) = self {
fidl::decode!(
BlockReadWrite,
fidl::encoding::DefaultFuchsiaResourceDialect,
val,
decoder,
_inner_offset,
depth
)?;
} else {
unreachable!()
}
}
3 => {
#[allow(irrefutable_let_patterns)]
if let BlockOp::Trim(_) = self {
} else {
*self = BlockOp::Trim(fidl::new_empty!(
BlockTrim,
fidl::encoding::DefaultFuchsiaResourceDialect
));
}
#[allow(irrefutable_let_patterns)]
if let BlockOp::Trim(ref mut val) = self {
fidl::decode!(
BlockTrim,
fidl::encoding::DefaultFuchsiaResourceDialect,
val,
decoder,
_inner_offset,
depth
)?;
} else {
unreachable!()
}
}
ordinal => panic!("unexpected ordinal {:?}", ordinal),
}
if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
return Err(fidl::Error::InvalidNumBytesInEnvelope);
}
if handles_before != decoder.remaining_handles() + (num_handles as usize) {
return Err(fidl::Error::InvalidNumHandlesInEnvelope);
}
Ok(())
}
}
}