sdmmc-core 0.5.0

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

lib_enum! {
    /// Represents the `Speed Class Control` field for legacy and UHS speed mode.
    VideoSpeedClass: u8 {
        default: LegacyUHS,
        error: Error,
        /// Indicates that the card is in legacy or UHS speed mode.
        LegacyUHS = 0b0,
        /// Indicates that the card is in Video speed mode.
        Video = 0b1,
    }
}

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

    /// Converts the [VideoSpeedClass] into a [`bool`].
    pub const fn into_bool(&self) -> bool {
        match self {
            Self::LegacyUHS => false,
            Self::Video => true,
        }
    }
}

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

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