No description
Find a file
Markus Scully 3b193c5aa3
♻️ bevy_vanth, vanth, vanth_derive, flake: Add Bevy integration crate and refactor entity/networking
- Created new crate `bevy_vanth` with basic plugin structure for Bevy integration.
- Refactored `Id` generation in `vanth` to use `OsRng` and removed redundant `to_u128_pair`/`from_u128_pair` methods.
- Moved networking functionality into new `net` module with `Node`, `Packet`, and `Message` types.
- Updated `vanth_derive` to use `proc-macro-crate` for reliable crate path resolution.
- Added `rand` dependency to replace custom ID generation logic.
- Updated `Cargo.toml`/`Cargo.lock` with new dependencies: `bevy_app`, `nix`, `cfg_aliases`, `proc-macro-crate`.
- Modified `README.md` with improved project description.
- Added commented clippy check in `flake.nix`.
2025-08-17 11:56:34 +03:00
.cargo ♻️🍱💩👷 crates/vanth, project: Refactor entity system and setup; migrate to Nix flakes 2025-08-04 21:03:15 +03:00
.github/workflows ♻️ ci, nix, rust: Set up CI and switch to rust-overlay toolchain 2025-08-12 17:01:33 +03:00
crates ♻️ bevy_vanth, vanth, vanth_derive, flake: Add Bevy integration crate and refactor entity/networking 2025-08-17 11:56:34 +03:00
.gitignore Init commit 2024-11-14 23:24:15 +00:00
Cargo.lock ♻️ bevy_vanth, vanth, vanth_derive, flake: Add Bevy integration crate and refactor entity/networking 2025-08-17 11:56:34 +03:00
Cargo.toml ♻️ bevy_vanth, vanth, vanth_derive, flake: Add Bevy integration crate and refactor entity/networking 2025-08-17 11:56:34 +03:00
flake.lock ♻️ ci, nix, rust: Set up CI and switch to rust-overlay toolchain 2025-08-12 17:01:33 +03:00
flake.nix ♻️ bevy_vanth, vanth, vanth_derive, flake: Add Bevy integration crate and refactor entity/networking 2025-08-17 11:56:34 +03:00
LICENSE Refactor: Convert project to a Bevy-based workspace and node 2025-07-12 22:59:41 +03:00
README.md ♻️ bevy_vanth, vanth, vanth_derive, flake: Add Bevy integration crate and refactor entity/networking 2025-08-17 11:56:34 +03:00
rust-toolchain.toml ♻️ ci, nix, rust: Set up CI and switch to rust-overlay toolchain 2025-08-12 17:01:33 +03:00
rustfmt.toml ♻️🍱 config, cli, vanth, vanth_derive, varo: Reformatted code and added editor configuration files 2025-08-07 12:49:33 +03:00

Vanth

Vanth is a content-addressed data storage and task memoization framework designed for entity-component-system (ECS) applications.

Inspired by Salsa and Bevy.

It is currently experimental and should not be used for anything.

Library usage

Any type that implements serde::Serialize can be hashed using vanth::hash to produce a vanth::ContentHash.

let x = "hello";
assert_eq!(vanth::hash(&x).hex(), "ea8f163db38682925e4491c5e58d4bb3506ef8c14eb78a86e908c5624a67200f");

Derive or implement the vanth::Vanth trait for types you want to store in the database.

use serde::{Deserialize, Serialize};
use vanth::Vanth;

#[derive(Deserialize, Serialize, Vanth)]
struct Data {
    value: u32,
}

This generates a method Vanth::ty() which returns a vanth::Ty. This should represent the type's fully qualified name - its module path followed by the type itself and any generics it has. E.g. Data::ty().to_string() could return "my::crate::module::Data".

The derive macro only works for basic types right now and is not implemented for std types. Moving or renaming types or modules will change the type name, necessitating a database migration. This is not supported yet.

This should be used with caution. There are good reasons why std::any::TypeId is opaque.

Database storage

use vanth::store::{Store, StoreParams};

// Or use `Store::in_memory`.
let mut store = Store::sqlite_from_path(
    "path/to/my_database.sqlite".into(),
    StoreParams { create_if_not_exists: true, ..Default::default() },
);
let hash = store.write(Data { value: 5 }).unwrap();
let my_data: Data = store.get_from_hash(hash).unwrap();

CLI usage

You can run the Vanth CLI with Nix using nix run git+https://git.mascully.com/mascully/vanth.git.

Use -- to pass arguments, e.g. nix run git+https://git.mascully.com/mascully/vanth.git -- --help.

Syntax

Write a component to the database:

$ vanth write --db /path/to/db.sqlite --ty my::type::Name --value '{ "field": "value" }'
a1cf81d8afe4e72604ea5c13bbd9b6cce14bd98c3a2f036f7156c4464a88ec09

Get a component from the database:

$ vanth get --db /path/to/db.sqlite --ty my::type::Name a1cf81d8afe4e72604ea5c13bbd9b6cce14bd98c3a2f036f7156c4464a88ec09
{"field":"value"}

Get all components of a type from the database:

$ vanth get-all --db /path/to/db.sqlite --ty my::type::Name
{"field":"value1"}
{"field":"value2"}
{"field":"value3"}

Delete a component by its content hash:

$ vanth delete --db /path/to/db.sqlite ea8f163db38682925e4491c5e58d4bb3506ef8c14eb78a86e908c5624a67200f

Delete all components of a type:

$ vanth delete-all --db /path/to/db.sqlite --ty my::type::Name