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).
    BlockUnitSelect: u8 {
        default: Bytes512,
        error: Error,
        /// Use 512-byte block units.
        Bytes512 = 0,
        /// Use 32k-byte block units.
        Bytes32k = 1,
    }
}

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

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

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

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