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