Skip to main content

substrate_data/
lib.rs

1//! Substrate Data: one data model, text syntax, binary form, packed frames
2//! and schema system — for a program's files, saves, caches and wire
3//! messages alike. See `docs/format.md`.
4//!
5//! - [`Value`]: the model — JSON's values plus typed ones (references
6//!   `@kind:id`, bytes);
7//! - [`text`]: JSON with comments, trailing commas and unquoted keys,
8//!   parsed with the position of every value; [`patch`] edits a document
9//!   in place, keeping its comments and layout;
10//! - [`typed`]: the one grammar of the typed values' string forms
11//!   (`@file:images/logo.png`, `@bytes:…`);
12//! - [`binary`]: the compact, self-describing tagged form;
13//! - [`frame`]: the packed form for messages whose schema both sides know;
14//! - [`Schema`] (`#[derive(Schema)]`): a format written once — read with
15//!   the path of every problem, written, encoded, packed, and described
16//!   ([`Shape`]) for editors and docs.
17
18// `::substrate_data::…` paths of `#[derive(Schema)]` work inside this crate too.
19extern crate self as substrate_data;
20
21pub mod diagnostic;
22mod forms;
23mod model;
24pub mod names;
25mod sync;
26mod utf8;
27mod wire;
28
29pub use atom::Atom;
30pub use bumpalo::Bump;
31pub use diagnostic::{Code, Diagnostic, Errors, Problem, Severity};
32#[cfg(feature = "json")]
33pub use forms::json;
34#[cfg(feature = "toml")]
35pub use forms::toml;
36pub use forms::{patch, source, text};
37pub use model::borrowed::{MapRef, ValueRef};
38pub use model::value::{KindName, Map, Path, Ref, RefKey, Seg, Value, ValueKind};
39pub use model::{atom, typed};
40pub use schema::with;
41pub use text::{Doc, LineCol, Span, Spans, SyntaxError};
42pub use wire::stream::{Stream, StreamWriter};
43pub use wire::{binary, frame, io};
44pub mod schema;
45
46pub use schema::{
47    Expected, Id, Kind, Kinds, NamedType, OneOrList, Ordered, Read, Reader, RefId, Resolve, Schema,
48    Shape, ShapeDoc, Uid, Unresolved, from_bytes_with, from_doc_with, from_text, from_value,
49    from_value_with, placed, read_bytes, read_ref_value, read_value, to_bytes, to_bytes_into,
50    to_text,
51};
52pub use substrate_data_derive::Schema;
53
54#[cfg(doctest)]
55mod readme;