msrtc-rans-core 0.2.3

Deterministic no_std rANS primitives for msrtc_rans entropy coder
Documentation
# msrtc-rans-core

**Deterministic, no_std-capable rANS primitives for the msrtc_rans entropy coder.**

This crate implements the raw rANS encoding and decoding primitives used by Microsoft MLVC's `msrtc_rans` package. The arithmetic (reciprocal preparation, Mul64Hi, fast division) is structurally faithful to the C++ implementation.

## Status — Phase 3 Sealed ✅

| Court | Status |
|-------|--------|
| Raw encoder differential | ✅ Sealed (8/8 cases) |
| Raw decoder differential | ✅ Sealed (16/16 cases) |

Both `RansByteEncoder` / `RansByteDecoder` (u32 state, u8 unit) and `Rans64Encoder` / `Rans64Decoder` (u64 state, u32 unit) have been verified byte-for-byte against the pinned Microsoft C++ oracle. All 30 core tests pass.

## Features

- `#![no_std]` — suitable for embedded and WASM targets
- `#![forbid(unsafe_code)]` — pure safe Rust
- Macro-generated variants from a single `generate_rans_impl!` macro
- `VecSink` (reverse-order, matching C++ `ResizableBufferSink` behavior)
- `SliceSource` (zero-copy span-like source)
- Checked API: `try_new()`, `try_put_raw()`, `try_get()`, `try_advance()`
- Transactional decoder — state not committed on failed advance

## Usage

```rust
use msrtc_rans_core::{RansByteEncoder, RansByteDecoder};
use msrtc_rans_core::sink::VecSink;
use msrtc_rans_core::source::SliceSource;

let sink = VecSink::<u8>::new(64);
let mut encoder = RansByteEncoder::new(sink);
encoder.put_raw(0, 128, 8);
encoder.flush();
let encoded = encoder.into_sink().encoded().to_vec();

let source = SliceSource::new(&encoded);
let mut decoder = RansByteDecoder::new(source);
assert!(decoder.init());
assert!(decoder.advance(0, 128, 8));
assert!(decoder.check_eof());
```

## Repository

Full project: [github.com/infinityabundance/msrtc-rans-rs](https://github.com/infinityabundance/msrtc-rans-rs)

## License

MIT — see [LICENSE](https://github.com/infinityabundance/msrtc-rans-rs/blob/main/LICENSE) and [NOTICE](https://github.com/infinityabundance/msrtc-rans-rs/blob/main/NOTICE) for attribution notices.