diff --git a/.earthlyignore b/.earthlyignore new file mode 100644 index 0000000..54c4968 --- /dev/null +++ b/.earthlyignore @@ -0,0 +1,11 @@ +.git/ +.gitignore +.gitlab-ci.yml +.idea/ +.rustfmt.toml +docker/ +target/ +.github/ +readme.md +*.dll +*.pdb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..12f4c6d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: Earthly + +on: + push: + pull_request: + +permissions: + contents: read + packages: write + +jobs: + build: + runs-on: ubuntu-latest + env: + FORCE_COLOR: 1 + steps: + - uses: earthly/actions-setup@v1 + with: + version: v0.8.0 + - uses: actions/checkout@v4 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Run build + if: ${{ github.event_name == 'push' && github.ref_name == github.event.repository.default_branch }} + run: earthly --ci --push -a '+addon/*' ./ + - name: Run build + if: ${{ !(github.event_name == 'push' && github.ref_name == github.event.repository.default_branch) }} + run: earthly --ci -a '+addon/*' ./ + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: addon + path: | + ./*.dll + ./*.pdb diff --git a/.gitignore b/.gitignore index 332008f..28d3e78 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /target **/*.rs.bk .idea/ +*.dll +*.pdb diff --git a/Cargo.lock b/Cargo.lock index 7ff0146..dc01b04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,39 +2,47 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_system_properties" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7ed72e1635e121ca3e79420540282af22da58be50de153d36f81ddc6b83aa9e" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" dependencies = [ "libc", ] [[package]] name = "arcdps" -version = "0.8.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e65a52ffa23ef3d47874967988fb55f4d9b0086e68681858b3ceb7181dbd4fc" +checksum = "66407109ed9b8bdbb15184796cd89196401b27034fcf7c415796b47f20d07805" dependencies = [ "arcdps-imgui", "arcdps_codegen", "chrono", "log", "once_cell", + "serde", ] [[package]] name = "arcdps-bhud" -version = "0.3.1" +version = "2.0.0" dependencies = [ "arcdps", + "async-broadcast", + "bincode", "futures", - "once_cell", - "parking_lot 0.10.2", - "piper", + "log", + "serde", "smol", - "winapi", + "windows_exe_info", ] [[package]] @@ -44,8 +52,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12f578f5194d5eb98de932684b4d2cdd1dcb8efdb97c2c0b2f57f79d262b866c" dependencies = [ "arcdps-imgui-sys", - "bitflags", - "parking_lot 0.11.2", + "bitflags 1.3.2", + "parking_lot", ] [[package]] @@ -60,44 +68,169 @@ dependencies = [ [[package]] name = "arcdps_codegen" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cafec678bbe0c1fb3f3dd13324b0c188b13dd57494d741fde9bf7c47ed80b85" +checksum = "476c49a9b0b6cad5aa7d534fc461e83d44984667f4570f8286633fe857742f2c" dependencies = [ "paste", "proc-macro2", "quote", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "async-broadcast" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cd0e2e25ea8e5f7e9df04578dc6cf5c83577fd09b1a46aaf5c85e1c33f2a7e" +dependencies = [ + "event-listener", + "event-listener-strategy", + "futures-core", + "pin-project-lite", ] [[package]] name = "async-channel" -version = "1.7.1" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a" +dependencies = [ + "concurrent-queue", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14485364214912d3b19cc3435dde4df66065127f05fa0d75c712f36f12c2f28" +checksum = "c8828ec6e544c02b0d6691d21ed9f9218d0384a82542855073c2a3f58304aaf0" dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "slab", +] + +[[package]] +name = "async-fs" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a" +dependencies = [ + "async-lock", + "blocking", + "futures-lite", +] + +[[package]] +name = "async-io" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6baa8f0178795da0e71bc42c9e5d13261aac7ee549853162e66a241ba17964" +dependencies = [ + "async-lock", + "cfg-if", "concurrent-queue", + "futures-io", + "futures-lite", + "parking", + "polling", + "rustix", + "slab", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "async-lock" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" +dependencies = [ + "event-listener", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-net" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b948000fad4873c1c9339d60f2623323a0cfd3816e5181033c6a5cb68b2accf7" +dependencies = [ + "async-io", + "blocking", + "futures-lite", +] + +[[package]] +name = "async-process" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7eda79bbd84e29c2b308d1dc099d7de8dcc7035e48f4bf5dc4a531a44ff5e2a" +dependencies = [ + "async-channel", + "async-io", + "async-lock", + "async-signal", + "async-task", + "blocking", + "cfg-if", "event-listener", + "futures-lite", + "rustix", + "tracing", + "windows-sys 0.52.0", +] + +[[package]] +name = "async-signal" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "794f185324c2f00e771cd9f1ae8b5ac68be2ca7abb129a87afd6e86d228bc54d" +dependencies = [ + "async-io", + "async-lock", + "atomic-waker", + "cfg-if", "futures-core", + "futures-io", + "rustix", + "signal-hook-registry", + "slab", + "windows-sys 0.52.0", ] [[package]] name = "async-task" -version = "3.0.0" +version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17772156ef2829aadc587461c7753af20b7e8db1529bc66855add962a3b35d3" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "atomic-waker" -version = "1.0.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "bincode" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] [[package]] name = "bitflags" @@ -105,43 +238,36 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + [[package]] name = "blocking" -version = "0.4.7" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2468ff7bf85066b4a3678fede6fe66db31846d753ff0adfbfab2c6a6e81612b" +checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" dependencies = [ "async-channel", - "atomic-waker", + "async-task", + "futures-io", "futures-lite", - "once_cell", - "parking 1.0.6", - "waker-fn", + "piper", ] [[package]] name = "bumpalo" -version = "3.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" - -[[package]] -name = "cache-padded" -version = "1.2.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "cc" -version = "1.0.73" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" - -[[package]] -name = "cfg-if" -version = "0.1.10" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" [[package]] name = "cfg-if" @@ -151,80 +277,108 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chlorine" -version = "1.0.10" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75476fe966a8af7c0ceae2a3e514afa87d4451741fcdfab8bfaa07ad301842ec" +checksum = "1e10e7569f6ca78ef7664d7d651115172d4875c4410c050306bccde856a99a49" [[package]] name = "chrono" -version = "0.4.21" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f725f340c3854e3cb3ab736dc21f0cca183303acea3b3ffec30f141503ac8eb" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ + "android-tzdata", "iana-time-zone", "js-sys", - "num-integer", "num-traits", - "time", + "serde", "wasm-bindgen", - "winapi", + "windows-targets 0.52.5", ] [[package]] -name = "cloudabi" -version = "0.0.3" +name = "concurrent-queue" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" dependencies = [ - "bitflags", + "crossbeam-utils", ] [[package]] -name = "concurrent-queue" -version = "1.2.4" +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "embed-resource" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c" +checksum = "c6985554d0688b687c5cb73898a34fbe3ad6c24c58c238a4d91d5e840670ee9d" dependencies = [ - "cache-padded", + "cc", + "memchr", + "rustc_version", + "toml", + "vswhom", + "winreg", ] [[package]] -name = "core-foundation-sys" -version = "0.8.3" +name = "equivalent" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] -name = "crossbeam-utils" -version = "0.7.2" +name = "errno" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "lazy_static", + "libc", + "windows-sys 0.52.0", ] [[package]] name = "event-listener" -version = "2.5.3" +version = "5.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] [[package]] -name = "fastrand" -version = "1.8.0" +name = "event-listener-strategy" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" dependencies = [ - "instant", + "event-listener", + "pin-project-lite", ] +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + [[package]] name = "futures" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -237,9 +391,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -247,15 +401,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -264,53 +418,51 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" -version = "0.1.11" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97999970129b808f0ccba93211201d431fcc12d7e1ffae03a61b5cedd1a7ced2" +checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ "fastrand", "futures-core", "futures-io", - "memchr", - "parking 2.0.0", - "pin-project-lite 0.1.12", - "waker-fn", + "parking", + "pin-project-lite", ] [[package]] name = "futures-macro" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.66", ] [[package]] name = "futures-sink" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.21" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -319,68 +471,91 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite", "pin-utils", "slab", ] +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + [[package]] name = "iana-time-zone" -version = "0.1.44" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf7d67cf4a22adc5be66e75ebdf769b3f2ea032041437a7061f97a63dad4b" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", + "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows-core", ] [[package]] -name = "instant" -version = "0.1.12" +name = "iana-time-zone-haiku" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ - "cfg-if 1.0.0", + "cc", ] [[package]] -name = "js-sys" -version = "0.3.59" +name = "indexmap" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ - "wasm-bindgen", + "equivalent", + "hashbrown", ] [[package]] -name = "lazy_static" -version = "1.4.0" +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "js-sys" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] [[package]] name = "libc" -version = "0.2.131" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04c3b4822ccebfa39c02fc03d1534441b22ead323fa0f48bb7ddd8e6ba076a40" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] -name = "lock_api" -version = "0.3.4" +name = "linux-raw-sys" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" -dependencies = [ - "scopeguard", -] +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" -version = "0.4.7" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -388,65 +563,36 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if 1.0.0", -] +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] +checksum = "6d0d8b92cd8358e8d229c11df9358decae64d137c5be540952c5ca7b25aea768" [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "once_cell" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" - -[[package]] -name = "parking" -version = "1.0.6" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cb300f271742d4a2a66c01b6b2fa0c83dfebd2e0bf11addb879a3547b4ed87c" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "parking" -version = "2.0.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" - -[[package]] -name = "parking_lot" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" -dependencies = [ - "lock_api 0.3.4", - "parking_lot_core 0.7.2", -] +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "parking_lot" @@ -455,55 +601,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", - "lock_api 0.4.7", - "parking_lot_core 0.8.5", + "lock_api", + "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.7.2" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall 0.1.57", - "smallvec", - "winapi", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" -dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "instant", "libc", - "redox_syscall 0.2.16", + "redox_syscall", "smallvec", "winapi", ] [[package]] name = "paste" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9423e2b32f7a043629287a536f21951e8c6a82482d0acb1eeebfc90bc2225b22" - -[[package]] -name = "pin-project-lite" -version = "0.1.12" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -513,113 +639,177 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "piper" -version = "0.1.3" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01608bfa680dafb103f9207fa944facf572e4e3e708d10de19a0d0c3d36e5f18" +checksum = "ae1d5c74c9876f070d3e8fd503d748c7d974c3e48da8f41350fa5222ef9b4391" dependencies = [ - "crossbeam-utils", + "atomic-waker", + "fastrand", "futures-io", - "futures-sink", - "futures-util", +] + +[[package]] +name = "polling" +version = "3.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6a007746f34ed64099e88783b0ae369eaa3da6392868ba262e2af9b8fbaea1" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi", + "pin-project-lite", + "rustix", + "tracing", + "windows-sys 0.52.0", ] [[package]] name = "proc-macro2" -version = "1.0.43" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.21" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.1.57" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] [[package]] -name = "redox_syscall" -version = "0.2.16" +name = "rustc_version" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "bitflags", + "semver", ] [[package]] -name = "scoped-tls" -version = "1.0.0" +name = "rustix" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "serde" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "serde_spanned" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +dependencies = [ + "serde", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] [[package]] name = "slab" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "smallvec" -version = "1.9.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smol" -version = "0.1.18" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "620cbb3c6e34da57d3a248cda0cd01cd5848164dc062e764e65d06fe3ea7aed5" +checksum = "e635339259e51ef85ac7aa29a1cd991b957047507288697a690e80ab97d07cad" dependencies = [ - "async-task", + "async-channel", + "async-executor", + "async-fs", + "async-io", + "async-lock", + "async-net", + "async-process", "blocking", - "concurrent-queue", - "fastrand", - "futures-io", - "futures-util", - "libc", - "once_cell", - "scoped-tls", - "slab", - "socket2", - "wepoll-sys-stjepang", - "winapi", + "futures-lite", ] [[package]] -name = "socket2" -version = "0.3.19" +name = "syn" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "cfg-if 1.0.0", - "libc", - "winapi", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] name = "syn" -version = "1.0.99" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", @@ -627,64 +817,111 @@ dependencies = [ ] [[package]] -name = "time" -version = "0.1.44" +name = "toml" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" dependencies = [ - "libc", - "wasi", - "winapi", + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-core", ] +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" + [[package]] name = "unicode-ident" -version = "1.0.3" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] -name = "waker-fn" -version = "1.1.0" +name = "vswhom" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" +checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b" +dependencies = [ + "libc", + "vswhom-sys", +] [[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +name = "vswhom-sys" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +checksum = "d3b17ae1f6c8a2b28506cd96d412eebf83b4a0ff2cbefeeb952f2f9dfa44ba18" +dependencies = [ + "cc", + "libc", +] [[package]] name = "wasm-bindgen" -version = "0.2.82" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.82" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.66", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.82" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -692,31 +929,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.82" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.66", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a" - -[[package]] -name = "wepoll-sys-stjepang" -version = "1.0.8" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fdfbb03f290ca0b27922e8d48a0997b4ceea12df33269b9f75e713311eb178d" -dependencies = [ - "cc", -] +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "winapi" @@ -739,3 +967,179 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.5", +] + +[[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.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", +] + +[[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.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] + +[[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.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[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.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_exe_info" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7e7bfd02caf5cd98a197cec15c852685c8c42605f91d7be3083541a0b40a7ff" +dependencies = [ + "embed-resource", +] + +[[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.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[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.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[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.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[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.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[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.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "winnow" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] diff --git a/Cargo.toml b/Cargo.toml index 4046e84..8d5f2cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,24 +1,32 @@ [package] name = "arcdps-bhud" -version = "0.3.1" +version = "2.0.0" authors = ["Greaka "] edition = "2018" [dependencies] -arcdps = "0.8.0" -smol = "0.1.10" -piper = "0.1.2" -futures = "0.3.5" -parking_lot = "0.10.2" -once_cell = "1.4.0" +smol = "2.0.0" +async-broadcast = "0.7.1" +futures = "0.3.30" +bincode = "1.3.3" +log = "0.4.21" -[dependencies.winapi] -version = "0.3.7" -features = ["ntdef", "minwindef"] +[dependencies.arcdps] +version = "0.10.1" +features = ["serde"] + +[dependencies.serde] +version = "1.0.203" +features = ["derive"] + +[build-dependencies] +windows_exe_info = "0.4.2" [lib] crate-type = ["cdylib"] [profile.release] codegen-units = 1 -lto = true +lto = 'thin' +strip = true +debug = true diff --git a/Earthfile b/Earthfile new file mode 100644 index 0000000..d968af8 --- /dev/null +++ b/Earthfile @@ -0,0 +1,59 @@ +VERSION 0.8 +IMPORT github.com/Jake-Shadle/xwin:0871d7dbbbf36839f3cba53de8879851670a6246 AS xwin + +builder: + FROM xwin+xwin + + RUN mkdir /build + WORKDIR /build + + RUN apt-get update && apt-get install --no-install-recommends -y jq + COPY --keep-ts --if-exists rust-toolchain.toml ./ + IF [ ! -f ./rust-toolchain.toml ] + RUN rustup default stable + END + RUN rustup target add x86_64-pc-windows-msvc + RUN ln $CARGO_HOME/bin/* /usr/bin/ + + SAVE IMAGE --cache-hint builder + +prefetch: + FROM +builder + + ARG --required cargo_home_cache_id + ARG --required CARGO_REGISTRIES_KTRA_INDEX + COPY --keep-ts --dir --if-exists .cargo ./ + COPY --keep-ts Cargo.toml ./ + COPY --keep-ts --if-exists Cargo.lock ./ + + RUN mkdir -p src && touch src/lib.rs + + RUN --mount=type=cache,mode=0777,id=$cargo_home_cache_id,sharing=shared,target=$CARGO_HOME \ + cargo --color=always fetch --target x86_64-pc-windows-msvc + + SAVE IMAGE --cache-hint prefetch + +addon: + ARG cargo_home_cache_id="earthly-cargo-cache" + ARG CARGO_REGISTRIES_KTRA_INDEX = https://git.0x0f.net/0x0f/ktra-crates.git + FROM --pass-args +prefetch + + ARG EARTHLY_TARGET_PROJECT_NO_TAG + ARG EARTHLY_TARGET_NAME + ARG target_cache_id="${EARTHLY_CARGO_HOME_CACHE_ID}#${EARTHLY_TARGET_PROJECT_NO_TAG}#${EARTHLY_TARGET_NAME}" + ARG target_folder="target/x86_64-pc-windows-msvc/release" + + ARG CARGO_TARGET_NAME = $(cargo metadata -q --no-deps --filter-platform x86_64-pc-windows-msvc | jq -r '.packages[0].name' | sed 's/-/_/g') + ARG CARGO_EXTRA_ARGS + + COPY --keep-ts --dir . ./ + RUN --mount=type=cache,mode=0777,id=$cargo_home_cache_id,sharing=shared,target=$CARGO_HOME \ + --mount=type=cache,mode=0777,id=$target_cache_id,sharing=locked,target=target \ + cargo build --release --color=always --target x86_64-pc-windows-msvc ${CARGO_EXTRA_ARGS} && \ + (rm ${CARGO_TARGET_NAME}.dll || true) && \ + (rm ${CARGO_TARGET_NAME}.pdb || true) && \ + cp ${target_folder}/${CARGO_TARGET_NAME}.dll ./ && \ + (cp ${target_folder}/${CARGO_TARGET_NAME}.pdb ./ || true) + + SAVE ARTIFACT ${CARGO_TARGET_NAME}.dll + SAVE ARTIFACT --if-exists ${CARGO_TARGET_NAME}.pdb diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 5a383f2..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,83 +0,0 @@ -# Based on the "trust" template v0.1.2 -# https://github.com/japaric/trust/tree/v0.1.2 - -environment: - global: - # TODO This is the Rust channel that build jobs will use by default but can be - # overridden on a case by case basis down below - RUST_VERSION: stable - - # TODO Update this to match the name of your project. - CRATE_NAME: arcdps-bhud - - # TODO These are all the build jobs. Adjust as necessary. Comment out what you - # don't need - matrix: - # MinGW - - TARGET: x86_64-pc-windows-gnu - - # MSVC - - TARGET: x86_64-pc-windows-msvc - - # Testing other channels - - TARGET: x86_64-pc-windows-gnu - RUST_VERSION: nightly - - TARGET: x86_64-pc-windows-msvc - RUST_VERSION: nightly - -install: - - ps: >- - If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') { - $Env:PATH += ';C:\msys64\mingw64\bin' - } ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') { - $Env:PATH += ';C:\msys64\mingw32\bin' - } - - curl -sSf -o rustup-init.exe https://win.rustup.rs/ - - rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION% - - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin - - rustc -Vv - - cargo -V - -# TODO This is the "test phase", tweak it as you see fit -test_script: - # we don't run the "test phase" when doing deploys - - if [%APPVEYOR_REPO_TAG%]==[false] ( - cargo build --target %TARGET% && - cargo build --target %TARGET% --release - ) - -before_deploy: - # TODO Update this to build the artifacts that matter to you - - cargo rustc --target %TARGET% --release --lib - - ps: ci\before_deploy.ps1 - -deploy: - artifact: /.*\.zip/ - # TODO update `auth_token.secure` - # - Create a `public_repo` GitHub token. Go to: https://github.com/settings/tokens/new - # - Encrypt it. Go to https://ci.appveyor.com/tools/encrypt - # - Paste the output down here - auth_token: - secure: LPPsrvyTKYDRI7NjSDHZRV8QpqCTupiuyHDaDKQorLpwvYU7FnRNCni9MleCvCsf - description: '' - on: - # TODO Here you can pick which targets will generate binary releases - # In this example, there are some targets that are tested using the stable - # and nightly channels. This condition makes sure there is only one release - # for such targets and that's generated using the stable channel - RUST_VERSION: stable - appveyor_repo_tag: true - provider: GitHub - -cache: - - C:\Users\appveyor\.cargo\registry - - target - -branches: - only: - # Release tags - - /^v\d+\.\d+\.\d+.*$/ - - master - -# Building is done in the test phase, so we disable Appveyor's build phase. -build: false \ No newline at end of file diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..63bbcb1 --- /dev/null +++ b/build.rs @@ -0,0 +1,6 @@ +fn main() { + let mut info = windows_exe_info::versioninfo::VersionInfo::from_cargo_env(); + info.file_info[0].original_filename = + format!("{}.dll", std::env::var("CARGO_PKG_NAME").unwrap()).into(); + info.link().unwrap(); +} diff --git a/ci/before_deploy.ps1 b/ci/before_deploy.ps1 deleted file mode 100644 index 546a2ae..0000000 --- a/ci/before_deploy.ps1 +++ /dev/null @@ -1,23 +0,0 @@ -# This script takes care of packaging the build artifacts that will go in the -# release zipfile - -$SRC_DIR = $PWD.Path -$STAGE = [System.Guid]::NewGuid().ToString() - -Set-Location $ENV:Temp -New-Item -Type Directory -Name $STAGE -Set-Location $STAGE - -$ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip" - -# TODO Update this to package the right artifacts -Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\arcdps_bhud.dll" '.\' - -7z a "$ZIP" * - -Push-AppveyorArtifact "$ZIP" - -Remove-Item *.* -Force -Set-Location .. -Remove-Item $STAGE -Set-Location $SRC_DIR \ No newline at end of file diff --git a/src/arcdps.rs b/src/arcdps.rs index 4e0814b..01868bd 100644 --- a/src/arcdps.rs +++ b/src/arcdps.rs @@ -8,4 +8,6 @@ arcdps::arcdps_export! { imgui: imgui, combat: combat, combat_local: combat_local, + unofficial_extras_squad_update: squad, + unofficial_extras_chat_message: message, } diff --git a/src/executor.rs b/src/executor.rs deleted file mode 100644 index ac28cf9..0000000 --- a/src/executor.rs +++ /dev/null @@ -1,26 +0,0 @@ -use once_cell::sync::Lazy; -use parking_lot::Mutex; -use piper::Sender; -use std::thread; - -static SHUTDOWN: Lazy>>> = Lazy::new(|| Mutex::new(None)); - -pub fn setup() { - // A channel that sends the SHUTDOWN signal. - let (s, r) = piper::chan::<()>(0); - { - let mut shutdown = SHUTDOWN.lock(); - *shutdown = Some(s); - } - - // Create an executor thread pool. - for _ in 0..3 { - // Spawn an executor thread that waits for the SHUTDOWN signal. - let r = r.clone(); - thread::spawn(move || smol::run(r.recv())); - } -} - -pub fn teardown() { - SHUTDOWN.lock().take(); -} diff --git a/src/exports/combat.rs b/src/exports/combat.rs index 2101e90..a27fb4f 100644 --- a/src/exports/combat.rs +++ b/src/exports/combat.rs @@ -1,164 +1,71 @@ -use crate::pubsub::dispatch; -use arcdps::{Agent, AgentOwned, CombatEvent}; -use smol::Task; +use arcdps::{Agent, CombatEvent}; +use serde::Serialize; -pub fn cbt( - ev: Option<&CombatEvent>, - src: Option, - dst: Option, - skillname: Option<&'static str>, - id: u64, - revision: u64, -) { - spawn_cbt(ev, src, dst, skillname, id, revision, 2); -} +use crate::{ + exports::{Message, MessageId}, + pubsub::dispatch, +}; -pub fn cbt_local( - ev: Option<&CombatEvent>, +pub fn cbt<'a>( + ev: Option<&'a CombatEvent>, src: Option, dst: Option, - skillname: Option<&'static str>, + skillname: Option<&'a str>, id: u64, revision: u64, ) { - spawn_cbt(ev, src, dst, skillname, id, revision, 3); + dispatch(&CombatMessage(CombatMessageInner { + ev, + src, + dst, + skillname, + id, + revision, + })) + .ok(); } -fn spawn_cbt( - ev: Option<&CombatEvent>, +pub fn cbt_local<'a>( + ev: Option<&'a CombatEvent>, src: Option, dst: Option, - skillname: Option<&'static str>, + skillname: Option<&'a str>, id: u64, revision: u64, - indicator: u8, ) { - Task::spawn(cbt_with_type( - ev.copied(), - src.map(|x| x.into()), - dst.map(|x| x.into()), + dispatch(&CombatMessageLocal(CombatMessageInner { + ev, + src, + dst, skillname, id, revision, - indicator, - )) - .detach(); + })) + .ok(); } -async fn cbt_with_type( - ev: Option, - src: Option, - dst: Option, - skillname: Option<&'static str>, - id: u64, - revision: u64, - indicator: u8, -) { - let mut message = Vec::new(); - message.push(indicator); // indicator for local/area combat message - add_bytes(&mut message, ev, src, dst, skillname, id, revision); - dispatch(message).await; -} +#[derive(Serialize)] +#[repr(transparent)] +pub struct CombatMessage<'a>(pub CombatMessageInner<'a>); -fn add_bytes( - message: &mut Vec, - ev: Option, - src: Option, - dst: Option, - skillname: Option<&str>, - id: u64, - revision: u64, -) { - let mut messages = 0; - if let Some(ev) = ev { - messages |= 1; - let mut bytes = get_ev_bytes(&ev); - message.append(&mut bytes); - }; - if let Some(ag) = src { - messages |= 1 << 1; - let mut bytes = get_ag_bytes(&ag); - message.append(&mut bytes); - }; - if let Some(ag) = dst { - messages |= 1 << 2; - let mut bytes = get_ag_bytes(&ag); - message.append(&mut bytes); - }; - if let Some(name) = skillname { - messages |= 1 << 3; - let bytes = name.as_bytes(); - let mut bytes = [&bytes.len().to_le_bytes(), bytes].concat(); - message.append(&mut bytes); - }; - message.insert(1, messages); - message.append(&mut id.to_le_bytes().to_vec()); - message.append(&mut revision.to_le_bytes().to_vec()); +impl Message for CombatMessage<'_> { + const MESSAGE_ID: MessageId = MessageId::Combat; } -fn get_ev_bytes(ev: &CombatEvent) -> Vec { - ev.time - .to_le_bytes() - .iter() - .chain(ev.src_agent.to_le_bytes().iter()) - .chain(ev.dst_agent.to_le_bytes().iter()) - .chain(ev.value.to_le_bytes().iter()) - .chain(ev.buff_dmg.to_le_bytes().iter()) - .chain(ev.overstack_value.to_le_bytes().iter()) - .chain(ev.skill_id.to_le_bytes().iter()) - .chain(ev.src_instance_id.to_le_bytes().iter()) - .chain(ev.dst_instance_id.to_le_bytes().iter()) - .chain(ev.src_master_instance_id.to_le_bytes().iter()) - .chain(ev.dst_master_instance_id.to_le_bytes().iter()) - .chain(ev.iff.to_le_bytes().iter()) - .chain(ev.buff.to_le_bytes().iter()) - .chain(ev.result.to_le_bytes().iter()) - .chain(ev.is_activation.to_le_bytes().iter()) - .chain(ev.is_buff_remove.to_le_bytes().iter()) - .chain(ev.is_ninety.to_le_bytes().iter()) - .chain(ev.is_fifty.to_le_bytes().iter()) - .chain(ev.is_moving.to_le_bytes().iter()) - .chain(ev.is_statechange.to_le_bytes().iter()) - .chain(ev.is_flanking.to_le_bytes().iter()) - .chain(ev.is_shields.to_le_bytes().iter()) - .chain(ev.is_off_cycle.to_le_bytes().iter()) - .chain(ev.pad61.to_le_bytes().iter()) - .chain(ev.pad62.to_le_bytes().iter()) - .chain(ev.pad63.to_le_bytes().iter()) - .chain(ev.pad64.to_le_bytes().iter()) - .cloned() - .collect::>() +#[derive(Serialize)] +#[repr(transparent)] +pub struct CombatMessageLocal<'a>(pub CombatMessageInner<'a>); + +impl Message for CombatMessageLocal<'_> { + const MESSAGE_ID: MessageId = MessageId::CombatLocal; } -fn get_ag_bytes(ag: &AgentOwned) -> Vec { - let (string_length, name_bytes) = if let Some(name) = &ag.name { - let bytes = name.as_bytes(); - (bytes.len(), Some(bytes)) - } else { - (0, None) - }; - if let Some(name_bytes) = name_bytes { - string_length - .to_le_bytes() - .iter() - .chain(name_bytes.iter()) - .chain(ag.id.to_le_bytes().iter()) - .chain(ag.prof.to_le_bytes().iter()) - .chain(ag.elite.to_le_bytes().iter()) - .chain(ag.self_.to_le_bytes().iter()) - .chain(ag.team.to_le_bytes().iter()) - .cloned() - .collect() - } else { - string_length - .to_le_bytes() - .iter() - .chain(ag.id.to_le_bytes().iter()) - .chain(ag.prof.to_le_bytes().iter()) - .chain(ag.elite.to_le_bytes().iter()) - .chain(ag.self_.to_le_bytes().iter()) - .chain(ag.team.to_le_bytes().iter()) - .cloned() - .collect() - } +#[derive(Serialize)] +pub struct CombatMessageInner<'a> { + pub ev: Option<&'a CombatEvent>, + pub src: Option>, + pub dst: Option>, + pub skillname: Option<&'a str>, + pub id: u64, + pub revision: u64, } diff --git a/src/exports/extras.rs b/src/exports/extras.rs new file mode 100644 index 0000000..547ac6f --- /dev/null +++ b/src/exports/extras.rs @@ -0,0 +1,28 @@ +use arcdps::{ChatMessageInfo, UserInfo, UserInfoIter}; + +use crate::{ + exports::{Message, MessageId}, + pubsub::dispatch, +}; + +pub fn ue_user(users: UserInfoIter) { + for user in users { + let user: UserInfo = user; + // https://discord.com/channels/456611641526845473/953659301162004591/1005618923921735721 + // Elite Insights Discord, mentions that callbacks are async, + // we just block receiving the event for other addons + dispatch(&user).ok(); + } +} + +impl Message for UserInfo<'_> { + const MESSAGE_ID: MessageId = MessageId::UserInfo; +} + +pub fn ue_msg<'a>(msg: &'a ChatMessageInfo<'a>) { + dispatch(msg).ok(); +} + +impl Message for ChatMessageInfo<'_> { + const MESSAGE_ID: MessageId = MessageId::ChatMessage; +} diff --git a/src/exports/mod.rs b/src/exports/mod.rs index 658ec62..f3be181 100644 --- a/src/exports/mod.rs +++ b/src/exports/mod.rs @@ -1,12 +1,42 @@ mod combat; +mod extras; + +use arcdps::imgui; +pub use combat::{cbt as combat, cbt_local as combat_local}; +pub use extras::{ue_msg as message, ue_user as squad}; +use serde::Serialize; use crate::pubsub::dispatch; -use arcdps::imgui::Ui; -use smol::Task; -pub fn imgui(_ui: &Ui, not_charsel_or_loading: bool) { - Task::spawn(dispatch([1, not_charsel_or_loading as u8].to_vec())).detach(); +pub trait Message: Serialize { + const MESSAGE_ID: MessageId; + /// block the sending thread when the message queue is full + const BLOCK: bool = true; +} + +#[repr(u8)] +#[derive(Serialize)] +pub enum MessageId { + ImguiCallback = 1, + Combat, + CombatLocal, + UserInfo, + ChatMessage, +} + +pub fn imgui(_ui: &imgui::Ui, not_charsel_or_loading: bool) { + dispatch(&Ui { + not_charsel_or_loading, + }) + .ok(); +} + +#[derive(Serialize)] +pub struct Ui { + pub not_charsel_or_loading: bool, } -pub use combat::cbt as combat; -pub use combat::cbt_local as combat_local; +impl Message for Ui { + const BLOCK: bool = false; + const MESSAGE_ID: MessageId = MessageId::ImguiCallback; +} diff --git a/src/lib.rs b/src/lib.rs index cc70c15..89caa38 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,15 +1,14 @@ +use std::{ffi::c_void, ptr::NonNull}; + mod arcdps; -mod executor; mod exports; mod pubsub; -fn main() -> Result<(), Box<(dyn std::error::Error + 'static)>> { - executor::setup(); +fn main(_: Option>) -> Result<(), Box<(dyn std::error::Error + 'static)>> { pubsub::setup(); Ok(()) } fn release() { pubsub::teardown(); - executor::teardown(); } diff --git a/src/pubsub.rs b/src/pubsub.rs index 379f69d..429727a 100644 --- a/src/pubsub.rs +++ b/src/pubsub.rs @@ -1,70 +1,139 @@ -use futures::lock::Mutex; -use futures::select; -use futures::FutureExt; -use once_cell::sync::Lazy; -use piper::Sender; -use smol::{Async, Task}; -use std::net::{TcpListener, TcpStream}; +use std::{ + error::Error, + net::Ipv4Addr, + sync::{Arc, OnceLock}, + thread, + time::Duration, +}; -static SHUTDOWN: Lazy>>> = Lazy::new(|| Mutex::new(None)); -static STREAMS: Lazy>>> = Lazy::new(|| Mutex::new(Vec::new())); +use async_broadcast::{InactiveReceiver, Receiver, Sender}; +use bincode::Options; +use futures::{select, AsyncWriteExt, FutureExt}; +use smol::{ + net::{TcpListener, TcpStream}, + Executor, Timer, +}; + +use crate::exports::Message; pub fn setup() { - Task::spawn(setup_pubsub()).unwrap().detach(); + thread::spawn(setup_pubsub); } -pub async fn dispatch(data: Vec) { - let data = [&data.len().to_le_bytes(), &data[..]].concat(); - let data = &data[..]; - let mut streams = STREAMS.lock().await; - let mut to_remove = Vec::new(); - for (i, stream) in streams.iter_mut().enumerate() { - if let Err(_) = futures::io::copy(data, stream).await { - to_remove.push(i); - } - } +pub fn teardown() { + MsgChannel::tx().close(); + smol::block_on(wait_for_channel_close()); +} + +pub fn dispatch(msg: &T) -> Result<(), Box> { + let mut data = Vec::with_capacity(1_024); + let msg = (T::MESSAGE_ID as u8, msg); + let serializer = bincode::DefaultOptions::new().with_varint_encoding(); + data.extend((serializer.serialized_size(&msg)? as u32).to_le_bytes()); + serializer.serialize_into(&mut data, &msg)?; - for i in to_remove.drain(..).rev() { - streams.remove(i); + let tx = MsgChannel::tx(); + if T::BLOCK { + // every event except imgui is sent in its own thread, we want to block here + smol::block_on(tx.broadcast_direct(Arc::new(data)))?; + } else { + // if the queue is full, we simply drop the message + tx.try_broadcast(Arc::new(data)).ok(); } + Ok(()) } -pub fn teardown() { - smol::block_on(async_teardown()); -} +fn setup_pubsub() { + let ex = Arc::new(Executor::new()); + + // worker threads sending data + for _ in 0..2 { + let ex = ex.clone(); + thread::spawn(move || smol::block_on(ex.run(wait_for_channel_close()))); + } + + smol::block_on(async { + // create a listener + // we are inside a fire and forget thread, + // crashing on error is equivalent to returning the error + let listener = + TcpListener::bind((Ipv4Addr::new(127, 0, 0, 1), get_port(std::process::id()))) + .await + .unwrap(); -async fn async_teardown() { - STREAMS.lock().await.clear(); - SHUTDOWN.lock().await.take(); + // accept clients in a loop + loop { + select! { + _ = wait_for_channel_close().fuse() => { + break; + }, + opt = listener.accept().fuse() => { + if let Ok((stream, _)) = opt { + // stream events + ex.spawn(stream_data(stream)).detach(); + } + }, + } + } + }); } -async fn setup_pubsub() -> Result<(), std::io::Error> { - // A channel that sends the SHUTDOWN signal. - let (s, r) = piper::chan::<()>(0); - { - let mut shutdown = SHUTDOWN.lock().await; - *shutdown = Some(s); - } +async fn wait_for_channel_close() { + let mut rx = MsgChannel::rx(); + while rx.recv().await.is_ok() {} +} - // Create a listener. - let listener = - Async::::bind(format!("127.0.0.1:{}", get_port(std::process::id())))?; +async fn stream_data(mut stream: TcpStream) -> std::io::Result<()> { + let mut rx = MsgChannel::rx(); - // Accept clients in a loop. - loop { + while let Ok(msg) = rx.recv().await { + // The channel waits for the last receiver before freeing messages. + // A broken connection could block receiving events for all connections. + // We kill the connection if it doesn't receive the event in time. + // We do not care about malicious connections as they could game the system + // by opening many connections and blocking all of them. select! { - _ = r.recv().fuse() => break, - opt = listener.accept().fuse() => { - if let Ok((stream, _)) = opt { - let mut streams = STREAMS.lock().await; - streams.push(stream); - } - }, + res = stream.write_all(msg.as_slice()).fuse() => { + res?; + } + _ = Timer::after(Duration::from_secs(5)).fuse() => { + break; + } } } Ok(()) } fn get_port(pid: u32) -> u16 { - pid as u16 | 1 << 14 | 1 << 15 + (pid as u16 + 1) | 1 << 14 | 1 << 15 +} + +pub type MsgChannelType = Arc>; +pub type MsgChannel = StaticChannel; + +pub struct StaticChannel { + tx: Sender, + rx: InactiveReceiver, +} + +impl StaticChannel { + pub fn tx() -> Sender { + Self::get().tx.clone() + } + + pub fn rx() -> Receiver { + Self::get().rx.clone().activate() + } + + fn get() -> &'static Self { + static THIS: OnceLock = OnceLock::new(); + + THIS.get_or_init(|| { + let (tx, rx) = async_broadcast::broadcast(1_000); + Self { + tx, + rx: rx.deactivate(), + } + }) + } }