dust_devil_core/u8_repr_enum.rs
1//! Provides the [`U8ReprEnum`] trait, which is made to be implemented by enums that can be
2//! converted into or parsed from an [`u8`] value, for easy serialization and deserialization.
3
4/// Allows a type to be converted into or parsed from an [`u8`] representation.
5pub trait U8ReprEnum: Sized {
6 /// Parses an `u8` into the enum variant it represents. If the `u8` represents a variant in
7 /// this enum, then `Some` is returned with said variant. Otherwise, `None` is returned.
8 fn from_u8(value: u8) -> Option<Self>;
9
10 /// Converts this enum into its `u8` representation.
11 fn into_u8(self) -> u8;
12}