substrate-data
One data model, text syntax, binary form, packed frames and schema system — for any program's files, saves and wire messages.
Layer and context: shared kernel · data
- For: the model with typed references, the text form (JSON with comments, spans, in-place patches), the binary form, packed frames and streams, schemas with
#[derive(Schema)], and diagnostics with codes and paths. - Not for: domain types or any product's vocabulary; those belong in the consumer's adapter crate (
impl Schema+Shape::Named). The format itself is specified in docs/format.md.
Usage
use ;
kind!;
/// A file attached to something.
let attachment: Attachment = from_text
.unwrap
.value;
assert_eq!;
let bytes = to_bytes; // compact, self-describing
let frame = to_frame; // packed, schema-known
let shape = shape.describe; // a typed ShapeDoc, for editors and docs
Features
| Feature | Enables |
|---|---|
json |
JSON read into and written from the model |
toml |
TOML read into the model, with spans |
Depends on / used by
- Depends on:
substrate-data-derive(re-exported asSchema) - Used by: programs and adapter crates that define their own formats
License
MIT OR Apache-2.0, see LICENSE-MIT and LICENSE-APACHE.