#[non_exhaustive]pub enum CardError {
Show 14 variants
OutOfRange,
AddressError,
BlockLenError,
EraseSequence,
EraseParam,
WriteProtect,
CardIsLocked,
LockUnlockFailed,
CommandCrcFailed,
IllegalCommand,
CardEccFailed,
ControllerError,
GenericError,
Unknown(u32),
}Expand description
Per-bit error status decoded out of an R1 response.
SD Physical Layer spec section 4.10.1 reserves bits 19..=31 of the 32-bit
native R1 response for card-state error flags. SPI R1 reuses bits 1..=6 of
the single response byte for a subset of those. Variants below cover both,
with CardError::Unknown preserving the raw native bit pattern when no
known flag matches (e.g. reserved-for-application bits).
Marked #[non_exhaustive]: new card-status bits may be classified out of
Unknown(_) over time, and downstream match sites must keep a _ => ...
arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
OutOfRange
OUT_OF_RANGE (bit 31): the command’s argument was out of the allowed
range for this card (e.g. LBA beyond capacity).
AddressError
ADDRESS_ERROR (bit 30) / SPI ADDRESS_ERROR (bit 5): misaligned
address for the current block length, or out-of-range address.
BlockLenError
BLOCK_LEN_ERROR (bit 29) / SPI PARAMETER_ERROR (bit 6): transferred
block length is not allowed for this card or the parameter argument
was out of range.
EraseSequence
ERASE_SEQ_ERROR (bit 28) / SPI ERASE_SEQ_ERROR (bit 4): erase
command sequence error, or ERASE_RESET (SPI bit 1).
EraseParam
ERASE_PARAM (bit 27): an invalid selection of write blocks for erase.
WriteProtect
WP_VIOLATION (bit 26): attempted write to a write-protected block.
CardIsLocked
CARD_IS_LOCKED (bit 25): card is locked by host, normal data
transfers are inhibited.
LockUnlockFailed
LOCK_UNLOCK_FAILED (bit 24): a sequence or password error in the
lock/unlock command.
CommandCrcFailed
COM_CRC_ERROR (bit 23) / SPI COM_CRC_ERROR (bit 3): CRC check of
the previous command failed.
IllegalCommand
ILLEGAL_COMMAND (bit 22) / SPI ILLEGAL_COMMAND (bit 2): command not
legal for the current card state.
CardEccFailed
CARD_ECC_FAILED (bit 21): card internal ECC was applied but failed
to correct the data.
ControllerError
CC_ERROR (bit 20): generic card controller error.
GenericError
ERROR (bit 19): a catch-all reported by the card when a non-classified
internal error occurred during the command execution.
Unknown(u32)
Unknown / reserved error bit set. Carries the native 13-bit error
nibble (raw >> 19) so the caller can log the exact pattern.
Trait Implementations§
Source§impl Error for CardError
impl Error for CardError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()