diff --git a/Cargo.lock b/Cargo.lock index 54ac03b..3985c88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,12 +17,119 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + [[package]] name = "allocator-api2" version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "async-stream" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "axum" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" +dependencies = [ + "async-trait", + "axum-core", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper", + "tower 0.5.3", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", +] + [[package]] name = "backtrace" version = "0.3.76" @@ -38,12 +145,24 @@ dependencies = [ "windows-link", ] +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "bitflags" version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + [[package]] name = "cassowary" version = "0.3.0" @@ -122,7 +241,7 @@ dependencies = [ "crossterm_winapi", "mio", "parking_lot", - "rustix", + "rustix 0.38.44", "signal-hook", "signal-hook-mio", "winapi", @@ -203,18 +322,124 @@ dependencies = [ "once_cell", ] +[[package]] +name = "fastrand" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" + +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "foldhash" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", + "wasip3", +] + [[package]] name = "gimli" version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" +[[package]] +name = "h2" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "171fefbc92fe4a4de27e0698d6a5b392d6a0e333506bc49133760b3bcf948733" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap 2.14.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + [[package]] name = "hashbrown" version = "0.15.5" @@ -226,12 +451,124 @@ dependencies = [ "foldhash", ] +[[package]] +name = "hashbrown" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" + [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6299f016b246a94207e63da54dbe807655bf9e00044f73ded42c3ac5305fbcca" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-timeout" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" +dependencies = [ + "hyper", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "libc", + "pin-project-lite", + "socket2 0.6.3", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + [[package]] name = "ident_case" version = "1.0.1" @@ -244,6 +581,28 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "964de6e86d545b246d84badc0fef527924ace5134f30641c203ef52ba83f58d5" +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +dependencies = [ + "equivalent", + "hashbrown 0.17.0", + "serde", + "serde_core", +] + [[package]] name = "indoc" version = "2.0.7" @@ -287,6 +646,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + [[package]] name = "libc" version = "0.2.186" @@ -299,6 +664,12 @@ version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + [[package]] name = "lock_api" version = "0.4.14" @@ -320,15 +691,27 @@ version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" dependencies = [ - "hashbrown", + "hashbrown 0.15.5", ] +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + [[package]] name = "memchr" version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + [[package]] name = "miniz_oxide" version = "0.8.9" @@ -350,6 +733,12 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "multimap" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" + [[package]] name = "nix" version = "0.29.0" @@ -412,12 +801,67 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "petgraph" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" +dependencies = [ + "fixedbitset", + "indexmap 2.14.0", +] + +[[package]] +name = "pin-project" +version = "1.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf0d9e68100b3a7989b4901972f265cd542e560a3a8a724e1e20322f4d06ce9" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a990e22f43e84855daf260dded30524ef4a9021cc7541c26540500a50b624389" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "pin-project-lite" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + [[package]] name = "proc-macro2" version = "1.0.106" @@ -427,6 +871,58 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "prost" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be769465445e8c1474e9c5dac2018218498557af32d9ed057325ec9a41ae81bf" +dependencies = [ + "heck", + "itertools", + "log", + "multimap", + "once_cell", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn", + "tempfile", +] + +[[package]] +name = "prost-derive" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-types" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52c2c1bf36ddb1a1c396b3601a3cec27c2462e45f07c386894ec3ccf5332bd16" +dependencies = [ + "prost", +] + [[package]] name = "quote" version = "1.0.45" @@ -436,6 +932,42 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + [[package]] name = "ratatui" version = "0.29.0" @@ -466,6 +998,35 @@ dependencies = [ "bitflags", ] +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" + [[package]] name = "rustc-demangle" version = "0.1.27" @@ -481,10 +1042,23 @@ dependencies = [ "bitflags", "errno", "libc", - "linux-raw-sys", + "linux-raw-sys 0.4.15", "windows-sys 0.59.0", ] +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys 0.12.1", + "windows-sys 0.61.2", +] + [[package]] name = "rustversion" version = "1.0.22" @@ -503,6 +1077,68 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap 2.14.0", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -543,12 +1179,38 @@ dependencies = [ "libc", ] +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + [[package]] name = "smallvec" version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +[[package]] +name = "socket2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "socket2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -594,6 +1256,25 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.2", + "once_cell", + "rustix 1.1.4", + "windows-sys 0.61.2", +] + [[package]] name = "thread_local" version = "1.1.9" @@ -603,6 +1284,146 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "tokio" +version = "1.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2 0.6.3", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-stream" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32da49809aab5c3bc678af03902d4ccddea2a87d028d86392a4b1560c6906c70" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tonic" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64", + "bytes", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-timeout", + "hyper-util", + "percent-encoding", + "pin-project", + "prost", + "socket2 0.5.10", + "tokio", + "tokio-stream", + "tower 0.4.13", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic-build" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9557ce109ea773b399c9b9e5dca39294110b74f1f342cb347a80d1fce8c26a11" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "prost-types", + "quote", + "syn", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite", + "rand", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + [[package]] name = "tracing" version = "0.1.44" @@ -610,9 +1431,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" dependencies = [ "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tracing-core" version = "0.1.36" @@ -644,6 +1477,12 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "ui-agregator" version = "0.1.0" @@ -651,7 +1490,13 @@ dependencies = [ "color-eyre", "crossterm", "nix", + "prost", "ratatui", + "serde", + "serde_yaml", + "tokio", + "tonic", + "tonic-build", ] [[package]] @@ -689,18 +1534,91 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + [[package]] name = "valuable" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" +[[package]] +name = "wasip2" +version = "1.0.3+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" +dependencies = [ + "wit-bindgen 0.57.1", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen 0.51.0", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap 2.14.0", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap 2.14.0", + "semver", +] + [[package]] name = "winapi" version = "0.3.9" @@ -729,6 +1647,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.59.0" @@ -810,3 +1737,123 @@ name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap 2.14.0", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap 2.14.0", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap 2.14.0", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "zerocopy" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml index 0bea1cf..24759d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,3 +8,12 @@ ratatui = "0.29" crossterm = "0.28" color-eyre = "0.6" nix = { version = "0.29", features = ["fs"] } +serde = { version = "1", features = ["derive"] } +serde_yaml = "0.9" + +tonic = "0.12" +prost = "0.13" +tokio = { version = "1", features = ["rt-multi-thread", "macros", "sync", "time"] } + +[build-dependencies] +tonic-build = "0.12" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..ae4f81f --- /dev/null +++ b/build.rs @@ -0,0 +1,17 @@ +fn main() -> Result<(), Box> { + let proto_root = "../music-agregator/proto"; + + tonic_build::configure() + .build_server(false) + .build_client(true) + .out_dir("src/proto") + .compile_protos( + &[format!( + "{}/music_agregator/v1/music_agregator.proto", + proto_root + )], + &[proto_root], + )?; + + Ok(()) +} diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..080511f --- /dev/null +++ b/config.yaml @@ -0,0 +1,3 @@ +server: + host: localhost + port: 3000 diff --git a/flake.nix b/flake.nix index 587d32d..771a691 100644 --- a/flake.nix +++ b/flake.nix @@ -61,6 +61,8 @@ clippy rustfmt + protobuf + opencode ]; }; diff --git a/src/app.rs b/src/app.rs index 53bcba6..2b8a4fc 100644 --- a/src/app.rs +++ b/src/app.rs @@ -8,11 +8,14 @@ use ratatui::{ widgets::{ListState, Paragraph}, }; -use crate::data::{Artist, CalendarEntry, HistoryEntry, QueueEntry, WantedEntry}; +use crate::data::{ + Album, AlbumStatus, Artist, CalendarEntry, HistoryEntry, MonitorState, QueueEntry, WantedEntry, +}; +use crate::grpc::{AlbumDetail, ArtistSummary, GrpcResponse}; use crate::theme; use crate::ui::library::{LibraryFocus, LibraryState, render_library}; use crate::ui::modals::{ModalKind, render_help_modal, render_quit_modal}; -use crate::ui::notifications::NotificationManager; +use crate::ui::notifications::{NotifKind, NotificationManager}; use crate::ui::statusbar::render_statusbar; use crate::ui::topbar::render_topbar; use crate::ui::views::{ @@ -286,41 +289,39 @@ impl App { } fn handle_library_click(&mut self, x: u16, rel_y: usize) { - let artists_width = 32u16; + const ARTISTS_PANE_WIDTH: u16 = 32; + const BORDER_TOP: usize = 1; + const HEADER_HEIGHT: usize = 6; + const DIVIDER_HEIGHT: usize = 1; + const ALBUMS_START_ROW: usize = BORDER_TOP + HEADER_HEIGHT + DIVIDER_HEIGHT; - if x < artists_width { + if x < ARTISTS_PANE_WIDTH { if rel_y > 0 && rel_y <= self.library.artists.len() { self.library.artist_state.select(Some(rel_y - 1)); self.library.album_state.select(Some(0)); self.library.track_state.select(Some(0)); self.library.focus = LibraryFocus::Artists; } - } else { - let detail_y = rel_y; - let header_height = 6; - let divider1 = 1; - let _albums_section_height = 40; - - if detail_y > header_height + divider1 { - let albums_start = header_height + divider1; - let albums_rel = detail_y - albums_start; + } else if rel_y >= ALBUMS_START_ROW { + let album_row = rel_y - ALBUMS_START_ROW; + let content_height = self.main_area.height.saturating_sub(10) as usize; + let albums_section_height = (content_height * 40) / 100; + let tracks_start_row = ALBUMS_START_ROW + albums_section_height + DIVIDER_HEIGHT; + if rel_y < tracks_start_row { if let Some(artist) = self.library.selected_artist() { - let album_count = artist.albums.len(); - let tracks_start = albums_start + album_count.min(6) + 1; - - if detail_y < tracks_start && albums_rel < album_count { - self.library.album_state.select(Some(albums_rel)); + if album_row < artist.albums.len() { + self.library.album_state.select(Some(album_row)); self.library.track_state.select(Some(0)); self.library.focus = LibraryFocus::Albums; - } else if detail_y >= tracks_start { - let tracks_rel = detail_y - tracks_start; - if let Some(album) = self.library.selected_album() { - if tracks_rel < album.total as usize { - self.library.track_state.select(Some(tracks_rel)); - self.library.focus = LibraryFocus::Tracks; - } - } + } + } + } else { + let track_row = rel_y - tracks_start_row; + if let Some(album) = self.library.selected_album() { + if track_row < album.total as usize { + self.library.track_state.select(Some(track_row)); + self.library.focus = LibraryFocus::Tracks; } } } @@ -412,6 +413,103 @@ impl App { pub fn handle_tick(&mut self) { self.notifications.tick(); } + + pub fn set_error(&mut self, msg: String) { + self.notifications + .push("Error", Some(msg), NotifKind::Error, "✗"); + } + + pub fn handle_grpc_response(&mut self, response: GrpcResponse) { + match response { + GrpcResponse::Artists(artists) => { + let converted: Vec = artists.into_iter().map(convert_artist).collect(); + let count = converted.len(); + self.library = LibraryState::new(converted); + self.notifications.push( + "Library loaded", + Some(format!("{} artists", count)), + NotifKind::Success, + "✓", + ); + } + GrpcResponse::Error(msg) => { + self.set_error(msg); + } + } + } +} + +fn convert_artist(summary: ArtistSummary) -> Artist { + let albums: Vec = summary.albums.into_iter().map(convert_album).collect(); + Artist { + id: summary.id, + name: summary.name, + country: summary.country, + genres: summary.genres, + monitor_state: MonitorState::from_proto(summary.monitor_state), + path: String::new(), + quality: "FLAC".to_string(), + size_gb: 0.0, + albums, + } +} + +fn convert_album(detail: AlbumDetail) -> Album { + let year = parse_year(&detail.release_date); + let monitor_state = MonitorState::from_proto(detail.monitor_state); + let monitored = monitor_state.is_monitored(); + + let (have, status, quality) = if let Some(download) = detail.download { + let have = if download.state == "downloaded" { + detail.total_tracks as u16 + } else { + 0 + }; + let status = match download.state.as_str() { + "downloaded" => AlbumStatus::Complete, + "downloading" => AlbumStatus::Partial, + _ => { + if monitored { + AlbumStatus::Wanted + } else { + AlbumStatus::Unmonitored + } + } + }; + let quality = if download.quality.is_empty() { + "—".to_string() + } else { + download.quality + }; + (have, status, quality) + } else { + let status = if monitored { + AlbumStatus::Wanted + } else { + AlbumStatus::Unmonitored + }; + (0, status, "—".to_string()) + }; + + Album { + id: detail.id, + title: detail.title, + year, + album_type: detail.album_type, + monitored, + total: detail.total_tracks as u16, + have, + quality, + status, + } +} + +fn parse_year(date_str: &str) -> u16 { + date_str + .split('-') + .next() + .and_then(|y| y.parse().ok()) + .unwrap_or(0) } fn scroll_list_state(state: &mut ListState, len: usize, delta: i32) { diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..a18f2a3 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,26 @@ +use serde::Deserialize; +use std::fs; +use std::path::Path; + +#[derive(Debug, Deserialize)] +pub struct Config { + pub server: ServerConfig, +} + +#[derive(Debug, Deserialize)] +pub struct ServerConfig { + pub host: String, + pub port: u16, +} + +impl Config { + pub fn load>(path: P) -> Result> { + let contents = fs::read_to_string(path)?; + let config: Config = serde_yaml::from_str(&contents)?; + Ok(config) + } + + pub fn grpc_addr(&self) -> String { + format!("http://{}:{}", self.server.host, self.server.port) + } +} diff --git a/src/data/models.rs b/src/data/models.rs index 8f01493..c4d4598 100644 --- a/src/data/models.rs +++ b/src/data/models.rs @@ -1,23 +1,45 @@ #![allow(dead_code)] -//! Data models for harmony music library. -/// Album completion status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] pub enum AlbumStatus { + #[default] Complete, Partial, Wanted, Unmonitored, } -/// A music artist in the library. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] +pub enum MonitorState { + #[default] + Unspecified, + Monitored, + Unmonitored, + Excluded, +} + +impl MonitorState { + pub fn from_proto(value: i32) -> Self { + match value { + 1 => MonitorState::Monitored, + 2 => MonitorState::Unmonitored, + 3 => MonitorState::Excluded, + _ => MonitorState::Unspecified, + } + } + + pub fn is_monitored(&self) -> bool { + matches!(self, MonitorState::Monitored) + } +} + #[derive(Debug, Clone)] pub struct Artist { pub id: String, pub name: String, pub country: String, pub genres: Vec, - pub monitored: bool, + pub monitor_state: MonitorState, pub path: String, pub quality: String, pub size_gb: f64, diff --git a/src/grpc/mod.rs b/src/grpc/mod.rs new file mode 100644 index 0000000..494aa1d --- /dev/null +++ b/src/grpc/mod.rs @@ -0,0 +1,73 @@ +use tokio::sync::mpsc; +use tonic::transport::Channel; + +use crate::proto::music_agregator_v1::music_agregator_service_client::MusicAgregatorServiceClient; + +pub use crate::proto::music_agregator_v1::{AlbumDetail, ArtistSummary, GetArtistsRequest}; + +#[derive(Debug)] +pub enum GrpcRequest { + GetArtists, +} + +#[derive(Debug)] +pub enum GrpcResponse { + Artists(Vec), + Error(String), +} + +pub struct GrpcClient { + music: MusicAgregatorServiceClient, +} + +impl GrpcClient { + pub async fn connect(addr: &str) -> Result { + let channel = Channel::from_shared(addr.to_string()) + .expect("valid uri") + .connect() + .await?; + + Ok(Self { + music: MusicAgregatorServiceClient::new(channel), + }) + } + + pub async fn get_artists(&mut self) -> Result, tonic::Status> { + let response = self.music.get_artists(GetArtistsRequest {}).await?; + Ok(response.into_inner().artists) + } +} + +pub fn spawn_grpc_worker( + addr: String, +) -> (mpsc::Sender, mpsc::Receiver) { + let (req_tx, mut req_rx) = mpsc::channel::(32); + let (resp_tx, resp_rx) = mpsc::channel::(32); + + tokio::spawn(async move { + let client = match GrpcClient::connect(&addr).await { + Ok(c) => c, + Err(e) => { + let _ = resp_tx.send(GrpcResponse::Error(e.to_string())).await; + return; + } + }; + + let mut client = client; + + while let Some(request) = req_rx.recv().await { + let response = match request { + GrpcRequest::GetArtists => match client.get_artists().await { + Ok(artists) => GrpcResponse::Artists(artists), + Err(e) => GrpcResponse::Error(e.to_string()), + }, + }; + + if resp_tx.send(response).await.is_err() { + break; + } + } + }); + + (req_tx, resp_rx) +} diff --git a/src/main.rs b/src/main.rs index b7d15e7..a1be067 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,15 +14,21 @@ use crossterm::{ use ratatui::prelude::*; mod app; +mod config; mod data; +mod grpc; +mod proto; mod theme; mod ui; use app::App; +use config::Config; +use grpc::{GrpcRequest, spawn_grpc_worker}; -const TICK_RATE: Duration = Duration::from_millis(250); +const TICK_RATE: Duration = Duration::from_millis(100); -fn main() -> Result<()> { +#[tokio::main] +async fn main() -> Result<()> { color_eyre::install()?; let hook = panic::take_hook(); @@ -32,7 +38,7 @@ fn main() -> Result<()> { })); setup_terminal()?; - let result = run(); + let result = run().await; restore_terminal()?; result @@ -52,23 +58,41 @@ fn restore_terminal() -> Result<()> { Ok(()) } -fn run() -> Result<()> { +async fn run() -> Result<()> { + let config = Config::load("config.yaml").unwrap_or_else(|e| { + eprintln!("Failed to load config.yaml: {}", e); + std::process::exit(1); + }); + let mut terminal = Terminal::new(CrosstermBackend::new(stdout()))?; let mut app = App::new(); + let (grpc_tx, mut grpc_rx) = spawn_grpc_worker(config.grpc_addr()); + + if grpc_tx.send(GrpcRequest::GetArtists).await.is_err() { + app.set_error("Failed to send initial request".to_string()); + } + while app.running { terminal.draw(|frame| app.draw(frame))?; + if let Ok(response) = grpc_rx.try_recv() { + app.handle_grpc_response(response); + } + if event::poll(TICK_RATE)? { match event::read()? { Event::Key(key) if key.kind == KeyEventKind::Press => { - // Only handle Ctrl+C and Escape for quit if key.modifiers.contains(KeyModifiers::CONTROL) && key.code == KeyCode::Char('c') { app.running = false; } else if key.code == KeyCode::Esc { app.handle_escape(); + } else if key.code == KeyCode::Char('r') + && key.modifiers.contains(KeyModifiers::CONTROL) + { + let _ = grpc_tx.send(GrpcRequest::GetArtists).await; } } Event::Mouse(mouse) => match mouse.kind { diff --git a/src/proto/mod.rs b/src/proto/mod.rs new file mode 100644 index 0000000..6f29876 --- /dev/null +++ b/src/proto/mod.rs @@ -0,0 +1,3 @@ +pub mod music_agregator_v1 { + include!("music_agregator.v1.rs"); +} diff --git a/src/proto/music_agregator.v1.rs b/src/proto/music_agregator.v1.rs new file mode 100644 index 0000000..ad9edbc --- /dev/null +++ b/src/proto/music_agregator.v1.rs @@ -0,0 +1,417 @@ +// This file is @generated by prost-build. +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MonitorAlbumRequest { + #[prost(string, tag = "1")] + pub album_id: ::prost::alloc::string::String, + #[prost(message, optional, tag = "2")] + pub indexer_options: ::core::option::Option, + #[prost(enumeration = "QualityType", tag = "3")] + pub quality: i32, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct IndexerOptions { + #[prost(string, tag = "1")] + pub tracker: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MonitorAlbumResponse { + #[prost(message, optional, tag = "1")] + pub release: ::core::option::Option, +} +#[derive(Clone, Copy, PartialEq, ::prost::Message)] +pub struct GetArtistsRequest {} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetArtistsResponse { + #[prost(message, repeated, tag = "1")] + pub artists: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ArtistSummary { + #[prost(string, tag = "1")] + pub id: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub external_id: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub name: ::prost::alloc::string::String, + #[prost(string, tag = "4")] + pub artist_type: ::prost::alloc::string::String, + #[prost(string, tag = "5")] + pub country: ::prost::alloc::string::String, + #[prost(string, repeated, tag = "6")] + pub genres: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, tag = "7")] + pub image_url: ::prost::alloc::string::String, + #[prost(enumeration = "MonitorState", tag = "8")] + pub monitor_state: i32, + #[prost(message, repeated, tag = "9")] + pub albums: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AlbumDetail { + #[prost(string, tag = "1")] + pub id: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub external_id: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub title: ::prost::alloc::string::String, + #[prost(string, tag = "4")] + pub album_type: ::prost::alloc::string::String, + #[prost(string, tag = "5")] + pub release_date: ::prost::alloc::string::String, + #[prost(int32, tag = "6")] + pub total_tracks: i32, + #[prost(int32, tag = "7")] + pub total_discs: i32, + #[prost(string, tag = "8")] + pub cover_url: ::prost::alloc::string::String, + #[prost(string, repeated, tag = "9")] + pub genres: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, tag = "10")] + pub label: ::prost::alloc::string::String, + #[prost(enumeration = "MonitorState", tag = "11")] + pub monitor_state: i32, + #[prost(message, optional, tag = "12")] + pub download: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct DownloadInfo { + #[prost(string, tag = "1")] + pub state: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub format: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub quality: ::prost::alloc::string::String, + #[prost(string, tag = "4")] + pub save_path: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetAlbumRequest { + #[prost(string, tag = "1")] + pub album_id: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct GetAlbumResponse { + #[prost(message, optional, tag = "1")] + pub album: ::core::option::Option, + #[prost(message, repeated, tag = "2")] + pub tracks: ::prost::alloc::vec::Vec, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TrackDetail { + #[prost(string, tag = "1")] + pub id: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub external_id: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub title: ::prost::alloc::string::String, + #[prost(int32, tag = "4")] + pub duration_ms: i32, + #[prost(int32, tag = "5")] + pub disc_number: i32, + #[prost(int32, tag = "6")] + pub track_number: i32, + #[prost(string, tag = "7")] + pub isrc: ::prost::alloc::string::String, + #[prost(bool, tag = "8")] + pub explicit: bool, + #[prost(message, repeated, tag = "9")] + pub artists: ::prost::alloc::vec::Vec, + #[prost(message, optional, tag = "10")] + pub file: ::core::option::Option, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct ArtistCredit { + #[prost(string, tag = "1")] + pub id: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub name: ::prost::alloc::string::String, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct TrackFile { + #[prost(string, tag = "1")] + pub path: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub format: ::prost::alloc::string::String, + #[prost(int64, tag = "3")] + pub size: i64, +} +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct MonitoredRelease { + #[prost(string, tag = "1")] + pub info_hash: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub artist: ::prost::alloc::string::String, + #[prost(string, tag = "3")] + pub album: ::prost::alloc::string::String, + #[prost(int32, tag = "4")] + pub year: i32, + #[prost(string, tag = "5")] + pub format: ::prost::alloc::string::String, + #[prost(bool, tag = "6")] + pub lossless: bool, + #[prost(int32, tag = "7")] + pub bit_depth: i32, + #[prost(int32, tag = "8")] + pub sample_rate: i32, + #[prost(string, tag = "9")] + pub source: ::prost::alloc::string::String, + #[prost(int32, tag = "10")] + pub track_count: i32, + #[prost(string, repeated, tag = "11")] + pub track_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(bool, tag = "12")] + pub has_cover_art: bool, + #[prost(bool, tag = "13")] + pub has_cue_sheet: bool, + #[prost(bool, tag = "14")] + pub has_rip_log: bool, + #[prost(int64, tag = "15")] + pub total_audio_size: i64, + #[prost(string, tag = "16")] + pub download_link: ::prost::alloc::string::String, + #[prost(int32, tag = "17")] + pub seeders: i32, + #[prost(string, tag = "18")] + pub tracker: ::prost::alloc::string::String, +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum QualityType { + QualityUnspecified = 0, + QualityLossless = 1, + QualityLossy = 2, +} +impl QualityType { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::QualityUnspecified => "QUALITY_UNSPECIFIED", + Self::QualityLossless => "QUALITY_LOSSLESS", + Self::QualityLossy => "QUALITY_LOSSY", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "QUALITY_UNSPECIFIED" => Some(Self::QualityUnspecified), + "QUALITY_LOSSLESS" => Some(Self::QualityLossless), + "QUALITY_LOSSY" => Some(Self::QualityLossy), + _ => None, + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum MonitorState { + Unspecified = 0, + Monitored = 1, + Unmonitored = 2, + Excluded = 3, +} +impl MonitorState { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + Self::Unspecified => "MONITOR_STATE_UNSPECIFIED", + Self::Monitored => "MONITOR_STATE_MONITORED", + Self::Unmonitored => "MONITOR_STATE_UNMONITORED", + Self::Excluded => "MONITOR_STATE_EXCLUDED", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "MONITOR_STATE_UNSPECIFIED" => Some(Self::Unspecified), + "MONITOR_STATE_MONITORED" => Some(Self::Monitored), + "MONITOR_STATE_UNMONITORED" => Some(Self::Unmonitored), + "MONITOR_STATE_EXCLUDED" => Some(Self::Excluded), + _ => None, + } + } +} +/// Generated client implementations. +pub mod music_agregator_service_client { + #![allow( + unused_variables, + dead_code, + missing_docs, + clippy::wildcard_imports, + clippy::let_unit_value, + )] + use tonic::codegen::*; + use tonic::codegen::http::Uri; + #[derive(Debug, Clone)] + pub struct MusicAgregatorServiceClient { + inner: tonic::client::Grpc, + } + impl MusicAgregatorServiceClient { + /// Attempt to create a new client by connecting to a given endpoint. + pub async fn connect(dst: D) -> Result + where + D: TryInto, + D::Error: Into, + { + let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; + Ok(Self::new(conn)) + } + } + impl MusicAgregatorServiceClient + where + T: tonic::client::GrpcService, + T::Error: Into, + T::ResponseBody: Body + std::marker::Send + 'static, + ::Error: Into + std::marker::Send, + { + pub fn new(inner: T) -> Self { + let inner = tonic::client::Grpc::new(inner); + Self { inner } + } + pub fn with_origin(inner: T, origin: Uri) -> Self { + let inner = tonic::client::Grpc::with_origin(inner, origin); + Self { inner } + } + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> MusicAgregatorServiceClient> + where + F: tonic::service::Interceptor, + T::ResponseBody: Default, + T: tonic::codegen::Service< + http::Request, + Response = http::Response< + >::ResponseBody, + >, + >, + , + >>::Error: Into + std::marker::Send + std::marker::Sync, + { + MusicAgregatorServiceClient::new(InterceptedService::new(inner, interceptor)) + } + /// Compress requests with the given encoding. + /// + /// This requires the server to support it otherwise it might respond with an + /// error. + #[must_use] + pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.send_compressed(encoding); + self + } + /// Enable decompressing responses. + #[must_use] + pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self { + self.inner = self.inner.accept_compressed(encoding); + self + } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } + pub async fn monitor_album( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/music_agregator.v1.MusicAgregatorService/MonitorAlbum", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "music_agregator.v1.MusicAgregatorService", + "MonitorAlbum", + ), + ); + self.inner.unary(req, path, codec).await + } + pub async fn get_artists( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/music_agregator.v1.MusicAgregatorService/GetArtists", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "music_agregator.v1.MusicAgregatorService", + "GetArtists", + ), + ); + self.inner.unary(req, path, codec).await + } + pub async fn get_album( + &mut self, + request: impl tonic::IntoRequest, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; + let codec = tonic::codec::ProstCodec::default(); + let path = http::uri::PathAndQuery::from_static( + "/music_agregator.v1.MusicAgregatorService/GetAlbum", + ); + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "music_agregator.v1.MusicAgregatorService", + "GetAlbum", + ), + ); + self.inner.unary(req, path, codec).await + } + } +} diff --git a/src/ui/library.rs b/src/ui/library.rs index 6ae5736..dece034 100644 --- a/src/ui/library.rs +++ b/src/ui/library.rs @@ -8,7 +8,7 @@ use ratatui::{ widgets::{List, ListItem, ListState, Paragraph}, }; -use crate::data::{Album, AlbumStatus, Artist, Track}; +use crate::data::{Album, AlbumStatus, Artist, MonitorState, Track}; use crate::theme; use crate::ui::pane::{Pane, section_divider}; use crate::ui::progress_bar::progress_bar; @@ -201,6 +201,20 @@ fn status_icon(status: AlbumStatus, monitored: bool) -> (char, Style) { } } +fn monitor_state_icon(state: MonitorState, status: AlbumStatus) -> (char, Style) { + match state { + MonitorState::Monitored => match status { + AlbumStatus::Complete => ('✓', Style::default().fg(theme::GREEN)), + AlbumStatus::Partial => ('◐', Style::default().fg(theme::YELLOW)), + AlbumStatus::Wanted => ('!', Style::default().fg(theme::RED)), + AlbumStatus::Unmonitored => ('-', Style::default().fg(theme::GRAY)), + }, + MonitorState::Unmonitored => ('-', Style::default().fg(theme::GRAY)), + MonitorState::Excluded => ('x', Style::default().fg(theme::RED)), + MonitorState::Unspecified => ('?', Style::default().fg(theme::GRAY)), + } +} + fn track_icon(have: bool) -> (char, Style) { if have { ('✓', Style::default().fg(theme::GREEN)) @@ -267,15 +281,12 @@ fn render_artists_pane(frame: &mut Frame, area: Rect, state: &mut LibraryState) .iter() .map(|artist| { let status = artist_status(artist); - let (icon_char, icon_style) = status_icon(status, artist.monitored); + let (icon_char, icon_style) = monitor_state_icon(artist.monitor_state, status); let total: u16 = artist.albums.iter().map(|a| a.total).sum(); let have: u16 = artist.albums.iter().map(|a| a.have).sum(); let mut name_text = artist.name.clone(); - if !artist.monitored { - name_text.push_str(" ·unm"); - } let count_str = format!("{}/{}", have, total); let name_width = inner.width as usize - 2 - count_str.len() - 2; @@ -399,18 +410,27 @@ fn render_artist_header(frame: &mut Frame, area: Rect, artist: &Artist) { let have: u16 = artist.albums.iter().map(|a| a.have).sum(); let total: u16 = artist.albums.iter().map(|a| a.total).sum(); - let (status_icon, status_text, status_style) = if artist.monitored { - ( + let (status_icon, status_text, status_style) = match artist.monitor_state { + MonitorState::Monitored => ( Span::styled("● ", Style::default().fg(theme::GREEN)), "Monitored", Style::default().fg(theme::FG2), - ) - } else { - ( + ), + MonitorState::Unmonitored => ( Span::styled("◌ ", Style::default().fg(theme::GRAY)), "Unmonitored", Style::default().fg(theme::GRAY), - ) + ), + MonitorState::Excluded => ( + Span::styled("⊘ ", Style::default().fg(theme::RED)), + "Excluded", + Style::default().fg(theme::RED), + ), + MonitorState::Unspecified => ( + Span::styled("? ", Style::default().fg(theme::GRAY)), + "Unknown", + Style::default().fg(theme::GRAY), + ), }; let lines = vec![ diff --git a/src/ui/modals/mod.rs b/src/ui/modals/mod.rs index 2bb4d01..39ce87a 100644 --- a/src/ui/modals/mod.rs +++ b/src/ui/modals/mod.rs @@ -5,6 +5,7 @@ pub use help::render_help_modal; pub use quit::render_quit_modal; #[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[allow(dead_code)] pub enum ModalKind { Help, Quit,