1#![cfg_attr(not(feature = "std"), no_std)]
2pub use primitive_enum_derive::{FromU8, PrimitiveFromEnum};
3#[cfg(feature = "std")]
4use std::{error::Error, fmt};
5
6pub trait PrimitiveFromEnum {
29 type PrimitiveEnum: TryFrom<u8> + UnsafeFromU8;
30
31 fn get_primitive_enum(&self) -> Self::PrimitiveEnum;
32
33 fn primitive_name() -> &'static str;
35}
36
37pub trait UnsafeFromU8: PartialEq<u8> + Sized {
38 unsafe fn from_unsafe(_: u8) -> Self;
42
43 fn name() -> &'static str;
45}
46
47#[cfg_attr(feature = "std", derive(Debug))]
48pub struct EnumFromU8Error;
49
50#[cfg(feature = "std")]
51impl fmt::Display for EnumFromU8Error {
52 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
53 write!(f, "EnumFromU8Error")
54 }
55}
56
57#[cfg(feature = "std")]
58impl Error for EnumFromU8Error {}