Expand description
§pathland-core
The 16-byte fixed-size opcode engine for Pathland: fixed-size opcodes, a single-producer ring buffer, a bump arena for variable-length data, and the linear-memory layout shared with host renderers.
This crate is no_std + alloc. It has no runtime dependencies.
§Producer (guest engine)
use pathland_core::{init_memory, Guest, MemoryLayout};
let layout = MemoryLayout::default();
let mut mem = vec![0u8; layout.total_bytes()];
init_memory(&mut mem, &layout);
let mut guest = Guest::new(&mut mem, &layout);
guest.begin_frame();
guest.create_node(1, pathland_core::component_type::VSTACK).unwrap();
guest.insert_child(0, 1, pathland_core::APPEND).unwrap();
guest.set_property(1, pathland_core::property_id::SPACING, pathland_core::value_type::F32, 4.0f32.to_bits()).unwrap();
guest.end_frame(); // publishes frameCount§Consumer (host renderer)
use pathland_core::{init_memory, Guest, Host, MemoryLayout};
let mut host = Host::new(&mut mem, &layout);
for frame in host.frames() {
for op in frame.opcodes() {
println!("{:?}", op);
}
}Modules§
- border_
edges - Bits for the
BORDER_EDGESstyle property (a u32 bitmask). - category
- Opcode categories (
Categoryfield, u8). - component_
type - Component types (u16, encoded in the low half of
BofTREE::CREATE_NODE). - environment
- Environment field ids for
META::ENVIRONMENT(host → guest). - event
- Commands within the
EVENTcategory. - fit
- The
SizeThatFitsfit rule — the single spec’d selection algorithm every renderer and host share (spec/PRIMITIVES.md §SizeThatFits). Given the slot’s allocated width and the app-declared candidate thresholds (ascending), it returns the selected candidate index. - flag
- Flag bits used across categories.
- icon
- Canonical icon names (
ICON_NAMEvalues; spec/ICONS.md). - listener
- Bits for the
EVENT_LISTENERSsemantic property (a u32 bitmask). - meta
- Commands within the
METAcategory. - parameter
- Commands within the
PARAMETERcategory. - property_
id - Property IDs (u16, encoded in the low half of
BofPARAMETER::SET_PROPERTY). - role
- Semantic-role codes for the
ROLEsemantic property (0x2001). - size
- Special size constants for
WIDTH/HEIGHT. - text_
style - Predefined typography codes for the
TEXT_STYLEproperty (seespec/MODIFIERS.md). Each value selects a whole typography from the design system (font size/weight/design). The heading styles (LargeTitle through Headline) imply a heading element when applied to aTEXT: the renderer emits<h1>–<h5>(the level comes from the style — noROLEneeded). The non-heading styles render as plain<span>text. A raw font modifier (FONT_SIZE,FONT_WEIGHT,FONT_FAMILY, …) never implies a heading — it only overrides the typography’s visual. - tokens
- Design-token resolution (spec/TOKENS.md) — the reference implementation.
- tree
- Commands within the
TREEcategory. - value_
type - Value types for
PARAMETERproperties (u8, encoded in the high byte ofB).
Structs§
- Frame
- A completed frame produced by the guest: a sequence of opcodes plus arena access.
- Frame
Iter - Iterator over the opcodes in a
Frame. - Guest
- Producer side: the guest engine writing opcodes and arena data into shared linear memory. Owns the header, ring, and arena regions as disjoint slices.
- Host
- Consumer side: the host renderer reading completed frames.
- Memory
Layout - The fixed layout of the shared linear memory.
- Opcode
- A fixed-size 16-byte opcode.
- Shared
Header - Accessor for a shared-memory ring header, for consumers that read the ring
in place (zero-copy) without a
Hosthandle — e.g. a foreign driver that holds a raw pointer to the shared linear memory.
Enums§
- Arena
Error - Errors produced by the arena.
- Event
- A raw-input event (host → guest).
- Event
Error - Error decoding a raw-input event from an opcode.
- Ring
Error - Errors produced by the ring producer.
Constants§
- APPEND
- Sentinel for append positions (
index = u32::MAX). - OPCODE_
SIZE - Size of one opcode in bytes.
Functions§
- init_
memory - Initialize the linear memory header for a layout. Call once at startup
before creating a
GuestorHost. - value_
type_ for - The protocol value type for a property id.