Rust implementation of the Recurram wire format and session-aware encoder/decoder.
- Dynamic encoding/decoding (
encode,decode) - Schema-aware encoding (
encode_with_schema) - Batch and micro-batch encoding (
encode_batch,SessionEncoder::encode_micro_batch) - Stateful features (base snapshots, state patch, template batch, control stream, trained dictionary)
- Rust stable (edition 2024)
Add one of the following to Cargo.toml.
From GitHub:
[dependencies]
recurram = { git = "https://github.com/recurram/recurram-rust.git" }From crates.io (if/when published):
[dependencies]
recurram = "0.1"From a local path:
[dependencies]
recurram = { path = "./recurram-rust" }use recurram::{decode, encode, Value};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let value = Value::Map(vec![
("id".to_string(), Value::U64(1001)),
("name".to_string(), Value::String("alice".to_string())),
]);
let bytes = encode(&value)?;
let decoded = decode(&bytes)?;
assert_eq!(decoded, value);
Ok(())
}use recurram::{create_session_encoder, SessionOptions, Value};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut enc = create_session_encoder(SessionOptions::default());
let value = Value::Map(vec![
("id".to_string(), Value::U64(1)),
("role".to_string(), Value::String("admin".to_string())),
]);
let _bytes = enc.encode(&value)?;
Ok(())
}Run checks locally:
cargo fmt --all
cargo testPublishing to crates.io is automated by .github/workflows/publish-crates.yml.
Setup:
- Add repository secret
CARGO_REGISTRY_TOKEN(crates.io API token). - Bump
versioninCargo.toml. - Create and push a matching tag:
v<version>.
Example:
git tag v0.1.0
git push origin v0.1.0This project is licensed under the MIT License - see the LICENSE file for details.