Skip to main content

CardError

Enum CardError 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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 Clone for CardError

Source§

fn clone(&self) -> CardError

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CardError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for CardError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for CardError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for CardError

Source§

fn eq(&self, other: &CardError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for CardError

Source§

impl Eq for CardError

Source§

impl StructuralPartialEq for CardError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.