Skip to main content

Crate yog_data

Crate yog_data 

Source
Expand description

Yog Data: one data model, text syntax, binary form and schema system for every Yog format, the build, the ABI and the IDE — the way Minecraft has NBT. See docs/design/yog-data.md.

  • Value: the model — JSON’s values plus typed ones (content references, tags, mod resources, Yog text, images, colors);
  • text: JSON with comments, trailing commas and unquoted keys, parsed with the position of every value;
  • typed: the one grammar of the typed values’ string forms (@item:minecraft:stick, @tag:item:minecraft:planks, @Strings.title);
  • binary: the compact tagged form content crosses the ABI in.

Re-exports§

pub use text::Doc;
pub use text::LineCol;
pub use text::Span;
pub use text::Spans;
pub use text::SyntaxError;
pub use schema::AnyRefOrTag;
pub use schema::BlockId;
pub use schema::Color;
pub use schema::EntityId;
pub use schema::Errors;
pub use schema::Id;
pub use schema::Image;
pub use schema::ItemId;
pub use schema::ItemIdOrTag;
pub use schema::Kind;
pub use schema::Kinds;
pub use schema::OneOrTag;
pub use schema::Ordered;
pub use schema::Read;
pub use schema::Reader;
pub use schema::RecipeId;
pub use schema::Resolve;
pub use schema::Schema;
pub use schema::Shape;
pub use schema::TagId;
pub use schema::Text;
pub use schema::from_doc_with;
pub use schema::from_text;
pub use schema::from_value;
pub use schema::from_value_with;
pub use schema::kinds;
pub use schema::read_bytes;
pub use schema::read_ref_value;
pub use schema::read_value;
pub use schema::to_text;

Modules§

binary
The binary form — what the build compiles content to and the runtime and the Java hosts read, like NBT:
schema
Schemas: a format is a Rust type implementing Schema (usually #[derive(Schema)]). One schema reads and writes the format, checks it with the path of every problem, collects its references for the build to check, and describes itself (Shape) for Yog-IDLE’s editors and the docs.
text
The text syntax: JSON, plus // and /* */ comments, trailing commas and unquoted keys (the part of JSON5 editors already understand).
typed
The typed values’ string forms — one grammar for every format:
with
Field codecs: #[data(with = "…")] reads and writes a field through a type other than its own — like serde’s with. The field keeps the plain type a program uses (String), the format says what it holds (an item reference, a text), checked and resolved by the Reader’s Resolve.

Macros§

kind
Declares kinds of content: yog_data::kind!(Pattern = "pattern");.

Structs§

Bump
An arena to bump allocate into.
Map
A map: entries in file order, keys unique. Keys are shared: a decoded document allocates each distinct key once, however many maps have it.
MapRef
A borrowed map: entries in file order.
Path
Where a value is in a document: entries[2].pages[0].item.
Ref
A reference to content: its kind (item, block, entity, recipe, entry, category, or a mod’s own) and id (minecraft:stick, minecraft:furnace[facing=north]).
Res
A mod resource: @<set>.<key> — @Strings.screen.title is set Strings, key screen.title.

Enums§

Seg
One step of a Path.
Value
A Yog Data value.
ValueRef
A borrowed Value: the same cases, strings &'a str, lists and maps slices.

Derive Macros§

Schema