blob: 8a2492fd795eeb88a17deefcfc720968c0352fc8 [file] [log] [blame]
// 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 {
::fidl_next::bitflags::bitflags! {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
)]
pub struct BitsType: u32 {
const A = 1;
const B = 128;
const C = 2;
}
}
unsafe impl<___E> ::fidl_next::Encode<crate::wire::BitsType, ___E> for BitsType
where
___E: ?Sized,
{
#[inline]
fn encode(
self,
encoder: &mut ___E,
out: &mut ::core::mem::MaybeUninit<crate::wire::BitsType>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
::fidl_next::Encode::encode(&self, encoder, out, ())
}
}
unsafe impl<'a, ___E> ::fidl_next::Encode<crate::wire::BitsType, ___E> for &'a BitsType
where
___E: ?Sized,
{
#[inline]
fn encode(
self,
_: &mut ___E,
out: &mut ::core::mem::MaybeUninit<crate::wire::BitsType>,
_: (),
) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
::fidl_next::munge!(let crate::wire::BitsType { 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<crate::wire::BitsType> for BitsType {
fn from(wire: crate::wire::BitsType) -> Self {
Self::from_bits_retain(u32::from(wire.value))
}
}
impl ::fidl_next::FromWire<crate::wire::BitsType> for BitsType {
#[inline]
fn from_wire(wire: crate::wire::BitsType) -> Self {
Self::from(wire)
}
}
impl ::fidl_next::FromWireRef<crate::wire::BitsType> for BitsType {
#[inline]
fn from_wire_ref(wire: &crate::wire::BitsType) -> Self {
Self::from(*wire)
}
}
}
pub mod wire {
/// The wire type corresponding to [`BitsType`](crate::natural::BitsType).
#[derive(Clone, Copy, Debug)]
#[repr(transparent)]
pub struct BitsType {
pub(crate) value: ::fidl_next::WireU32,
}
unsafe impl ::fidl_next::Wire for BitsType {
type Owned<'de> = Self;
#[inline]
fn zero_padding(_: &mut ::core::mem::MaybeUninit<Self>) {
// Wire bits have no padding
}
}
unsafe impl<___D> ::fidl_next::Decode<___D> for BitsType
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 & !crate::natural::BitsType::all().bits() != 0 {
return Err(::fidl_next::DecodeError::InvalidBits {
expected: crate::natural::BitsType::all().bits() as usize,
actual: set as usize,
});
}
Ok(())
}
}
impl ::core::convert::From<crate::natural::BitsType> for BitsType {
fn from(natural: crate::natural::BitsType) -> Self {
Self { value: ::fidl_next::WireU32::from(natural.bits()) }
}
}
impl ::fidl_next::IntoNatural for BitsType {
type Natural = crate::natural::BitsType;
}
impl ::fidl_next::Unconstrained for BitsType {}
}
pub mod wire_optional {}
pub mod generic {}
pub use self::natural::*;
pub const CONST0: crate::natural::BitsType = crate::natural::BitsType::from_bits_retain(0);
pub const CONST1: crate::natural::BitsType = crate::natural::BitsType::A;
pub const CONST2: crate::natural::BitsType = crate::natural::BitsType::from_bits_retain(129);
pub const CONST3: crate::natural::BitsType = crate::natural::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())
}
}
}