#[non_exhaustive]pub enum StringLayerHeader {
SingleString {
version: u8,
},
Chunked {
version: u8,
chunk_set_id: u32,
total_chunks: u8,
chunk_index: u8,
},
}Expand description
String-layer header for one mk1 chunk.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
SingleString
Card fits in one mk1 string; no chunking. Carries no chunk-set identifier or index because the format is unambiguous.
Chunked
One chunk in a multi-chunk encoding. All chunks of one card share
the same version, chunk_set_id, and total_chunks; only
chunk_index varies.
Fields
chunk_set_id: u3220-bit per-encoding random tag for reassembly mismatch
detection. Decoders compare across chunks; mismatch is
rejected with Error::ChunkSetIdMismatch.
Implementations§
Source§impl StringLayerHeader
impl StringLayerHeader
Sourcepub fn to_5bit_symbols(self) -> Vec<u8> ⓘ
pub fn to_5bit_symbols(self) -> Vec<u8> ⓘ
Emit this header as a sequence of 5-bit symbols.
The output length is SINGLE_HEADER_SYMBOLS (= 2) for
StringLayerHeader::SingleString and CHUNKED_HEADER_SYMBOLS
(= 8) for StringLayerHeader::Chunked. The caller prepends
these symbols to bytes_to_5bit(fragment) to form a chunk’s
data part before BCH checksumming.
Sourcepub fn from_5bit_symbols(symbols: &[u8]) -> Result<(Self, usize)>
pub fn from_5bit_symbols(symbols: &[u8]) -> Result<(Self, usize)>
Parse a header off the front of a 5-bit-symbol stream.
Returns the parsed header and the number of symbols consumed
(2 for SingleString, 8 for Chunked). The caller slices off
the remainder as the fragment-payload symbols.
§Errors
Error::UnexpectedEndifsymbolsis shorter than the minimum 2-symbol single-string header.Error::UnsupportedVersionif the version field is non-zero in v0.1.Error::UnsupportedCardTypeif the type field is not in{0x00, 0x01}(the reserved range0x02..=0x1Fis rejected).Error::ChunkedHeaderMalformedif a chunked header hastotal_chunks == 0,total_chunks > MAX_CHUNKS, orchunk_index >= total_chunks.
Sourcepub fn is_chunked(self) -> bool
pub fn is_chunked(self) -> bool
Returns true if this header is the Chunked variant.
Trait Implementations§
Source§impl Clone for StringLayerHeader
impl Clone for StringLayerHeader
Source§fn clone(&self) -> StringLayerHeader
fn clone(&self) -> StringLayerHeader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StringLayerHeader
impl Debug for StringLayerHeader
Source§impl PartialEq for StringLayerHeader
impl PartialEq for StringLayerHeader
Source§fn eq(&self, other: &StringLayerHeader) -> bool
fn eq(&self, other: &StringLayerHeader) -> bool
self and other values to be equal, and is used by ==.