| // WARNING: This file is machine generated by fidlgen. |
| |
| // fidl_experiment = output_index_json |
| |
| #![warn(clippy::all)] |
| #![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)] |
| |
| use bitflags::bitflags; |
| use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect}; |
| use futures::future::{self, MaybeDone, TryFutureExt}; |
| use zx_status; |
| |
| #[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] |
| pub struct BasicStruct { |
| pub x: u32, |
| pub y: String, |
| } |
| |
| impl fidl::Persistable for BasicStruct {} |
| |
| #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] |
| pub struct Simple { |
| pub f1: u8, |
| pub f2: bool, |
| } |
| |
| impl fidl::Persistable for Simple {} |
| |
| mod internal { |
| use super::*; |
| |
| impl fidl::encoding::ValueTypeMarker for BasicStruct { |
| type Borrowed<'a> = &'a Self; |
| fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker for BasicStruct { |
| 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<BasicStruct, D> |
| for &BasicStruct |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_, D>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<BasicStruct>(offset); |
| // Delegate to tuple encoding. |
| fidl::encoding::Encode::<BasicStruct, D>::encode( |
| ( |
| <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.x), |
| <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow( |
| &self.y, |
| ), |
| ), |
| encoder, |
| offset, |
| _depth, |
| ) |
| } |
| } |
| unsafe impl< |
| D: fidl::encoding::ResourceDialect, |
| T0: fidl::encoding::Encode<u32, D>, |
| T1: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>, |
| > fidl::encoding::Encode<BasicStruct, 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::<BasicStruct>(offset); |
| // Zero out padding regions. There's no need to apply masks |
| // because the unmasked parts will be overwritten by fields. |
| unsafe { |
| let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0); |
| (ptr as *mut u64).write_unaligned(0); |
| } |
| // Write the fields. |
| self.0.encode(encoder, offset + 0, depth)?; |
| self.1.encode(encoder, offset + 8, depth)?; |
| Ok(()) |
| } |
| } |
| |
| impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BasicStruct { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self { |
| x: fidl::new_empty!(u32, D), |
| y: fidl::new_empty!(fidl::encoding::UnboundedString, 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); |
| // Verify that padding bytes are zero. |
| 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!(u32, D, &mut self.x, decoder, offset + 0, _depth)?; |
| fidl::decode!( |
| fidl::encoding::UnboundedString, |
| D, |
| &mut self.y, |
| decoder, |
| offset + 8, |
| _depth |
| )?; |
| Ok(()) |
| } |
| } |
| |
| impl fidl::encoding::ValueTypeMarker for Simple { |
| type Borrowed<'a> = &'a Self; |
| fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker for Simple { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(_context: fidl::encoding::Context) -> usize { |
| 1 |
| } |
| |
| #[inline(always)] |
| fn inline_size(_context: fidl::encoding::Context) -> usize { |
| 2 |
| } |
| } |
| |
| unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Simple, D> for &Simple { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_, D>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<Simple>(offset); |
| // Delegate to tuple encoding. |
| fidl::encoding::Encode::<Simple, D>::encode( |
| ( |
| <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.f1), |
| <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.f2), |
| ), |
| encoder, |
| offset, |
| _depth, |
| ) |
| } |
| } |
| unsafe impl< |
| D: fidl::encoding::ResourceDialect, |
| T0: fidl::encoding::Encode<u8, D>, |
| T1: fidl::encoding::Encode<bool, D>, |
| > fidl::encoding::Encode<Simple, 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::<Simple>(offset); |
| // Zero out padding regions. There's no need to apply masks |
| // because the unmasked parts will be overwritten by fields. |
| // Write the fields. |
| self.0.encode(encoder, offset + 0, depth)?; |
| self.1.encode(encoder, offset + 1, depth)?; |
| Ok(()) |
| } |
| } |
| |
| impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Simple { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self { f1: fidl::new_empty!(u8, D), f2: fidl::new_empty!(bool, 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); |
| // Verify that padding bytes are zero. |
| fidl::decode!(u8, D, &mut self.f1, decoder, offset + 0, _depth)?; |
| fidl::decode!(bool, D, &mut self.f2, decoder, offset + 1, _depth)?; |
| Ok(()) |
| } |
| } |
| } |