sdmmc_driver/config/
erase_mode.rs

1use sdmmc::lib_enum;
2
3use crate::result::Error;
4
5lib_enum! {
6    /// Represents the erase mode argument.
7    EraseMode: u32 {
8        default: Erase,
9        error: Error,
10        Erase = 0x0000_0000,
11        SecureErase = 0x8000_0000,
12        Trim = 0x0000_0001,
13        SecureTrim1 = 0x8000_0001,
14        SecureTrim2 = 0x8000_8000,
15        Discard = 0x0000_0003,
16    }
17}
18
19impl EraseMode {
20    /// Indicates if the [EraseMode] is a `SECURE` mode.
21    pub const fn is_secure(&self) -> bool {
22        matches!(
23            self,
24            Self::SecureErase | Self::SecureTrim1 | Self::SecureTrim2
25        )
26    }
27
28    /// Indicates if the [EraseMode] is a `TRIM` or `DISCARD` mode.
29    pub const fn is_trim_or_discard(&self) -> bool {
30        matches!(
31            self,
32            Self::Trim | Self::SecureTrim1 | Self::SecureTrim2 | Self::Discard
33        )
34    }
35}