use crate::{Error, lib_enum};
lib_enum! {
Direction: u8 {
default: Write,
error: Error,
Write = 0,
Read = 1,
}
}
impl Direction {
pub const fn from_bool(val: bool) -> Self {
match val {
false => Self::Write,
true => Self::Read,
}
}
pub const fn into_bool(self) -> bool {
(self as u8) != 0
}
}
impl From<bool> for Direction {
fn from(val: bool) -> Self {
Self::from_bool(val)
}
}
impl From<Direction> for bool {
fn from(val: Direction) -> Self {
val.into_bool()
}
}