Expand description
§Justcode
A compact binary encoder/decoder with space-efficient encoding scheme. The encoded size will be the same or smaller than the in-memory size.
§Features
- Compact binary encoding (space-efficient)
- Varint encoding for lengths and small integers
- Architecture invariant (byte-order independent)
- Streaming Reader/Writer API
- Configurable encoding options
§Example
use justcode_core::{Encode, Decode, config};
#[derive(Encode, Decode, PartialEq, Debug)]
struct Entity {
x: f32,
y: f32,
}
#[derive(Encode, Decode, PartialEq, Debug)]
struct World(Vec<Entity>);
fn main() {
let config = config::standard();
let world = World(vec![Entity { x: 0.0, y: 4.0 }, Entity { x: 10.0, y: 20.5 }]);
let encoded = justcode_core::encode_to_vec(&world, config).unwrap();
let (decoded, len) = justcode_core::decode_from_slice(&encoded, config).unwrap();
assert_eq!(world, decoded);
assert_eq!(len, encoded.len());
}Re-exports§
pub use config::Config;pub use decode::Decode;pub use encode::Encode;pub use error::JustcodeError;pub use error::Result;
Modules§
- config
- Configuration for encoding and decoding behavior.
- decode
- Re-export Decode trait (defined in encode.rs for convenience).
- encode
- Encoding trait and implementations.
- error
- Error types for justcode encoding/decoding.
- reader
- Reader for decoding values from bytes.
- varint
- Variable-length integer encoding (varint).
- writer
- Writer for encoding values to bytes.
Functions§
- decode_
from_ slice - Decode a value from a byte slice.
- encode_
to_ vec - Encode a value to a
Vec<u8>.