| // DO NOT EDIT: This file is machine-generated by fidlgen |
| #![warn(clippy::all)] |
| #![allow(unused_parens, unused_variables, unused_mut, unused_imports, unreachable_code)] |
| |
| ::fidl_next::bitflags::bitflags! { |
| #[derive( |
| Clone, |
| Copy, |
| Debug, |
| PartialEq, |
| Eq, |
| Hash, |
| )] |
| pub struct BitsType: u32 { |
| const A = 1; |
| const B = 128; |
| const C = 2; |
| |
| } |
| } |
| |
| impl ::fidl_next::Encodable for BitsType { |
| type Encoded = WireBitsType; |
| } |
| |
| unsafe impl<___E> ::fidl_next::Encode<___E> for BitsType |
| where |
| ___E: ?Sized, |
| { |
| #[inline] |
| fn encode( |
| self, |
| encoder: &mut ___E, |
| out: &mut ::core::mem::MaybeUninit<Self::Encoded>, |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::EncodeRef::encode_ref(&self, encoder, out) |
| } |
| } |
| |
| unsafe impl<___E> ::fidl_next::EncodeRef<___E> for BitsType |
| where |
| ___E: ?Sized, |
| { |
| #[inline] |
| fn encode_ref( |
| &self, |
| _: &mut ___E, |
| out: &mut ::core::mem::MaybeUninit<Self::Encoded>, |
| ) -> ::core::result::Result<(), ::fidl_next::EncodeError> { |
| ::fidl_next::munge!(let WireBitsType { value } = out); |
| |
| if ::fidl_next::bitflags::Flags::contains_unknown_bits(self) { |
| return Err(::fidl_next::EncodeError::InvalidStrictBits); |
| } |
| |
| let _ = value.write(::fidl_next::WireU32::from(self.bits())); |
| Ok(()) |
| } |
| } |
| |
| impl ::core::convert::From<WireBitsType> for BitsType { |
| fn from(wire: WireBitsType) -> Self { |
| Self::from_bits_retain(u32::from(wire.value)) |
| } |
| } |
| |
| impl ::fidl_next::FromWire<WireBitsType> for BitsType { |
| #[inline] |
| fn from_wire(wire: WireBitsType) -> Self { |
| Self::from(wire) |
| } |
| } |
| |
| impl ::fidl_next::IntoNatural for WireBitsType { |
| type Natural = BitsType; |
| } |
| |
| impl ::fidl_next::FromWireRef<WireBitsType> for BitsType { |
| #[inline] |
| fn from_wire_ref(wire: &WireBitsType) -> Self { |
| Self::from(*wire) |
| } |
| } |
| |
| /// The wire type corresponding to [`BitsType`]. |
| #[derive(Clone, Copy, Debug)] |
| #[repr(transparent)] |
| pub struct WireBitsType { |
| value: ::fidl_next::WireU32, |
| } |
| |
| unsafe impl ::fidl_next::Wire for WireBitsType { |
| type Decoded<'de> = Self; |
| |
| #[inline] |
| fn zero_padding(_: &mut ::core::mem::MaybeUninit<Self>) { |
| // Wire bits have no padding |
| } |
| } |
| |
| unsafe impl<___D> ::fidl_next::Decode<___D> for WireBitsType |
| where |
| ___D: ?Sized, |
| { |
| fn decode( |
| slot: ::fidl_next::Slot<'_, Self>, |
| _: &mut ___D, |
| ) -> ::core::result::Result<(), ::fidl_next::DecodeError> { |
| ::fidl_next::munge!(let Self { value } = slot); |
| let set = u32::from(*value); |
| if set & !BitsType::all().bits() != 0 { |
| return Err(::fidl_next::DecodeError::InvalidBits { |
| expected: BitsType::all().bits() as usize, |
| actual: set as usize, |
| }); |
| } |
| |
| Ok(()) |
| } |
| } |
| |
| impl ::core::convert::From<BitsType> for WireBitsType { |
| fn from(natural: BitsType) -> Self { |
| Self { value: ::fidl_next::WireU32::from(natural.bits()) } |
| } |
| } |
| |
| pub const CONST0: crate::BitsType = crate::BitsType::from_bits_retain(0); |
| |
| pub const CONST1: crate::BitsType = crate::BitsType::A; |
| |
| pub const CONST2: crate::BitsType = crate::BitsType::from_bits_retain(129); |
| |
| pub const CONST3: crate::BitsType = crate::BitsType::from_bits_retain(131); |
| |
| /// Compatibility shims which mimic some API surfaces of the current Rust bindings. |
| pub mod compat { |
| |
| impl ::fidl_next::CompatFrom<crate::BitsType> for ::fidl_test_bitsconstants::BitsType { |
| fn compat_from(value: crate::BitsType) -> Self { |
| Self::from_bits_retain(value.bits()) |
| } |
| } |
| |
| impl ::fidl_next::CompatFrom<::fidl_test_bitsconstants::BitsType> for crate::BitsType { |
| fn compat_from(value: ::fidl_test_bitsconstants::BitsType) -> Self { |
| Self::from_bits_retain(value.bits()) |
| } |
| } |
| } |