| // DO NOT EDIT: This file is machine-generated by fidlgen |
| #![warn(clippy::all)] |
| #![allow(unused_parens, unused_variables, unused_mut, unused_imports, unreachable_code)] |
| |
| pub mod natural { |
| |
| #[derive(PartialEq, Clone, Debug)] |
| pub struct BasicStruct { |
| pub x: u32, |
| |
| pub y: ::std::string::String, |
| } |
| |
| unsafe impl<___E> ::fidl_next::Encode<crate::wire::BasicStruct<'static>, ___E> for BasicStruct |
| where |
| ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized, |
| ___E: ::fidl_next::Encoder, |
| { |
| #[inline] |
| fn encode( |
| self, |
| encoder_: &mut ___E, |
| out_: &mut ::core::mem::MaybeUninit<crate::wire::BasicStruct<'static>>, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::munge! { |
| let crate::wire::BasicStruct { |
| x, |
| y, |
| |
| } = out_; |
| } |
| |
| ::fidl_next::Encode::encode(self.x, encoder_, x, ())?; |
| |
| let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(x.as_mut_ptr()) }; |
| |
| ::fidl_next::Encode::encode(self.y, encoder_, y, 4294967295)?; |
| |
| let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(y.as_mut_ptr()) }; |
| ::fidl_next::Constrained::validate(_field, 4294967295)?; |
| |
| Ok(()) |
| } |
| } |
| |
| unsafe impl<'a, ___E> ::fidl_next::Encode<crate::wire::BasicStruct<'static>, ___E> |
| for &'a BasicStruct |
| where |
| ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized, |
| ___E: ::fidl_next::Encoder, |
| { |
| #[inline] |
| fn encode( |
| self, |
| encoder_: &mut ___E, |
| out_: &mut ::core::mem::MaybeUninit<crate::wire::BasicStruct<'static>>, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::munge! { |
| let crate::wire::BasicStruct { |
| |
| x, |
| y, |
| |
| } = out_; |
| } |
| |
| ::fidl_next::Encode::encode(&self.x, encoder_, x, ())?; |
| |
| let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(x.as_mut_ptr()) }; |
| |
| ::fidl_next::Encode::encode(&self.y, encoder_, y, 4294967295)?; |
| |
| let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(y.as_mut_ptr()) }; |
| ::fidl_next::Constrained::validate(_field, 4294967295)?; |
| |
| Ok(()) |
| } |
| } |
| |
| unsafe impl<___E> |
| ::fidl_next::EncodeOption< |
| ::fidl_next::WireBox<'static, crate::wire::BasicStruct<'static>>, |
| ___E, |
| > for BasicStruct |
| where |
| ___E: ::fidl_next::Encoder + ?Sized, |
| BasicStruct: ::fidl_next::Encode<crate::wire::BasicStruct<'static>, ___E>, |
| { |
| #[inline] |
| fn encode_option( |
| this: ::core::option::Option<Self>, |
| encoder: &mut ___E, |
| out: &mut ::core::mem::MaybeUninit< |
| ::fidl_next::WireBox<'static, crate::wire::BasicStruct<'static>>, |
| >, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| if let Some(inner) = this { |
| ::fidl_next::EncoderExt::encode_next(encoder, inner, ())?; |
| ::fidl_next::WireBox::encode_present(out); |
| } else { |
| ::fidl_next::WireBox::encode_absent(out); |
| } |
| |
| Ok(()) |
| } |
| } |
| |
| unsafe impl<'a, ___E> |
| ::fidl_next::EncodeOption< |
| ::fidl_next::WireBox<'static, crate::wire::BasicStruct<'static>>, |
| ___E, |
| > for &'a BasicStruct |
| where |
| ___E: ::fidl_next::Encoder + ?Sized, |
| &'a BasicStruct: ::fidl_next::Encode<crate::wire::BasicStruct<'static>, ___E>, |
| { |
| #[inline] |
| fn encode_option( |
| this: ::core::option::Option<Self>, |
| encoder: &mut ___E, |
| out: &mut ::core::mem::MaybeUninit< |
| ::fidl_next::WireBox<'static, crate::wire::BasicStruct<'static>>, |
| >, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| if let Some(inner) = this { |
| ::fidl_next::EncoderExt::encode_next(encoder, inner, ())?; |
| ::fidl_next::WireBox::encode_present(out); |
| } else { |
| ::fidl_next::WireBox::encode_absent(out); |
| } |
| |
| Ok(()) |
| } |
| } |
| |
| impl<'de> ::fidl_next::FromWire<crate::wire::BasicStruct<'de>> for BasicStruct { |
| #[inline] |
| fn from_wire(wire: crate::wire::BasicStruct<'de>) -> Self { |
| Self { |
| x: ::fidl_next::FromWire::from_wire(wire.x), |
| |
| y: ::fidl_next::FromWire::from_wire(wire.y), |
| } |
| } |
| } |
| |
| impl<'de> ::fidl_next::FromWireRef<crate::wire::BasicStruct<'de>> for BasicStruct { |
| #[inline] |
| fn from_wire_ref(wire: &crate::wire::BasicStruct<'de>) -> Self { |
| Self { |
| x: ::fidl_next::FromWireRef::from_wire_ref(&wire.x), |
| |
| y: ::fidl_next::FromWireRef::from_wire_ref(&wire.y), |
| } |
| } |
| } |
| |
| #[derive(PartialEq, Clone, Debug)] |
| #[repr(C)] |
| pub struct Simple { |
| pub f1: u8, |
| |
| pub f2: bool, |
| } |
| |
| unsafe impl<___E> ::fidl_next::Encode<crate::wire::Simple, ___E> for Simple |
| where |
| ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized, |
| { |
| const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self, crate::wire::Simple> = unsafe { |
| ::fidl_next::CopyOptimization::enable_if( |
| true && <u8 as ::fidl_next::Encode<u8, ___E>>::COPY_OPTIMIZATION.is_enabled() |
| && <bool as ::fidl_next::Encode<bool, ___E>>::COPY_OPTIMIZATION.is_enabled(), |
| ) |
| }; |
| |
| #[inline] |
| fn encode( |
| self, |
| encoder_: &mut ___E, |
| out_: &mut ::core::mem::MaybeUninit<crate::wire::Simple>, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::munge! { |
| let crate::wire::Simple { |
| f1, |
| f2, |
| |
| } = out_; |
| } |
| |
| ::fidl_next::Encode::encode(self.f1, encoder_, f1, ())?; |
| |
| let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(f1.as_mut_ptr()) }; |
| |
| ::fidl_next::Encode::encode(self.f2, encoder_, f2, ())?; |
| |
| let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(f2.as_mut_ptr()) }; |
| |
| Ok(()) |
| } |
| } |
| |
| unsafe impl<'a, ___E> ::fidl_next::Encode<crate::wire::Simple, ___E> for &'a Simple |
| where |
| ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized, |
| { |
| #[inline] |
| fn encode( |
| self, |
| encoder_: &mut ___E, |
| out_: &mut ::core::mem::MaybeUninit<crate::wire::Simple>, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::munge! { |
| let crate::wire::Simple { |
| |
| f1, |
| f2, |
| |
| } = out_; |
| } |
| |
| ::fidl_next::Encode::encode(&self.f1, encoder_, f1, ())?; |
| |
| let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(f1.as_mut_ptr()) }; |
| |
| ::fidl_next::Encode::encode(&self.f2, encoder_, f2, ())?; |
| |
| let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(f2.as_mut_ptr()) }; |
| |
| Ok(()) |
| } |
| } |
| |
| unsafe impl<___E> |
| ::fidl_next::EncodeOption<::fidl_next::WireBox<'static, crate::wire::Simple>, ___E> |
| for Simple |
| where |
| ___E: ::fidl_next::Encoder + ?Sized, |
| Simple: ::fidl_next::Encode<crate::wire::Simple, ___E>, |
| { |
| #[inline] |
| fn encode_option( |
| this: ::core::option::Option<Self>, |
| encoder: &mut ___E, |
| out: &mut ::core::mem::MaybeUninit<::fidl_next::WireBox<'static, crate::wire::Simple>>, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| if let Some(inner) = this { |
| ::fidl_next::EncoderExt::encode_next(encoder, inner, ())?; |
| ::fidl_next::WireBox::encode_present(out); |
| } else { |
| ::fidl_next::WireBox::encode_absent(out); |
| } |
| |
| Ok(()) |
| } |
| } |
| |
| unsafe impl<'a, ___E> |
| ::fidl_next::EncodeOption<::fidl_next::WireBox<'static, crate::wire::Simple>, ___E> |
| for &'a Simple |
| where |
| ___E: ::fidl_next::Encoder + ?Sized, |
| &'a Simple: ::fidl_next::Encode<crate::wire::Simple, ___E>, |
| { |
| #[inline] |
| fn encode_option( |
| this: ::core::option::Option<Self>, |
| encoder: &mut ___E, |
| out: &mut ::core::mem::MaybeUninit<::fidl_next::WireBox<'static, crate::wire::Simple>>, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| if let Some(inner) = this { |
| ::fidl_next::EncoderExt::encode_next(encoder, inner, ())?; |
| ::fidl_next::WireBox::encode_present(out); |
| } else { |
| ::fidl_next::WireBox::encode_absent(out); |
| } |
| |
| Ok(()) |
| } |
| } |
| |
| impl ::fidl_next::FromWire<crate::wire::Simple> for Simple { |
| const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<crate::wire::Simple, Self> = unsafe { |
| ::fidl_next::CopyOptimization::enable_if( |
| true && <u8 as ::fidl_next::FromWire<u8>>::COPY_OPTIMIZATION.is_enabled() |
| && <bool as ::fidl_next::FromWire<bool>>::COPY_OPTIMIZATION.is_enabled(), |
| ) |
| }; |
| |
| #[inline] |
| fn from_wire(wire: crate::wire::Simple) -> Self { |
| Self { |
| f1: ::fidl_next::FromWire::from_wire(wire.f1), |
| |
| f2: ::fidl_next::FromWire::from_wire(wire.f2), |
| } |
| } |
| } |
| |
| impl ::fidl_next::FromWireRef<crate::wire::Simple> for Simple { |
| #[inline] |
| fn from_wire_ref(wire: &crate::wire::Simple) -> Self { |
| Self { |
| f1: ::fidl_next::FromWireRef::from_wire_ref(&wire.f1), |
| |
| f2: ::fidl_next::FromWireRef::from_wire_ref(&wire.f2), |
| } |
| } |
| } |
| } |
| |
| pub mod wire { |
| |
| /// The wire type corresponding to [`BasicStruct`]. |
| #[derive(Debug)] |
| #[repr(C)] |
| pub struct BasicStruct<'de> { |
| pub x: ::fidl_next::WireU32, |
| |
| pub y: ::fidl_next::WireString<'de>, |
| } |
| |
| static_assertions::const_assert_eq!(std::mem::size_of::<BasicStruct<'_>>(), 24); |
| static_assertions::const_assert_eq!(std::mem::align_of::<BasicStruct<'_>>(), 8); |
| |
| static_assertions::const_assert_eq!(std::mem::offset_of!(BasicStruct<'_>, x), 0); |
| |
| static_assertions::const_assert_eq!(std::mem::offset_of!(BasicStruct<'_>, y), 8); |
| |
| unsafe impl ::fidl_next::Wire for BasicStruct<'static> { |
| type Decoded<'de> = BasicStruct<'de>; |
| |
| #[inline] |
| fn zero_padding(out_: &mut ::core::mem::MaybeUninit<Self>) { |
| ::fidl_next::munge! { |
| let Self { |
| |
| x, |
| y, |
| |
| } = &mut *out_; |
| } |
| |
| ::fidl_next::Wire::zero_padding(x); |
| |
| ::fidl_next::Wire::zero_padding(y); |
| |
| unsafe { |
| out_.as_mut_ptr().cast::<u8>().add(4).write_bytes(0, 4); |
| } |
| } |
| } |
| |
| unsafe impl<___D> ::fidl_next::Decode<___D> for BasicStruct<'static> |
| where |
| ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized, |
| ___D: ::fidl_next::Decoder, |
| { |
| fn decode( |
| slot_: ::fidl_next::Slot<'_, Self>, |
| decoder_: &mut ___D, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::DecodeError> { |
| if slot_.as_bytes()[4..8] != [0u8; 4] { |
| return Err(::fidl_next::DecodeError::InvalidPadding); |
| } |
| |
| ::fidl_next::munge! { |
| let Self { |
| |
| mut x, |
| mut y, |
| |
| } = slot_; |
| } |
| |
| let _field = x.as_mut(); |
| |
| ::fidl_next::Decode::decode(x.as_mut(), decoder_, ())?; |
| |
| let _field = y.as_mut(); |
| ::fidl_next::Constrained::validate(_field, 4294967295)?; |
| ::fidl_next::Decode::decode(y.as_mut(), decoder_, 4294967295)?; |
| |
| Ok(()) |
| } |
| } |
| |
| impl<'de> ::fidl_next::IntoNatural for BasicStruct<'de> { |
| type Natural = crate::natural::BasicStruct; |
| } |
| |
| impl ::fidl_next::Unconstrained for BasicStruct<'static> {} |
| |
| /// The wire type corresponding to [`Simple`]. |
| #[derive(Clone, Debug)] |
| #[repr(C)] |
| pub struct Simple { |
| pub f1: u8, |
| |
| pub f2: bool, |
| } |
| |
| static_assertions::const_assert_eq!(std::mem::size_of::<Simple>(), 2); |
| static_assertions::const_assert_eq!(std::mem::align_of::<Simple>(), 1); |
| |
| static_assertions::const_assert_eq!(std::mem::offset_of!(Simple, f1), 0); |
| |
| static_assertions::const_assert_eq!(std::mem::offset_of!(Simple, f2), 1); |
| |
| unsafe impl ::fidl_next::Wire for Simple { |
| type Decoded<'de> = Simple; |
| |
| #[inline] |
| fn zero_padding(out_: &mut ::core::mem::MaybeUninit<Self>) { |
| ::fidl_next::munge! { |
| let Self { |
| |
| f1, |
| f2, |
| |
| } = &mut *out_; |
| } |
| |
| ::fidl_next::Wire::zero_padding(f1); |
| |
| ::fidl_next::Wire::zero_padding(f2); |
| } |
| } |
| |
| unsafe impl<___D> ::fidl_next::Decode<___D> for Simple |
| where |
| ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized, |
| { |
| fn decode( |
| slot_: ::fidl_next::Slot<'_, Self>, |
| decoder_: &mut ___D, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::DecodeError> { |
| ::fidl_next::munge! { |
| let Self { |
| |
| mut f1, |
| mut f2, |
| |
| } = slot_; |
| } |
| |
| let _field = f1.as_mut(); |
| |
| ::fidl_next::Decode::decode(f1.as_mut(), decoder_, ())?; |
| |
| let _field = f2.as_mut(); |
| |
| ::fidl_next::Decode::decode(f2.as_mut(), decoder_, ())?; |
| |
| Ok(()) |
| } |
| } |
| |
| impl ::fidl_next::IntoNatural for Simple { |
| type Natural = crate::natural::Simple; |
| } |
| |
| impl ::fidl_next::Unconstrained for Simple {} |
| } |
| |
| pub mod wire_optional {} |
| |
| pub mod generic { |
| |
| pub struct BasicStruct<T0, T1> { |
| pub x: T0, |
| |
| pub y: T1, |
| } |
| |
| unsafe impl<___E, T0, T1> ::fidl_next::Encode<crate::wire::BasicStruct<'static>, ___E> |
| for BasicStruct<T0, T1> |
| where |
| ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized, |
| ___E: ::fidl_next::Encoder, |
| T0: ::fidl_next::Encode<::fidl_next::WireU32, ___E>, |
| T1: ::fidl_next::Encode<::fidl_next::WireString<'static>, ___E>, |
| { |
| #[inline] |
| fn encode( |
| self, |
| encoder_: &mut ___E, |
| out_: &mut ::core::mem::MaybeUninit<crate::wire::BasicStruct<'static>>, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::munge! { |
| let crate::wire::BasicStruct { |
| |
| x, |
| y, |
| |
| } = out_; |
| } |
| |
| ::fidl_next::Encode::encode(self.x, encoder_, x, ())?; |
| |
| ::fidl_next::Encode::encode(self.y, encoder_, y, 4294967295)?; |
| |
| Ok(()) |
| } |
| } |
| |
| pub struct Simple<T0, T1> { |
| pub f1: T0, |
| |
| pub f2: T1, |
| } |
| |
| unsafe impl<___E, T0, T1> ::fidl_next::Encode<crate::wire::Simple, ___E> for Simple<T0, T1> |
| where |
| ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized, |
| T0: ::fidl_next::Encode<u8, ___E>, |
| T1: ::fidl_next::Encode<bool, ___E>, |
| { |
| #[inline] |
| fn encode( |
| self, |
| encoder_: &mut ___E, |
| out_: &mut ::core::mem::MaybeUninit<crate::wire::Simple>, |
| _: (), |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::munge! { |
| let crate::wire::Simple { |
| |
| f1, |
| f2, |
| |
| } = out_; |
| } |
| |
| ::fidl_next::Encode::encode(self.f1, encoder_, f1, ())?; |
| |
| ::fidl_next::Encode::encode(self.f2, encoder_, f2, ())?; |
| |
| Ok(()) |
| } |
| } |
| } |
| |
| pub use self::natural::*; |
| |
| /// Compatibility shims which mimic some API surfaces of the current Rust bindings. |
| pub mod compat { |
| |
| impl ::fidl_next::CompatFrom<crate::BasicStruct> for ::fidl_test_struct::BasicStruct { |
| #[inline] |
| fn compat_from(value: crate::BasicStruct) -> Self { |
| Self { |
| x: ::fidl_next::CompatFrom::compat_from(value.x), |
| |
| y: ::fidl_next::CompatFrom::compat_from(value.y), |
| } |
| } |
| } |
| |
| impl ::fidl_next::CompatFrom<::fidl_test_struct::BasicStruct> for crate::BasicStruct { |
| #[inline] |
| fn compat_from(value: ::fidl_test_struct::BasicStruct) -> Self { |
| Self { |
| x: ::fidl_next::CompatFrom::compat_from(value.x), |
| |
| y: ::fidl_next::CompatFrom::compat_from(value.y), |
| } |
| } |
| } |
| |
| impl ::fidl_next::CompatFrom<crate::Simple> for ::fidl_test_struct::Simple { |
| #[inline] |
| fn compat_from(value: crate::Simple) -> Self { |
| Self { |
| f1: ::fidl_next::CompatFrom::compat_from(value.f1), |
| |
| f2: ::fidl_next::CompatFrom::compat_from(value.f2), |
| } |
| } |
| } |
| |
| impl ::fidl_next::CompatFrom<::fidl_test_struct::Simple> for crate::Simple { |
| #[inline] |
| fn compat_from(value: ::fidl_test_struct::Simple) -> Self { |
| Self { |
| f1: ::fidl_next::CompatFrom::compat_from(value.f1), |
| |
| f2: ::fidl_next::CompatFrom::compat_from(value.f2), |
| } |
| } |
| } |
| } |