From 81d454b256947c2a983957b230a698372bf8c416 Mon Sep 17 00:00:00 2001 From: Markus Scully Date: Sat, 12 Jul 2025 22:59:41 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20Refactor:=20Convert=20project?= =?UTF-8?q?=20to=20a=20Bevy-based=20workspace=20and=20node?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit refactors the Vanth project to utilize a `Cargo.toml` workspace, encapsulating the core logic within a `vanth` library crate. The existing `src` files are moved into the new `vanth/src` directory. The primary change is the integration of the Bevy game engine as the underlying framework for the Vanth node, shifting from the previous `whirlwind` dependency. This transition is reflected in `Cargo.toml` updates, adding `bevy_app` and `bevy_ecs` as dependencies and removing `whirlwind`. A new test file `vanth/tests/test_node.rs` is introduced to cover the initial functionality of the `Node` struct. The `LICENSE` year range is also updated. This refactoring sets the stage for Vanth's evolution into a distributed ECS-based database model, leveraging Bevy's robust ECS capabilities. --- .rules | 1 + Cargo.lock | 926 ++++++++++++++++++++++++++++++++++- Cargo.toml | 11 +- LICENSE | 2 +- README.md | 560 +-------------------- vanth/Cargo.toml | 12 + vanth/src/lib.rs | 22 + {src => vanth/src}/main.rs | 0 {src => vanth/src}/parser.rs | 0 {src => vanth/src}/util.rs | 0 {src => vanth/src}/vanth.rs | 0 vanth/tests/test_node.rs | 7 + 12 files changed, 963 insertions(+), 578 deletions(-) create mode 120000 .rules create mode 100644 vanth/Cargo.toml create mode 100644 vanth/src/lib.rs rename {src => vanth/src}/main.rs (100%) rename {src => vanth/src}/parser.rs (100%) rename {src => vanth/src}/util.rs (100%) rename {src => vanth/src}/vanth.rs (100%) create mode 100644 vanth/tests/test_node.rs diff --git a/.rules b/.rules new file mode 120000 index 0000000..daec0be --- /dev/null +++ b/.rules @@ -0,0 +1 @@ +/home/asraelite/base/ai_rules/zed.md \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 31b4ad2..83a9dc4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,12 +1,291 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] -name = "allocator-api2" -version = "0.2.18" +name = "arrayvec" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "assert_type_match" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f548ad2c4031f2902e3edc1f29c29e835829437de49562d8eb5dc5584d3a1043" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-executor" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb812ffb58524bdd10860d7d974e2f01cc0950c2438a74ee5ec2e2280c6c4ffa" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "pin-project-lite", + "slab", +] + +[[package]] +name = "async-task" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "bevy_app" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4491cc4c718ae76b4c6883df58b94cc88b32dcd894ea8d5b603c7c7da72ca967" +dependencies = [ + "bevy_derive", + "bevy_ecs", + "bevy_platform", + "bevy_reflect", + "bevy_tasks", + "bevy_utils", + "cfg-if", + "ctrlc", + "downcast-rs", + "log", + "thiserror", + "variadics_please", +] + +[[package]] +name = "bevy_derive" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b837bf6c51806b10ebfa9edf1844ad80a3a0760d6c5fac4e90761df91a8901a" +dependencies = [ + "bevy_macro_utils", + "quote", + "syn", +] + +[[package]] +name = "bevy_ecs" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c2bf6521aae57a0ec3487c4bfb59e36c4a378e834b626a4bea6a885af2fdfe7" +dependencies = [ + "arrayvec", + "bevy_ecs_macros", + "bevy_platform", + "bevy_ptr", + "bevy_reflect", + "bevy_tasks", + "bevy_utils", + "bitflags", + "bumpalo", + "concurrent-queue", + "derive_more", + "disqualified", + "fixedbitset", + "indexmap", + "log", + "nonmax", + "serde", + "smallvec", + "thiserror", + "variadics_please", +] + +[[package]] +name = "bevy_ecs_macros" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38748d6f3339175c582d751f410fb60a93baf2286c3deb7efebb0878dce7f413" +dependencies = [ + "bevy_macro_utils", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "bevy_macro_utils" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052eeebcb8e7e072beea5031b227d9a290f8a7fbbb947573ab6ec81df0fb94be" +dependencies = [ + "parking_lot", + "proc-macro2", + "quote", + "syn", + "toml_edit", +] + +[[package]] +name = "bevy_platform" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7573dc824a1b08b4c93fdbe421c53e1e8188e9ca1dd74a414455fe571facb47" +dependencies = [ + "cfg-if", + "critical-section", + "foldhash", + "hashbrown", + "portable-atomic", + "portable-atomic-util", + "serde", + "spin", +] + +[[package]] +name = "bevy_ptr" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df7370d0e46b60e071917711d0860721f5347bc958bf325975ae6913a5dfcf01" + +[[package]] +name = "bevy_reflect" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daeb91a63a1a4df00aa58da8cc4ddbd4b9f16ab8bb647c5553eb156ce36fa8c2" +dependencies = [ + "assert_type_match", + "bevy_platform", + "bevy_ptr", + "bevy_reflect_derive", + "bevy_utils", + "derive_more", + "disqualified", + "downcast-rs", + "erased-serde", + "foldhash", + "glam", + "serde", + "smallvec", + "smol_str", + "thiserror", + "uuid", + "variadics_please", + "wgpu-types", +] + +[[package]] +name = "bevy_reflect_derive" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ddadc55fe16b45faaa54ab2f9cb00548013c74812e8b018aa172387103cce6" +dependencies = [ + "bevy_macro_utils", + "proc-macro2", + "quote", + "syn", + "uuid", +] + +[[package]] +name = "bevy_tasks" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b674242641cab680688fc3b850243b351c1af49d4f3417a576debd6cca8dcf5" +dependencies = [ + "async-executor", + "async-task", + "atomic-waker", + "bevy_platform", + "cfg-if", + "crossbeam-queue", + "derive_more", + "futures-lite", + "heapless", +] + +[[package]] +name = "bevy_utils" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94f7a8905a125d2017e8561beefb7f2f5e67e93ff6324f072ad87c5fd6ec3b99" +dependencies = [ + "bevy_platform", + "thread_local", +] + +[[package]] +name = "bitflags" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" +dependencies = [ + "serde", +] + +[[package]] +name = "bumpalo" +version = "3.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cfg-if" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", + "portable-atomic", +] + +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + +[[package]] +name = "crossbeam-queue" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" +dependencies = [ + "crossbeam-utils", +] [[package]] name = "crossbeam-utils" @@ -14,42 +293,665 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +[[package]] +name = "ctrlc" +version = "3.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46f93780a459b7d656ef7f071fe699c4d3d2cb201c4b24d085b6ddc505276e73" +dependencies = [ + "nix", + "windows-sys", +] + +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "disqualified" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9c272297e804878a2a4b707cfcfc6d2328b5bb936944613b4fdf2b9269afdfd" + +[[package]] +name = "downcast-rs" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea8a8b81cacc08888170eef4d13b775126db426d0b348bee9d18c2c1eaf123cf" + [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "erased-serde" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e004d887f51fcb9fef17317a2f3525c887d8aa3f4f50fed920816a688284a5b7" +dependencies = [ + "serde", + "typeid", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + [[package]] name = "foldhash" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-lite" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[package]] +name = "getrandom" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi", +] + +[[package]] +name = "glam" +version = "0.29.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8babf46d4c1c9d92deac9f7be466f76dfc4482b6452fc5024b5e8daf6ffeb3ee" +dependencies = [ + "serde", +] + +[[package]] +name = "hash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" +dependencies = [ + "byteorder", +] + [[package]] name = "hashbrown" version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" dependencies = [ - "allocator-api2", "equivalent", - "foldhash", + "serde", +] + +[[package]] +name = "heapless" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" +dependencies = [ + "hash32", + "portable-atomic", + "stable_deref_trait", +] + +[[package]] +name = "indexmap" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "js-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.174" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" + +[[package]] +name = "lock_api" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "memchr" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" + +[[package]] +name = "nix" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" +dependencies = [ + "bitflags", + "cfg-if", + "cfg_aliases", + "libc", +] + +[[package]] +name = "nonmax" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "610a5acd306ec67f907abe5567859a3c693fb9886eb1f012ab8f2a47bef3db51" + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "proc-macro2" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "redox_syscall" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6" +dependencies = [ + "bitflags", +] + +[[package]] +name = "rustversion" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "slab" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "smol_str" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead" +dependencies = [ + "serde", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "syn" +version = "2.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" + +[[package]] +name = "toml_edit" +version = "0.22.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "uuid" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d" +dependencies = [ + "getrandom", + "js-sys", + "serde", + "wasm-bindgen", ] [[package]] name = "vanth" version = "0.1.0" dependencies = [ - "whirlwind", + "bevy_app", + "bevy_ecs", ] [[package]] -name = "whirlwind" -version = "0.1.1" +name = "variadics_please" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bdd6495360c0280cb4910c4dc98472cf2a8e3a9fe0f1b55290956fa312dc07" +checksum = "41b6d82be61465f97d42bd1d15bf20f3b0a3a0905018f38f9d6f6962055b0b5c" dependencies = [ - "crossbeam-utils", - "hashbrown", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wgpu-types" +version = "24.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50ac044c0e76c03a0378e7786ac505d010a873665e2d51383dcff8dd227dc69c" +dependencies = [ + "bitflags", + "js-sys", + "log", + "serde", + "web-sys", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3edebf492c8125044983378ecb5766203ad3b4c2f7a922bd7dd207f6d443e95" +dependencies = [ + "memchr", +] + +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags", ] diff --git a/Cargo.toml b/Cargo.toml index 167d8f9..1f4b212 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,6 @@ -[package] -name = "vanth" -version = "0.1.0" -edition = "2021" +[workspace] +members = ["vanth"] -[dependencies] -whirlwind = "0.1.1" +[workspace.dependencies] +bevy_app = "0.16.1" +bevy_ecs = "0.16.1" diff --git a/LICENSE b/LICENSE index d9dcb8a..a559ae5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Markus Scully +Copyright (c) 2024-2025 Markus Scully Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index af79381..8bfbe49 100644 --- a/README.md +++ b/README.md @@ -1,561 +1,3 @@ # Vanth -Currently this a not-very-organized collection of ideas I have for a new programming language. My goal is to make a data-oriented language for configuration, build scripts, and reproducible development environments. - -Inspired by ideas from Rust, Typescript, Zig, D, Unison, Nickel, and Nix. - - -## Example - -```va -use vanth::v1; - -interface MyInterface { - foo: String; - optional_foo = "default"; -} - -Module { - Module.description = "An example expression"; -} -``` - - -## Expressions - -Everything in Vanth is an expression. - -`use` and `interface` declarations have the same effect whether they are inside an object expression or preceding it. - - -## Types - -Types are values, like in Zig. All values are fully immutable. - - -### Primitive types - -* `String` -* `Char` -* `Byte` -* `Path` -* `Bool` -* `Int` -* `Nat` -* `Float` -* `Type` - -Objects are `Object` and are not primitives. - -`Int` is always 32-bit 2's complement encoding. `Nat` is unsigned. `Float` is always IEEE 754 32-bit single precision. `Nat` is a subtype of `Int`, i.e. anywhere that accepts `Int` can also take a `Nat`. It is always an error when either of these types reaches a magnitude above or equal to 231. Note that this means that `Nat` effectively only has 31 bits, not 32. - -`String` is any valid UTF-8 string. - -`Char` is a 32-bit Unicode codepoint. - -`Byte` is an octet. - -Arrays are `[T]` or `[T; len]` like Rust. There are also Typescript-like tuples, `[Int, Int, String]` etc. - -Use `&` for type intersections, e.g. `Module & Module.Shell`. Use `|` for type unions, e.g. `Os.Windows | Os.Linux`. - - -### Literals - -Rich numeric notation is supported: `42`, `0x2a`, `0b101010`, `1_000_000`, `4.2`, `1.0e42`. - -`String`s use double quotes: `"hello, world"`. - -`Char`s use single quotes: `'a'`. - -`Byte`s can be defined either with `b` prefixed to a character literal, e.g. `b'a'` is 0x61, or by using a `Nat` literal, which will be implictly casted if possible. - -### Casting - -There is a `Cast` interface which is implemented by primitive types. - -Something like the following, but not quite. I haven't decided on the exact design yet. - -```va -let x_int: Int = 12; -let x_float: Float = x_int.Cast.Float; -``` - - -## Syntax - -Whitespace is not significant. - -Formatting options for autoformatters can be configured using the `@format` annotation. This applies to the formatting of the entire annotated expression. - -```va -@format({ indentation = format.Indentation.Spaces { 4 } }) -Module { - /* ... */ -} -``` - -Not all formatting options are inheritable. For example, modifying the indentation style of a single element of an array will have no effect on the indentation of the line overall. - -```va -@format({ indentation = format.Indentation.Tabs }) -{ - // The line is still indented with a tab. - .foo = [1, @format({ indentation = format.Indentation.Spaces { 8 } }) 2, 3]; -} -``` - -Single-line comments are `//`. Multi-line comments are `/* */`. - - - - - -## Objects - -Objects are like structs, classes, dictionaries, or maps in other languages. They are collections of properties defined by key-value pairs. Both keys and values may be of any type. Properties can be set using either `.` syntax or `.[expression]` with an arbitrary expression inside. - -```va -let my_object: Object = { - .foo = 5; - .["bar"] = 42; - .[9 + 7] = "sixteen"; - .[{ .key = "hello" }] = "world"; -} -``` - -A key defined with `.` is identical to using `[]` with a string that is the same as the key, like in JavaScript. Properties can be indexed using either `.` or `[]`. - -```va -let a = my_object["foo"]; -let b = my_object.bar; -let c = my_object[16]; -let d = my_object[{ .key = "hello" }]; -``` - -The type of an object may be accessed from within the object itself using `Self`. - -```va -let - -``` - -An empty object, `{}`, acts as the unit type for Vanth. When a function returns no value and is only used for its side-effects, its return type is `{}`. This is equivalent to `()` in Rust. - - -### Overrides - -An object can be dereferenced with `.{ /* ... */ }` to create a new object with fields inherited from another object, with some of them possible changed. This is like an overlay in Nix. - -```va -let x = { .inner = { .a = 6; .b = 8; .sum = $.a + $.b }; }; -let y = x.inner.{ .b = 10; }.sum; // y is now `16` -``` - - -### Variables - -Variables are declared using the `let` keyword. - -```va -let x = 1; -``` - -Although values themselves are immutable, variables can be reassigned to new values. - -```va -let x = 1; -x = 2; -``` - -Variable shadowing is permitted, allowing the type of a variable to be changed. - -```va -// `x` is now an `Int`. -let x = 1; -// `x` is now a `String`. -let x = "foo"; -``` - -Note that it is often possible to reassign a variable to a different type, but without shadowing, this may force the type to be overly broad. - -```va -let x = 1; -x = "foo"; -// `x` now has the type `Int | String`, even though we know it can only be `String`. -``` - - -## Hashing - -Vanth hashes are 192-bit values represented as Base52, i.e. uppercase and lowercase ASCII letters only. They are always 34 characters long. They can optionally be truncated to any desired length for better readability but reduced security. If the `Vanth.hashTruncation` configuration property is set to `Vanth.HashTruncation.Deny`, then any truncated hashes will result in a build failure. - -Any type can be suffixed with `#` followed by a hash of its expected value. - - -```va - use vanth.pkgs#TYFTYfrtfghdRYerOhjvbfghcjklNXRTdFYUVBNHJvhjk; - - let x: [Int]#asqihoasq = [1, 2, 3]; -``` - -If the actual hash of the expression `[1, 2, 3]` does not match the provided expected hash, then an error will occur. - -The type itself can be left to be inferred using _. - -``` -let x: _#asqihoasq = [1, 2, 3]; -``` - -Equality of values is entirely determined by their hash. If two values have the same hash, then they can be substituted for one another in any context to produce the same result, assuming no impure functions are used. - -Note that fixed-length arrays have the same hash as dynamic-length arrays which happen to have the same length. - -```va -let x: [Int] = [1, 2, 3]; -let y: [Int; 3] = [1, 2, 3]; -assert_eq(x, y); -``` - -The hash of the value returned by a function call is determined by the hash of the function itself and the hashes of the arguments passed to it. E.g. the hash of `foo(x, y)` is essentially the hashes of `foo`, `x`, and `y` combined together. - -### Function hashes - -The hash of a function is determined by its contents at the abstract syntax tree (AST) level. Formatting and whitespace do not affect the hash. Local variable names also do not affect the hash, but their position and usage in the function do. - - -### Locking - -To calculate the hash of a particular value and add it to the source code of a Vanth file, run the command `vanth lock `. - -``` -> cat test.va -.x: Int = some_calculation(15); -> vanth lock test.x -> cat test.va -.x: Int#oauyiqQIuASsaqwuiSAQDuiadwuidasiwdqiow = some_calculation(15); -``` - -If the expression for `x` was changed, e.g. to `some_calculation(16)`, then the file would fail to build because of a mismatched hash. This can be fixed by re-locking the expression with the same command. - -To lock multiple expressions at once, expression path filters can be used, e.g. `vanth lock test._` will lock all top-level values in the file `test.va`. - - -## Memoization - -Vanth uses an SQLite file to cache the results of evaluating expressions. Whenever it needs to evaluate the result of a function call, it calculates its hash and then checks to see if it has been calculated already. If so, the previously calculated value is reused. - -No memoization is performed for impure functions. - - -## Imports - -External dependencies can be imported somehow. - - -## Interfaces - -```va -interface Foo { - x: String, - // Lazy evaluation means recursive fields are okay. - y: Foo, -} - -open interface OpenFoo {} - -``` - -Open interfaces allow for any property to be defined for them. This is useful for e.g. `shell.Env`. A module can define its environment variables like so: - -```va -Module { - Module.shell.Env.SHELL = "zsh"; -} -``` - -Or - -```va -Module { - Module.shell.Env += { .SHELL = "zsh"; } -} -``` - -You can restrict the type of additional properties that can be defined. I'm not sure about the syntax of this yet. - -```va -open interface Env {} -``` - - -## Enums - -Enums are named collections of types called variants. Any value can be an enum variant. Unlike Rust, enum variants are types themselves. - -```va -enum Foo { - Bar, - Baz, - interface BarBaz { - x: String, - y: Int, - } - "hello" - 5 - [10 + 4] -} - -open enum OpenFoo { - Bar, -} -``` - -In `Foo`, there are 6 variants. For 5 of the variants, only a single value will satisfy the type of the variant. E.g. the value `14` is the only value which is valid for the type `Foo.[14]`. The value `Baz` is the only value valid for the type `Foo.Baz`. For the `Foo.BarBaz` variant, there exist multiple values that satisfy its type, like `Foo.BarBaz { .x = "hi"; .y = 2 }`. - -An enum is like a named version of a type intersection. - -## Blocks - -The contents within the curly braces `{}` of an expression are called a "block". Variables defined within a block are scoped locally to it. - -```va -let x = 1; -let y = { - let x = 2; -}; -trace(x); -``` - -Here, `1` will be printed because the `x` inside the `y` block is a different variable. - -Objects can also be used as collections of operations used to calculate a single, final value. The `return` keyword at the end of a block causes the entire expression to evaluate to its current state merged with the value provided to `return`. - -```va -let x = { - .foo = "hello"; - return { .bar = "world" }; -} -``` - -Here, `x` evaluates to `{ .foo = "hello"; .bar = "world" }`. - -In general, the value passed to `return` can be of any type, but if other properties are defined in the block, like `.foo` in the example above, then the `return` value must be an `Object`. If used, `return` must be the final expression within a block. - -If only local variables are used, no properties, then this syntax can be used to create expressions that resembles the bodies of functions in other programming languages. - -```va -let x = { - let sum = 0; - for i in 0..10 { - sum += i; - } - return sum; -} -``` - -Here, `x` evaluates to `45`. - - -### Self-references - -The keyword `$` can be used like `this` or `self` in other languages. I'm not sure if I'll use `$` or `self` as the syntax yet. - -```va -let obj = { - .a = 5; - .b = $.a + 3; // .b is now 8. -}; -``` - -`$` evaluates to the object block that is currently in scope. This works because of lazy evaluation. If a self-referential loop is detected, it results in a build error. - - -## Functions - -Functions may be defined locally using the `fn` keyword, or the same way as properties, but with parentheses `()` suffixed onto their name. They may contain any number of parameters of any type. - -```va -// Locally defined function -fn add(a: Int, b: Int) = a + b; - -// Function that is a property of the object -.add(a: Int, b: Int) = a + b; - -// Using an expression with `return` -fn fib(n: Int) = { - let a = 0; - let b = 1; - for _ in 0..n { - let new_value = a + b; - a = b; - b = new_value; - } - return b; -} -``` - -The return type of a function can be inferred, or it can be explicitly declared with `:`. - -```va -let add(a: Int, b: Int): Int = a + b; -``` - -If the first parameter of a function is the keyword `self`, then it can be used as a method of its object. - -```va -let x = { - .data: [u8] = /* ... */; - .to_json(self): String = { /* ... */ } -} -let json = x.to_json(); -``` - -Functions are values themselves and can be used as such. The type of a function is annotated with parentheses, the same as the definition of a function itself but without the function and paramter identifiers. - -```va -let add_one(x: Int): Int = x + 1; -let mapping_function: (Int): Int = add_one; -``` - - -### Purity - -All functions in Vanth are pure by default. This means that for a given set of input arguments, the returned value of a function called with those arguments is guaranteed to always be the same. - -A function can be explicitly marked as impure with the annotation `@impure`. Functions which are impure can only be called by functions which are also impure themselves. - -```va -use vanth.xml.[parse_xml, Xml]; - -// Okay -@impure -let get_xml(path: Path): Xml = read_file(path).parse_xml(); - -// Error, cannot call impure function `read_file` from pure function. -let get_xml_without_annotation(path: Path): Xml = read_file(path).parse_xml -``` - -Values which use the results from impure functions are themselves impure, unless locked to a hash, in which case they become pure again. - -```va -// Must be annotated as `@impure`. -@impure -let x = get_xml(my_path); - -// Pure, does not need `@impure`. -let y: _#IAyuiAuiaiAyusbhafaJVy = get_xml(my_path); -``` - -If the value returned by an impure function, in this case `get_xml`, does not match the provided hash then it will result in an error. - - -### Anonymous functions - -Omit the name to make a function anonymous. - -```va -let squared = range(0, 20).map(fn(n: Int) = n * n); -``` - - -### Implicit parameters - -Use `$` followed by a number to define expressions that behave as anonymous functions. This is like the `it` keyword in Kotlin. - -```va -let squared = range(0, 20).map($1 * $1); -``` - -This value can be used like any other, including accessing its fields. - -```va -let person_a = { .name: "Bob"; .age = 2 }; -let person_b = { .name: "Maria"; .age = 87 }; -let ages = [person_a, person_b].map($1.age); -``` - -`$0` within an anonymous function refers to the function itself. This can be used for recursive calls of anonymous functions. - -```va -let prime_fibs = [2, 3, 5, 7, 11].map(match $1 { 0 | 1 => $1; _ => $0($1 - 1) + $0($1 - 2) }); -``` - - -## Pattern matching - -Pattern matching can be used to destructure objects. - -```va -let x = [1, 2, 3]; -let y = match x { - [1, _, _] => "starts with 1"; - [_, _, 3] => "ends with 3"; - _ => "other"; -}; -``` - -Matching is exhaustive, like in Rust. - -Since types are values, it is also possible to match on types: - -```va -fn type_as_string(ty: Type) = match ty { - -} -``` - - -## Filters - -The `Filter` type is like a regex for Vanth expression paths. E.g. the filter `gcc._.include` will match `gcc.v13_3_0.include`. - -`[]` syntax can be used in filters for more fine-grained matching, e.g. `gcc.["v13_3_0" | "v13_2_0"].include`. - - -## Advanced types - -### Generics - -Types can take generic parameters with the syntax `<>`. - -```va -interface List { - .get(index: Nat): T; - .len: Nat; -} -``` - - -### Negative types - -A type can be negated by prefixing it with `!`. Values then only satisfy this type if they don't implement it. - -``` -let x: !Int = "hello"; // Okay -x = false; // Okay -x = 5; // Error -``` - - -## Annotations - -Any expression may be prefixed with an annotation of the form `@annotation_name(argument_value)`. If an annotation does not take an argument then the parentheses are unnecessary, `@annotation_name`. The type of argument value is specific to the annotation, but in general this may be any type. - -Annotations may be placed on the same line as an expression, separated by a space, or they may be on separate lines. - -```va - -``` - - -## Documentation - -The `@doc` annotation is used to provide documentation for values and types. - -Strings inside it, e.g. `@doc("this function fixes things")` can use interpolation, `@doc("example usage: {foo(5, 6)}")`. Specifically for strings in `@doc`, these expressions are not expanded but rather printed verbatim. The interpreter still checks that they evaluate successfully, otherwise the docs fail to compile. - - -## Licenses - -Modules have a `Module.license: String` property, as well as a `Module.allowLicenses` and `Module.denyLicenses` property. I don't know what the types of these properties will be yet. Modules will only build successfully if the license of every one of their dependencies recursively satisfies the specified license requirements. +Vanth is a work in progress. Maybe some kind of distributed ECS database? diff --git a/vanth/Cargo.toml b/vanth/Cargo.toml new file mode 100644 index 0000000..f28dcaf --- /dev/null +++ b/vanth/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "vanth" +version = "0.1.0" +edition = "2024" +publish = false + +[lib] +path = "src/lib.rs" + +[dependencies] +bevy_app.workspace = true +bevy_ecs.workspace = true diff --git a/vanth/src/lib.rs b/vanth/src/lib.rs new file mode 100644 index 0000000..b787ee0 --- /dev/null +++ b/vanth/src/lib.rs @@ -0,0 +1,22 @@ +/// Library crate for the `vanth` ECS-based database node. +use bevy_app::App; +use bevy_ecs::prelude::*; + +/// A server node wrapping a Bevy App without running it. +pub struct Node { + app: App, +} + +impl Node { + /// Creates a new server node with an empty Bevy App. + pub fn new() -> Self { + let app = App::new(); + Node { app } + } + + /// Returns the number of entities currently in the world. + pub fn entity_count(&self) -> usize { + // Query for no components returns one item per entity. + self.app.world().entities().len() + } +} diff --git a/src/main.rs b/vanth/src/main.rs similarity index 100% rename from src/main.rs rename to vanth/src/main.rs diff --git a/src/parser.rs b/vanth/src/parser.rs similarity index 100% rename from src/parser.rs rename to vanth/src/parser.rs diff --git a/src/util.rs b/vanth/src/util.rs similarity index 100% rename from src/util.rs rename to vanth/src/util.rs diff --git a/src/vanth.rs b/vanth/src/vanth.rs similarity index 100% rename from src/vanth.rs rename to vanth/src/vanth.rs diff --git a/vanth/tests/test_node.rs b/vanth/tests/test_node.rs new file mode 100644 index 0000000..e4249ab --- /dev/null +++ b/vanth/tests/test_node.rs @@ -0,0 +1,7 @@ +use vanth::Node; + +#[test] +fn test_entity_count_zero() { + let mut node = Node::new(); + assert_eq!(node.entity_count(), 0); +} From f55dbf78cc72e0a803c697978510809e53161b5c Mon Sep 17 00:00:00 2001 From: Markus Scully Date: Sun, 13 Jul 2025 00:21:46 +0300 Subject: [PATCH 2/2] Move to crates --- Cargo.toml | 2 +- {vanth => crates/vanth}/Cargo.toml | 0 {vanth => crates/vanth}/src/lib.rs | 0 {vanth => crates/vanth}/src/main.rs | 0 {vanth => crates/vanth}/src/parser.rs | 0 {vanth => crates/vanth}/src/util.rs | 0 {vanth => crates/vanth}/src/vanth.rs | 0 {vanth => crates/vanth}/tests/test_node.rs | 0 8 files changed, 1 insertion(+), 1 deletion(-) rename {vanth => crates/vanth}/Cargo.toml (100%) rename {vanth => crates/vanth}/src/lib.rs (100%) rename {vanth => crates/vanth}/src/main.rs (100%) rename {vanth => crates/vanth}/src/parser.rs (100%) rename {vanth => crates/vanth}/src/util.rs (100%) rename {vanth => crates/vanth}/src/vanth.rs (100%) rename {vanth => crates/vanth}/tests/test_node.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 1f4b212..8df760e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["vanth"] +members = ["crates/*"] [workspace.dependencies] bevy_app = "0.16.1" diff --git a/vanth/Cargo.toml b/crates/vanth/Cargo.toml similarity index 100% rename from vanth/Cargo.toml rename to crates/vanth/Cargo.toml diff --git a/vanth/src/lib.rs b/crates/vanth/src/lib.rs similarity index 100% rename from vanth/src/lib.rs rename to crates/vanth/src/lib.rs diff --git a/vanth/src/main.rs b/crates/vanth/src/main.rs similarity index 100% rename from vanth/src/main.rs rename to crates/vanth/src/main.rs diff --git a/vanth/src/parser.rs b/crates/vanth/src/parser.rs similarity index 100% rename from vanth/src/parser.rs rename to crates/vanth/src/parser.rs diff --git a/vanth/src/util.rs b/crates/vanth/src/util.rs similarity index 100% rename from vanth/src/util.rs rename to crates/vanth/src/util.rs diff --git a/vanth/src/vanth.rs b/crates/vanth/src/vanth.rs similarity index 100% rename from vanth/src/vanth.rs rename to crates/vanth/src/vanth.rs diff --git a/vanth/tests/test_node.rs b/crates/vanth/tests/test_node.rs similarity index 100% rename from vanth/tests/test_node.rs rename to crates/vanth/tests/test_node.rs