SPUD (Structured Payload of Unintelligible Data)
SPUD is a custom binary file format for efficient storage and transmission of structured data. It uses type tags and field name interning for compactness. This implementation is written in Rust.
Features
- Compact Binary Representation: Binary encoding for all supported data types.
- Supported Data Types:
null,bool, signed/unsigned integers (i8–i64,u8–u64),f32,f64,String, and raw binary blobs (Vec<u8>). - Field Name Interning: Field names are mapped to unique IDs to reduce redundancy.
- Versioning: Files start with a version string for compatibility.
- Simple Structure: Version header, field name map, data payload, and EOF marker (
[0xDE, 0xAD, 0xBE, 0xEF]). - Serde Integration: Serialize/deserialize Rust structs via
serde.
File Structure
A .spud file consists of:
- Version String: UTF-8 bytes.
- Field Name Map: Sequence of
(length, field_name_bytes, id)entries, ending with0x01. - Data Payload: Sequence of
(field_id, type_tag, value_bytes)entries. Strings/blobs include length. Arrays/objects are delimited by start/end tags. - EOF Marker:
0xDE, 0xAD, 0xBE, 0xEF.
Usage
Encoding (Writing a SPUD file)
You can build SPUD files manually or by serializing Rust structs with serde.
Manual Usage
```rust
use SpudBuilder;
Serde Usage (TODO)
use SpudBuilder;
use Serialize;
let data = MyData ;
let mut builder = from_serde;
builder.build_file.unwrap;
Decoding (Reading a SPUD file)
You can decode SPUD files manually or deserialize them into Rust structs with serde.
Manual Usage
use SpudDecoder;
let mut decoder = new_from_path.unwrap;
let data = decoder.decode.unwrap;
println!;
Serde Usage
use SpudDecoder;
use Deserialize;
let mut decoder = new_from_path.unwrap;
let data: MyData = decoder.deserialize.unwrap;
println!;
Roadmap / TODO
- Parallelism
- Support for nested objects
serdeintegration forSpudBuilderandSpudDecoder- spud!{} macro
- CLI tool for inspecting and converting
.spudfiles
Known Issues
Some minor bugs may exist; please report any issues.
Contributing
Contributions are welcome! Open an issue or submit a pull request.