StatusWord class sealed

What a card said in its two status bytes, decoded.

The point of the type is that a caller stops carrying a table of hex constants in its head: 9000, 61xx, 6A82 and the rest turn into cases the analyzer can check.

It is a sealed hierarchy rather than an enum because the interesting status words carry a number -- how many bytes are still waiting, what length the card wanted, how many attempts remain -- and because an enum would have to answer for every value a future card can send. Anything this release does not classify arrives as StatusWordUnrecognised with value intact, so a card that speaks a proprietary dialect stays readable instead of being flattened into "unknown" or, worse, throwing.

switch (response.status) {
  case StatusWordSuccess():
    return response.payload;
  case StatusWordMoreData(:final remainingBytes):
    return getResponse(remainingBytes);
  case StatusWordError(reason: StatusWordErrorReason.fileNotFound):
    throw StateError('no such file on this card');
  case final other:
    throw StateError('card answered ${other.value.toRadixString(16)}');
}
Implementers

Constructors

StatusWord(int statusWord1, int statusWord2)
Decodes the two status bytes as the card sent them.
factory
StatusWord.fromValue(int value)
Decodes the 16-bit form card specifications are written in, such as 0x6A82.
factory

Properties

hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusWord1 int
SW1.
final
statusWord2 int
SW2.
final
value int
SW1 and SW2 as one 16-bit value, which is how card specifications write them.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override