| // WARNING: This file is machine generated by fidlgen. |
| |
| // fidl_experiment = no_optional_structs |
| // fidl_experiment = output_index_json |
| // fidl_experiment = unknown_interactions |
| // fidl_experiment = unknown_interactions_mandate |
| |
| #![warn(clippy::all)] |
| #![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)] |
| |
| use { |
| bitflags::bitflags, |
| fidl::{ |
| client::QueryResponseFut, |
| endpoints::{ControlHandle as _, Responder as _}, |
| }, |
| fuchsia_zircon_status as zx_status, |
| futures::future::{self, MaybeDone, TryFutureExt}, |
| }; |
| |
| #[cfg(target_os = "fuchsia")] |
| use fuchsia_zircon as zx; |
| |
| #[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::*; |
| |
| unsafe impl fidl::encoding::TypeMarker for BasicStruct { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 8, |
| fidl::encoding::WireFormatVersion::V2 => 8, |
| } |
| } |
| |
| #[inline(always)] |
| fn inline_size(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 24, |
| fidl::encoding::WireFormatVersion::V2 => 24, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for BasicStruct { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<BasicStruct> for &BasicStruct { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<BasicStruct>(offset); |
| // Delegate to tuple encoding. |
| fidl::encoding::Encode::<BasicStruct>::encode( |
| ( |
| <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.x), |
| <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow( |
| &self.y, |
| ), |
| ), |
| encoder, |
| offset, |
| _depth, |
| ) |
| } |
| } |
| unsafe impl< |
| T0: fidl::encoding::Encode<u32>, |
| T1: fidl::encoding::Encode<fidl::encoding::UnboundedString>, |
| > fidl::encoding::Encode<BasicStruct> for (T0, T1) |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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. |
| match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => unsafe { |
| let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0); |
| (ptr as *mut u64).write_unaligned(0); |
| }, |
| fidl::encoding::WireFormatVersion::V2 => unsafe { |
| let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0); |
| (ptr as *mut u64).write_unaligned(0); |
| }, |
| }; |
| // Write the fields. |
| let member_offset = match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| self.0.encode(encoder, offset + member_offset, depth)?; |
| let member_offset = match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 8, |
| fidl::encoding::WireFormatVersion::V2 => 8, |
| }; |
| self.1.encode(encoder, offset + member_offset, depth)?; |
| Ok(()) |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for BasicStruct { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self { x: fidl::new_empty!(u32), y: fidl::new_empty!(fidl::encoding::UnboundedString) } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| decoder.debug_check_bounds::<Self>(offset); |
| // Verify that padding bytes are zero. |
| match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => { |
| let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) }; |
| let padval = unsafe { (ptr as *const u64).read_unaligned() }; |
| let maskedval = padval & 0xffffffff00000000u64; |
| if (maskedval != 0) { |
| return Err(fidl::Error::NonZeroPadding { |
| padding_start: offset |
| + 0 |
| + ((0xffffffff00000000u64 as u64).trailing_zeros() / 8) as usize, |
| }); |
| } |
| } |
| fidl::encoding::WireFormatVersion::V2 => { |
| let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) }; |
| let padval = unsafe { (ptr as *const u64).read_unaligned() }; |
| let maskedval = padval & 0xffffffff00000000u64; |
| if (maskedval != 0) { |
| return Err(fidl::Error::NonZeroPadding { |
| padding_start: offset |
| + 0 |
| + ((0xffffffff00000000u64 as u64).trailing_zeros() / 8) as usize, |
| }); |
| } |
| } |
| }; |
| let member_offset = match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| fidl::decode!(u32, &mut self.x, decoder, offset + member_offset, _depth)?; |
| let member_offset = match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 8, |
| fidl::encoding::WireFormatVersion::V2 => 8, |
| }; |
| fidl::decode!( |
| fidl::encoding::UnboundedString, |
| &mut self.y, |
| decoder, |
| offset + member_offset, |
| _depth |
| )?; |
| Ok(()) |
| } |
| } |
| |
| unsafe impl fidl::encoding::TypeMarker for Simple { |
| type Owned = Self; |
| |
| #[inline(always)] |
| fn inline_align(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 1, |
| fidl::encoding::WireFormatVersion::V2 => 1, |
| } |
| } |
| |
| #[inline(always)] |
| fn inline_size(context: fidl::encoding::Context) -> usize { |
| match context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 2, |
| fidl::encoding::WireFormatVersion::V2 => 2, |
| } |
| } |
| } |
| impl fidl::encoding::ValueTypeMarker for Simple { |
| type Borrowed<'a> = &'a Self; |
| fn borrow<'a>( |
| value: &'a <Self as fidl::encoding::TypeMarker>::Owned, |
| ) -> Self::Borrowed<'a> { |
| value |
| } |
| } |
| |
| unsafe impl fidl::encoding::Encode<Simple> for &Simple { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| encoder.debug_check_bounds::<Simple>(offset); |
| // Delegate to tuple encoding. |
| fidl::encoding::Encode::<Simple>::encode( |
| ( |
| <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.f1), |
| <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.f2), |
| ), |
| encoder, |
| offset, |
| _depth, |
| ) |
| } |
| } |
| unsafe impl<T0: fidl::encoding::Encode<u8>, T1: fidl::encoding::Encode<bool>> |
| fidl::encoding::Encode<Simple> for (T0, T1) |
| { |
| #[inline] |
| unsafe fn encode( |
| self, |
| encoder: &mut fidl::encoding::Encoder<'_>, |
| 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. |
| match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => {} |
| fidl::encoding::WireFormatVersion::V2 => {} |
| }; |
| // Write the fields. |
| let member_offset = match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| self.0.encode(encoder, offset + member_offset, depth)?; |
| let member_offset = match encoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 1, |
| fidl::encoding::WireFormatVersion::V2 => 1, |
| }; |
| self.1.encode(encoder, offset + member_offset, depth)?; |
| Ok(()) |
| } |
| } |
| |
| impl fidl::encoding::Decode<Self> for Simple { |
| #[inline(always)] |
| fn new_empty() -> Self { |
| Self { f1: fidl::new_empty!(u8), f2: fidl::new_empty!(bool) } |
| } |
| |
| #[inline] |
| unsafe fn decode( |
| &mut self, |
| decoder: &mut fidl::encoding::Decoder<'_>, |
| offset: usize, |
| _depth: fidl::encoding::Depth, |
| ) -> fidl::Result<()> { |
| decoder.debug_check_bounds::<Self>(offset); |
| // Verify that padding bytes are zero. |
| match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => {} |
| fidl::encoding::WireFormatVersion::V2 => {} |
| }; |
| let member_offset = match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 0, |
| fidl::encoding::WireFormatVersion::V2 => 0, |
| }; |
| fidl::decode!(u8, &mut self.f1, decoder, offset + member_offset, _depth)?; |
| let member_offset = match decoder.context.wire_format_version { |
| fidl::encoding::WireFormatVersion::V1 => 1, |
| fidl::encoding::WireFormatVersion::V2 => 1, |
| }; |
| fidl::decode!(bool, &mut self.f2, decoder, offset + member_offset, _depth)?; |
| Ok(()) |
| } |
| } |
| } |