Skip to main content

Module schema

Module schema 

Source
Expand description

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.

Modules§

kinds
The kinds every Yog format knows.

Macros§

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

Structs§

EnumShape
Errors
Problems found reading a document, with where each is.
Field
Found
Where a reference was found.
Id
The id of content of kind K: written @item:minecraft:stick or, in a field that can only be an item, just minecraft:stick (stick).
Located
A problem and its place in the source.
OneOrList
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.
Problem
A problem found reading a value.
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).
StructShape
TagId
A tag of content of kind K: @tag:item:minecraft:planks.
Variant

Enums§

AnyRefOrTag
Content of any kind or a tag of it: @entity:minecraft:pig, @tag:entity:c:bosses — a tag’s entries, whose kind the tag says.
Color
A color: #RRGGBB, #AARRGGBB, or a .yres color.
Image
An image: a source (sprite:button, mymod:gui/logo, item:minecraft:stick) or a .yres image.
OneOrTag
Content of kind K or a tag of it — a recipe ingredient.
Shape
What a format looks like: drives Yog-IDLE’s property grids and pickers, completion, hover docs and the docs’ field tables.
Text
A text a player reads: Yog text as written, a .yres text, the name of some content (@item:minecraft:stick shows “Stick”), or any translation key (@lang:gui.done).

Constants§

COMMENT_KEY
A note for whoever edits the file — every object may have one.
META_PREFIX
What a source-only key starts with: $… (a note on an entry: $<key>), _….
PRIVATE_PREFIX
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 content: item, block, … — a mod declares its own with kind!.
Kinds
One kind or several ((Item, Block)): what a reference field takes.
Numbers
The numbers a value holds — what #[data(range = …)] checks.
Resolve
What a tool makes of the references and texts it reads: yog build checks each reference against the content there is and turns texts into translation keys; the IDE shows them.
Schema
A Yog Data format.

Functions§

built_in
A table a crate ships (include_str! of its .ydata), read: what it says, or — when it won’t read, which its crate’s tests catch — the error logged (what: which table) and nothing.
field_name
ident’s name in files among fields — a compile error when it’s used in a constant (as field! does) and there’s no such field.
field_names
The field names of a struct’s shape (none for anything else).
from_doc
Reads a parsed document as T; text is its source, for positions.
from_doc_with
from_doc, references and texts going through resolver.
from_text
Parses text and reads it as T; problems come with their line and column.
from_value
Reads v as T: the value and its references, or every problem.
from_value_with
from_value, references and texts going through resolver.
is_metadata_key
Source-only keys every object may have: $…, _…, comment.
read_both
A and B read from the same object — each allowing the other’s fields, like serde’s flatten: a recipe’s common fields and its kind’s.
read_bytes
Reads the binary form as T, borrowed all the way: no string is copied but into T itself — content as the runtime takes it.
read_ref
v as a reference to content of one of kinds (any kind if empty), written @kind:id — a bare id is an error that says how to write it.
read_ref_value
read_value of a borrowed value.
read_value
Reads v as T, nothing else: what the game wants of content (the references met aren’t kept).
to_bytes
v in the binary form, written straight (Schema::encode).
to_text
value as text, indented.

Type Aliases§

BlockId
EntityId
ItemId
ItemIdOrTag
An item or an item tag: "minecraft:stick", "@tag:item:minecraft:planks".
RecipeId
ShapeFn
A shape, built on demand — so shapes of recursive types are fine.