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 `MIO` (memory or I/O) field of the [Argument](super::Argument).
    Mio: u8 {
        default: Memory,
        error: Error,
        /// Use the memory extension.
        Memory = 0,
        /// Use the I/O extension.
        Io = 1,
    }
}

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

    /// Converts a [Mio] into a [`bool`].
    pub const fn into_bool(self) -> bool {
        (self as u8) != 0
    }
}

impl From<bool> for Mio {
    fn from(val: bool) -> Self {
        Self::from_bool(val)
    }
}

impl From<Mio> for bool {
    fn from(val: Mio) -> Self {
        val.into_bool()
    }
}