Varshamov-Tenengolts (VT) codes for single insertion/deletion correction.
no_std, zero allocations.
VT codes are forward error correction codes that can correct a single insertion or deletion in transmitted data β unlike most error correction codes that only handle bit flips.
- π§ In-place β encode/decode without extra buffers
- π¦
no_stdβ works on bare-metal & embedded - π Zero alloc β no heap, ever
- π Zero deps β no external dependencies
- π‘οΈ Indel protection β corrects single insertions/deletions
let mut buf = [0u8; 256];
buf[..11].copy_from_slice(b"Hello world");
// Encode
let enc_len = vt_codes::vt_encode_in_place(&mut buf, 11)?;
// Simulate a deletion
buf.copy_within(3.., 2); // Remove byte at position 2
// Decode (corrects the deletion)
let dec_len = vt_codes::vt_decode_in_place(&mut buf, enc_len - 1)?;
assert_eq!(&buf[..dec_len], b"Hello world");[dependencies]
vt-codes = "0.1"- Max message length: 240 bytes
- Stack usage: ~1 KB for internal scratch buffers (4 Γ 256 bytes)
MIT β do whatever.