A schema language and binary encoding for serializing data structures.
The baler program can validate schemas and decode/encode data to and from a diagnostic notation.
; A 24 bit color value
let color be
tuple
r: u8
g: u8
b: u8
end
; Tuples are sequences of multiple data items
tuple
; We can have optional items with `maybe`
position: maybe tuple
; `uv`s are compact variable size numbers
x: uv
y: uv
end
width: u32
; A choice of one of multiple data items
union
pixels: array color
image: string
end
end
Schema | Value | Encoded |
---|---|---|
void |
||
bool |
false | 00 |
bool |
true | 01 |
maybe u16 |
just 12 | 01 00 0c |
maybe i8 |
nothing | 00 |
2 u8 |
3, 4 | 03 04 |
uv |
2200 | f8 a8 |
- Versioning of schemas
- Random access
- Self description of data
- No four byte alignment
- Use of variable size integers instead of a fixed 32 bits for length encoding.
- Let bindings can have parameters unlike XDR typedefs
- Fewer predefined types
Code generation is not required and encoding/decoding bale is trivial, this means you are not limited to a subset of languages.
But generating code is still possible if you really want to.