Expand description
Data components system for items and entities.
This module provides an ABI-stable component system where:
- Vanilla components get dedicated enum variants for zero-cost typed access
- Plugin components use opaque bytes (
ComponentData::Other)
§Architecture
ComponentData- ABI-stable enum storing component valuesComponent- Trait for types that convert to/fromComponentDataDataComponentType<T>- Compile-time type handle for accessing componentsDataComponentMap- Storage for component values on itemsDataComponentPatch- Diff representation for network/storageDataComponentRegistry- Registry of component types with serialization
§Example
ⓘ
use steel_registry::data_components::vanilla_components::DAMAGE;
// Type-safe access (compile-time checked)
let damage: Option<&i32> = components.get(DAMAGE);
components.set(DAMAGE, Some(10));
// Raw access for plugins
let data = components.get_raw(&key)?;Re-exports§
pub use components::Equippable;pub use components::EquippableSlot;pub use components::Tool;pub use components::ToolRule;
Modules§
- component_
data 🔒 - ABI-stable component data storage.
- components
- Individual component type definitions.
- registry 🔒
- Data component registry and storage types.
- vanilla_
components - Vanilla data component definitions and registration.
Structs§
- Component
Entry - Metadata for a registered component type.
- Data
Component Map - Storage for component values.
- Data
Component Patch - A patch representing modifications to a
DataComponentMap. - Data
Component Registry - Registry of all data component types.
- Data
Component Type - A typed handle for a data component.
Enums§
- Component
Data - ABI-stable component value storage.
- Component
Data Discriminant - Discriminant for
ComponentDatavariants. - Component
Patch Entry - Entry in a component patch.
Traits§
- Component
- Trait for types that can be converted to/from
ComponentData.
Functions§
- component_
try_ into - Attempts to extract a typed component from
ComponentData.
Type Aliases§
- Component
Entry Ref - NbtReader
- Reader function for deserializing a component from NBT format.
- NbtWriter
- Writer function for serializing a component to NBT format.
- Network
Reader - Reader function for deserializing a component from network format.
- Network
Writer - Writer function for serializing a component to network format.