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 wire;
27
28pub use atom::Atom;
29pub use bumpalo::Bump;
30pub use diagnostic::{Code, Diagnostic, Errors, Problem, Severity};
31#[cfg(feature = "json")]
32pub use forms::json;
33#[cfg(feature = "toml")]
34pub use forms::toml;
35pub use forms::{patch, source, text};
36pub use model::borrowed::{MapRef, ValueRef};
37pub use model::value::{KindName, Map, Path, Ref, RefKey, Seg, Value, ValueKind};
38pub use model::{atom, typed};
39pub use schema::with;
40pub use text::{Doc, LineCol, Span, Spans, SyntaxError};
41pub use wire::stream::{Stream, StreamWriter};
42pub use wire::{binary, frame, io};
43pub mod schema;
44
45pub use schema::{
46    Expected, Id, Kind, Kinds, NamedType, OneOrList, Ordered, Read, Reader, RefId, Resolve, Schema,
47    Shape, ShapeDoc, Uid, Unresolved, from_doc_with, from_text, from_value, from_value_with,
48    placed, read_bytes, read_ref_value, read_value, to_bytes, to_text,
49};
50pub use substrate_data_derive::Schema;
51
52#[cfg(doctest)]
53mod readme;