steel_registry/data_components/mod.rs
1//! Data components system for items and entities.
2//!
3//! This module provides an ABI-stable component system where:
4//! - Vanilla components get dedicated enum variants for zero-cost typed access
5//! - Plugin components use opaque bytes (`ComponentData::Other`)
6//!
7//! # Architecture
8//!
9//! - [`ComponentData`] - ABI-stable enum storing component values
10//! - [`Component`] - Trait for types that convert to/from `ComponentData`
11//! - [`DataComponentType<T>`] - Compile-time type handle for accessing components
12//! - [`DataComponentMap`] - Storage for component values on items
13//! - [`DataComponentPatch`] - Diff representation for network/storage
14//! - [`DataComponentRegistry`] - Registry of component types with serialization
15//!
16//! # Example
17//! ```ignore
18//! use steel_registry::data_components::vanilla_components::DAMAGE;
19//!
20//! // Type-safe access (compile-time checked)
21//! let damage: Option<&i32> = components.get(DAMAGE);
22//! components.set(DAMAGE, Some(10));
23//!
24//! // Raw access for plugins
25//! let data = components.get_raw(&key)?;
26//! ```
27
28mod component_data;
29pub mod components;
30mod registry;
31pub mod vanilla_components;
32
33// Re-export core types
34pub use component_data::{Component, ComponentData, ComponentDataDiscriminant};
35pub use components::{Equippable, EquippableSlot, Tool, ToolRule};
36pub use registry::{
37 ComponentEntry,
38 ComponentEntryRef,
39 ComponentPatchEntry,
40 DataComponentMap,
41 DataComponentPatch,
42 DataComponentRegistry,
43 DataComponentType,
44 NbtReader,
45 NbtWriter,
46 // Type aliases for reader/writer functions
47 NetworkReader,
48 NetworkWriter,
49 component_try_into,
50};