Expand description
Modules§
- with
- Field codecs:
#[data(with = "…")]reads and writes a field through a type other than its own — like serde’swith. The field keeps the plain type a program uses (String), the format says what it holds (a reference to a file), checked and resolved by theReader’sResolve.
Structs§
- Dictionary
- The values references expand to — the words of a vocabulary, the texts
of a language, the entries of a table — kept per kind and id, in the
order they were added. It is a
Resolve: a reference of a kind it holds is checked against its ids and, where a field takes a value (with::Expand), expanded to the value; a reference of a kind it doesn’t hold is left alone. - Enum
Shape - An enum’s shape: its variants, and the key naming one if it’s tagged.
- Field
- A field of a struct (or of an enum’s variant).
- Field
Doc - A field: its name, doc, shape, whether it must be written, its range.
- Found
- Where a reference was found.
- Id
- The id of something of kind
K, ofK’s id type: written@file:images/logo.png,@user:42. - Named
Shape - The shape of a
NamedType: its name and its stored shape. - OneOr
List - One value or several, read either way and written back the same way (one as itself). Never empty: an empty list is a problem.
- Ordered
- An object kept in file order, values of one schema.
- Read
- What reading a document gives: the value and the references in it.
- Reader
- The state of reading a value: where it is, the problems so far, and the references met (for the build to check against the content there is).
- Shape
Doc - A shape as data: written
{ root, defs }, structs and enums once indefsand referred to by name. - Struct
Shape - A struct’s shape: its fields.
- Uid
- A 128-bit id (a UUID’s bits, a hash), spelled as 32 lower-case hex
digits:
@doc:0123456789abcdef0123456789abcdef. - Variant
- A variant of an enum.
- Variant
Doc - A variant: its name, doc, and (in a tagged enum) its fields.
Enums§
- Definition
Doc - A struct or an enum, as written once in a description’s
defs. - Expansion
- What a reference read where a value may stand came to.
- Expected
- What a field takes, for the “expected …, found …” problem.
- Shape
- What a format looks like: drives an editor’s property grids and pickers, completion, hover docs and the docs’ field tables.
- Shape
Node - One shape as data, tagged by
kind; a struct or enum is adef, its definition written once in the description’sdefs. - Unresolved
- Why a reference doesn’t resolve.
Constants§
- COMMENT_
KEY - A note for whoever edits the file — every object may have one.
- MAX_
EXPANSION_ DEPTH - How many expanded values may be read inside one another: a value that expands to itself (through references that expand to references) stops here with a problem instead of never.
- META_
PREFIX - What a source-only key starts with:
$…(a note on an entry:$<key>),_…. - PRIVATE_
PREFIX - What a private source-only key starts with:
_…. - RESULT_
ERR - The key of a
Result’s failure side. - RESULT_
OK - The key of a
Result’s success side. - WRAPPED
- Where a tagged enum’s variant keeps what it wraps when that isn’t a
struct (
Id(String)is{type: "id", value: "…"}); a wrapped struct’s fields sit next to the tag instead.
Traits§
- Fields
- A struct with named fields (
#[derive(Schema)]): each field’s Rust name and its name in files. - Kind
- A kind of thing a reference names:
user,doc,file, … — a format declares its own withkind!, each with the type of its ids. - Kinds
- One kind or several (
(File, Doc), sharing an id type): what a reference field takes. - Named
Type - A type of a format’s own, stored as
NamedType::Storedin every form (text, binary, frames) and described byNamedType::NAME, so a tool that knows the name shows its own editor (a colour picker, a calendar) and one that doesn’t edits the stored data.crate::named_schema!implementsSchemafor it. - Numbers
- The numbers a value holds — what
#[data(range = …)]checks. - RefId
- The type of a kind’s ids: how one is spelled in a reference
(
@user:42), read back, and stored in every other form (a frame packs it as itself — a number as a number). - Resolve
- What a tool makes of the references it reads: a build checks each one against what there is (and may rewrite its id), an editor shows them.
- Schema
- A format: a type that reads, writes, encodes, packs and describes itself.
Functions§
- field_
name ident’s name in files amongfields— a compile error when it’s used in a constant (asfield!does) and there’s no such field.- field_
names - The field names of a struct’s shape (none for anything else).
- from_
bytes_ with read_byteswithresolverfor the references: the binary form read through a value tree (the straight path has nowhere to ask), so references can be checked, rewritten and expanded (with::Expand).- from_
doc - Reads a parsed document as
T;textis its source, for positions. - from_
doc_ with from_doc, references and texts going throughresolver.- from_
text - Parses
textand reads it asT; problems come with their line and column. - from_
value - Reads
vasT: the value and its references, or every problem. - from_
value_ with from_value, references and texts going throughresolver.- is_
metadata_ key - Source-only keys every object may have:
$…,_…,comment. - placed
d(about a value ofdoc, parsed fromtext) at its line and column: its key’s for one about the key (an unknown field).- read_
both AandBread from the same object — each allowing the other’s fields, like serde’sflatten: a record’s common fields and its kind’s.- read_
bytes - Reads the binary form as
T, borrowed all the way: no string is copied but intoTitself — content as the runtime takes it. - read_id
vas a reference to one ofK’s kinds, its id read asK::Id— as written, or as thecrate::Resolverewrote it.- read_
named - Reads a
NamedTypethrough its stored form (whatcrate::named_schema!calls). - read_
ref vas a reference to one ofkinds(any kind if empty), written@kind:id— a bare id is an error that says how to write it. The id is read untyped (read_idreads it as a kind’s id type).- read_
ref_ value read_valueof a borrowed value.- read_
value - Reads
vasT, nothing else: what a runtime wants of content (the references met aren’t kept). - ref_
shape - The shape of a reference to
K. - to_
bytes vin the binary form, written straight (Schema::encode).- to_
bytes_ into vin the binary form, appended toout(a whole document, header first): a buffer that is kept and reused grows once.- to_text
valueas text, indented: written straight, no value tree built.
Type Aliases§
- ShapeFn
- A shape, built on demand — so shapes of recursive types are fine.