| Crates.io | anvaya |
| lib.rs | anvaya |
| version | 0.1.0 |
| created_at | 2025-08-03 13:17:41.260819+00 |
| updated_at | 2025-08-03 13:17:41.260819+00 |
| description | ECS like dynamic storage in ~500 LOC. |
| homepage | |
| repository | https://github.com/nilaysavant/anvaya |
| max_upload_size | |
| id | 1779705 |
| size | 43,973 |
ECS like dynamic storage in ~500 LOC.
🚧 WIP toy project. Use at your own risk ⚠️
use anvaya::prelude::*;
// Create Components (of any type with no boilerplate)...
struct Player(&'static str);
struct Age(u8);
// World and spawn...
let mut world = World::new();
world.spawn().insert(Player("Mike")).insert(Age(30));
world.spawn().insert(Player("Hannah")).insert(Age(25));
// Query and filter...
let mut query = world.query();
let mut results = query
.with::<Age>()
.get::<Player>()
.unwrap()
.map(|(_, player)| player.0);
// Validate...
assert_eq!(results.next().unwrap(), "Mike");
assert_eq!(results.next().unwrap(), "Hannah");
TypeMap data structure.unsafe, no Clone, no smart pointers/atomics. Just Box<dyn Any>.Slab as default tabular storage. But allows swapping it for your own custom storage by impl a few traits like Storage etc. See custom_storage.rs example.The above features are subject to change based on the goals of the project.
Box<dyn Any> and type identifications using TypeID led to creation of data structures like TypeMap. This was the key inspiration to start this project.