reflect only.Expand description
The component registry: which components a bridge can address.
A component is any 'static type, so a world alone cannot name one. A
component becomes addressable by submitting a ComponentEntry to a
link-time table; the entry is the only place its name and its codec are
written down.
The codec speaks [Partial] values rather than text: a caller that has a
component in reflection form writes it without ever spelling it out, and one
that has it as text fills a partial first. JSON is one such spelling, and
encode_json, set_json and push_json are that front door; a
bridge of another format uses the partials underneath it.
For a component that derives [facet::Facet] the entry carries no field list
at all: its own struct fields are the JSON shape, and ComponentEntry::new
turns that reflection into the codec. A component whose fields cannot be
reflected – a GPU handle, a private field – reflects through a proxy instead,
and one that cannot be written makes its proxy’s conversion fail, so a write
reports why rather than inventing a value.
Entries are collected from wherever they are written, so a crate that defines its own components registers them itself – nothing has to be handed a registry. The table is link-time, so a crate whose entries are never reachable from the binary is not linked in either; a binary that wants a crate’s entries has to name that crate.
Re-exports§
use facet::Characteristic;🔒use facet::Facet;🔒use facet::Facet;🔒use facet::Partial;🔒use facet::AllocError;🔒use facet::ReflectError;🔒use facet::ShapeMismatchError;🔒use facet_format::DeserializeError;🔒use facet_format::SerializeError;🔒use facet_json::JsonSerializeError;🔒use crate::DynamicBundle;🔒use crate::Entity;🔒use crate::EntityAccessError;🔒use crate::Scope;🔒
Structs§
- Component
Entry - One component a bridge can address.
Enums§
- Component
Error - Why the registry could not address a component.
Functions§
- contains
- Whether a component with this name is submitted.
- current_
partial - A partial value over the entity’s current component, ready to be filled and handed back to set.
- current_
partial_ 🔒component - A partial over the entity’s current C, seeded with a copy of it.
- default_
partial - A partial value over the named component’s Default, ready to be filled and handed to push.
- default_
partial_ 🔒component - A partial over a fresh C, seeded with C’s Default when it has one.
- describe 🔒
- The backend’s own message, which [SerializeError]’s Display
leaves out of the
Backendvariant. - encode_
json - Entity’s name component as JSON text, or why either is missing.
- encode_
json_ 🔒component - entries
- Every submitted entry.
- entry
- The entry a name addresses, or ComponentError::Unknown naming the ones that exist.
- fill 🔒
- The partial a JSON patch produces over
partial. - find 🔒
- materialize 🔒
- missing 🔒
- Says which component was asked for and why the lookup failed: the handle may be dead or out of the scope’s reach, and each has its own reply.
- names
- The bare names of every submitted component.
- push
- Push the name component, taken from
partial, into builder. - push_
component 🔒 - push_
json - Push a name component decoded from JSON text into builder.
- set
- Overwrite entity’s name component with the value
partialholds. - set_
component 🔒 - set_
json - Overwrite entity’s name component from JSON text.
- to_json 🔒
- A value as JSON text, through the reflection it derives.