10 releases
0.1.43 | Mar 1, 2021 |
---|---|
0.1.42 | Dec 22, 2020 |
0.1.41 | Jan 12, 2020 |
0.1.40 | Dec 13, 2019 |
0.1.2 | May 6, 2019 |
#889 in Data structures
160KB
3.5K
SLoC
This crate has soundness troubles; see the documentation & tests.
lib.rs
:
v9
is a clean, easy to use, and flexible data engine.
It provides a means to implement applications using Data Oriented Design.
#[v9::table]
struct engines {
pub cylinder_count: u8,
pub lines_of_code: u64,
}
use v9::prelude::Universe;
let mut universe = Universe::new();
use v9::prelude::Register;
engines::Marker::register(&mut universe);
let (v9, v11) = universe.eval(|mut engines: engines::Write| {
(
engines.push(engines::Row {
cylinder_count: 9,
lines_of_code: 5000,
}),
engines.push(engines::Row {
cylinder_count: 11,
lines_of_code: std::u64::MAX,
}),
)
});
#[v9::table]
struct projects {
pub name: &'static str,
pub engine: crate::engines::Id,
}
projects::Marker::register(&mut universe);
universe.eval(|mut projects: projects::Write| {
projects.push(projects::Row {
name: "TOP SECRET!",
engine: v9,
});
projects.push(projects::Row {
name: "Stinky Cheese Inc!",
engine: v11,
});
});
universe.eval(|projects: projects::Read| {
assert_eq!(projects.iter().count(), 2);
});
universe.eval(|mut engines: engines::Write| {
engines.remove(v11);
});
universe.eval(|projects: projects::Read| {
// No dangling pointers!
assert_eq!(projects.iter().count(), 1);
});
Design
A Universe
works like a HashMap<TypeId, Any>
.
A single instance of any type can be inserted into the universe.
Changes can then be made by run
ning a Kernel
.
A Kernel
is any closure whose arguments all implement Extract
,
a trait that works like fn extract(&Universe) -> Self
.
Encapsulation
This crate makes an unreasonable amount of things public. It's very intentional!
It's hard to foresee all needs; hopefully you can do something useful with them,
and this is more honest than making things pub
to satisfy my whims.
A serious application should provide its own interfaces to hide v9
behind.
Safety
┐(ツ)┌
My priorities are:
- A beautiful API.
- Gotta go fast:
- Compile-times must be fast.
- Bulk operations (via kernels) must be h*ckin' fast.
- Safety.
Monkey-proofing is not a high priority. That said, you'll probably only have trouble if you go looking for it.
If you've tripped over something, that we'd maybe wish didn't compile, and it doesn't blow up at runtime in an obvious way, then I'll be concerned.
Dependencies
~0.5–1MB
~25K SLoC