diff --git a/.vscode/settings.json b/.vscode/settings.json index 9dac79b..38feaed 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,6 @@ { - "nixEnvSelector.nixFile": "${workspaceFolder}/shell.nix" + "nixEnvSelector.nixFile": "${workspaceFolder}/shell.nix", + "cSpell.words": [ + "evtbuzz" + ] } \ No newline at end of file diff --git a/clover-hub/Cargo.lock b/clover-hub/Cargo.lock index dad62ff..5b1c4be 100644 --- a/clover-hub/Cargo.lock +++ b/clover-hub/Cargo.lock @@ -17,6 +17,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" + [[package]] name = "aho-corasick" version = "1.1.3" @@ -38,7 +44,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" dependencies = [ - "libc", + "libc 0.2.155", ] [[package]] @@ -109,6 +115,23 @@ dependencies = [ "uuid", ] +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "async-recursion" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "autocfg" version = "1.3.0" @@ -123,8 +146,8 @@ checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" dependencies = [ "addr2line", "cc", - "cfg-if", - "libc", + "cfg-if 1.0.0", + "libc 0.2.155", "miniz_oxide", "object", "rustc-demangle", @@ -148,6 +171,29 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +[[package]] +name = "bindgen" +version = "0.69.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +dependencies = [ + "bitflags 2.5.0", + "cexpr", + "clang-sys", + "itertools 0.12.1", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.77", + "which", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -199,6 +245,21 @@ version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -220,6 +281,17 @@ dependencies = [ "windows-targets 0.52.5", ] +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc 0.2.155", + "libloading", +] + [[package]] name = "clap" version = "4.5.4" @@ -251,7 +323,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.77", ] [[package]] @@ -265,15 +337,18 @@ name = "clover" version = "1.0.0" dependencies = [ "api_key", + "async-recursion", "chrono", "clap", "crossterm 0.19.0", + "egl", "env_logger", "eventbus", "fast_websocket_client", "futures", "log", "rand 0.7.3", + "raylib", "regex", "serde", "serde_json", @@ -286,6 +361,15 @@ dependencies = [ "warp", ] +[[package]] +name = "cmake" +version = "0.1.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb1e43aa7fd152b1f968787f7dbcdeb306d1867ff373c69955211876c053f91a" +dependencies = [ + "cc", +] + [[package]] name = "colorchoice" version = "1.0.1" @@ -304,7 +388,29 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ - "libc", + "libc 0.2.155", +] + +[[package]] +name = "crossbeam-queue" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" +dependencies = [ + "cfg-if 0.1.10", + "crossbeam-utils", + "maybe-uninit", +] + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg", + "cfg-if 0.1.10", + "lazy_static", ] [[package]] @@ -316,7 +422,7 @@ dependencies = [ "bitflags 1.3.2", "crossterm_winapi 0.6.2", "lazy_static", - "libc", + "libc 0.2.155", "mio 0.7.14", "parking_lot 0.11.2", "signal-hook", @@ -332,7 +438,7 @@ dependencies = [ "bitflags 1.3.2", "crossterm_winapi 0.7.0", "lazy_static", - "libc", + "libc 0.2.155", "mio 0.7.14", "parking_lot 0.11.2", "serde", @@ -384,6 +490,16 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "egl" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a373bc9844200b1ff15bd1b245931d1c20d09d06e4ec09f361171f29a4b0752d" +dependencies = [ + "khronos", + "libc 0.2.155", +] + [[package]] name = "either" version = "1.12.0" @@ -396,7 +512,7 @@ version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -428,6 +544,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc 0.2.155", + "windows-sys 0.52.0", +] + [[package]] name = "eventbus" version = "0.5.1" @@ -435,7 +561,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3fa67f764d610e66099ce261c5fcf884b9c595db26ab390ee558c0a77f50d50" dependencies = [ "anymap", - "itertools", + "itertools 0.7.11", "lazy_static", ] @@ -494,6 +620,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "futures" version = "0.3.30" @@ -572,8 +704,8 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ - "cfg-if", - "libc", + "cfg-if 1.0.0", + "libc 0.2.155", "wasi 0.9.0+wasi-snapshot-preview1", ] @@ -583,8 +715,8 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ - "cfg-if", - "libc", + "cfg-if 1.0.0", + "libc 0.2.155", "wasi 0.11.0+wasi-snapshot-preview1", ] @@ -594,6 +726,12 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "h2" version = "0.3.26" @@ -613,6 +751,16 @@ dependencies = [ "tracing", ] +[[package]] +name = "hashbrown" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96282e96bfcd3da0d3aa9938bedf1e50df3269b6db08b4876d2da0bb1a0841cf" +dependencies = [ + "ahash", + "autocfg", +] + [[package]] name = "hashbrown" version = "0.14.5" @@ -655,6 +803,21 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hibitset" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3ede5cfa60c958e60330d65163adbc4211e15a2653ad80eb0cce878de120121" + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "http" version = "0.2.12" @@ -828,7 +991,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.14.5", ] [[package]] @@ -837,7 +1000,7 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -855,6 +1018,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -870,18 +1042,55 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "khronos" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0711aaa80e6ba6eb1fa8978f1f46bfcb38ceb2f3f33f3736efbff39dac89f50" +dependencies = [ + "libc 0.1.12", +] + [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e32a70cf75e5846d53a673923498228bbec6a8624708a9ea5645f075d6276122" + [[package]] name = "libc" version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +[[package]] +name = "libloading" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +dependencies = [ + "cfg-if 1.0.0", + "windows-targets 0.52.5", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + [[package]] name = "lock_api" version = "0.4.12" @@ -898,6 +1107,12 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + [[package]] name = "memchr" version = "2.7.2" @@ -920,6 +1135,12 @@ dependencies = [ "unicase", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.7.3" @@ -935,7 +1156,7 @@ version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" dependencies = [ - "libc", + "libc 0.2.155", "log", "miow", "ntapi", @@ -948,7 +1169,7 @@ version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ - "libc", + "libc 0.2.155", "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.48.0", ] @@ -962,6 +1183,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "mopa" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a785740271256c230f57462d3b83e52f998433a7062fc18f96d5999474a9f915" + [[package]] name = "multer" version = "2.1.0" @@ -980,6 +1207,16 @@ dependencies = [ "version_check", ] +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "ntapi" version = "0.3.7" @@ -1005,7 +1242,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ "hermit-abi", - "libc", + "libc 0.2.155", ] [[package]] @@ -1050,9 +1287,9 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "instant", - "libc", + "libc 0.2.155", "redox_syscall 0.2.16", "smallvec", "winapi", @@ -1064,8 +1301,8 @@ version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ - "cfg-if", - "libc", + "cfg-if 1.0.0", + "libc 0.2.155", "redox_syscall 0.5.1", "smallvec", "windows-targets 0.52.5", @@ -1094,7 +1331,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.77", ] [[package]] @@ -1115,6 +1352,16 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "prettyplease" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" +dependencies = [ + "proc-macro2", + "syn 2.0.77", +] + [[package]] name = "proc-macro2" version = "1.0.84" @@ -1140,7 +1387,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ "getrandom 0.1.16", - "libc", + "libc 0.2.155", "rand_chacha 0.2.2", "rand_core 0.5.1", "rand_hc", @@ -1152,7 +1399,7 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "libc", + "libc 0.2.155", "rand_chacha 0.3.1", "rand_core 0.6.4", ] @@ -1204,6 +1451,33 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "raylib" +version = "5.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2a7a6734329d7b872a418fe4cb08ca282eb66a6f4a3430bd4ee4e6a8cac6632" +dependencies = [ + "cfg-if 1.0.0", + "lazy_static", + "libc 0.2.155", + "parking_lot 0.12.3", + "raylib-sys", + "specs", + "specs-derive", +] + +[[package]] +name = "raylib-sys" +version = "5.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db5c6001cfaeec17210713227d11f3b1ba4b723bb12cff47d1b93c4060e10ad0" +dependencies = [ + "bindgen", + "cc", + "cmake", + "fs_extra", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -1258,9 +1532,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", - "cfg-if", + "cfg-if 1.0.0", "getrandom 0.2.15", - "libc", + "libc 0.2.155", "spin", "untrusted", "windows-sys 0.52.0", @@ -1272,6 +1546,25 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.5.0", + "errno", + "libc 0.2.155", + "linux-raw-sys", + "windows-sys 0.52.0", +] + [[package]] name = "rustls" version = "0.22.4" @@ -1338,7 +1631,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.77", ] [[package]] @@ -1370,18 +1663,43 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "shred" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5f08237e667ac94ad20f8878b5943d91a93ccb231428446c57c21c57779016d" +dependencies = [ + "arrayvec", + "hashbrown 0.7.2", + "mopa", + "smallvec", + "tynm", +] + +[[package]] +name = "shrev" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5ea33232fdcf1bf691ca33450e5a94dde13e1a8cbb8caabc5e4f9d761e10b1a" + [[package]] name = "signal-hook" version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729" dependencies = [ - "libc", + "libc 0.2.155", "mio 0.7.14", "signal-hook-registry", ] @@ -1392,7 +1710,7 @@ version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ - "libc", + "libc 0.2.155", ] [[package]] @@ -1422,10 +1740,36 @@ version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ - "libc", + "libc 0.2.155", "windows-sys 0.52.0", ] +[[package]] +name = "specs" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fff28a29366aff703d5da8a7e2c8875dc8453ac1118f842cbc0fa70c7db51240" +dependencies = [ + "crossbeam-queue", + "hashbrown 0.7.2", + "hibitset", + "log", + "shred", + "shrev", + "tuple_utils", +] + +[[package]] +name = "specs-derive" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e23e09360f3d2190fec4222cd9e19d3158d5da948c0d1ea362df617dd103511" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "spin" version = "0.9.8" @@ -1446,9 +1790,20 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "syn" -version = "2.0.66" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -1472,7 +1827,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.77", ] [[package]] @@ -1498,7 +1853,7 @@ checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", - "libc", + "libc 0.2.155", "mio 0.8.11", "num_cpus", "parking_lot 0.12.3", @@ -1516,7 +1871,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.77", ] [[package]] @@ -1631,6 +1986,21 @@ dependencies = [ "utf-8", ] +[[package]] +name = "tuple_utils" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44834418e2c5b16f47bedf35c28e148db099187dd5feee6367fb2525863af4f1" + +[[package]] +name = "tynm" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd30d05e69d1478e13fe3e7a853409cfec82cebc2cf9b8d613b3c6b0081781ed" +dependencies = [ + "nom", +] + [[package]] name = "typenum" version = "1.17.0" @@ -1780,7 +2150,7 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "wasm-bindgen-macro", ] @@ -1795,7 +2165,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.77", "wasm-bindgen-shared", ] @@ -1817,7 +2187,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.77", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1837,6 +2207,18 @@ dependencies = [ "rustls-pki-types", ] +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/clover-hub/Cargo.toml b/clover-hub/Cargo.toml index 5e2c59b..7207f9d 100644 --- a/clover-hub/Cargo.toml +++ b/clover-hub/Cargo.toml @@ -24,3 +24,6 @@ eventbus = "0.5.1" regex = "1.10.4" api_key = "0.1.0" url = "2.5.0" +raylib = "5.0.2" +egl = "0.2.7" +async-recursion = "1.1.1" diff --git a/clover-hub/src/server/appd/mod.rs b/clover-hub/src/server/appd/mod.rs index 23629d2..ca4b03d 100644 --- a/clover-hub/src/server/appd/mod.rs +++ b/clover-hub/src/server/appd/mod.rs @@ -1,3 +1,7 @@ -pub async fn appd_main() { +use std::sync::Arc; +use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; +use super::evtbuzz::models::{IPCMessageWithId, Store}; +pub async fn appd_main(ipc_tx: UnboundedSender, ipc_rx: UnboundedReceiver, store: Arc) { + // TODO: Add docker crate to manage applications. } diff --git a/clover-hub/src/server/arbiter/mod.rs b/clover-hub/src/server/arbiter/mod.rs index c408f50..17dc979 100644 --- a/clover-hub/src/server/arbiter/mod.rs +++ b/clover-hub/src/server/arbiter/mod.rs @@ -1,3 +1,7 @@ -pub async fn arbiter_main() { +use std::sync::Arc; +use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; +use super::evtbuzz::models::{IPCMessageWithId, Store}; + +pub async fn arbiter_main(ipc_tx: UnboundedSender, ipc_rx: UnboundedReceiver, store: Arc) { } diff --git a/clover-hub/src/server/evtbuzz/listener.rs b/clover-hub/src/server/evtbuzz/listener.rs index 58da436..27234ed 100644 --- a/clover-hub/src/server/evtbuzz/listener.rs +++ b/clover-hub/src/server/evtbuzz/listener.rs @@ -185,6 +185,10 @@ pub async fn evtbuzz_listener(port: u16, ipc_tx: UnboundedSender ApiKey { - self.into() - } -} - impl Into for ApiKeyWithKey { fn into(self) -> ApiKey { ApiKey { @@ -51,6 +44,25 @@ impl Into for ApiKeyWithKey { } } +impl Into for ApiKeyWithKey { + fn into(self) -> ApiKeyWithKeyWithoutUID { + ApiKeyWithKeyWithoutUID { + key: self.key, + allowed_events_to: self.allowed_events_to, + allowed_events_from: self.allowed_events_from, + echo: self.echo, + } + } +} + +#[derive(Debug, Deserialize, Serialize, Clone)] +pub struct ApiKeyWithKeyWithoutUID { + pub key: String, + pub allowed_events_to: Vec, + pub allowed_events_from: Vec, + pub echo: bool, +} + #[derive(Debug, Deserialize, Serialize, Clone)] pub struct IPCMessage { pub author: String, @@ -58,17 +70,6 @@ pub struct IPCMessage { pub message: String, } -impl IPCMessage { - pub fn to_message_with_id(self, id: String) -> IPCMessageWithId { - IPCMessageWithId { - id, - author: self.author, - kind: self.kind, - message: self.message, - } - } -} - #[derive(Debug, Deserialize, Serialize, Clone)] pub struct IPCMessageWithId { pub author: String, @@ -77,12 +78,6 @@ pub struct IPCMessageWithId { pub id: String, } -impl IPCMessageWithId { - pub fn to_message(self) -> IPCMessage { - self.into() - } -} - impl Into for IPCMessageWithId { fn into(self) -> IPCMessage { IPCMessage { @@ -100,17 +95,6 @@ pub struct Client { pub active: bool, } -impl Client { - pub fn to_client_with_id(self, id: String) -> ClientWithId { - ClientWithId { - id, - api_key: self.api_key, - user_id: self.user_id, - active: self.active, - } - } -} - #[derive(Debug, Deserialize, Serialize, Clone)] pub struct ClientWithId { pub id: String, @@ -119,12 +103,6 @@ pub struct ClientWithId { pub active: bool, } -impl ClientWithId { - pub fn to_client(self) -> Client { - self.into() - } -} - impl Into for ClientWithId { fn into(self) -> Client { Client { @@ -140,21 +118,18 @@ pub struct User { /// A vector of API keys associated with this user. pub api_keys: Vec, pub sessions: Arc>>, + pub user_type: String, + pub pretty_name: String } impl User { - pub fn new() -> Self { - User { - api_keys: Vec::new(), - sessions: Arc::new(Mutex::new(HashMap::new())), - } - } - pub fn to_user_with_id(self, id: String) -> UserWithId { UserWithId { id, api_keys: self.api_keys, sessions: self.sessions, + user_type: self.user_type, + pretty_name: self.pretty_name } } } @@ -171,23 +146,40 @@ pub struct UserWithId { pub id: String, pub api_keys: Vec, pub sessions: Arc>>, -} - -impl UserWithId { - pub fn to_user(self) -> User { - self.into() - } + pub user_type: String, + pub pretty_name: String } impl Into for UserWithId { fn into(self) -> User { User { api_keys: self.api_keys, - sessions: self.sessions + sessions: self.sessions, + user_type: self.user_type, + pretty_name: self.pretty_name } } } +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct MasterUserConfig { + pub id: String, + pub api_key: String +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct UserConfig { + pub user_type: String, + pub pretty_name: String, + pub id: String, + pub api_keys: Vec +} + +// TODO: Add module models!!!! + +// TODO: Create application manifest schema/models + +// TODO: Add serialization/deserialization functions.... ough. #[derive(Debug, Clone)] pub struct Store { pub users: Arc>>, @@ -207,26 +199,182 @@ impl Store { } // Create a new store with a set master user. - pub async fn new_with_set_master_user(master_user_id: String) -> Self { + pub async fn new_configured_store() -> (Store, MasterUserConfig, (MasterUserConfig, MasterUserConfig, MasterUserConfig, MasterUserConfig, MasterUserConfig, MasterUserConfig)) { let ret = Store::new(); - ret.clone().create_set_master_user(master_user_id).await; + let master_user_config = ret.clone().create_master_user().await; + let core_users_config = ret.clone().add_all_core_users().await; - ret + (ret, master_user_config, core_users_config) } - pub async fn create_master_user(self) -> String { - let master_user_id = Uuid::new_v4().to_string(); - - self.create_set_master_user(master_user_id.clone()).await; - - master_user_id + pub async fn add_user(self, user_config: UserConfig) { + let mut key_ids: Vec = vec![]; + for key_config in user_config.api_keys.iter() { key_ids.push(key_config.key.clone()); }; + self.users.lock().await.insert(user_config.id.clone(), User { + pretty_name: user_config.pretty_name, + user_type: user_config.user_type, + api_keys: key_ids, + sessions: Arc::new(Mutex::new(HashMap::new())) + }); + + for key_config in user_config.api_keys.iter() { + self.api_keys.lock().await.insert(key_config.key.clone(), ApiKey { + allowed_events_to: key_config.allowed_events_to.clone(), + allowed_events_from: key_config.allowed_events_from.clone(), + user_id: user_config.id.clone(), + echo: key_config.echo.clone() + }); + }; } - pub async fn create_set_master_user(self, master_user_id: String) { - let master_api_key = gen_api_key(); + pub async fn create_master_user(self) -> MasterUserConfig { + let master_user_id = gen_uid_with_check(&self).await; + let master_api_key = gen_api_key_with_check(&self).await; + + + self.add_user(UserConfig { + id: master_user_id.clone(), + pretty_name: "Master User".to_string(), + user_type: "com.reboot-codes.clover.master".to_string(), + api_keys: vec![ApiKeyWithKeyWithoutUID { + allowed_events_to: vec![".*".to_string()], + allowed_events_from: vec![".*".to_string()], + key: master_api_key.clone(), + echo: true + }] + }).await; + + MasterUserConfig { + id: master_user_id.clone(), + api_key: master_api_key.clone() + } + } - self.users.lock().await.insert(master_user_id.clone(), User { api_keys: vec![master_api_key.clone()], sessions: Arc::new(Mutex::new(HashMap::new())) }); - self.api_keys.lock().await.insert(master_api_key.clone(), ApiKey { allowed_events_to: vec![".*".to_string()], allowed_events_from: vec![".*".to_string()], user_id: master_user_id.clone(), echo: true }); + /// Adds all the core user accounts, returns their configurations in the following order: + /// + /// - EvtBuzz + /// - Arbiter + /// - Renderer + /// - AppD + /// - ModMan + /// - and Inference Engine + pub async fn add_all_core_users(self) -> (MasterUserConfig, MasterUserConfig, MasterUserConfig, MasterUserConfig, MasterUserConfig, MasterUserConfig) { + // EvtBuzz + let evtbuzz_uid = gen_uid_with_check(&self).await; + let evtbuzz_key = gen_api_key_with_check(&self).await; + self.clone().add_user(UserConfig { + user_type: "com.reboot-codes.clover.evtbuzz".to_string(), + pretty_name: "EvtBuzz".to_string(), + id: evtbuzz_uid.clone(), + api_keys: vec![ApiKeyWithKeyWithoutUID { + allowed_events_to: vec![".*".to_string()], + allowed_events_from: vec![".*".to_string()], + key: evtbuzz_key.clone(), + echo: true + }] + }).await; + + // Arbiter + let arbiter_uid = gen_uid_with_check(&self).await; + let arbiter_key = gen_api_key_with_check(&self).await; + self.clone().add_user(UserConfig { + user_type: "com.reboot-codes.clover.arbiter".to_string(), + pretty_name: "Arbiter".to_string(), + id: arbiter_uid.clone(), + api_keys: vec![ApiKeyWithKeyWithoutUID { + allowed_events_to: vec![".*".to_string()], + allowed_events_from: vec![".*".to_string()], + key: arbiter_key.clone(), + echo: true + }] + }).await; + + // Renderer + let renderer_uid = gen_uid_with_check(&self).await; + let renderer_key = gen_api_key_with_check(&self).await; + self.clone().add_user(UserConfig { + user_type: "com.reboot-codes.clover.renderer".to_string(), + pretty_name: "Renderer".to_string(), + id: renderer_uid.clone(), + api_keys: vec![ApiKeyWithKeyWithoutUID { + allowed_events_to: vec![".*".to_string()], + allowed_events_from: vec![".*".to_string()], + key: renderer_key.clone(), + echo: true + }] + }).await; + + // AppD + let appd_uid = gen_uid_with_check(&self).await; + let appd_key = gen_api_key_with_check(&self).await; + self.clone().add_user(UserConfig { + user_type: "com.reboot-codes.clover.appd".to_string(), + pretty_name: "appd".to_string(), + id: appd_uid.clone(), + api_keys: vec![ApiKeyWithKeyWithoutUID { + allowed_events_to: vec![".*".to_string()], + allowed_events_from: vec![".*".to_string()], + key: appd_key.clone(), + echo: true + }] + }).await; + + // ModMan + let modman_uid = gen_uid_with_check(&self).await; + let modman_key = gen_api_key_with_check(&self).await; + self.clone().add_user(UserConfig { + user_type: "com.reboot-codes.clover.modman".to_string(), + pretty_name: "ModMan".to_string(), + id: modman_uid.clone(), + api_keys: vec![ApiKeyWithKeyWithoutUID { + allowed_events_to: vec![".*".to_string()], + allowed_events_from: vec![".*".to_string()], + key: modman_key.clone(), + echo: true + }] + }).await; + + // Inference Engine + let inference_engine_uid = gen_uid_with_check(&self).await; + let inference_engine_key = gen_api_key_with_check(&self).await; + self.clone().add_user(UserConfig { + user_type: "com.reboot-codes.clover.inference-engine".to_string(), + pretty_name: "Inference Engine".to_string(), + id: inference_engine_uid.clone(), + api_keys: vec![ApiKeyWithKeyWithoutUID { + allowed_events_to: vec![".*".to_string()], + allowed_events_from: vec![".*".to_string()], + key: inference_engine_key.clone(), + echo: true + }] + }).await; + + ( + MasterUserConfig { + id: evtbuzz_uid.clone(), + api_key: evtbuzz_key.clone() + }, + MasterUserConfig { + id: arbiter_uid.clone(), + api_key: arbiter_key.clone() + }, + MasterUserConfig { + id: renderer_uid.clone(), + api_key: renderer_uid.clone() + }, + MasterUserConfig { + id: appd_uid.clone(), + api_key: appd_key.clone() + }, + MasterUserConfig { + id: modman_uid.clone(), + api_key: modman_key.clone() + }, + MasterUserConfig { + id: inference_engine_uid.clone(), + api_key: inference_engine_key.clone() + } + ) } } diff --git a/clover-hub/src/server/inference_engine/mod.rs b/clover-hub/src/server/inference_engine/mod.rs index 956bcfe..93110d9 100644 --- a/clover-hub/src/server/inference_engine/mod.rs +++ b/clover-hub/src/server/inference_engine/mod.rs @@ -1,3 +1,7 @@ -pub async fn inference_engine_main() { +use std::sync::Arc; +use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; +use super::evtbuzz::models::{IPCMessageWithId, Store}; + +pub async fn inference_engine_main(ipc_tx: UnboundedSender, ipc_rx: UnboundedReceiver, store: Arc) { } diff --git a/clover-hub/src/server/mod.rs b/clover-hub/src/server/mod.rs index 2219979..f6eaae8 100644 --- a/clover-hub/src/server/mod.rs +++ b/clover-hub/src/server/mod.rs @@ -1,16 +1,15 @@ -mod evtbuzz; -mod arbiter; -mod renderer; -mod modman; -mod inference_engine; -mod appd; +pub mod evtbuzz; +pub mod arbiter; +pub mod renderer; +pub mod modman; +pub mod inference_engine; +pub mod appd; use std::sync::Arc; use appd::appd_main; use tokio::sync::mpsc; use log::{debug, error, info}; use evtbuzz::models::Store; -use uuid::Uuid; use evtbuzz::models::IPCMessageWithId; use evtbuzz::listener::evtbuzz_listener; use arbiter::arbiter_main; @@ -30,12 +29,11 @@ fn handle_ipc_send(sender: &mpsc::UnboundedSender, msg: IPCMes pub async fn server_main(port: u16) { info!("Running Backend Server Threads..."); - let master_user_id = Uuid::new_v4().to_string(); - let store = Store::new_with_set_master_user(master_user_id.clone()).await; - debug!("Master user id: {}, primary api key: {}", master_user_id.clone(), store.users.lock().await.get(&master_user_id.clone()).unwrap().api_keys.get(0).unwrap()); + // TODO: Pass creds to each core service. + let (store, master_user_config, core_users_config) = Store::new_configured_store().await; + let master_user_id = master_user_config.id.clone(); + debug!("Master user id: {}, primary api key: {}", master_user_id.clone(), master_user_config.api_key.clone()); - // Start EVTBuzz - // TODO: Rename to EVTBuzz let (evtbuzz_from_tx, mut evtbuzz_from_rx) = mpsc::unbounded_channel::(); let (evtbuzz_to_tx, evtbuzz_to_rx) = mpsc::unbounded_channel::(); let evtbuzz_port = Arc::new(port); @@ -44,38 +42,56 @@ pub async fn server_main(port: u16) { evtbuzz_listener(*evtbuzz_port.to_owned(), evtbuzz_from_tx, evtbuzz_to_rx, evtbuzz_store.clone()).await; }); - let ipc_from_listener_dispatch = tokio::task::spawn(async move { - while let Some(msg) = evtbuzz_from_rx.recv().await { - // TODO: Add all IPC channels to this list. - handle_ipc_send(&evtbuzz_to_tx, msg, "clover::server::listener".to_string()); - } - }); - // Start Arbiter + let (arbiter_from_tx, mut arbiter_from_rx) = mpsc::unbounded_channel::(); + let (arbiter_to_tx, arbiter_to_rx) = mpsc::unbounded_channel::(); + let arbiter_store = Arc::new(store.clone()); let arbiter_handler = tokio::task::spawn(async move { - arbiter_main().await; + arbiter_main(arbiter_from_tx, arbiter_from_rx, arbiter_store.clone()).await; }); // Start Renderer + let (renderer_from_tx, mut renderer_from_rx) = mpsc::unbounded_channel::(); + let (renderer_to_tx, renderer_to_rx) = mpsc::unbounded_channel::(); + let renderer_store = Arc::new(store.clone()); let renderer_handler = tokio::task::spawn(async move { - renderer_main().await; + renderer_main(renderer_from_tx, renderer_to_rx, renderer_store.clone()).await; }); // Start ModMan + let (modman_from_tx, mut modman_from_rx) = mpsc::unbounded_channel::(); + let (modman_to_tx, modman_to_rx) = mpsc::unbounded_channel::(); + let modman_store = Arc::new(store.clone()); let modman_handler = tokio::task::spawn(async move { - modman_main().await; + modman_main(modman_from_tx, modman_to_rx, modman_store.clone()).await; }); // Start InferenceEngine + let (inference_engine_from_tx, mut inference_engine_from_rx) = mpsc::unbounded_channel::(); + let (inference_engine_to_tx, inference_engine_to_rx) = mpsc::unbounded_channel::(); + let inference_engine_store = Arc::new(store.clone()); let inference_engine_handler = tokio::task::spawn(async move { - inference_engine_main().await; + inference_engine_main(inference_engine_from_tx, inference_engine_to_rx, inference_engine_store.clone()).await; }); // Start AppDaemon + let (appd_from_tx, mut appd_from_rx) = mpsc::unbounded_channel::(); + let (appd_to_tx, appd_to_rx) = mpsc::unbounded_channel::(); + let appd_store = Arc::new(store.clone()); let appd_handler = tokio::task::spawn(async move { - appd_main().await; + appd_main(appd_from_tx, appd_to_rx, appd_store.clone()).await; }); + let ipc_from_listener_dispatch = tokio::task::spawn(async move { + while let Some(msg) = evtbuzz_from_rx.recv().await { + // TODO: Add all IPC channels to this list. + handle_ipc_send(&evtbuzz_to_tx, msg.clone(), "clover::server::evtbuzz".to_string()); + handle_ipc_send(&renderer_to_tx, msg.clone(), "clover::server::renderer".to_string()); + } + }); + + // TODO: Figure out routing between all threads... send all messages to EvtBuzz and have it send events out? + futures::future::join_all(vec![ evtbuzz_handler, ipc_from_listener_dispatch, diff --git a/clover-hub/src/server/modman/mod.rs b/clover-hub/src/server/modman/mod.rs index 2d2f57c..c7f7986 100644 --- a/clover-hub/src/server/modman/mod.rs +++ b/clover-hub/src/server/modman/mod.rs @@ -1,3 +1,7 @@ -pub async fn modman_main() { +use std::sync::Arc; +use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; +use super::evtbuzz::models::{IPCMessageWithId, Store}; + +pub async fn modman_main(ipc_tx: UnboundedSender, ipc_rx: UnboundedReceiver, store: Arc) { } diff --git a/clover-hub/src/server/renderer/mod.rs b/clover-hub/src/server/renderer/mod.rs index 8171ef4..6453d74 100644 --- a/clover-hub/src/server/renderer/mod.rs +++ b/clover-hub/src/server/renderer/mod.rs @@ -1,3 +1,7 @@ -pub async fn renderer_main() { - +use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; +use std::sync::Arc; +use crate::server::evtbuzz::models::{IPCMessageWithId, Store}; + +pub async fn renderer_main(ipc_tx: UnboundedSender, ipc_rx: UnboundedReceiver, store: Arc) { + // TODO: Setup EGL ctx for each display we're handling. } diff --git a/clover-hub/src/utils.rs b/clover-hub/src/utils.rs index c393508..58e495e 100644 --- a/clover-hub/src/utils.rs +++ b/clover-hub/src/utils.rs @@ -1,12 +1,16 @@ -use std::hash::{DefaultHasher, Hash, Hasher}; +use std::{hash::{DefaultHasher, Hash, Hasher}, ops::Deref}; use api_key::types::{ApiKeyResults, Default, StringGenerator}; +use async_recursion::async_recursion; use chrono::prelude::{DateTime, Utc}; +use futures::{future::BoxFuture, FutureExt}; +use uuid::Uuid; +use crate::server::evtbuzz::models::Store; +/// formats like "2001-07-08T00:34:60.026490+09:30" pub fn iso8601(st: &std::time::SystemTime) -> String { let dt: DateTime = st.clone().into(); format!("{}", dt.format("%+")) - // formats like "2001-07-08T00:34:60.026490+09:30" } pub fn calculate_hash(t: &T) -> u64 { @@ -15,6 +19,7 @@ pub fn calculate_hash(t: &T) -> u64 { s.finish() } +/// Generates a new api key. Please use [`gen_api_key_with_check`] to ensure that its' unique! pub fn gen_api_key() -> String { let options = StringGenerator { prefix: "CLOVER:".to_string(), @@ -28,3 +33,41 @@ pub fn gen_api_key() -> String { ApiKeyResults::StringArray(res_vec) => res_vec.join(""), } } + +#[async_recursion] +async fn gen_api_key_with_check_with_set_key(store: &Store, src_key: String) -> String { + let mut key = src_key; + + match store.api_keys.lock().await.get(&key.clone()) { + Some(_) => { + key = gen_api_key_with_check_with_set_key(store, gen_api_key()).await; + }, + None => {} + } + + key +} + +/// Generates a new API key after checking that it is not currently in the Store. +pub async fn gen_api_key_with_check(store: &Store) -> String { + gen_api_key_with_check_with_set_key(store, gen_api_key()).await +} + +#[async_recursion] +async fn gen_uid_with_check_with_set_key(store: &Store, src_key: String) -> String { + let mut key = src_key; + + match store.api_keys.lock().await.get(&key.clone()) { + Some(_) => { + key = gen_api_key_with_check_with_set_key(store, Uuid::new_v4().to_string()).await; + }, + None => {} + } + + key +} + +/// Generates a new UID after checking that it is currently not in the Store. +pub async fn gen_uid_with_check(store: &Store) -> String { + gen_uid_with_check_with_set_key(store, Uuid::new_v4().to_string()).await +} diff --git a/docs/docs/clover-hub/server/arbiter/master-users.md b/docs/docs/clover-hub/server/arbiter/master-users.md new file mode 100644 index 0000000..96ab848 --- /dev/null +++ b/docs/docs/clover-hub/server/arbiter/master-users.md @@ -0,0 +1,11 @@ +# Master Users + +| Name | Allowed Events From | Allowed Events To | Type | +|-|-|-|-| +| Master | `[".*"]` | `[".*"]` | `com.reboot-codes.clover.master` | +| EvtBuzz | `` | `` | `com.reboot-codes.clover.evtbuzz`| +| Arbiter | `` | `` | `com.reboot-codes.clover.arbiter` | +| Renderer | `` | `` | `com.reboot-codes.clover.renderer` | +| AppD | `` | `` | `com.reboot-codes.clover.appd` | +| ModMan | `` | `` | `com.reboot-codes.clover.modman` | +| Inference Engine | `` | `` | `com.reboot-codes.inference-engine` |