pub struct EnumByte<E: UnitEnum> { /* private fields */ }Expand description
One byte that stores a UnitEnum. Pod, so it can sit in a
#[hopper::state] layout, a #[hopper::pod] struct, or
#[hopper::args]; the enum is validated when it is read.
Implementations§
Source§impl<E: UnitEnum> EnumByte<E>
impl<E: UnitEnum> EnumByte<E>
Sourcepub const fn from_raw(byte: u8) -> Self
pub const fn from_raw(byte: u8) -> Self
Wrap a raw byte without checking that it names a variant;
get checks on every read.
Sourcepub fn get(&self) -> Result<E, ProgramError>
pub fn get(&self) -> Result<E, ProgramError>
The stored variant. A byte that names no variant is refused with
InvalidAccountData.
Sourcepub fn validate(&self) -> ProgramResult
pub fn validate(&self) -> ProgramResult
Whether the stored byte names a variant.
Trait Implementations§
impl<E: UnitEnum> Copy for EnumByte<E>
impl<E: UnitEnum> Eq for EnumByte<E>
impl<E: UnitEnum> Pod for EnumByte<E>
impl<E: UnitEnum> Zeroable for EnumByte<E>
Auto Trait Implementations§
impl<E> Freeze for EnumByte<E>where
PhantomData<E>: Freeze,
impl<E> RefUnwindSafe for EnumByte<E>where
PhantomData<E>: RefUnwindSafe,
impl<E> Send for EnumByte<E>where
PhantomData<E>: Send,
impl<E> Sync for EnumByte<E>where
PhantomData<E>: Sync,
impl<E> Unpin for EnumByte<E>where
PhantomData<E>: Unpin,
impl<E> UnsafeUnpin for EnumByte<E>where
PhantomData<E>: UnsafeUnpin,
impl<E> UnwindSafe for EnumByte<E>where
PhantomData<E>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more