Files
ucobs/CLAUDE.md
T
swaitsandClaude Opus 4.6 a5e3e5f63b feat: add benchmarks, justfile, optimize throughput, harden quality gates
Benchmarking & comparison:
- Add criterion benchmarks (ucobs vs cobs 0.3 vs corncobs 0.1)
- Add Python cobs benchmark script
- Add performance comparison section to README with full results

Performance:
- Rewrite encode to scan-and-bulk-copy via copy_from_slice
- Rewrite decode to bulk-copy via copy_from_slice
- ~2-4x throughput improvement; now matches corncobs on most workloads

Quality hardening:
- Add #![forbid(unsafe_code)], #![warn(missing_docs)], #[must_use]
- Add [lints.rust] unsafe_code = "forbid" in Cargo.toml
- Add rust-version (MSRV) = "1.56"
- Add docs.rs metadata
- 106 tests: 80 unit/corpus + 25 property tests (25k cases each = 625k total)
- External test vectors from: Wikipedia, Cheshire & Baker paper, nanocobs,
  cobs-c, cobs2-rs, Jacques Fortier, Python cobs package
- Add fuzz_small_dest fuzz target (encode/decode with undersized buffers)
- Improve doc examples to show sentinel append/strip convention

Infrastructure:
- Add justfile with test (nextest), check, bench, fuzz, miri, fmt targets
- cargo-nextest for parallel test execution
- Update .gitignore for Python cache files

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 17:19:12 -06:00

2.0 KiB

μCOBS (ucobs)

Identity

  • Crate name: ucobs (on crates.io)
  • Display name: μCOBS
  • Mission: Become THE COBS crate for Rust — embedded and non-embedded alike

First Principles

  1. Correct — 100% COBS spec-compliant (Cheshire & Baker 1999). No shortcuts, no deviations.
  2. Interoperable — proven byte-for-byte compatibility with corncobs, cobs crates and Python cobs packages.
  3. Insanely tested — canonical vectors, property-based tests (proptest), fuzz targets (cargo-fuzz), cross-crate interop, randomized payloads. If you think testing is done, you're 10% done.
  4. Fast — benchmark against every competing implementation. Must be at least as fast, ideally fastest. Benchmarks are CI-enforced.
  5. Tiny — no_std, zero-alloc, zero runtime dependencies. ~120 lines of implementation. Runs on 8-bit MCUs and servers alike.
  6. Trustworthy — small enough to audit by hand. No unsafe. No panics in release. Fuzz-hardened.

Architecture

Single-file library: src/lib.rs

Public API (3 functions)

pub fn encode(src: &[u8], dest: &mut [u8]) -> Option<usize>
pub fn decode(src: &[u8], dest: &mut [u8]) -> Option<usize>
pub const fn max_encoded_len(src_len: usize) -> usize

Convention: Output does NOT include trailing 0x00 sentinel. Caller appends it for framing.

Development

# Run all tests
cargo test

# Fuzz (requires nightly + cargo-fuzz)
cd fuzz
cargo +nightly fuzz run fuzz_decode -- -max_total_time=60
cargo +nightly fuzz run fuzz_roundtrip -- -max_total_time=60

Dev Dependencies (test-only)

  • corncobs — cross-validation against another COBS implementation
  • proptest — property-based testing
  • rand — randomized test payloads

Roadmap

  • More interop targets: cobs crate, Python cobs package
  • Benchmarks (criterion) vs corncobs, cobs, and others
  • quickcheck in addition to proptest
  • Even more fuzz targets and edge-case generators
  • MSRV policy and CI
  • #[deny(unsafe_code)] badge