sdmmc-core 0.5.0

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

lib_enum! {
    /// Represents the maximum write data block length.
    WriteBlockLength: u8 {
        default: Bytes512,
        error: Error,
        /// Maximum read block length: 512 bytes.
        Bytes512 = 9,
        /// Maximum read block length: 1024 bytes.
        Bytes1024 = 10,
        /// Maximum read block length: 2048 bytes.
        Bytes2048 = 11,
    }
}

impl WriteBlockLength {
    /// Gets the block length in bytes for the [WriteBlockLength].
    #[inline]
    pub const fn block_len(self) -> usize {
        1usize << ((self as u8) - 1)
    }

    /// Attempts to convert an inner representation into a [WriteBlockLength].
    pub const fn try_from_inner(val: u8) -> Result<Self> {
        Self::from_raw(val)
    }

    /// Converts a [WriteBlockLength] into an inner representation.
    pub const fn into_inner(self) -> u8 {
        self.into_raw()
    }
}