sdmmc-core 0.5.0

SD/MMC core data structures and algorithms
Documentation
use crate::lib_enum;
use crate::result::Error;

lib_enum! {
    /// Represents the `R/W` (read/write flag) field of the [Argument](super::Argument).
    ReadWrite: u8 {
        default: Write,
        error: Error,
        /// The command is used to write a single data block from the card.
        Write = 0,
        /// The command is used to read a single data block from the card.
        Read = 1,
    }
}

impl ReadWrite {
    /// Converts a [`bool`] into a [ReadWrite].
    pub const fn from_bool(val: bool) -> Self {
        match val {
            false => Self::Write,
            true => Self::Read,
        }
    }

    /// Converts a [ReadWrite] into a [`bool`].
    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()
    }
}