commit 2569596ca58859fccbebb58d3c3a422f308d94d8 Author: Mark Kalsbeek Date: Thu Mar 5 12:38:22 2026 +0100 First Commit, it compiles! diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..1d953f4 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d7b0c5d --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/target + +.direnv/ + +*.db diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..6a0e83e --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2325 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "axum" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" +dependencies = [ + "async-trait", + "axum-core", + "axum-macros", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d123550fa8d071b7255cb0cc04dc302baa6c8c4a79f55701552684d8399bce" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64ct" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" + +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" +dependencies = [ + "serde_core", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "cc" +version = "1.2.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "crc" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eb8a2a1cd12ab0d987a5d5e825195d372001a4094a0376319d5a0ad71c1ba0d" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + +[[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" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "dashmap" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +dependencies = [ + "serde", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.48.0", +] + +[[package]] +name = "event-listener" +version = "5.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "flume" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" +dependencies = [ + "futures-core", + "futures-sink", + "spin", +] + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-executor" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot", +] + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", + "wasip3", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" + +[[package]] +name = "hashlink" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" +dependencies = [ + "hashbrown 0.15.5", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "home" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", +] + +[[package]] +name = "hyper-util" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" +dependencies = [ + "bytes", + "http", + "http-body", + "hyper", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" +dependencies = [ + "equivalent", + "hashbrown 0.16.1", + "serde", + "serde_core", +] + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "js-sys" +version = "0.3.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +dependencies = [ + "spin", +] + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "libc" +version = "0.2.182" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "libredox" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1744e39d1d6a9948f4f388969627434e31128196de472883b39f148769bfe30a" +dependencies = [ + "bitflags", + "libc", + "plain", + "redox_syscall 0.7.3", +] + +[[package]] +name = "libsqlite3-sys" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] +name = "livevue-rs" +version = "0.1.0" +dependencies = [ + "anyhow", + "axum", + "dashmap", + "maud", + "serde", + "serde_json", + "sqlx", + "tokio", + "tokio-stream", + "uuid", +] + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + +[[package]] +name = "maud" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df518b75016b4289cdddffa1b01f2122f4a49802c93191f3133f6dc2472ebcaa" +dependencies = [ + "axum-core", + "http", + "itoa", + "maud_macros", +] + +[[package]] +name = "maud_macros" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa453238ec218da0af6b11fc5978d3b5c3a45ed97b722391a2a11f3306274e18" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mio" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "num-bigint-dig" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e661dda6640fad38e827a6d4a310ff4763082116fe217f279885c97f511bb0b7" +dependencies = [ + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand", + "smallvec", + "zeroize", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.18", + "smallvec", + "windows-link", +] + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_syscall" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce70a74e890531977d37e532c34d45e9055d2409ed08ddba14529471ed0be16" +dependencies = [ + "bitflags", +] + +[[package]] +name = "rsa" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core", + "signature", + "spki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" +dependencies = [ + "itoa", + "serde", + "serde_core", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +dependencies = [ + "serde", +] + +[[package]] +name = "socket2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "sqlx" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fefb893899429669dcdd979aff487bd78f4064e5e7907e4269081e0ef7d97dc" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6798b1838b6a0f69c007c133b8df5866302197e404e8b6ee8ed3e3a5e68dc6" +dependencies = [ + "base64", + "bytes", + "crc", + "crossbeam-queue", + "either", + "event-listener", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashbrown 0.15.5", + "hashlink", + "indexmap", + "log", + "memchr", + "once_cell", + "percent-encoding", + "serde", + "serde_json", + "sha2", + "smallvec", + "thiserror", + "tokio", + "tokio-stream", + "tracing", + "url", +] + +[[package]] +name = "sqlx-macros" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2d452988ccaacfbf5e0bdbc348fb91d7c8af5bee192173ac3636b5fb6e6715d" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19a9c1841124ac5a61741f96e1d9e2ec77424bf323962dd894bdb93f37d5219b" +dependencies = [ + "dotenvy", + "either", + "heck", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", + "sqlx-core", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", + "syn", + "tokio", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa003f0038df784eb8fecbbac13affe3da23b45194bd57dba231c8f48199c526" +dependencies = [ + "atoi", + "base64", + "bitflags", + "byteorder", + "bytes", + "crc", + "digest", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "percent-encoding", + "rand", + "rsa", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-postgres" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db58fcd5a53cf07c184b154801ff91347e4c30d17a3562a635ff028ad5deda46" +dependencies = [ + "atoi", + "base64", + "bitflags", + "byteorder", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "rand", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2d12fe70b2c1b4401038055f90f151b78208de1f9f89a7dbfd41587a10c3eea" +dependencies = [ + "atoi", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "serde_urlencoded", + "sqlx-core", + "thiserror", + "tracing", + "url", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "stringprep" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" +dependencies = [ + "unicode-bidi", + "unicode-normalization", + "unicode-properties", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-stream" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32da49809aab5c3bc678af03902d4ccddea2a87d028d86392a4b1560c6906c70" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "typenum" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" + +[[package]] +name = "unicode-bidi" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-normalization" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-properties" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b672338555252d43fd2240c714dc444b8c6fb0a5c5335e65a07bba7742735ddb" +dependencies = [ + "getrandom 0.4.2", + "js-sys", + "serde_core", + "wasm-bindgen", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + +[[package]] +name = "whoami" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d4a4db5077702ca3015d3d02d74974948aba2ad9e12ab7df718ee64ccd7e97d" +dependencies = [ + "libredox", + "wasite", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a789c6e490b576db9f7e6b6d661bcc9799f7c0ac8352f56ea20193b2681532e5" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f65c489a7071a749c849713807783f70672b28094011623e200cb86dcb835953" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..e109ffc --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "livevue-rs" +version = "0.1.0" +edition = "2021" + +[dependencies] +axum = { version = "0.7", features = ["macros"] } +tokio = { version = "1", features = ["full"] } +serde = { version = "1", features = ["derive"] } +serde_json = "1" +sqlx = { version = "0.8", features = ["runtime-tokio", "sqlite"] } +maud = { version = "0.26", features = ["axum"] } +uuid = { version = "1", features = ["v4", "serde"] } +dashmap = "6" +anyhow = "1" +tokio-stream = "0.1" diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..2cebdcf --- /dev/null +++ b/shell.nix @@ -0,0 +1,28 @@ +{ pkgs ? import {} }: + +pkgs.mkShell { + buildInputs = with pkgs; [ + # Rust toolchain + cargo + rustc + rustfmt + clippy + rust-analyzer + + # Build dependencies + pkg-config + + # Additional tools + cargo-watch + cargo-edit + + # Profiling tools + cargo-flamegraph + samply + linuxPackages.perf + + ]; + + # Environment variables + RUST_BACKTRACE = 1; +} diff --git a/src/app/about.rs b/src/app/about.rs new file mode 100644 index 0000000..c696b5b --- /dev/null +++ b/src/app/about.rs @@ -0,0 +1,47 @@ +use crate::framework::context::RenderContext; +use maud::{html, Markup}; + +/// Second page component: a simple "About" page. +/// +/// This exists specifically to exercise: +/// - The `tree` signal page routing (resolve_root match arm) +/// - SPA-like navigation via tree signal mutation +/// - Round-trip: TodoList → About → TodoList without full page reload +/// +/// In a real app this might show user info, settings, etc. +pub async fn about(_cx: &mut RenderContext) -> anyhow::Result { + Ok(html! { + div.about-page { + h1 { "About LiveVue.rs" } + + nav { + button.nav-link + data-on-click="$tree = {page: 'TodoList'}; @post('/render')" { + "Todos" + } + " | " + span.nav-current { "About" } + } + + div.about-content { + p { + "LiveVue.rs is a reactive server-side rendering framework for Rust. " + "The server renders full-page HTML on every state change. " + "DataStar morphs it into the DOM." + } + p { + "The architectural bet: " + strong { "full rerender is cheap" } + ", so skip diffing, skip partial updates, skip client-side state management." + } + h2 { "v0 Status" } + ul { + li { "Single process, single node" } + li { "SQLite for storage" } + li { "Subscription keys collected (Phase 2 seam)" } + li { "No cache, no auth, no WAL consumer" } + } + } + } + }) +} diff --git a/src/app/mod.rs b/src/app/mod.rs new file mode 100644 index 0000000..20d8894 --- /dev/null +++ b/src/app/mod.rs @@ -0,0 +1,470 @@ +pub mod about; +pub mod queries; +pub mod todo_list; + +use crate::framework::connection::{ConnectionManager, SubscriptionRegistry}; +use crate::framework::context::{ComponentTree, RenderContext}; +use crate::framework::signal::SignalStore; +use crate::framework::sse::{format_patch_elements, format_patch_signals}; + +use axum::extract::{Query as AxumQuery, State}; +use axum::http::header; +use axum::response::sse::{Event, KeepAlive, Sse}; +use axum::response::{Html, IntoResponse}; +use axum::routing::{get, post}; +use axum::{Json, Router}; +use std::convert::Infallible; +use std::sync::Arc; +use tokio::sync::mpsc; +use tokio_stream::wrappers::ReceiverStream; +use uuid::Uuid; + +// --------------------------------------------------------------------------- +// Shared application state +// --------------------------------------------------------------------------- + +/// All shared state, wrapped in Arc for axum's State extractor. +pub struct AppState { + pub db: sqlx::SqlitePool, + pub connections: ConnectionManager, + pub subscriptions: SubscriptionRegistry, +} + +pub type SharedState = Arc; + +// --------------------------------------------------------------------------- +// Router +// --------------------------------------------------------------------------- + +/// Build the axum Router with all routes. +/// +/// Lesson from v0.0: handlers live here next to the components they call, +/// not in a separate routes.rs with complex trait object signatures. +pub fn router(state: SharedState) -> Router { + Router::new() + .route("/", get(initial_page_load)) + .route("/about", get(initial_about_load)) + .route("/sse", get(sse_handler)) + .route("/render", post(render_handler)) + .route("/action/add_todo", post(action_add_todo)) + .route("/action/toggle_todo", post(action_toggle_todo)) + .route("/action/delete_todo", post(action_delete_todo)) + .with_state(state) +} + +// --------------------------------------------------------------------------- +// Document shell +// --------------------------------------------------------------------------- + +/// Wrap rendered component HTML in a full HTML document. +/// +/// Lesson from v0.0: Maud can't handle DataStar's attribute syntax +/// (e.g. `data-on-signal-change__debounce.300ms`). The document shell uses +/// format! / raw string. Maud is for component interiors only. +/// +/// DataStar v1 contract (verified against https://data-star.dev/reference): +/// - `data-signals` — initialize signals (JS object literal syntax) +/// - `data-on-signal-change` — fires when any signal changes +/// - `__debounce.300ms` — modifier: debounce 300ms +/// - `@post('/render')` — send all non-_ signals as JSON body +/// - `@get('/sse?conn=...')` — open long-lived SSE pipe +/// - `data-on-load` — fires when element enters DOM +/// +/// KNOWN v0 QUIRK: Nav buttons use `$tree = {...}; @post('/render')`, +/// which fires an immediate POST. The signal change handler then fires a +/// second debounced POST 300ms later. This double-fire is harmless (same +/// HTML both times) but wasteful. Phase 2 could fix this with request +/// deduplication or by switching nav to only mutate the signal and relying +/// solely on the auto-poster. +fn document_shell(conn_id: Uuid, initial_signals: &str, inner_html: &str) -> String { + format!( + r#" + + + + + LiveVue.rs Demo + + + + +
+ {inner} +
+ +"#, + css = INLINE_CSS, + signals = initial_signals, + conn = conn_id, + inner = inner_html, + ) +} + +/// Minimal CSS for the demo app. In a real app this would be a separate file. +const INLINE_CSS: &str = r#" + body { font-family: system-ui, sans-serif; max-width: 600px; margin: 2rem auto; padding: 0 1rem; background: #fafafa; color: #333; } + h1 { color: #2563eb; } + nav { margin-bottom: 1.5rem; } + .nav-link { background: none; border: none; color: #2563eb; cursor: pointer; text-decoration: underline; font-size: inherit; padding: 0; } + .nav-current { font-weight: bold; } + .add-form { display: flex; gap: 0.5rem; margin-bottom: 1rem; } + .add-form input { flex: 1; padding: 0.5rem; border: 1px solid #ccc; border-radius: 4px; } + .add-form button { padding: 0.5rem 1rem; background: #2563eb; color: white; border: none; border-radius: 4px; cursor: pointer; } + .add-form button:disabled { opacity: 0.5; cursor: not-allowed; } + .stats { color: #666; font-size: 0.9rem; } + .todo-list { list-style: none; padding: 0; } + .todo-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid #eee; } + .todo-title { flex: 1; } + .todo-title.completed { text-decoration: line-through; color: #999; } + .delete-btn { background: none; border: none; color: #ef4444; cursor: pointer; font-size: 1.2rem; padding: 0 0.25rem; } + .empty { color: #999; font-style: italic; } + .about-content p { line-height: 1.6; } +"#; + +// --------------------------------------------------------------------------- +// Page resolution +// --------------------------------------------------------------------------- + +/// Match a page name (from the `tree` signal) to its component function. +/// +/// This is a plain match statement — no ComponentRegistry, no trait objects, +/// no async lifetime gymnastics. The right call for a v0 with two pages. +async fn resolve_and_render(cx: &mut RenderContext) -> anyhow::Result { + let markup = match cx.tree.page.as_str() { + "TodoList" => todo_list::todo_list(cx).await?, + "About" => about::about(cx).await?, + other => maud::html! { + div { + h1 { "404 — Unknown page" } + p { "No component registered for: " (other) } + button.nav-link + data-on-click="$tree = {page: 'TodoList'}; @post('/render')" { + "Go to Todos" + } + } + }, + }; + Ok(markup.into_string()) +} + +/// Shared render pipeline used by both initial page load and POST /render. +/// +/// Returns `(rendered_html, subscription_keys, signals_json)`. +async fn render_page( + db: &sqlx::SqlitePool, + conn_id: Uuid, + signals: SignalStore, + tree: ComponentTree, +) -> anyhow::Result<(String, Vec, String)> { + let signals_json = signals.to_json_string(); + let mut cx = RenderContext::new(conn_id, signals, tree, db.clone()); + let html = resolve_and_render(&mut cx).await?; + let keys = cx.take_subscription_keys(); + Ok((html, keys, signals_json)) +} + +// --------------------------------------------------------------------------- +// Handlers +// --------------------------------------------------------------------------- + +/// `GET /` — Initial page load for the todo list. +async fn initial_page_load(State(state): State) -> impl IntoResponse { + let conn_id = Uuid::new_v4(); + + // Build initial signals + let tree = ComponentTree { + page: "TodoList".into(), + ..Default::default() + }; + let signals = SignalStore::from_pairs(vec![ + ("connId".into(), serde_json::json!(conn_id.to_string())), + ("tree".into(), serde_json::to_value(&tree).unwrap()), + ("newTodo".into(), serde_json::json!("")), + ]); + + let initial_signals_attr = signals.to_data_signals_attr(); + + match render_page(&state.db, conn_id, signals, tree).await { + Ok((html, _keys, _signals_json)) => { + // Keys and signals_json are stored when SSE connects + Html(document_shell(conn_id, &initial_signals_attr, &html)) + } + Err(e) => Html(document_shell( + conn_id, + &initial_signals_attr, + &format!("

Render error: {}

", e), + )), + } +} + +/// `GET /about` — Initial page load for the about page. +async fn initial_about_load(State(state): State) -> impl IntoResponse { + let conn_id = Uuid::new_v4(); + + let tree = ComponentTree { + page: "About".into(), + ..Default::default() + }; + let signals = SignalStore::from_pairs(vec![ + ("connId".into(), serde_json::json!(conn_id.to_string())), + ("tree".into(), serde_json::to_value(&tree).unwrap()), + ]); + + let initial_signals_attr = signals.to_data_signals_attr(); + + match render_page(&state.db, conn_id, signals, tree).await { + Ok((html, _keys, _signals_json)) => { + Html(document_shell(conn_id, &initial_signals_attr, &html)) + } + Err(e) => Html(document_shell( + conn_id, + &initial_signals_attr, + &format!("

Render error: {}

", e), + )), + } +} + +/// Query params for the SSE endpoint. +#[derive(serde::Deserialize)] +struct SseParams { + conn: Uuid, +} + +/// `GET /sse?conn=` — Long-lived SSE pipe for server-initiated push. +/// +/// In v0, nothing actively pushes events through this pipe (no invalidation +/// events yet). It exists to: +/// 1. Register the connection in ConnectionManager. +/// 2. Keep the SSE connection alive (DataStar expects it). +/// 3. Provide the Phase 2 seam for server-initiated rerenders. +/// +/// On drop, the connection is cleaned up from both the ConnectionManager +/// and the SubscriptionRegistry. +async fn sse_handler( + State(state): State, + AxumQuery(params): AxumQuery, +) -> Sse>> { + let conn_id = params.conn; + + // Create a channel for sending events to this connection + let (tx, rx) = mpsc::channel::(32); + + // Clone sender for the cleanup watcher. Sender::closed() resolves when + // the receiver is dropped (i.e. client disconnects and the SSE stream + // drops). This is the proper cleanup mechanism — no arbitrary sleep. + let tx_watch = tx.clone(); + + // Register the connection + state.connections.insert(conn_id, tx); + + // Spawn cleanup task: waits for the receiver to drop (client disconnect), + // then removes the connection from all registries. + let state_cleanup = state.clone(); + tokio::spawn(async move { + tx_watch.closed().await; + state_cleanup.connections.remove(&conn_id); + state_cleanup.subscriptions.remove_connection(&conn_id); + }); + + // Convert the receiver into an SSE stream. + // DESIGN NOTE: For v0, the SSE pipe is mostly idle — POST /render + // returns SSE directly in its response, not through this pipe. This + // channel exists for Phase 2 server-initiated pushes (data invalidation). + // Messages sent via the channel should be plain content strings (not + // pre-formatted SSE); axum's Sse wrapper handles the SSE framing. + let stream = ReceiverStream::new(rx); + let event_stream = tokio_stream::StreamExt::map(stream, |msg| { + Ok(Event::default().data(msg)) + }); + + Sse::new(event_stream).keep_alive(KeepAlive::default()) +} + +/// `POST /render` — Signal-triggered rerender. +/// +/// DataStar sends all non-`_` signals as JSON body when any signal changes +/// (triggered by `data-on-signal-change` + `@post('/render')`). +/// +/// Returns `Content-Type: text/event-stream` with a single +/// `datastar-patch-elements` event containing the full page HTML. +async fn render_handler( + State(state): State, + Json(body): Json, +) -> impl IntoResponse { + let signals = SignalStore::from_json(body); + + // Extract connection id + let conn_id: Uuid = signals + .get("connId") + .and_then(|v| v.as_str()) + .and_then(|s| s.parse().ok()) + .unwrap_or_else(Uuid::new_v4); + + // Extract component tree + let tree: ComponentTree = signals + .get("tree") + .and_then(|v| serde_json::from_value(v.clone()).ok()) + .unwrap_or_default(); + + match render_page(&state.db, conn_id, signals, tree).await { + Ok((html, keys, signals_json)) => { + // Update connection state + state.connections.update_signals(&conn_id, signals_json); + state.subscriptions.update(conn_id, keys); + + let sse_body = format_patch_elements(&html); + ( + [(header::CONTENT_TYPE, "text/event-stream")], + sse_body, + ) + .into_response() + } + Err(e) => { + let error_html = format!(r#"

Render error: {}

"#, e); + let sse_body = format_patch_elements(&error_html); + ( + [(header::CONTENT_TYPE, "text/event-stream")], + sse_body, + ) + .into_response() + } + } +} + +/// Query params for action endpoints that need an entity id. +#[derive(serde::Deserialize)] +struct ActionIdParams { + id: i64, +} + +/// Helper: extract common fields from signal body, run a mutation, then rerender. +/// +/// Returns an SSE response with the rerendered page. +async fn action_then_render( + state: &AppState, + body: serde_json::Value, + mutation: impl std::future::Future> + Send, + patch_signals: Option<&str>, +) -> impl IntoResponse { + let signals = SignalStore::from_json(body); + + let conn_id: Uuid = signals + .get("connId") + .and_then(|v| v.as_str()) + .and_then(|s| s.parse().ok()) + .unwrap_or_else(Uuid::new_v4); + + let tree: ComponentTree = signals + .get("tree") + .and_then(|v| serde_json::from_value(v.clone()).ok()) + .unwrap_or_default(); + + // Run the mutation + if let Err(e) = mutation.await { + let error_html = format!(r#"

Action error: {}

"#, e); + return ( + [(header::CONTENT_TYPE, "text/event-stream")], + format_patch_elements(&error_html), + ) + .into_response(); + } + + // Rerender + match render_page(&state.db, conn_id, signals, tree).await { + Ok((html, keys, signals_json)) => { + state.connections.update_signals(&conn_id, signals_json); + state.subscriptions.update(conn_id, keys); + + let mut sse_body = String::new(); + // Optionally patch signals (e.g. clear the input) + if let Some(ps) = patch_signals { + sse_body.push_str(&format_patch_signals(ps)); + } + sse_body.push_str(&format_patch_elements(&html)); + + ( + [(header::CONTENT_TYPE, "text/event-stream")], + sse_body, + ) + .into_response() + } + Err(e) => { + let error_html = format!(r#"

Render error: {}

"#, e); + ( + [(header::CONTENT_TYPE, "text/event-stream")], + format_patch_elements(&error_html), + ) + .into_response() + } + } +} + +/// `POST /action/add_todo` — Create a new todo, then rerender. +/// +/// Reads the `newTodo` signal from the POST body, inserts it, and sends +/// back a `datastar-patch-signals` event to clear the input followed by +/// a `datastar-patch-elements` event with the rerendered page. +async fn action_add_todo( + State(state): State, + Json(body): Json, +) -> impl IntoResponse { + let title = body + .get("newTodo") + .and_then(|v| v.as_str()) + .unwrap_or("") + .trim() + .to_string(); + + let db = state.db.clone(); + action_then_render( + &state, + body, + async move { + if !title.is_empty() { + queries::create_todo(&db, &title).await?; + } + Ok(()) + }, + Some("{newTodo: ''}"), // Clear the input after adding + ) + .await +} + +/// `POST /action/toggle_todo?id=` — Toggle a todo's completed status. +async fn action_toggle_todo( + State(state): State, + AxumQuery(params): AxumQuery, + Json(body): Json, +) -> impl IntoResponse { + let db = state.db.clone(); + let id = params.id; + action_then_render( + &state, + body, + async move { queries::toggle_todo(&db, id).await }, + None, + ) + .await +} + +/// `POST /action/delete_todo?id=` — Delete a todo. +async fn action_delete_todo( + State(state): State, + AxumQuery(params): AxumQuery, + Json(body): Json, +) -> impl IntoResponse { + let db = state.db.clone(); + let id = params.id; + action_then_render( + &state, + body, + async move { queries::delete_todo(&db, id).await }, + None, + ) + .await +} diff --git a/src/app/queries.rs b/src/app/queries.rs new file mode 100644 index 0000000..7f8a963 --- /dev/null +++ b/src/app/queries.rs @@ -0,0 +1,75 @@ +use crate::framework::CacheKey; +use serde::{Deserialize, Serialize}; + +// --------------------------------------------------------------------------- +// Models +// --------------------------------------------------------------------------- + +/// A single todo item. Maps to the `todos` SQLite table. +#[derive(Debug, Clone, Serialize, Deserialize, sqlx::FromRow)] +pub struct Todo { + pub id: i64, + pub title: String, + pub completed: bool, +} + +// --------------------------------------------------------------------------- +// Read queries (go through cx.run / Query trait) +// --------------------------------------------------------------------------- + +/// Fetch all todos, ordered by id. +pub struct ListTodos; + +crate::query_all!(ListTodos { + sql: "SELECT id, title, completed FROM todos ORDER BY id", + params: [], + output: Todo, + cache: |_s: &ListTodos| CacheKey::Table { table: "todos" }, +}); + +/// Fetch a single todo by id. +pub struct GetTodo { + pub id: i64, +} + +crate::query_one!(GetTodo { + sql: "SELECT id, title, completed FROM todos WHERE id = ?", + params: [|s: &GetTodo| s.id], + output: Todo, + cache: |s: &GetTodo| CacheKey::PrimaryKey { table: "todos", id: s.id }, +}); + +// --------------------------------------------------------------------------- +// Write operations (plain sqlx, not through Query trait) +// --------------------------------------------------------------------------- +// +// Mutations don't go through cx.run() because they're not reads and don't +// produce subscription keys. They're called directly by action handlers, +// which then trigger a full rerender. + +/// Insert a new todo. Returns the new row's id. +pub async fn create_todo(db: &sqlx::SqlitePool, title: &str) -> anyhow::Result { + let result = sqlx::query("INSERT INTO todos (title, completed) VALUES (?, false)") + .bind(title) + .execute(db) + .await?; + Ok(result.last_insert_rowid()) +} + +/// Toggle a todo's completed status. +pub async fn toggle_todo(db: &sqlx::SqlitePool, id: i64) -> anyhow::Result<()> { + sqlx::query("UPDATE todos SET completed = NOT completed WHERE id = ?") + .bind(id) + .execute(db) + .await?; + Ok(()) +} + +/// Delete a todo by id. +pub async fn delete_todo(db: &sqlx::SqlitePool, id: i64) -> anyhow::Result<()> { + sqlx::query("DELETE FROM todos WHERE id = ?") + .bind(id) + .execute(db) + .await?; + Ok(()) +} diff --git a/src/app/todo_list.rs b/src/app/todo_list.rs new file mode 100644 index 0000000..53fc86e --- /dev/null +++ b/src/app/todo_list.rs @@ -0,0 +1,122 @@ +use crate::app::queries::{ListTodos, Todo}; +use crate::framework::context::RenderContext; +use crate::framework::signal::{global, mangle}; +use maud::{html, Markup}; + +/// Root page component: renders the full todo list with add form. +/// +/// Reads signals: +/// - `newTodo` (global, server-relevant): the text input value +/// +/// Exercises: +/// - `cx.run()` for data fetching +/// - `cx.signal()` with `global()` scoping + `Signal::val` in expressions +/// - `cx.signal()` with `mangle().client_only()` scoping (in todo_item) +/// - DataStar `data-bind`, `data-on-click`, `data-attr` attributes +/// - `@post()` actions for mutations +pub async fn todo_list(cx: &mut RenderContext) -> anyhow::Result { + // Fetch all todos + let todos = cx.run(ListTodos).await?; + + // Global signal for the "new todo" input. This call does two things: + // 1. Records "newTodo" as a touched signal (for demangling tracking) + // 2. Returns a Signal struct whose .val is "$newTodo" for expressions + let new_todo = cx.signal("newTodo", global()); + + let todo_count = todos.len(); + let done_count = todos.iter().filter(|t| t.completed).count(); + + Ok(html! { + div.todo-app { + h1 { "LiveVue.rs — Todo List" } + + // Navigation link to About page (exercises tree signal + page routing) + nav { + span.nav-current { "Todos" } + " | " + button.nav-link + data-on-click="$tree = {page: 'About'}; @post('/render')" { + "About" + } + } + + // Add todo form. + // data-bind-newTodo binds the input to the $newTodo signal. + // The button uses new_todo.val ("$newTodo") in a DataStar expression. + div.add-form { + input + type="text" + placeholder="What needs to be done?" + data-bind-newTodo="" + ; + button + data-on-click="@post('/action/add_todo')" + data-attr=(format!("{{disabled: {}.trim() === ''}}", new_todo.val)) { + "Add" + } + } + + // Stats + p.stats { + (format!("{} items, {} completed", todo_count, done_count)) + } + + // Todo items + ul.todo-list { + @for todo in &todos { + (todo_item(cx, todo)) + } + } + + @if todos.is_empty() { + p.empty { "No todos yet. Add one above!" } + } + } + }) +} + +/// Renders a single todo item. +/// +/// This is a static child component — called directly from `todo_list`, +/// not resolved through the component registry. +/// +/// Demonstrates per-instance, client-only signal via `mangle().client_only()`. +fn todo_item(cx: &mut RenderContext, todo: &Todo) -> Markup { + // Per-instance, client-only signal for edit mode. + // Not used in v0 rendering, but demonstrates the mangled signal API + // and ensures it's tracked as touched. Produces: "_editing__" + let _editing = cx.signal("editing", mangle(todo.id).client_only()); + + // Build class string server-side. Since we do a full rerender on every + // state change, there's no need for data-class here — the server knows + // whether the todo is completed. + let title_class = if todo.completed { + "todo-title completed" + } else { + "todo-title" + }; + + html! { + li.todo-item id=(format!("todo-{}", todo.id)) { + // Checkbox to toggle completion. + // `checked[expr]` is maud's syntax for conditional boolean attributes. + input + type="checkbox" + checked[todo.completed] + data-on-click=(format!("@post('/action/toggle_todo?id={}')", todo.id)) + ; + + // Title with strikethrough when completed (class set server-side) + span class=(title_class) { + (todo.title) + } + + // Delete button + button.delete-btn + data-on-click=(format!("@post('/action/delete_todo?id={}')", todo.id)) + { + "×" + } + } + } +} diff --git a/src/framework/connection.rs b/src/framework/connection.rs new file mode 100644 index 0000000..7186ee1 --- /dev/null +++ b/src/framework/connection.rs @@ -0,0 +1,147 @@ +use crate::framework::query::CacheKey; +use dashmap::DashMap; +use std::collections::HashSet; +use tokio::sync::mpsc; +use uuid::Uuid; + +// --------------------------------------------------------------------------- +// Connection state +// --------------------------------------------------------------------------- + +/// Per-connection state stored in the manager. +pub struct ConnectionState { + /// Sender half of the SSE channel. Messages written here get forwarded + /// to the client's long-lived SSE pipe (`GET /sse`). + pub sse_sender: mpsc::Sender, + + /// The full signal JSON from the most recent render for this connection. + /// Phase 2 uses this to re-enter the render pipeline on data invalidation + /// without a client request. + pub last_signals_json: Option, +} + +// --------------------------------------------------------------------------- +// ConnectionManager +// --------------------------------------------------------------------------- + +/// Concurrent map of connection_id → ConnectionState. +/// +/// Accessed from: +/// - `GET /sse` handler (insert) +/// - `POST /render` handler (read sender, update signals) +/// - SSE drop cleanup (remove) +/// - Phase 2: invalidation handler (read sender + signals) +pub struct ConnectionManager { + connections: DashMap, +} + +impl ConnectionManager { + pub fn new() -> Self { + Self { + connections: DashMap::new(), + } + } + + /// Register a new connection with its SSE sender. + pub fn insert(&self, id: Uuid, sender: mpsc::Sender) { + self.connections.insert( + id, + ConnectionState { + sse_sender: sender, + last_signals_json: None, + }, + ); + } + + /// Get the SSE sender for a connection (for sending server-initiated events). + pub fn get_sender(&self, id: &Uuid) -> Option> { + self.connections.get(id).map(|c| c.sse_sender.clone()) + } + + /// Update the stored signals for a connection after a render. + pub fn update_signals(&self, id: &Uuid, signals_json: String) { + if let Some(mut conn) = self.connections.get_mut(id) { + conn.last_signals_json = Some(signals_json); + } + } + + /// Remove a connection (called on SSE pipe drop). + pub fn remove(&self, id: &Uuid) -> Option<(Uuid, ConnectionState)> { + self.connections.remove(id) + } + + /// Check if a connection exists. + pub fn contains(&self, id: &Uuid) -> bool { + self.connections.contains_key(id) + } +} + +// --------------------------------------------------------------------------- +// SubscriptionRegistry +// --------------------------------------------------------------------------- + +/// Bidirectional map: CacheKey ↔ ConnectionId. +/// +/// After each render, the connection's key associations are replaced with +/// the new set from `cx.subscription_keys`. On connection drop, all entries +/// for that connection are removed. +/// +/// Phase 2: on data invalidation event, look up `key_to_conns` to find +/// which connections need rerender. +pub struct SubscriptionRegistry { + key_to_conns: DashMap>, + conn_to_keys: DashMap>, +} + +impl SubscriptionRegistry { + pub fn new() -> Self { + Self { + key_to_conns: DashMap::new(), + conn_to_keys: DashMap::new(), + } + } + + /// Replace a connection's subscription keys after a render. + /// + /// Removes old associations and inserts new ones. + pub fn update(&self, conn_id: Uuid, new_keys: Vec) { + // Remove old associations + if let Some((_, old_keys)) = self.conn_to_keys.remove(&conn_id) { + for key in &old_keys { + if let Some(mut conns) = self.key_to_conns.get_mut(key) { + conns.remove(&conn_id); + } + } + } + + // Insert new associations + let key_set: HashSet = new_keys.into_iter().collect(); + for key in &key_set { + self.key_to_conns + .entry(key.clone()) + .or_insert_with(HashSet::new) + .insert(conn_id); + } + self.conn_to_keys.insert(conn_id, key_set); + } + + /// Remove all entries for a connection (called on SSE pipe drop). + pub fn remove_connection(&self, conn_id: &Uuid) { + if let Some((_, keys)) = self.conn_to_keys.remove(conn_id) { + for key in &keys { + if let Some(mut conns) = self.key_to_conns.get_mut(key) { + conns.remove(conn_id); + } + } + } + } + + /// Phase 2: look up which connections are subscribed to a given key. + #[allow(dead_code)] + pub fn get_connections_for_key(&self, key: &CacheKey) -> HashSet { + self.key_to_conns + .get(key) + .map(|c| c.clone()) + .unwrap_or_default() + } +} diff --git a/src/framework/context.rs b/src/framework/context.rs new file mode 100644 index 0000000..f2ff0dc --- /dev/null +++ b/src/framework/context.rs @@ -0,0 +1,200 @@ +use crate::framework::signal::{Signal, SignalOpts, SignalStore}; +use crate::framework::query::{CacheKey, Query}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; +use uuid::Uuid; + +// --------------------------------------------------------------------------- +// Component tree +// --------------------------------------------------------------------------- + +/// Describes which dynamic components are mounted, parsed from the `tree` +/// signal. +/// +/// Static children (always rendered by their parent) do NOT appear here — +/// only dynamic/conditional slots. In v0 we primarily use `page` to resolve +/// the root component. The `children` map is the seam for nested dynamic +/// components in Phase 2. +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ComponentTree { + /// The root page component name, e.g. `"TodoList"`. + pub page: String, + /// Dynamic child slots. Key is the slot name, value describes the child. + #[serde(default)] + pub children: HashMap, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ComponentNode { + pub component: String, + #[serde(default)] + pub key: Option, +} + +impl Default for ComponentTree { + fn default() -> Self { + Self { + page: "TodoList".into(), + children: HashMap::new(), + } + } +} + +// --------------------------------------------------------------------------- +// RenderContext +// --------------------------------------------------------------------------- + +/// The component's window into the framework. +/// +/// Passed as `&mut cx` to every component function. Provides access to +/// signals, database queries, and subscription key collection. +/// +/// Phase 2 adds: cache handle, auth/session info. +pub struct RenderContext { + /// This connection's UUID. + pub connection_id: Uuid, + + /// Signal values populated from the incoming POST body (or initial + /// defaults on first page load). + pub signals: SignalStore, + + /// Parsed component tree from the `tree` signal. + pub tree: ComponentTree, + + /// Database pool. Cloneable (it's an Arc internally). + pub db: sqlx::SqlitePool, + + /// Subscription keys accumulated during this render. After render + /// completes, these are flushed to the SubscriptionRegistry for this + /// connection. + pub(crate) subscription_keys: Vec, + + /// Signal names touched during this render (for demangling tracking). + pub(crate) touched_signals: Vec, +} + +impl RenderContext { + pub fn new( + connection_id: Uuid, + signals: SignalStore, + tree: ComponentTree, + db: sqlx::SqlitePool, + ) -> Self { + Self { + connection_id, + signals, + tree, + db, + subscription_keys: Vec::new(), + touched_signals: Vec::new(), + } + } + + // ----------------------------------------------------------------------- + // Signals + // ----------------------------------------------------------------------- + + /// Create a signal reference with the given name and scoping options. + /// + /// Records the signal as "touched" for demangling tracking. + /// + /// ```ignore + /// let open = cx.signal("open", mangle(card.id)); + /// let val: bool = open.read_or(&cx.signals, false); + /// ``` + pub fn signal(&mut self, name: &str, opts: SignalOpts) -> Signal { + let mangled = opts.apply(name); + self.touched_signals.push(mangled.clone()); + Signal::new(mangled) + } + + // ----------------------------------------------------------------------- + // Queries + // ----------------------------------------------------------------------- + + /// Execute a single query, collecting its subscription key. + /// + /// ```ignore + /// let todos = cx.run(ListTodos).await?; + /// ``` + pub async fn run(&mut self, query: Q) -> anyhow::Result { + let key = query.cache_key(); + if key != CacheKey::None { + self.subscription_keys.push(key); + } + query.execute(&self.db).await + } + + /// Execute two queries concurrently, collecting both subscription keys. + /// + /// This avoids the `&mut self` borrow conflict by collecting keys + /// synchronously first, then running the async executions against a + /// cloned pool handle (pool clones are cheap — they share the inner Arc). + /// + /// ```ignore + /// let (board, columns) = cx.run_all( + /// GetBoard { id: 1 }, + /// ListColumns { board_id: 1 }, + /// ).await?; + /// ``` + pub async fn run_all( + &mut self, + a: A, + b: B, + ) -> anyhow::Result<(A::Output, B::Output)> { + // Collect subscription keys synchronously (no borrow conflict) + let key_a = a.cache_key(); + let key_b = b.cache_key(); + if key_a != CacheKey::None { + self.subscription_keys.push(key_a); + } + if key_b != CacheKey::None { + self.subscription_keys.push(key_b); + } + + // Execute concurrently against a cloned pool handle + let db = self.db.clone(); + let (ra, rb) = tokio::try_join!(a.execute(&db), b.execute(&db))?; + Ok((ra, rb)) + } + + /// Three-query variant of `run_all`. + pub async fn run_all3( + &mut self, + a: A, + b: B, + c: C, + ) -> anyhow::Result<(A::Output, B::Output, C::Output)> { + let key_a = a.cache_key(); + let key_b = b.cache_key(); + let key_c = c.cache_key(); + if key_a != CacheKey::None { + self.subscription_keys.push(key_a); + } + if key_b != CacheKey::None { + self.subscription_keys.push(key_b); + } + if key_c != CacheKey::None { + self.subscription_keys.push(key_c); + } + + let db = self.db.clone(); + let (ra, rb, rc) = tokio::try_join!(a.execute(&db), b.execute(&db), c.execute(&db))?; + Ok((ra, rb, rc)) + } + + // ----------------------------------------------------------------------- + // Post-render access + // ----------------------------------------------------------------------- + + /// Take the subscription keys collected during this render. + /// Called by the handler after rendering to flush them to the registry. + pub fn take_subscription_keys(&mut self) -> Vec { + std::mem::take(&mut self.subscription_keys) + } + + /// Take the touched signal names. + pub fn take_touched_signals(&mut self) -> Vec { + std::mem::take(&mut self.touched_signals) + } +} diff --git a/src/framework/mod.rs b/src/framework/mod.rs new file mode 100644 index 0000000..1e9046c --- /dev/null +++ b/src/framework/mod.rs @@ -0,0 +1,11 @@ +pub mod signal; +pub mod query; +pub mod context; +pub mod connection; +pub mod sse; + +pub use signal::{Signal, SignalStore, SignalOpts, mangle, client_only, global, data_signals}; +pub use query::{CacheKey, Query}; +pub use context::{RenderContext, ComponentTree, ComponentNode}; +pub use connection::{ConnectionManager, ConnectionState, SubscriptionRegistry}; +pub use sse::{format_patch_elements, format_patch_signals}; diff --git a/src/framework/query.rs b/src/framework/query.rs new file mode 100644 index 0000000..d65d199 --- /dev/null +++ b/src/framework/query.rs @@ -0,0 +1,161 @@ +use std::future::Future; +use std::pin::Pin; + +// --------------------------------------------------------------------------- +// CacheKey +// --------------------------------------------------------------------------- + +/// Identifies what data a query depends on, for subscription tracking. +/// +/// In v0 these are collected but not acted on. Phase 2 uses them to map +/// data changes → affected connections → rerender. +/// +/// Phase 2 adds: `Derived { key: String, value: i64 }` for composite keys +/// like `"posts:user_id:42"`. +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub enum CacheKey { + /// Query has no cacheable identity (rare — side-effect-only reads). + None, + /// Single row by primary key: `("todos", 42)`. + PrimaryKey { table: &'static str, id: i64 }, + /// future, something like this + //ColumnValue { table: &'static str, column: &'static str, val: Box }, + /// Entire table: `("todos")`. Used for list queries. + Table { table: &'static str }, +} + +// --------------------------------------------------------------------------- +// Query trait +// --------------------------------------------------------------------------- + +/// The central data-access abstraction. +/// +/// Every read goes through `cx.run(SomeQuery { ... })`, which: +/// 1. Collects the query's `cache_key` for subscription tracking. +/// 2. Executes the query against the database. +/// +/// Phase 2 inserts a cache check between steps 1 and 2. +/// +/// The trait uses `Pin>` instead of `async fn` to guarantee +/// `Send` bounds needed for `tokio::try_join!` in `cx.run_all()`. The +/// `query_one!` / `query_all!` macros hide this behind a clean declaration. +pub trait Query: Send + Sync { + type Output: Send; + + fn cache_key(&self) -> CacheKey; + + fn execute<'a>( + &'a self, + db: &'a sqlx::SqlitePool, + ) -> Pin> + Send + 'a>>; +} + +// --------------------------------------------------------------------------- +// query_one! — fetch exactly one row +// --------------------------------------------------------------------------- + +/// Generate a `Query` impl that fetches a single row. +/// +/// Both `params` and `cache` take closures receiving `&StructName`, so `self` +/// is always available without hygiene issues. +/// +/// ```ignore +/// pub struct GetTodo { pub id: i64 } +/// +/// query_one!(GetTodo { +/// sql: "SELECT id, title, completed FROM todos WHERE id = ?", +/// params: [|s: &GetTodo| s.id], +/// output: Todo, +/// cache: |s: &GetTodo| CacheKey::PrimaryKey { table: "todos", id: s.id }, +/// }); +/// ``` +/// +/// The `output` type must implement `sqlx::FromRow<'_, SqliteRow>`. +#[macro_export] +macro_rules! query_one { + ($name:ident { + sql: $sql:expr, + params: [$($param:expr),* $(,)?], + output: $output:ty, + cache: $cache:expr $(,)? + }) => { + impl $crate::framework::Query for $name { + type Output = $output; + + fn cache_key(&self) -> $crate::framework::CacheKey { + ($cache)(self) + } + + fn execute<'a>( + &'a self, + db: &'a sqlx::SqlitePool, + ) -> ::std::pin::Pin< + Box> + Send + 'a>, + > { + let zelf = self; + Box::pin(async move { + let row = sqlx::query_as::<_, $output>($sql) + $(.bind(($param)(zelf)))* + .fetch_one(db) + .await?; + Ok(row) + }) + } + } + }; +} + +// --------------------------------------------------------------------------- +// query_all! — fetch zero or more rows +// --------------------------------------------------------------------------- + +/// Generate a `Query` impl that fetches multiple rows. +/// +/// Both `params` and `cache` take closures receiving `&StructName`, so the +/// style is consistent with `query_one!` even when `s` goes unused. +/// +/// ```ignore +/// pub struct ListTodos; +/// +/// query_all!(ListTodos { +/// sql: "SELECT id, title, completed FROM todos ORDER BY id", +/// params: [], +/// output: Todo, +/// cache: |_s: &ListTodos| CacheKey::Table { table: "todos" }, +/// }); +/// ``` +/// +/// `Output` is `Vec`. +#[macro_export] +macro_rules! query_all { + ($name:ident { + sql: $sql:expr, + params: [$($param:expr),* $(,)?], + output: $output:ty, + cache: $cache:expr $(,)? + }) => { + impl $crate::framework::Query for $name { + type Output = Vec<$output>; + + fn cache_key(&self) -> $crate::framework::CacheKey { + ($cache)(self) + } + + fn execute<'a>( + &'a self, + db: &'a sqlx::SqlitePool, + ) -> ::std::pin::Pin< + Box> + Send + 'a>, + > { + let zelf = self; + Box::pin(async move { + let rows = sqlx::query_as::<_, $output>($sql) + $(.bind(($param)(zelf)))* + .fetch_all(db) + .await?; + Ok(rows) + }) + } + } + }; +} \ No newline at end of file diff --git a/src/framework/signal.rs b/src/framework/signal.rs new file mode 100644 index 0000000..0aeea01 --- /dev/null +++ b/src/framework/signal.rs @@ -0,0 +1,296 @@ +use serde::de::DeserializeOwned; +use std::collections::HashMap; +use std::fmt::Display; + +// --------------------------------------------------------------------------- +// Signal scoping +// --------------------------------------------------------------------------- + +/// Controls how a signal name is constructed. +/// +/// Every signal must choose a scope (per-instance via `mangle(key)` or +/// page-global via `global()`) and a visibility (server-relevant or +/// client-only via `.client_only()`). There is no default — forcing the +/// developer to think about "is this mine or the page's?" on every signal. +#[derive(Debug, Clone)] +pub struct SignalOpts { + pub scope: SignalScope, + pub visibility: SignalVisibility, +} + +#[derive(Debug, Clone)] +pub enum SignalScope { + /// Per-instance signal. The key is appended as `__`. + Mangled(String), + /// Page-global signal. No suffix. + Global, +} + +#[derive(Debug, Clone, PartialEq)] +pub enum SignalVisibility { + /// Sent to server on every @post (no prefix). + ServerRelevant, + /// Never sent to server (`_` prefix). + ClientOnly, +} + +/// Per-instance, server-relevant signal (most common). +/// +/// ```ignore +/// cx.signal("open", mangle(card.id)) // → "open__42" +/// ``` +pub fn mangle(key: impl Display) -> SignalOpts { + SignalOpts { + scope: SignalScope::Mangled(key.to_string()), + visibility: SignalVisibility::ServerRelevant, + } +} + +/// Page-global, client-only signal. +/// +/// ```ignore +/// cx.signal("draggingCardId", client_only()) // → "_draggingCardId" +/// ``` +pub fn client_only() -> SignalOpts { + SignalOpts { + scope: SignalScope::Global, + visibility: SignalVisibility::ClientOnly, + } +} + +/// Page-global, server-relevant signal. +/// +/// ```ignore +/// cx.signal("activeTab", global()) // → "activeTab" +/// ``` +pub fn global() -> SignalOpts { + SignalOpts { + scope: SignalScope::Global, + visibility: SignalVisibility::ServerRelevant, + } +} + +impl SignalOpts { + /// Chain `.client_only()` to make any signal client-only. + /// + /// ```ignore + /// cx.signal("hovered", mangle(card.id).client_only()) // → "_hovered__42" + /// ``` + pub fn client_only(mut self) -> Self { + self.visibility = SignalVisibility::ClientOnly; + self + } + + /// Compute the final signal name from a base name + these options. + pub fn apply(&self, base: &str) -> String { + let prefix = match self.visibility { + SignalVisibility::ClientOnly => "_", + SignalVisibility::ServerRelevant => "", + }; + let suffix = match &self.scope { + SignalScope::Mangled(key) => format!("__{}", key), + SignalScope::Global => String::new(), + }; + format!("{}{}{}", prefix, base, suffix) + } +} + +// --------------------------------------------------------------------------- +// Signal +// --------------------------------------------------------------------------- + +/// A resolved signal reference. Produced by `cx.signal()`. +/// +/// Use `name` in `data-bind` attributes and `val` in expressions. +#[derive(Debug, Clone)] +pub struct Signal { + /// Raw name, e.g. `"open__42"` or `"_draggingCardId"`. + /// Use for `data-bind-{name}`. + pub name: String, + /// `$`-prefixed name for DataStar expressions, e.g. `"$open__42"`. + pub val: String, +} + +impl Signal { + pub fn new(name: String) -> Self { + let val = format!("${}", name); + Self { name, val } + } + + /// Produce a key-value entry for a `data-signals` attribute. + /// + /// Returns `"name: default"`. Wrap in `data_signals(&[...])` to build + /// the full attribute value. + /// + /// The `default` should be a JS literal: `"false"`, `"0"`, `"'hello'"`. + pub fn declare(&self, default: impl Display) -> String { + format!("{}: {}", self.name, default) + } + + /// Produce a set expression for `data-on-*` attributes. + /// + /// Returns `"$name = value"`. + pub fn set(&self, value: impl Display) -> String { + format!("{} = {}", self.val, value) + } + + /// Read this signal's current value from the store, or return `default`. + pub fn read_or(&self, store: &SignalStore, default: T) -> T { + store + .get(&self.name) + .and_then(|v| serde_json::from_value(v.clone()).ok()) + .unwrap_or(default) + } +} + +// --------------------------------------------------------------------------- +// SignalStore +// --------------------------------------------------------------------------- + +/// Holds the signal values received from the client in a POST body. +/// +/// Keyed by the full (mangled) signal name. Values are JSON. +#[derive(Debug, Clone, Default)] +pub struct SignalStore { + values: HashMap, +} + +impl SignalStore { + pub fn new() -> Self { + Self::default() + } + + /// Build a store from a JSON object (the POST body from DataStar). + pub fn from_json(json: serde_json::Value) -> Self { + let values = match json { + serde_json::Value::Object(map) => { + map.into_iter().collect() + } + _ => HashMap::new(), + }; + Self { values } + } + + /// Build a store from an initial set of key-value pairs. + pub fn from_pairs(pairs: Vec<(String, serde_json::Value)>) -> Self { + Self { + values: pairs.into_iter().collect(), + } + } + + pub fn get(&self, key: &str) -> Option<&serde_json::Value> { + self.values.get(key) + } + + pub fn insert(&mut self, key: String, value: serde_json::Value) { + self.values.insert(key, value); + } + + /// Serialize all server-relevant signals (no `_` prefix) to a JSON string. + /// Used for `last_signals_json` storage. + pub fn to_json_string(&self) -> String { + let obj: serde_json::Map = self + .values + .iter() + .filter(|(k, _)| !k.starts_with('_')) + .map(|(k, v)| (k.clone(), v.clone())) + .collect(); + serde_json::Value::Object(obj).to_string() + } + + /// Format all signals as a JS object literal for `data-signals` attribute. + /// Uses JSON format which is valid JS. + pub fn to_data_signals_attr(&self) -> String { + self.to_json_string() + } +} + +// --------------------------------------------------------------------------- +// Helpers +// --------------------------------------------------------------------------- + +/// Build a `data-signals` attribute value from a list of `signal.declare()` +/// entries. +/// +/// ```ignore +/// data_signals(&[open.declare("false"), count.declare("0")]) +/// // → "{open__42: false, count__42: 0}" +/// ``` +pub fn data_signals(entries: &[String]) -> String { + format!("{{{}}}", entries.join(", ")) +} + +// --------------------------------------------------------------------------- +// Demangling +// --------------------------------------------------------------------------- + +/// Demangle a signal name back to `(base_name, Option)`. +/// +/// `"open__42"` → `("open", Some("42"))` +/// `"_hovered__42"` → `("hovered", Some("42"))` (prefix stripped) +/// `"activeTab"` → `("activeTab", None)` +pub fn demangle(mangled: &str) -> (&str, Option<&str>) { + // Strip client-only prefix for demangling purposes + let stripped = mangled.strip_prefix('_').unwrap_or(mangled); + match stripped.split_once("__") { + Some((base, key)) => (base, Some(key)), + None => (stripped, None), + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_mangle_server_relevant() { + let opts = mangle(42); + assert_eq!(opts.apply("open"), "open__42"); + } + + #[test] + fn test_mangle_client_only() { + let opts = mangle(42).client_only(); + assert_eq!(opts.apply("hovered"), "_hovered__42"); + } + + #[test] + fn test_global_client_only() { + let opts = client_only(); + assert_eq!(opts.apply("draggingCardId"), "_draggingCardId"); + } + + #[test] + fn test_global_server_relevant() { + let opts = global(); + assert_eq!(opts.apply("activeTab"), "activeTab"); + } + + #[test] + fn test_demangle() { + assert_eq!(demangle("open__42"), ("open", Some("42"))); + assert_eq!(demangle("_hovered__42"), ("hovered", Some("42"))); + assert_eq!(demangle("activeTab"), ("activeTab", None)); + } + + #[test] + fn test_signal_declare() { + let sig = Signal::new("open__42".into()); + assert_eq!(sig.declare("false"), "open__42: false"); + } + + #[test] + fn test_signal_set() { + let sig = Signal::new("open__42".into()); + assert_eq!(sig.set("true"), "$open__42 = true"); + } + + #[test] + fn test_data_signals_helper() { + let result = data_signals(&[ + "open__42: false".into(), + "count: 0".into(), + ]); + assert_eq!(result, "{open__42: false, count: 0}"); + } +} diff --git a/src/framework/sse.rs b/src/framework/sse.rs new file mode 100644 index 0000000..5725708 --- /dev/null +++ b/src/framework/sse.rs @@ -0,0 +1,79 @@ +/// SSE event formatting for DataStar v1. +/// +/// DataStar v1 SSE event names (verified against https://data-star.dev/reference/sse_events): +/// +/// - `datastar-patch-elements` — morph HTML into the DOM by element ID +/// Each line of HTML is prefixed with `data: elements ` +/// +/// - `datastar-patch-signals` — update client-side signals +/// Signals are a JS object literal: `data: signals {key: value}` +/// +/// SSE events are terminated by a blank line (`\n\n`). + +/// Format a `datastar-patch-elements` SSE event. +/// +/// The `html` should contain a top-level element with an `id` attribute +/// (e.g. `
...
`). DataStar will morph it into the +/// existing element with that ID. +/// +/// Multi-line HTML is split and each line gets the `data: elements ` prefix, +/// per the SSE protocol (multiple `data:` lines are concatenated with `\n` +/// by the SSE parser; DataStar then strips the `elements ` prefix from each). +pub fn format_patch_elements(html: &str) -> String { + let mut event = String::from("event: datastar-patch-elements\n"); + for line in html.lines() { + event.push_str("data: elements "); + event.push_str(line); + event.push('\n'); + } + event.push('\n'); // blank line terminates SSE event + event +} + +/// Format a `datastar-patch-signals` SSE event. +/// +/// `signals_js` should be a JS object literal string, e.g. `{foo: '', bar: 0}`. +/// Note: this is JS syntax (unquoted keys OK), not strict JSON. +pub fn format_patch_signals(signals_js: &str) -> String { + format!( + "event: datastar-patch-signals\ndata: signals {}\n\n", + signals_js + ) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_patch_elements_single_line() { + let result = format_patch_elements(r#"
hello
"#); + assert_eq!( + result, + "event: datastar-patch-elements\ndata: elements
hello
\n\n" + ); + } + + #[test] + fn test_patch_elements_multi_line() { + let html = "
\n

Hello

\n
"; + let result = format_patch_elements(html); + let expected = concat!( + "event: datastar-patch-elements\n", + "data: elements
\n", + "data: elements

Hello

\n", + "data: elements
\n", + "\n", + ); + assert_eq!(result, expected); + } + + #[test] + fn test_patch_signals() { + let result = format_patch_signals("{newTodo: ''}"); + assert_eq!( + result, + "event: datastar-patch-signals\ndata: signals {newTodo: ''}\n\n" + ); + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..d6b47a7 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,63 @@ +mod framework; +mod app; + +use app::AppState; +use framework::connection::{ConnectionManager, SubscriptionRegistry}; +use std::sync::Arc; + +#[tokio::main] +async fn main() -> anyhow::Result<()> { + // ----------------------------------------------------------------------- + // Database setup + // ----------------------------------------------------------------------- + + // SQLite with create-if-missing. In-memory `:memory:` also works for dev. + let db = sqlx::SqlitePool::connect("sqlite:livevue.db?mode=rwc").await?; + + // Run migrations inline (no migration files needed for v0). + sqlx::query( + "CREATE TABLE IF NOT EXISTS todos ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + title TEXT NOT NULL, + completed BOOLEAN NOT NULL DEFAULT FALSE + )", + ) + .execute(&db) + .await?; + + // Seed a few todos if the table is empty (nice for first run) + let count: (i64,) = sqlx::query_as("SELECT COUNT(*) FROM todos") + .fetch_one(&db) + .await?; + if count.0 == 0 { + for title in &["Learn Rust", "Build LiveVue.rs", "Ship v0"] { + sqlx::query("INSERT INTO todos (title, completed) VALUES (?, false)") + .bind(title) + .execute(&db) + .await?; + } + } + + // ----------------------------------------------------------------------- + // Application state + // ----------------------------------------------------------------------- + + let state = Arc::new(AppState { + db, + connections: ConnectionManager::new(), + subscriptions: SubscriptionRegistry::new(), + }); + + // ----------------------------------------------------------------------- + // Server + // ----------------------------------------------------------------------- + + let app = app::router(state); + + let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?; + println!("LiveVue.rs v0.1 listening on http://localhost:3000"); + + axum::serve(listener, app).await?; + + Ok(()) +}