Jaguar
A lightweight binary serialization library designed for high-performance operations in resource-constrained environments like sBPF programs and embedded systems.
Installation
Run:
Or add to your Cargo.toml:
[]
= "0.1.0"
Usage
With primitive types:
use ;
let pubkey = ;
let mut ser = new;
pubkey.serialize.unwrap;
let data = ser.finish;
let mut de = new;
let decoded = deserialize.unwrap;
With custom data structures:
use ;
let mut ser = new;
let instance = MyData .serialize.unwrap;
let mut de = new;
let value = deserialize.unwrap;
Supported Types
- Primitive integers (u8/i8, u16/i16, u64/i64, etc...)
- Booleans
- Floats (f32, f64)
- Strings and byte slices
- Arrays and vectors of supported types
- Custom structs
- Enums
Performance
Benchmarks on an M1 Mac Pro:
Serialization
SimpleStruct: ~60.04nsComplexStruct: ~1.121µsVec<SimpleStruct>: ~46.12µsVec<u8>: ~348.49ns,Vec<i8>: ~19.31µsVec<u16>: ~22.01µsVec<i16>: ~20.50µsVec<u64>: ~22.14µsVec<i64>: ~20.55µsVec<bool>: ~4.07µs
Deserialization
SimpleStruct: ~46.7nsComplexStruct: ~1.153µsVec<SimpleStruct>: ~39.4µsVec<u8>: ~171ns,Vec<i8>: ~11.36µsVec<u16>: ~9.71µsVec<i16>: ~12.09µsVec<u64>: ~9.82µsVec<i64>: ~11.92µsVec<bool>: ~4.07µs
Contributing
Contributions are welcome! Please read the Contributing Guide for details on the process for submitting pull requests.
License
This project is MIT licensed - see LICENSE for details.