Relish
Relish is a binary serialization format and Rust library, designed for efficiency and backwards compatibility.
Stability
The Relish format specification is stable. All future changes will be backwards compatible.
The Relish Format
Relish is a Type-Length-Value (TLV) binary serialization format that prioritizes:
- Efficiency
- Backwards Compatibility
- Simplicity
Relish draws inspiration from ASN.1 DER, protobufs, and many other formats.
For detailed format specifications, see SPEC.md.
Supported Types
Fixed-Size Types
Null- Null value (0 bytes)bool- Boolean values (1 byte)u8,u16,u32,u64,u128- Unsigned integersi8,i16,i32,i64,i128- Signed integersf32,f64- Floating-point numbers
Variable-Size Types
String- UTF-8 encoded textArray- Sequences of any Relish typeMap- Key-value mappingsStruct- Structured data with field IDsEnum- Tagged union types
Schema Evolution
Relish supports backwards-compatible schema changes through field versioning:
- Adding fields: New optional fields can always be safely added to a struct. Parsers ignore unknown fields that they see.
- Remove fields: A field can always be made optional to allow it to be omitted.
Rust Implementation
The reference implementation is a Rust library that provides a safe, idiomatic API for working with the Relish format.
Features
- Derive Macro - Automatic implementation for custom structs and enums
- Zero-Copy Parsing - Efficient deserialization using the
bytescrate
Installation
$ cargo add relish
Quick Start
Basic Usage
use Bytes;
// Serialize a value to bytes
let value = 42u32;
let bytes = to_vec.unwrap;
// Deserialize bytes back to a value
let parsed: u32 = parse.unwrap;
assert_eq!;
Derive (Struct)
let person = Person ;
let bytes = to_vec.unwrap;
let parsed: Person = parse.unwrap;
Derive (Enum)