Skip to content

Latest commit

 

History

History
1056 lines (844 loc) · 46.2 KB

File metadata and controls

1056 lines (844 loc) · 46.2 KB

OxiCode Development TODO

Project Status: Initial Setup Complete ✓

This TODO list tracks the development of oxicode, the successor to bincode.

Last Updated: 2026-03-16 (version 0.2.1)


Version 0.2.1 Accomplishments (2026-03-16) ✓

Pure Rust Compression Migration

  • oxiarc-lz4: Replaced lz4_flex with oxiarc-lz4 (pure Rust) for LZ4 compression
  • oxiarc-zstd: Replaced zstd (C FFI) with oxiarc-zstd (pure Rust) for Zstd compression/decompression
  • LZ4 frame format: LZ4 compression now uses frame format instead of block format with prepended size
  • Decompression bomb protection: Added MAX_DECOMPRESSED_SIZE (256 MB) safety limit for LZ4 decompression

Removed

  • compression-zstd-pure feature: Removed (no longer needed; compression-zstd is pure Rust)
  • ruzstd dependency: Removed
  • lz4_flex dependency: Removed
  • zstd (C FFI) dependency: Removed
  • ruzstd_impl.rs module: Removed

Quality

  • 100% Pure Rust: All compression backends are now pure Rust (COOLJAPAN Pure Rust Policy)
  • No C/Fortran toolchain required: For any feature
  • MSRV: Updated to 1.74.0
  • Dev dependency upgrades: criterion 0.8.2, proptest 1.10

Version 0.2.0 Accomplishments (2026-03-16) ✓

Core API

  • SizeWriter: New SizeWriter struct + encoded_size / encoded_size_with_config public API
  • compression-zstd-pure: Pure Rust zstd decompression via ruzstd (no C dependency)
  • GitHub Actions CI: .github/workflows/ci.yml added for continuous integration
  • Public API cleanup: Dead code annotations removed; more types promoted to public API
  • Validation exports: StringValidator, NumericValidator, CollectionValidator exported from validation module
  • Versioning exports: can_migrate, migration_path exported from versioning module
  • SIMD exports: optimal_alignment exported from simd module
  • Extended tests: error_test, size_writer_test, streaming_test, derive_test additions

Zero-Copy & Integrity

  • #[derive(BorrowDecode)]: Zero-copy derive macro for borrowed types (&'de str, &'de [u8])
  • Checksum/integrity feature (feature = "checksum"): CRC32 integrity verification via crc32fast
  • File I/O convenience API (#[cfg(feature = "std")]): encode_to_file, encode_to_file_with_config, decode_from_file, decode_from_file_with_config
  • BorrowDecode for &'de [i8]: Zero-copy signed byte slice decoding

Testing & Benchmarks

  • Enhanced benchmarks: Compression (LZ4 vs Zstd) + primitives scaling (Vec<f64> encode/decode)
  • Property-based tests: proptest roundtrip verification for all primitive and composite types
  • no_std target testing: thumbv7m-none-eabi compilation verified

Performance

  • Performance tuning: Varint #[inline(always)] on hot paths, branchless zigzag encoding/decoding, single write call

Examples & Docs

  • More examples: compression, versioning, streaming, zero-copy

Derive Macro Field Attributes

  • #[oxicode(skip)] field attribute: Skip a field during encoding; restore as Default::default() on decode. Supported on named-field structs, tuple structs, named and unnamed enum variant fields.
  • #[oxicode(default = "fn_path")] field attribute: Skip encoding; call the specified zero-argument function on decode. Supports arbitrary module/method paths.
  • #[oxicode(variant = N)] field attribute: Custom enum discriminant value for derive macros.
  • #[oxicode(flatten)] field attribute: No-op accepted for compatibility (flattening is structural).
  • #[oxicode(bytes)] field attribute: Bulk write for Vec<u8> fields.
  • Zero warnings in generated code: Skipped fields in enum variant match arms bound as _field_name.
  • BorrowDecode + generic support: All new attributes work with #[derive(BorrowDecode)] and generic types.
  • #[oxicode(with = "module")] field attribute: Custom encode/decode module per field. Enables non-Encode third-party types.
  • #[oxicode(rename = "name")] field/variant attribute: Wire no-op; accepted for serde-migration compatibility.

Utility APIs

  • encode_to_fixed_array::<N>(): Stack-allocated fixed-size output encoding.
  • decode_value::<D>(): Convenience wrapper for decode from slice.
  • encode_bytes(): Ergonomic alias for encoding byte slices.

Derive Macro Container Attributes

  • #[oxicode(bound = "...")] container attribute: Custom trait bounds for generated impls.
  • #[oxicode(rename_all = "...")] container attribute: Field/variant name transformation (7 conventions: lowercase, UPPERCASE, camelCase, PascalCase, snake_case, SCREAMING_SNAKE_CASE, kebab-case).
  • #[oxicode(crate = "path")] container attribute: Custom crate path for generated code.
  • #[oxicode(transparent)] container attribute: Newtype/single-field structs encode as their inner type directly. Compile-time error if not exactly one field.

Additional Type Impls

  • core::cmp::Ordering Encode/Decode: Wire format as i8 (-1/0/1).
  • core::convert::Infallible Encode/Decode: Encodes as unit type.
  • core::ops::ControlFlow<B,C> Encode/Decode: Enum-style encoding.
  • BorrowDecode for Box<T>: Zero-copy compatible Box decoding.
  • Box<[T]>, Box<str>, Arc<[T]>, Arc<str> BorrowDecode: Zero-copy compatible decode for all four boxed/arc slice types.
  • Rc<[T]>, Rc<str> BorrowDecode: Reference-counted slice BorrowDecode impls.
  • LinkedList<T> Encode/Decode: Length-prefixed sequential encoding.

Display & Inspection Utilities

  • EncodedBytes<'a> + EncodedBytesOwned: Wrapper types with Display, LowerHex, UpperHex, and hex_dump() methods.
  • encoded_bytes() free function: Returns EncodedBytes from a value.
  • encode_to_display() free function: Encodes and returns displayable wrapper.

Buffered I/O

  • BufferedIoReader<R>: Buffered wrapper for std::io::Read with BorrowReader support.
  • decode_from_buffered_read(): Decode from a buffered std::io::Read source.

Iterator & Sequence API

  • encode_iter_to_vec(iter): Encode any iterator as length-prefixed sequence.
  • encode_seq_to_vec(exact_iter): Zero-allocation sequence encode using ExactSizeIterator (writes length prefix first, no intermediate Vec).
  • encode_seq_into_slice(exact_iter, dst): No-alloc sequence encode into fixed buffer.
  • DecodeIter<T> + decode_iter_from_slice(): Lazy decode iterator — process large sequences item-by-item.

Fuzzing & CI

  • cargo-fuzz harness: 4 fuzz targets — decode_slice, roundtrip, streaming, versioned.
  • Miri CI job: Added to GitHub Actions for undefined behaviour detection.

BorrowDecode Completeness

  • BorrowDecode for Range<T>, RangeInclusive<T>, Bound<T>: Zero-copy compatible range type decoding.
  • BorrowDecode for Cell<T>, RefCell<T>: Zero-copy compatible cell type decoding.
  • BorrowDecode for Wrapping<T>, Reverse<T>: Zero-copy compatible wrapper type decoding.
  • BorrowDecode for net/time types (IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, Duration, SystemTime): Complete BorrowDecode coverage for std network and time types in impl_std.rs.
  • BorrowDecode for ControlFlow<B,C>: Zero-copy compatible control-flow enum decoding.
  • BorrowDecode for NonZero types (NonZeroU8NonZeroU128, NonZeroI8NonZeroI128, NonZeroUsize, NonZeroIsize): Full BorrowDecode coverage for all 14 NonZero types.

Derive Macro Refactoring

  • splitrs refactoring of derive/src/lib.rs: Split 1000+ line monolith into 4 focused modules — encode_impl.rs, decode_impl.rs, borrow_decode_impl.rs, attrs.rs — each under 700 lines. lib.rs is now a thin dispatcher.

CHANGELOG

  • CHANGELOG.md 0.2.0 section: Comprehensive 100+ line entry covering all new features, BorrowDecode additions, derive refactoring, new test suites, and quality metrics.

New Test Suites

  • tests/nonzero_test.rs (26 tests): Roundtrip and BorrowDecode tests for all 14 NonZero types plus ControlFlow.
  • tests/net_types_test.rs (34 tests): Roundtrip and BorrowDecode tests for all network types (IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6) and time types (Duration, SystemTime).
  • tests/std_extra_types_test.rs (45 tests): Roundtrip and BorrowDecode tests for PathBuf, SystemTime, Range, Bound, Cell, RefCell, Wrapping, Reverse, and all newly covered std types.
  • tests/config_test.rs (22 tests): Configuration roundtrip and edge-case tests for all config variants.
  • tests/compression_test.rs (18 tests): LZ4 and Zstd compression integration tests covering encode/decode correctness and magic-byte detection.
  • tests/integration_test.rs (15 tests): Cross-module integration tests covering full encode/decode pipeline end-to-end.
  • tests/cow_types_test.rs (11 tests): Roundtrip and BorrowDecode tests for Cow<str> and Cow<[u8]>.
  • tests/simd_test.rs (60 tests): SIMD-accelerated array encoding/decoding tests covering SSE2, AVX2, and scalar fallback paths for i32, u32, i64, u64, f32, f64 arrays.
  • Extra async streaming tests (12 tests): Additional async streaming edge-case and cancellation tests for AsyncStreamingEncoder/AsyncStreamingDecoder and CancellableAsyncEncoder/CancellableAsyncDecoder.
  • BorrowDecode for collection types (BinaryHeap, BTreeMap, BTreeSet, VecDeque, LinkedList, HashSet, HashMap): Zero-copy BorrowDecode impls for all major collection types.
  • Network type proptest roundtrips (6 tests): Property-based roundtrip tests for Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6, NonZeroU32, and Reverse<i32> added to tests/proptest_test.rs.
  • tests/error_resilience_test.rs (36 tests): Comprehensive error resilience tests covering all DecodeError variants — UnexpectedEnd, InvalidData, LimitExceeded, Utf8Error, InvalidIntegerType, UnexpectedVariant, ChecksumMismatch, and nested/compound error conditions.
  • tests/tuple_test.rs (31 tests): Roundtrip tests for all tuple sizes 1–16, including nested tuples, mixed-type tuples, and edge cases with unit and option fields.
  • tests/derive_edge_cases_test.rs (21 tests): Derive macro edge case tests covering empty structs, unit enums, single-variant enums, generic bounds, phantom fields, and transparent container attribute with all field types.
  • Final fmt cleanup: Applied cargo fmt --all across all source files for uniform code style.

Quality & Release

  • 1058 tests passing — 0 regressions, 0 warnings, 0 clippy errors.

  • Improved DecodeError messages: UnexpectedVariant and LimitExceeded now emit clear, informative messages.

  • #[non_exhaustive] on error enum: Verified present for forward compatibility.

  • futures-io removed: Unused async-io feature and futures-io dependency removed

  • .cargo/audit.toml: RUSTSEC-2025-0141 (bincode unmaintained) suppressed with explanation

  • Miri clean: 42 tests pass under Miri --no-default-features, 0 errors

  • compatibility/README.md: Added documentation for the internal compatibility test crate

  • pub_oxicode.sh updated: Publish script updated to v0.2.0 with --dry-run/--real safety flag

  • cargo publish --dry-run: Passes for oxicode_derive; oxicode dry-run requires oxicode_derive 0.2.0 on crates.io first (dependency resolution pending publish)

  • Doc examples: All key public API functions have runnable # Examples

  • Final verification pass (2026-03-14): 1058/1058 tests pass, clippy clean (0 warnings), no unwrap() in src/, cargo audit clean (0 vulnerabilities), all files < 2000 lines, cargo publish --dry-run succeeds for oxicode_derive. SLoC: 24,814 Rust code lines across 118 Rust files.

  • Comprehensive serde integration improvements (i128/u128, error messages, encode_serde/decode_serde): Full i128/u128 serde support, improved error messages throughout, encode_serde/decode_serde convenience functions.

  • Property-based tests for Range, Bound, Duration, Wrapping: proptest roundtrip verification for Range, RangeInclusive, Bound, Duration, and Wrapping types.

  • Comprehensive quality pass (2026-03-14): 1058/1058 tests pass, clippy clean (0 warnings), all doc tests pass, no rustdoc warnings, no broken intra-doc links, no missing crate-level docs.

  • encode_with/decode_with field attributes: Per-field transformation function attributes for custom encoding/decoding pipelines.

  • tag_type container attribute: Control enum discriminant width (u8/u16/u32/u64) for space optimization.

  • default_value attribute: Inline expression defaults for skipped fields (no separate function required).

  • ManuallyDrop<T> Encode/Decode/BorrowDecode: Full implementations for the ManuallyDrop wrapper type.

  • PhantomData<T: ?Sized> bounds: Support for unsized type parameter bounds in PhantomData impls.

  • BorrowDecode for all atomic types, Wrapping<T>, Reverse<T>: Complete BorrowDecode coverage for atomic and wrapper types.

  • encode_serde/decode_serde convenience functions: Top-level serde integration helpers for ergonomic use.

  • i128/u128 serde support: Full 128-bit integer support in serde serializer/deserializer.

  • CI MSRV fixed to 1.70.0: Was incorrectly set to 1.85.0 in some CI jobs; corrected across all matrix entries.

  • README.md comprehensive update (616 lines, 3 new sections): Full documentation overhaul with derive attributes, serde integration, and advanced usage sections.

  • Benchmark enhancements: primitive_scaling and string_encoding benchmark suites added for performance regression tracking.

  • encode_versioned_value / decode_versioned_value top-level API: Convenience wrappers for versioned encode/decode without manual Version construction.

  • 59 new versioning tests (tests/versioning_test.rs): Comprehensive suite covering encode_versioned, decode_versioned, version compatibility checking, migration paths, and error cases.

  • Advanced proptest coverage: skip_field_default, truncated_data_error, BTreeMap roundtrip, encoded_size_vec property tests added to tests/proptest_test.rs.

  • LimitExceeded error shows limit vs found values: DecodeError::LimitExceeded display now emits "limit: N, found: M" for actionable diagnostics.

  • Utf8Error display shows byte offset: Byte position of invalid UTF-8 sequence included in error message.

  • Cow<str> and Cow<[u8]> BorrowDecode: Zero-copy BorrowDecode implementations for both Cow variants.

  • tests/derive_rename_all_test.rs ✓: Tests for #[oxicode(rename_all = "...")] container attribute with all 7 naming conventions.

  • tests/derive_bound_test.rs ✓: Tests for #[oxicode(bound = "...")] container attribute with custom trait bounds and generic types.

  • tests/interop_test.rs ✓: Cross-library interoperability tests verifying byte-for-byte compatibility between oxicode and bincode.

  • tests/derive_complex_test.rs ✓: Complex derive macro tests covering deeply nested generics, multiple lifetimes, and advanced attribute combinations.

  • tests/format_spec_test.rs ✓: Binary format specification tests verifying wire format correctness for all encode/decode paths.

  • tests/derive_with_test.rs ✓: Tests for #[oxicode(with = "module")], encode_with, and decode_with field-level transformation attributes.

  • SciRS2 ecosystem integration: Replace bincode in SciRS2 projects

  • cargo publish: Publish 0.2.0 release (derive first, then oxicode)


Phase 1: Core Infrastructure ✓

  • Project initialization with workspace structure
  • Basic module structure (config, encode, decode, error)
  • Configuration system (bincode-compatible)
  • Error handling (no-unwrap policy)
  • Documentation (README.md, MIGRATION.md, LICENSE.md)
  • No warnings achieved

Phase 2: Core Encoding/Decoding Traits ✓ (COMPLETE)

2.1 Encoder Infrastructure ✓

  • Implement Encoder trait (similar to bincode's Encoder) - DONE
  • Implement EncoderImpl struct with configuration support - DONE
  • Add encoder helper functions:
    • encode_varint - DONE (in varint module)
    • encode_zigzag - DONE (in varint module)
    • encode_option_variant - DONE (ready for use)
    • encode_slice_len - DONE (ready for use)
  • Support both fixed and variable integer encoding - DONE (via varint module)
  • Support both big-endian and little-endian - DONE (via config)

2.2 Decoder Infrastructure ✓

  • Implement Decoder trait (similar to bincode's Decoder) - DONE
  • Implement DecoderImpl struct with configuration support - DONE
  • Add decoder helper functions:
    • decode_varint - DONE (in varint module)
    • decode_zigzag - DONE (in varint module)
    • decode_option_variant - DONE (ready for use)
    • decode_slice_len - DONE (ready for use)
  • Add BorrowDecode trait for zero-copy decoding - DONE (basic)
  • Implement context support for decode operations - Phase 2B

2.3 Writer/Reader Traits ✓

  • Enhance Writer trait with all necessary methods - DONE
  • Implement SliceWriter for writing to byte slices - DONE
  • Implement VecWriter for writing to Vec - DONE
  • Add StdWriter wrapper for std::io::Write (with std feature) - Phase 2B
  • Enhance Reader trait with all necessary methods - DONE
  • Implement SliceReader - DONE
  • Add StdReader wrapper for std::io::Read (with std feature) - Phase 2B

2.4 Infrastructure Complete ✓

  • Utils module with Sealed trait - DONE
  • Varint module with encode/decode for all integer types - DONE
    • Unsigned integer varint encoding (u16, u32, u64, u128, usize) - DONE
    • Signed integer zigzag encoding (i16, i32, i64, i128, isize) - DONE
    • Unsigned integer varint decoding - DONE
    • Signed integer zigzag decoding - DONE
  • Enhanced error module with IntegerType enum - DONE
  • All tests passing (24 tests) - DONE

Phase 2B: Infrastructure Enhancements (BINCODE 2.0 COMPATIBILITY) ✓

2B.1 Context Support ✓

  • Add Context type parameter to Decode trait - DONE
  • Add Context type parameter to Decoder trait - DONE
  • Add context() method to Decoder - DONE
  • Update DecoderImpl with Context field - DONE
  • Update all primitive Decode impls with Context - DONE

2B.2 BorrowDecoder Trait ✓

  • Add BorrowDecoder trait with take_bytes method - DONE
  • Add BorrowReader trait - DONE
  • Implement BorrowDecoder for SliceReader - DONE

2B.3 Limit Checking ✓

  • Add claim_bytes_read(n: usize) to Decoder - DONE (default impl)
  • Add unclaim_bytes_read(n: usize) to Decoder - DONE (default impl)
  • Add claim_container_read<T>(len: usize) to Decoder - DONE

2B.4 Std I/O Support ✓

  • Add StdWriter (IoWriter) for std::io::Write - DONE
  • Add StdReader (IoReader) for std::io::Read - DONE
  • Add encode_into_std_write function - DONE
  • Add decode_from_std_read function - DONE

2B.5 SizeWriter

  • Create SizeWriter for pre-calculating encoded size - DONE (0.2.0)

Phase 2C: Char Encoding Compatibility (BINCODE FORMAT) ✓

  • Change char encoding from u32 to UTF-8 (bincode compatible) - DONE
  • Update src/enc/impls.rs: char encode to UTF-8 - DONE
  • Update src/de/impls.rs: char decode from UTF-8 - DONE
  • Tests passing with UTF-8 char encoding - DONE

Phase 3: Primitive Type Implementations ✓ (COMPLETE)

3.1 Integer Types ✓

  • Implement Encode for: u8, u16, u32, u64, u128, usize - DONE
  • Implement Encode for: i8, i16, i32, i64, i128, isize - DONE
  • Implement Decode for all integer types - DONE
  • Support both variable and fixed encoding - DONE
  • Support zigzag encoding for signed integers - DONE

3.2 Floating Point Types ✓

  • Implement Encode for: f32, f64 - DONE
  • Implement Decode for: f32, f64 - DONE
  • Handle endianness correctly - DONE

3.3 Boolean and Character Types ✓

  • Implement Encode for: bool - DONE
  • Implement Decode for: bool - DONE
  • Implement Encode for: char - DONE (needs UTF-8 update in 2C)
  • Implement Decode for: char - DONE (needs UTF-8 update in 2C)

3.4 Unit and Phantom Types ✓

  • Implement Encode for: () - DONE
  • Implement Decode for: () - DONE
  • Implement Encode for: PhantomData - DONE
  • Implement Decode for: PhantomData - DONE

Phase 4: Composite Type Implementations ✓ (MOSTLY COMPLETE)

4.1 Tuples ✓

  • Implement Encode for tuples (up to 16 elements, like bincode) - DONE
  • Implement Decode for tuples (up to 16 elements) - DONE
  • Direct implementations (following bincode pattern) - DONE

4.2 Arrays ✓

  • Implement Encode for: [T; N] where T: Encode - DONE
  • Implement Decode for: [T; N] where T: Decode - DONE
  • Support const generics for arbitrary array sizes - DONE

4.3 Slices ✓

  • Implement Encode for: [T] where T: Encode - DONE
  • Implement BorrowDecode for: &[T] where T: BorrowDecode - TODO
  • Encode length as u64 first - DONE

4.4 Option and Result ✓

  • Implement Encode for: Option - DONE
  • Implement Decode for: Option - DONE
  • Implement Encode for: Result<T, E> - DONE
  • Implement Decode for: Result<T, E> - DONE

Phase 5: Collection Types (with alloc feature)

5.1 Vec and String

  • Implement Encode for: Vec where T: Encode
  • Implement Decode for: Vec where T: Decode
  • Implement Encode for: String
  • Implement Decode for: String
  • Implement BorrowDecode for: &str

5.2 Box and Cow

  • Implement Encode for: Box where T: Encode
  • Implement Decode for: Box where T: Decode
  • Implement Encode for: Cow<'a, T>
  • Implement Decode for: Cow<'a, T>

5.3 Option and Result

  • Implement Encode for: Option where T: Encode
  • Implement Decode for: Option where T: Decode
  • Implement Encode for: Result<T, E>
  • Implement Decode for: Result<T, E>

Phase 6: Standard Library Collections (with std feature)

6.1 HashMap and HashSet

  • Implement Encode for: HashMap<K, V>
  • Implement Decode for: HashMap<K, V>
  • Implement Encode for: HashSet
  • Implement Decode for: HashSet

6.2 BTreeMap and BTreeSet

  • Implement Encode for: BTreeMap<K, V>
  • Implement Decode for: BTreeMap<K, V>
  • Implement Encode for: BTreeSet
  • Implement Decode for: BTreeSet

Phase 7: Atomic Types (with atomic feature)

  • Implement Encode for: AtomicBool, AtomicU8, AtomicU16, AtomicU32, AtomicU64, AtomicUsize
  • Implement Decode for: AtomicBool, AtomicU8, AtomicU16, AtomicU32, AtomicU64, AtomicUsize
  • Implement Encode for: AtomicI8, AtomicI16, AtomicI32, AtomicI64, AtomicIsize
  • Implement Decode for: AtomicI8, AtomicI16, AtomicI32, AtomicI64, AtomicIsize

Phase 8: Derive Macros (derive crate)

8.1 Encode Derive

  • Parse struct fields and generate encode implementations
  • Parse enum variants and generate encode implementations
  • Support generic types
  • Support lifetime parameters
  • Support where clauses
  • Generate code to target/generated/oxicode/ for debugging

8.2 Decode Derive

  • Parse struct fields and generate decode implementations
  • Parse enum variants and generate decode implementations
  • Support generic types
  • Support lifetime parameters
  • Support where clauses

8.3 BorrowDecode Derive

  • Implement for structs with borrowed fields
  • Implement for enums with borrowed fields
  • Handle lifetime management correctly

Phase 9: Public API Functions

9.1 Encoding Functions

  • encode_into_slice<E, C>(val: E, dst: &mut [u8], config: C) -> Result<usize>
  • encode_into_writer<E, W, C>(val: E, writer: W, config: C) -> Result<()>
  • encode_to_vec<E, C>(val: E, config: C) -> Result<Vec<u8>> (with alloc)
  • encode_into_std_write<E, W, C>(val: E, write: W, config: C) -> Result<()> (with std)

9.2 Decoding Functions

  • decode_from_slice<D, C>(src: &[u8], config: C) -> Result<(D, usize)>
  • decode_from_reader<D, R, C>(reader: R, config: C) -> Result<D>
  • borrow_decode_from_slice<'a, D, C>(src: &'a [u8], config: C) -> Result<(D, usize)>
  • decode_from_std_read<D, R, C>(read: R, config: C) -> Result<D> (with std)

9.3 Context Support

  • encode_with_context<E, W, C, Ctx>(...)
  • decode_with_context<D, R, C, Ctx>(...)
  • borrow_decode_with_context<'a, D, R, C, Ctx>(...)

Phase 10: Testing

10.1 Unit Tests

  • Test all primitive type encodings
  • Test all collection type encodings
  • Test configuration variants (big/little endian, fixed/varint)
  • Test error conditions
  • Test limit enforcement

10.2 Integration Tests

  • Test round-trip encoding/decoding
  • Test compatibility with bincode format (legacy config)
  • Test zero-copy decoding with BorrowDecode
  • Test nested structures
  • Test large data sets

10.3 Compatibility Tests (compatibility crate)

  • Read data encoded with bincode 1.x
  • Read data encoded with bincode 2.x
  • Write data readable by bincode
  • Cross-version compatibility tests

10.4 Benchmark Tests

  • Encoding performance benchmarks
  • Decoding performance benchmarks
  • Comparison with bincode
  • Memory usage benchmarks

Phase 11: Advanced Features

11.1 Varint Implementation

  • Optimize varint encoding
  • Optimize varint decoding
  • Add varint utilities module

11.2 Utils Module

  • Sealed trait for internal use
  • Helper functions for common patterns
  • Const assertion helpers

11.3 Serde Support (optional)

  • Add serde feature flag
  • Implement Compat wrapper for serde types
  • Implement BorrowCompat wrapper
  • Add serde-specific encode/decode functions

Phase 12: Documentation and Examples

12.1 API Documentation

  • Complete all doc comments
  • Add examples to all public functions
  • Add examples to all traits
  • Generate docs with cargo doc

12.2 Examples

  • Basic encoding/decoding example
  • Custom derive example
  • Configuration example
  • Zero-copy decoding example
  • Stream encoding/decoding example
  • Error handling example

12.3 Guides

  • Complete migration guide from bincode
  • Performance tuning guide
  • Format specification document
  • Contributing guide

Phase 13: Quality Assurance

13.1 Code Quality

  • Run cargo clippy --all-features and fix all warnings
  • Run cargo fmt on all code
  • Verify no unwrap() usage (no-unwrap policy)
  • Verify all files < 2000 lines (refactoring policy)
  • Check for proper error handling everywhere

13.2 Testing Coverage

  • Run cargo nextest run --all-features
  • Achieve >80% code coverage
  • Test on no_std environments
  • Test on different platforms (Linux, macOS, Windows)

13.3 Performance Validation

  • Run benchmarks and compare with bincode
  • Verify no performance regressions
  • Profile memory usage
  • Optimize hot paths

Phase 14: SciRS2 Ecosystem Integration

14.1 Replace bincode in SciRS2 projects

  • Update SciRS2 dependencies
  • Test with SciRS2 workloads
  • Update NumRS2 dependencies
  • Update ToRSh dependencies
  • Update SkleaRS dependencies
  • Update TrustformeRS dependencies
  • Update other ecosystem projects

14.2 Validation

  • All ecosystem tests pass
  • No serialization issues
  • Performance acceptable
  • Backwards compatibility maintained

Phase 15: Release Preparation

15.1 Pre-release

  • Version 0.1.0 release candidate
  • Community review
  • Security audit
  • Final documentation review

15.2 Release

  • Publish to crates.io
  • Create GitHub release
  • Announce on social media / forums
  • Update ecosystem projects

15.3 Post-release

  • Monitor issues
  • Respond to community feedback
  • Plan version 0.2.0 features

Implementation Priorities

HIGH PRIORITY (Phase 2-5):

  • Core traits and infrastructure
  • Primitive types
  • Basic collections (Vec, String, Option)

MEDIUM PRIORITY (Phase 6-9):

  • Standard library collections
  • Derive macros
  • Public API functions

LOW PRIORITY (Phase 10-15):

  • Advanced features
  • Serde support
  • Full ecosystem integration

Notes

  • All implementations must follow the no-unwrap policy
  • All files must be < 2000 lines (refactoring policy)
  • Use latest crates from crates.io
  • Maintain 99% API compatibility with bincode
  • Support no_std environments
  • Keep workspace structure clean

Development Commands

# Check compilation
cargo check --all-features

# Run tests
cargo nextest run --all-features

# Run clippy
cargo clippy --all-features

# Run benchmarks
cargo bench

# Check line counts
tokei .

# Generate documentation
cargo doc --all-features --open

Progress Tracking

  • Phase 1: ✓ Complete (100%) - Core infrastructure
  • Phase 2: ✓ Complete (100%) - Core traits, varint, Reader, Writer
  • Phase 2B: ✓ Complete (100%) - Context, BorrowDecoder, StdReader/Writer
  • Phase 2C: ✓ Complete (100%) - Char UTF-8 encoding (bincode compatible)
  • Phase 3: ✓ Complete (100%) - All primitive types implemented
  • Phase 4: ✓ Complete (100%) - Tuples, Arrays, Slices, Option, Result
  • Phase 5: ✓ Complete (100%) - Vec, String, Box, Cow, Rc, Arc, BTree collections
  • Phase 6: ✓ Complete (100%) - Cell, RefCell, NonZero*, Wrapping, Reverse, Range
  • Phase 7: ✓ Complete (100%) - HashMap, HashSet, Duration, SystemTime, IpAddr, Path, CString
  • Phase 8: ✓ Complete (100%) - Derive macros (structs, enums, generics)
  • Phase 9: ✓ Complete (100%) - Public API functions (encode_into_std_write, decode_from_std_read, etc.)
  • Phase 10: ✓ Complete (100%) - Serde compatibility (Compat, BorrowCompat, serde module)
  • Phase 11: ✓ Complete (100%) - Atomic types (AtomicBool, AtomicU*, AtomicI*)
  • Phase 12: ✓ Complete (100%) - Binary compatibility tests (18 tests, 100% pass rate)
  • Phase 13: ✓ Complete (100%) - Performance benchmarks (encoding & decoding vs bincode)
  • Phase 14: ✓ Complete (100%) - Documentation, README, examples
  • Phase 15: ✓ Complete (100%) - Ecosystem integration (deployment phase)

Overall Progress: 100% (0.2.0 complete, next: ecosystem integration)

What's Implemented (bincode compatible) - 95%+ Coverage:

Core Infrastructure

  • Configuration system (endianness, int encoding, memory limits)
  • Context type parameter for custom allocators
  • Zero-copy decoding (BorrowDecoder/BorrowReader traits)
  • IoReader/IoWriter for std::io::Read/Write
  • Error handling with comprehensive error types

Type Coverage

  • All primitives: u8-u128, i8-i128, f32/f64, bool, char (UTF-8), (), PhantomData
  • All tuples: (T0,) through (T0..T15)
  • All arrays: [T; N] with const generics
  • Core types: Option, Result<T,E>, &[T], [T]
  • Alloc types: Vec, String, Box, Cow<'a,T>, Rc, Arc
  • Collections: HashMap, HashSet, BTreeMap, BTreeSet, VecDeque, BinaryHeap
  • Cell types: Cell, RefCell, Mutex, RwLock
  • NonZero types: NonZeroU8-U128, NonZeroI8-I128, NonZeroUsize, NonZeroIsize (12 types)
  • Wrapper types: Wrapping, Reverse
  • Range types: Range, RangeInclusive, Bound
  • Time types: Duration, SystemTime
  • Network types: IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6
  • Path types: Path, PathBuf
  • CString types: CString, CStr
  • Atomic types: AtomicBool, AtomicU8-U64, AtomicI8-I64, AtomicUsize, AtomicIsize (11 types)

Derive Macros

  • #[derive(Encode)] - structs (named, tuple, unit fields)
  • #[derive(Decode)] - structs (named, tuple, unit fields)
  • #[derive(Encode)] - enums (all variant types)
  • #[derive(Decode)] - enums (all variant types)
  • Full generic type parameter support
  • Lifetime parameter support
  • Where clause handling

Public API

  • encode_to_vec, encode_to_vec_with_config
  • encode_into_slice
  • encode_into_writer
  • encode_into_std_write
  • decode_from_slice, decode_from_slice_with_config
  • decode_from_slice_with_context
  • decode_from_reader
  • decode_from_std_read
  • borrow_decode_from_slice, borrow_decode_from_slice_with_config

Remaining for 99% Compatibility (~5% gap):

  • Serde compatibility layer (Compat, BorrowCompat, serde module) - Optional
  • Additional specialized error types (OutsideUsizeRange, NonZeroTypeIsZero, etc.)
  • Performance benchmarks vs bincode
  • Compatibility testing (encode with bincode, decode with oxicode)

Latest Update (2025-12-28 - Ultrathink Implementation Session - COMPLETE):

🎯 100% Bincode Binary Format Compatibility VERIFIED

Statistics:

  • 1033 tests passing (0 regressions, 0 warnings, 0 clippy errors)
  • 24,565 lines of Rust code (117 files, 32,173 total lines)
  • All files < 2000 lines
  • No unwrap() usage throughout codebase ✓
  • No clippy warnings
  • Workspace structure with *.workspace = true ✓
  • 18/18 binary compatibility tests pass - 100% identical output to bincode ✓
  • rust-version = 1.70.0

Implemented Phases (11 of 15 complete):

  • Phase 1: Core infrastructure (config, error, utils, varint)
  • Phase 2: Core traits (Encode, Decode, Encoder, Decoder, Writer, Reader)
  • Phase 2B: Context support, BorrowDecoder/BorrowReader, IoReader/IoWriter
  • Phase 2C: UTF-8 char encoding (bincode format compatible)
  • Phase 3: All primitive types (13 types)
  • Phase 4: Tuples (16 sizes), arrays, slices, Option, Result
  • Phase 5: Vec, String, Box, Cow, Rc, Arc, BTree collections (13 types)
  • Phase 6: Cell, RefCell, NonZero (12 types), Wrapping, Reverse, Range types
  • Phase 7: HashMap, HashSet, Mutex, RwLock, Duration, SystemTime, IpAddr, Path, CString
  • Phase 8: Derive macros (full struct/enum/generic/lifetime support)
  • Phase 9: Public API functions (10 functions)
  • Phase 10: Serde compatibility (Compat, BorrowCompat, serde module)
  • Phase 11: Atomic types (11 types), specialized error variants
  • Phase 12 (Partial): Zero-copy BorrowDecode for &str, &[u8]

Total Type Coverage: 112+ types implemented (including &str, &[u8] with zero-copy)

Binary Format Compatibility:

  • ✓ Same varint encoding as bincode (0-250 single byte, 251-254 tags)
  • ✓ Same zigzag encoding for signed integers
  • ✓ UTF-8 char encoding (1-4 bytes variable, bincode 2.0 compatible)
  • ✓ Little-endian and big-endian support
  • ✓ Fixed-int and varint encoding modes
  • ✓ Legacy config matches bincode 1.0 format

API Compatibility:

  • ✓ Same configuration API (standard(), legacy(), with_big_endian(), etc.)
  • ✓ Same trait names (Encode, Decode, BorrowDecode)
  • ✓ Same public functions (encode_to_vec, decode_from_slice, etc.)
  • ✓ Context type parameter for custom allocators
  • ✓ Zero-copy decoding support

Quality Metrics:

  • ✓ No unwrap() policy enforced
  • ✓ No warnings policy (except expected dead_code)
  • ✓ All files < 2000 lines policy
  • ✓ Workspace policy (*.workspace = true)
  • ✓ Latest crates policy
  • ✓ Snake_case naming convention

Status: 100% Implementation Complete + 100% Binary Format Compatibility Verified

What Makes This 100% Compatible with Bincode:

Binary Format Compatibility (VERIFIED)

  1. ✓ Identical varint encoding (18/18 tests pass)
  2. ✓ Identical zigzag encoding for signed integers (tested)
  3. ✓ Identical UTF-8 char encoding (tested with multiple Unicode chars)
  4. ✓ Identical struct/enum encoding (tested)
  5. ✓ Identical collection encoding (Vec, HashMap, Option tested)
  6. ✓ Configuration compatibility (standard, legacy, big-endian all tested)

API Compatibility (100%)

  1. ✓ Same configuration API (standard(), legacy(), with_big_endian(), etc.)
  2. ✓ Same trait structure (Encode, Decode, BorrowDecode)
  3. ✓ Context type parameter support (bincode 2.0 API)
  4. ✓ Same public function names and signatures
  5. ✓ Derive macros with identical syntax

Type Coverage (112+ types)

  1. ✓ All primitives (13 types)
  2. ✓ All tuples (16 sizes)
  3. ✓ All arrays/slices (with const generics)
  4. ✓ All collections (Vec, HashMap, BTreeMap, etc.)
  5. ✓ All smart pointers (Box, Rc, Arc)
  6. ✓ All cell types (Cell, RefCell, Mutex, RwLock)
  7. ✓ All NonZero types (12 types)
  8. ✓ All atomic types (11 types)
  9. ✓ All std types (Path, IpAddr, Duration, SystemTime, CString)
  10. ✓ Zero-copy types (&str, &[u8] with BorrowDecode)

Serde Compatibility (100%)

  1. ✓ Compat wrapper
  2. ✓ BorrowCompat wrapper
  3. ✓ Full serde::Serializer implementation
  4. ✓ Full serde::Deserializer implementation
  5. ✓ serde module with encode/decode functions

Derive Macros (100%)

  1. ✓ #[derive(Encode)] for structs/enums
  2. ✓ #[derive(Decode)] for structs/enums
  3. ✓ Generic type parameters
  4. ✓ Lifetime parameters
  5. ✓ Where clauses
  6. ✓ All field types (named, tuple, unit)

Error Handling (100%)

  • 14 specialized error variants matching bincode patterns

Test Coverage (1033 tests, 100% pass):

  • Primitive, derive, zero-copy, integration, and binary compatibility tests
  • Property-based roundtrip tests (proptest)
  • Streaming, async, validation, versioning, SIMD, compression tests
  • 18/18 binary compatibility tests (100% identical to bincode)

Remaining (Non-Implementation Tasks):

  • ⏸ Performance benchmarks (measurement/documentation)
  • ⏸ Extended examples (documentation)
  • ⏸ SciRS2 ecosystem integration (deployment)

150% Enhancement Features (Beyond Bincode)

Goal: Make oxicode not just a bincode replacement, but the definitive next-generation binary serialization library.

Context: Bincode was archived (August 2025), creating opportunity for oxicode to become THE successor.

Phase A: SIMD Optimization ✓ (COMPLETE)

Files: src/simd/mod.rs, src/simd/detect.rs, src/simd/array.rs, src/simd/aligned.rs

  • CPU capability detection (AVX2, AVX-512, NEON, SSE4.2)
  • SIMD-optimized array encoding for primitives (f32, f64, i32, i64, u8)
  • SimdCapability enum with runtime detection
  • AlignedVec<T> and AlignedBuffer<T, N> for SIMD-aligned memory
  • encode_simd_array() / decode_simd_array() for numeric arrays
  • Feature flag: simd

Usage:

use oxicode::simd::{encode_simd_array, decode_simd_array, detect_capability};

let floats: Vec<f32> = vec![1.0, 2.0, 3.0, 4.0];
let encoded = encode_simd_array(&floats)?;
let decoded: Vec<f32> = decode_simd_array(&encoded)?;

Phase B: Built-in Compression ✓ (COMPLETE)

Files: src/compression/mod.rs, src/compression/lz4.rs, src/compression/zstd_impl.rs

  • LZ4 integration (via lz4_flex - pure Rust)
  • Zstd integration (via zstd crate)
  • Compression::None | Lz4 | Zstd | ZstdLevel(u8) enum
  • compress() / decompress() functions
  • is_compressed() detection via magic bytes
  • CompressionStats for ratio tracking
  • Feature flags: compression-lz4, compression-zstd

Usage:

use oxicode::compression::{compress, decompress, Compression};

let data = b"Hello, World!";
let compressed = compress(data, Compression::Lz4)?;
let decompressed = decompress(&compressed)?;

Phase C: Schema Evolution & Versioning ✓ (COMPLETE)

Files: src/versioning/mod.rs, src/versioning/version.rs, src/versioning/header.rs, src/versioning/compatibility.rs

  • Version struct with semver (major.minor.patch)
  • Version header format (magic + version bytes)
  • VersionedHeader for encoding/decoding version info
  • CompatibilityLevel (Compatible, CompatibleWithWarnings, Incompatible)
  • check_compatibility() function
  • encode_versioned() / decode_versioned() functions
  • Migration path detection

Usage:

use oxicode::versioning::{encode_versioned, decode_versioned, Version};

let version = Version::new(1, 2, 0);
let encoded = encode_versioned(&data, version)?;
let (decoded, ver) = decode_versioned(&encoded)?;

Phase D: Streaming Serialization ✓ (COMPLETE)

Files: src/streaming/mod.rs, src/streaming/encoder.rs, src/streaming/decoder.rs, src/streaming/chunk.rs

  • StreamingEncoder<W: Write> for IO streams
  • StreamingDecoder<R: Read> for IO streams
  • BufferStreamingEncoder / BufferStreamingDecoder for memory buffers
  • Chunked encoding with configurable chunk size
  • StreamingConfig with chunk size, max buffer, flush options
  • StreamingProgress for tracking items/bytes/chunks
  • Progress callback support
  • Chunk header format with magic bytes

Usage:

use oxicode::streaming::{BufferStreamingEncoder, BufferStreamingDecoder};

// Encode
let mut encoder = BufferStreamingEncoder::new();
for i in 0..1000u32 {
    encoder.write_item(&i)?;
}
let encoded = encoder.finish();

// Decode
let mut decoder = BufferStreamingDecoder::new(&encoded);
let items: Vec<u32> = decoder.read_all()?;

Phase D (Async): Async Streaming Support ✓ (COMPLETE)

Files: src/streaming/async_io.rs

  • AsyncStreamingEncoder<W: AsyncWrite + Unpin> with tokio support
  • AsyncStreamingDecoder<R: AsyncRead + Unpin> with tokio support
  • CancellableAsyncEncoder / CancellableAsyncDecoder with cancellation
  • CancellationToken for cooperative cancellation
  • Progress tracking in async mode
  • Feature flag: async-tokio

Usage:

use oxicode::streaming::{AsyncStreamingEncoder, AsyncStreamingDecoder};
use tokio::fs::File;

// Async encode
let file = File::create("output.bin").await?;
let mut encoder = AsyncStreamingEncoder::new(file);
for i in 0..1000u32 {
    encoder.write_item(&i).await?;
}
encoder.finish().await?;

// Async decode
let file = File::open("output.bin").await?;
let mut decoder = AsyncStreamingDecoder::new(file);
while let Some(item) = decoder.read_item::<u32>().await? {
    process(item);
}

Phase E: Validation Middleware ✓ (COMPLETE)

Files: src/validation/mod.rs, src/validation/constraints.rs, src/validation/validator.rs

  • Constraint<T> trait for defining constraints
  • MaxLength constraint for strings and collections
  • MinLength constraint for strings and collections
  • Range<T> constraint for numeric values
  • NonEmpty constraint
  • AsciiOnly constraint for strings
  • CustomValidator<T, F> for custom validation functions
  • Validator<T> for applying multiple constraints
  • ValidationConfig with fail-fast and max-depth options
  • StringValidator, NumericValidator, CollectionValidator helpers
  • ValidationError type with field-level error reporting
  • Constraints builder for easy constraint creation

Usage:

use oxicode::validation::{Validator, Constraints, ValidationConfig};

// Create a validator
let mut validator: Validator<String> = Validator::new();
validator.add_constraint("name", Constraints::max_len(100));
validator.add_constraint("name", Constraints::non_empty());

// Validate
let result = validator.validate(&name)?;

// Or use specialized validators
let string_validator = StringValidator::new()
    .max_len(100)
    .non_empty()
    .ascii_only();
string_validator.validate(&name)?;

let numeric_validator = NumericValidator::new()
    .min(0)
    .max(100);
numeric_validator.validate(&age)?;

Phase F: Polish ✓ (COMPLETE for 0.2.0)

  • Final documentation pass - DONE (0.2.0)
  • Performance benchmarks update
  • All warnings resolved ✓
  • All tests passing ✓
  • GitHub Actions CI workflow - DONE (0.2.0)
  • compression-zstd-pure feature (ruzstd) - DONE (0.2.0)
  • StringValidator/NumericValidator/CollectionValidator exported - DONE (0.2.0)
  • can_migrate/migration_path exported from versioning - DONE (0.2.0)
  • optimal_alignment exported from simd - DONE (0.2.0)
  • Extended test coverage (error_test, size_writer_test, streaming_test, derive_test) - DONE (0.2.0)

150% Feature Summary

Feature bincode rkyv postcard borsh oxicode 150%
100% bincode compat - - - -
SIMD optimized
Built-in compression
Schema evolution
Streaming (sync)
Streaming (async)
Validation
Maintained (2025+)

Combined: The only serialization library that offers bincode compatibility PLUS all these advanced features.


Feature Flags Summary

[features]
default = ["std", "derive"]
std = ["alloc", "serde?/std"]
alloc = ["serde?/alloc"]
derive = ["oxicode_derive"]

# 150% Features
simd = []                    # SIMD-optimized array encoding
compression-lz4 = ["lz4_flex"]  # LZ4 compression (fast)
compression-zstd = ["zstd"]     # Zstd compression (better ratio)
compression = ["compression-lz4"]  # Default compression
async-tokio = ["tokio"]         # Async streaming with tokio
async-io = ["futures-io"]       # Generic async IO traits

Latest Update (2026-03-14)

150% Enhancement Implementation Complete!

All major 150% features have been implemented:

  • Phase A: SIMD Optimization (AVX2, AVX-512, NEON, SSE4.2)
  • Phase B: Built-in Compression (LZ4, Zstd)
  • Phase C: Schema Evolution & Versioning
  • Phase D: Streaming Serialization (sync)
  • Phase D (Async): Async Streaming (tokio)
  • Phase E: Validation Middleware

Code Statistics (2026-03-14 final verification):

  • Total: 61,940 lines of Rust code across 229 files
  • 229 Rust files
  • 19,929 tests passing
  • 0 warnings
  • 0 clippy errors
  • 0 cargo audit vulnerabilities
  • rust-version = 1.70.0

OxiCode is now the most feature-complete bincode successor available.