Skip to content

Varshamov-Tenengolts (VT) codes for single insertion/deletion correction

License

Notifications You must be signed in to change notification settings

darkcodi/vt-codes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”§ vt-codes

crates.io docs.rs MIT License

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.

✨ Why?

  • πŸ”§ 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

πŸš€ Quick look

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");

πŸ“¦ Install

[dependencies]
vt-codes = "0.1"

Limitations

  • Max message length: 240 bytes
  • Stack usage: ~1 KB for internal scratch buffers (4 Γ— 256 bytes)

License

MIT β€” do whatever.

About

Varshamov-Tenengolts (VT) codes for single insertion/deletion correction

Topics

Resources

License

Stars

Watchers

Forks

Languages