blob: 052dbf52a055804bda4f115dcb6525853fd8c663 [file] [log] [blame]
// WARNING: This file is machine generated by fidlgen.
#![allow(
unused_parens, // one-element-tuple-case is not a tuple
unused_mut, // not all args require mutation, but many do
nonstandard_style, // auto-caps does its best, but is not always successful
)]
#![recursion_limit = "512"]
#[cfg(target_os = "fuchsia")]
#[allow(unused_imports)]
use fuchsia_zircon as zx;
#[allow(unused_imports)]
use {
bitflags::bitflags,
fidl::{
client::{decode_transaction_body_fut, QueryResponseFut},
encoding::{Decodable as _, Encodable as _},
endpoints::{ControlHandle as _, Responder as _},
fidl_bits, fidl_empty_struct, fidl_enum, fidl_struct, fidl_struct_copy, fidl_table,
fidl_union, wrap_handle_metadata,
},
fuchsia_zircon_status as zx_status,
futures::future::{self, MaybeDone, TryFutureExt},
};
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[non_exhaustive]
pub enum MyEmptyFlexibleEnum {
#[deprecated = "Use `MyEmptyFlexibleEnum::unknown()` to construct and `MyEmptyFlexibleEnumUnknown!()` to exhaustively match."]
#[doc(hidden)]
__Unknown(u32),
}
/// Pattern that matches an unknown `MyEmptyFlexibleEnum` member.
#[macro_export]
macro_rules! MyEmptyFlexibleEnumUnknown {
() => {
_
};
}
impl MyEmptyFlexibleEnum {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
_ => None,
}
}
#[inline]
pub fn from_primitive_allow_unknown(prim: u32) -> Self {
match prim {
#[allow(deprecated)]
x => Self::__Unknown(x),
}
}
#[inline]
pub fn unknown() -> Self {
#[allow(deprecated)]
Self::__Unknown(0xffffffff)
}
#[inline]
pub const fn into_primitive(self) -> u32 {
match self {
#[allow(deprecated)]
Self::__Unknown(x) => x,
}
}
#[inline]
pub fn validate(self) -> std::result::Result<Self, u32> {
match self {
#[allow(deprecated)]
Self::__Unknown(x) => Err(x),
}
}
#[inline]
pub fn is_unknown(&self) -> bool {
self.validate().is_err()
}
}
fidl_enum! {
name: MyEmptyFlexibleEnum,
prim_ty: u32,
flexible: true,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[non_exhaustive]
pub enum MyFlexibleEnum {
Foo,
Bar,
#[deprecated = "Use `MyFlexibleEnum::unknown()` to construct and `MyFlexibleEnumUnknown!()` to exhaustively match."]
#[doc(hidden)]
__Unknown(u32),
}
/// Pattern that matches an unknown `MyFlexibleEnum` member.
#[macro_export]
macro_rules! MyFlexibleEnumUnknown {
() => {
_
};
}
impl MyFlexibleEnum {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
1 => Some(Self::Foo),
2 => Some(Self::Bar),
_ => None,
}
}
#[inline]
pub fn from_primitive_allow_unknown(prim: u32) -> Self {
match prim {
1 => Self::Foo,
2 => Self::Bar,
#[allow(deprecated)]
x => Self::__Unknown(x),
}
}
#[inline]
pub fn unknown() -> Self {
#[allow(deprecated)]
Self::__Unknown(0xffffffff)
}
#[inline]
pub const fn into_primitive(self) -> u32 {
match self {
Self::Foo => 1,
Self::Bar => 2,
#[allow(deprecated)]
Self::__Unknown(x) => x,
}
}
#[inline]
pub fn validate(self) -> std::result::Result<Self, u32> {
match self {
#[allow(deprecated)]
Self::__Unknown(x) => Err(x),
_ => Ok(self),
}
}
#[inline]
pub fn is_unknown(&self) -> bool {
self.validate().is_err()
}
}
fidl_enum! {
name: MyFlexibleEnum,
prim_ty: u32,
flexible: true,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[non_exhaustive]
pub enum MyFlexibleEnumWithCustomUnknown {
Foo,
Bar,
CustomUnknown,
#[deprecated = "Use `MyFlexibleEnumWithCustomUnknown::unknown()` to construct and `MyFlexibleEnumWithCustomUnknownUnknown!()` to exhaustively match."]
#[doc(hidden)]
__Unknown(u32),
}
/// Pattern that matches an unknown `MyFlexibleEnumWithCustomUnknown` member.
#[macro_export]
macro_rules! MyFlexibleEnumWithCustomUnknownUnknown {
() => {
_
};
}
impl MyFlexibleEnumWithCustomUnknown {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
1 => Some(Self::Foo),
2 => Some(Self::Bar),
3 => Some(Self::CustomUnknown),
_ => None,
}
}
#[inline]
pub fn from_primitive_allow_unknown(prim: u32) -> Self {
match prim {
1 => Self::Foo,
2 => Self::Bar,
3 => Self::CustomUnknown,
#[allow(deprecated)]
x => Self::__Unknown(x),
}
}
#[inline]
pub fn unknown() -> Self {
#[allow(deprecated)]
Self::__Unknown(0x3)
}
#[inline]
pub const fn into_primitive(self) -> u32 {
match self {
Self::Foo => 1,
Self::Bar => 2,
Self::CustomUnknown => 3,
#[allow(deprecated)]
Self::__Unknown(x) => x,
}
}
#[inline]
pub fn validate(self) -> std::result::Result<Self, u32> {
match self {
Self::CustomUnknown => Err(self.into_primitive()),
#[allow(deprecated)]
Self::__Unknown(x) => Err(x),
_ => Ok(self),
}
}
#[inline]
pub fn is_unknown(&self) -> bool {
self.validate().is_err()
}
}
fidl_enum! {
name: MyFlexibleEnumWithCustomUnknown,
prim_ty: u32,
flexible: true,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u32)]
pub enum MyStrictEnum {
Foo = 1,
Bar = 2,
}
impl MyStrictEnum {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
1 => Some(Self::Foo),
2 => Some(Self::Bar),
_ => None,
}
}
#[inline]
pub const fn into_primitive(self) -> u32 {
self as u32
}
#[deprecated = "Strict enums should not use `validate`"]
#[inline]
pub fn validate(self) -> std::result::Result<Self, u32> {
Ok(self)
}
#[deprecated = "Strict enums should not use `is_unknown`"]
#[inline]
pub fn is_unknown(&self) -> bool {
false
}
}
fidl_enum! {
name: MyStrictEnum,
prim_ty: u32,
strict: true,
min_member: Foo,
}