pub fn decode_with_correction(
strings: &[&str],
) -> Result<(Descriptor, Vec<CorrectionDetail>), Error>Expand description
BCH-error-correcting decode for a chunk-set of md1 strings.
Per plan §1 Q1 lock — full-decode semantics: this is the single entry point that callers needing both “did anything get repaired?” AND “the fully-decoded descriptor” should use.
Algorithm:
- For each chunk, parse the data-part into 5-bit symbols and compute
the BCH polymod residue (
hrp_expand("md") || data_with_checksum) XOR’d againstcrate::bch::MD_REGULAR_CONST. - Residue
== 0⇒ chunk passes through unchanged. - Residue
!= 0⇒ invokecrate::bch_decode::decode_regular_errors. IfNone, returnErr(Error::TooManyErrors { chunk_index, bound: 8 })per plan §2.B.4 D29 error-mapping table. - Apply corrections to the chunk’s symbol vector, re-encode as a
fresh md1 string, and record one
CorrectionDetailper repaired character. - After ALL chunks have been processed (any single uncorrectable
chunk aborts atomically per plan §1 D28), forward the corrected
chunk strings to
reassembleto produce theDescriptor.
On success returns (Descriptor, Vec<CorrectionDetail>). The
correction-detail vector is in (chunk_index ascending,
position ascending within chunk) order; an empty vector means every
input chunk was already a valid codeword.