structecs/
lib.rs

1//! # structecs
2//!
3//! A flexible entity-component framework without the System.
4//!
5//! ## Overview
6//!
7//! structecs provides an ECS-inspired data management system that focuses on flexibility
8//! over rigid System architecture. It allows you to:
9//!
10//! - Store hierarchical component data naturally
11//! - Query components efficiently using archetype-based storage
12//! - Extract components dynamically at runtime
13//! - Write game logic however you want (no forced System pattern)
14//!
15//! ## Example
16//!
17//! ```rust
18//! use structecs::*;
19//!
20//! #[derive(Debug, Extractable)]
21//! pub struct Entity {
22//!     pub name: String,
23//! }
24//!
25//! #[derive(Debug, Extractable)]
26//! #[extractable(entity)]
27//! pub struct Player {
28//!     pub entity: Entity,
29//!     pub health: u32,
30//! }
31//!
32//! let mut world = World::default();
33//!
34//! let player = Player {
35//!     entity: Entity {
36//!         name: "Hero".to_string(),
37//!     },
38//!     health: 100,
39//! };
40//!
41//! let player_id = world.add_entity(player);
42//!
43//! // Iterator-based query (efficient, no allocation)
44//! for (id, entity) in world.query::<Entity>() {
45//!     println!("Entity: {:?}", *entity);
46//! }
47//!
48//! // Extract specific component
49//! if let Ok(health) = world.extract_component::<u32>(&player_id) {
50//!     println!("Health: {}", *health);
51//! }
52//! ```
53
54// Re-export the derive macro
55pub use structecs_macros::Extractable;
56
57// Module declarations
58mod acquirable;
59mod archetype;
60mod entity;
61mod error;
62mod extractable;
63mod extractor;
64mod handler;
65mod world;
66
67// Public exports
68pub use acquirable::Acquirable;
69pub use entity::EntityId;
70pub use error::WorldError;
71pub use extractable::{Extractable, ExtractionMetadata};
72pub use handler::ComponentHandler;
73pub use world::World;
74
75// Test module
76#[cfg(test)]
77mod tests;