Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
56fde73a40
|
|||
|
3108aca6ba
|
|||
|
09459615b8
|
|||
|
6872e7897b
|
|||
|
2d1497cb36
|
|||
|
f1fb3506b5
|
|||
|
f4050fe645
|
@@ -1,8 +1,12 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.yaml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
1
.rustfmt.toml
Normal file
1
.rustfmt.toml
Normal file
@@ -0,0 +1 @@
|
||||
hard_tabs = true
|
||||
@@ -1,5 +1,9 @@
|
||||
# Changelog
|
||||
|
||||
## v1.2.2
|
||||
|
||||
* dependencies upgraded
|
||||
|
||||
## v1.2.1
|
||||
|
||||
* dependencies upgraded
|
||||
|
||||
265
Cargo.lock
generated
265
Cargo.lock
generated
@@ -1,5 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.18"
|
||||
@@ -20,9 +22,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.41"
|
||||
version = "1.0.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15af2628f6890fe2609a3b91bef4c83450512802e59489f9c1cb1fa5df064a61"
|
||||
checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1"
|
||||
|
||||
[[package]]
|
||||
name = "array-init"
|
||||
@@ -43,7 +45,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "audio-conv"
|
||||
version = "1.2.1"
|
||||
version = "1.2.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
@@ -72,9 +74,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.1"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bstr"
|
||||
@@ -87,9 +89,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.0.1"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040"
|
||||
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
|
||||
|
||||
[[package]]
|
||||
name = "cassowary"
|
||||
@@ -99,9 +101,9 @@ checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-expr"
|
||||
version = "0.7.4"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30aa9e2ffbb838c6b451db14f3cd8e63ed622bf859f9956bc93845a10fafc26a"
|
||||
checksum = "b412e83326147c2bb881f8b40edfbf9905b9b8abaebd0e47ca190ba62fda8f0e"
|
||||
dependencies = [
|
||||
"smallvec",
|
||||
]
|
||||
@@ -135,38 +137,39 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
|
||||
|
||||
[[package]]
|
||||
name = "crossterm"
|
||||
version = "0.19.0"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c36c10130df424b2f3552fcc2ddcd9b28a27b1e54b358b45874f88d1ca6888c"
|
||||
checksum = "c0ebde6a9dd5e331cd6c6f48253254d117642c31653baa475e394657c59c1f7d"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"crossterm_winapi",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
"signal-hook",
|
||||
"signal-hook-mio",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossterm_winapi"
|
||||
version = "0.7.0"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0da8964ace4d3e4a044fd027919b2237000b24315a37c916f61809f1ff2140b9"
|
||||
checksum = "3a6966607622438301997d3dac0d2f6e9a90c68bb6bc1785ea98456ab93c0507"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_more"
|
||||
version = "0.99.14"
|
||||
version = "0.99.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5cc7b9cef1e351660e5443924e4f43ab25fbbed3e9a5f052df3677deb4d6b320"
|
||||
checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustc_version",
|
||||
"syn",
|
||||
]
|
||||
|
||||
@@ -190,9 +193,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.15"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e7e43a803dae2fa37c1f6a8fe121e1f7bf9548b4dfc0522a42f34145dadfc27"
|
||||
checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
@@ -205,9 +208,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.15"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e682a68b29a882df0545c143dc3646daefe80ba479bcdede94d5a703de2871e2"
|
||||
checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
@@ -215,15 +218,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.15"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0402f765d8a89a26043b889b26ce3c4679d268fa6bb22cd7c6aad98340e179d1"
|
||||
checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.15"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "badaa6a909fac9e7236d0620a2f57f7664640c56575b71a7552fbd68deafab79"
|
||||
checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
@@ -232,15 +235,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.15"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acc499defb3b348f8d8f3f66415835a9131856ff7714bf10dadfc4ec4bdb29a1"
|
||||
checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.15"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4c40298486cdf52cc00cd6d6987892ba502c7656a16a4192a9992b1ccedd121"
|
||||
checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"proc-macro-hack",
|
||||
@@ -251,21 +254,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-sink"
|
||||
version = "0.3.15"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a57bead0ceff0d6dde8f465ecd96c9338121bb7717d3e7b108059531870c4282"
|
||||
checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11"
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.15"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a16bef9fc1a4dddb5bee51c989e3fbba26569cbb0e31f5b303c184e3dd33dae"
|
||||
checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.15"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "feb5c238d27e2bf94ffdfd27b2c29e3df4a68c4193bb6427384259e2bf191967"
|
||||
checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"futures-channel",
|
||||
@@ -284,9 +287,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "glib"
|
||||
version = "0.14.0"
|
||||
version = "0.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0028bbfd270d0778540294abca11141d59cb474da4c1f61ca1e11f579c49247"
|
||||
checksum = "d4a930b7208e6e0ab839eea5f65ac2b82109f729621430d47fe905e2e09d33f4"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"futures-channel",
|
||||
@@ -303,9 +306,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "glib-macros"
|
||||
version = "0.14.0"
|
||||
version = "0.14.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9eb7bdf41972a6f6dab5d72c23d22789f400059a43ba0d72b4bb2f8664d946a9"
|
||||
checksum = "2aad66361f66796bfc73f530c51ef123970eb895ffba991a234fcf7bea89e518"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
@@ -352,9 +355,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer"
|
||||
version = "0.17.0"
|
||||
version = "0.17.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2163b09b359d8b651d627d9c83dcce5550929ad678b8ce7ec750787affa93ec"
|
||||
checksum = "c6a255f142048ba2c4a4dce39106db1965abe355d23f4b5335edea43a553faa4"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
@@ -375,9 +378,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-audio"
|
||||
version = "0.17.0"
|
||||
version = "0.17.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba5d560479c5fe704ea9eecdf394cfd514b6628e0c0a4207bb5c1230370d116b"
|
||||
checksum = "420b6bcb1759231f01172751da094e7afa5cd9edf40bee7475f5bc86df433c57"
|
||||
dependencies = [
|
||||
"array-init",
|
||||
"bitflags",
|
||||
@@ -406,9 +409,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-base"
|
||||
version = "0.17.0"
|
||||
version = "0.17.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5cf50118e1933d9e9e043036f2306d0b9660182ea61a75f266cd9fb3607b7a19"
|
||||
checksum = "2c0c1d8c62eb5d08fb80173609f2eea71d385393363146e4e78107facbd67715"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
@@ -433,9 +436,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-sys"
|
||||
version = "0.17.0"
|
||||
version = "0.17.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8188ba998999a4a16005c3984812807ff882a87f5f3457c3d5bbbfcbdf631ebd"
|
||||
checksum = "a81704feeb3e8599913bdd1e738455c2991a01ff4a1780cb62200993e454cc3e"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
@@ -443,6 +446,12 @@ dependencies = [
|
||||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.3.3"
|
||||
@@ -462,10 +471,20 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.9"
|
||||
name = "indexmap"
|
||||
version = "1.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec"
|
||||
checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
@@ -479,17 +498,11 @@ dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.97"
|
||||
version = "0.2.102"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6"
|
||||
checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103"
|
||||
|
||||
[[package]]
|
||||
name = "linked-hash-map"
|
||||
@@ -499,9 +512,9 @@ checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.4"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb"
|
||||
checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109"
|
||||
dependencies = [
|
||||
"scopeguard",
|
||||
]
|
||||
@@ -517,9 +530,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.4.0"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"
|
||||
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
@@ -606,9 +619,9 @@ checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.11.1"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
|
||||
checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
|
||||
dependencies = [
|
||||
"instant",
|
||||
"lock_api",
|
||||
@@ -617,9 +630,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018"
|
||||
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"instant",
|
||||
@@ -635,6 +648,15 @@ version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58"
|
||||
|
||||
[[package]]
|
||||
name = "pest"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53"
|
||||
dependencies = [
|
||||
"ucd-trie",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.7"
|
||||
@@ -661,9 +683,9 @@ checksum = "bc5c99d529f0d30937f6f4b8a86d988047327bb88d04d2c4afc356de74722131"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "1.0.0"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41fdbd1df62156fbc5945f4762632564d7d038153091c3fcf1067f6aef7cff92"
|
||||
checksum = "1ebace6889caf889b4d3f76becee12e90353f2b8c7d875534a71e5742f8f6f83"
|
||||
dependencies = [
|
||||
"thiserror",
|
||||
"toml",
|
||||
@@ -707,9 +729,9 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.27"
|
||||
version = "1.0.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038"
|
||||
checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
@@ -725,9 +747,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.2.9"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee"
|
||||
checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
@@ -749,6 +771,15 @@ version = "0.6.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee"
|
||||
dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
@@ -765,19 +796,37 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.126"
|
||||
name = "semver"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03"
|
||||
checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
|
||||
dependencies = [
|
||||
"semver-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver-parser"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7"
|
||||
dependencies = [
|
||||
"pest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.130"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.126"
|
||||
version = "1.0.130"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43"
|
||||
checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -786,25 +835,35 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_yaml"
|
||||
version = "0.8.17"
|
||||
version = "0.8.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15654ed4ab61726bf918a39cb8d98a2e2995b002387807fa6ba58fdf7f59bb23"
|
||||
checksum = "d8c608a35705a5d3cdc9fbe403147647ff34b921f8e833e49306df898f9b20af"
|
||||
dependencies = [
|
||||
"dtoa",
|
||||
"linked-hash-map",
|
||||
"indexmap",
|
||||
"serde",
|
||||
"yaml-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook"
|
||||
version = "0.1.17"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e31d442c16f047a671b5a71e2161d6e68814012b7f5379d269ebd915fac2729"
|
||||
checksum = "9c98891d737e271a2954825ef19e46bd16bdb98e2746f2eec4f7a4ef7946efd1"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"signal-hook-registry",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-mio"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29fd5867f1c4f2c5be079aee7a2adf1152ebb04a4bc4d341f504b7dece607ed4"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"mio",
|
||||
"signal-hook-registry",
|
||||
"signal-hook",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -818,9 +877,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.3"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527"
|
||||
checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
@@ -854,9 +913,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.73"
|
||||
version = "1.0.76"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7"
|
||||
checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -865,9 +924,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "system-deps"
|
||||
version = "3.1.2"
|
||||
version = "3.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ab7dbd121ce66af2176147a48c7e01aaf1f001837a18a7cf4317858606bbdf8"
|
||||
checksum = "480c269f870722b3b08d2f13053ce0c2ab722839f472863c3e2d61ff3a1c2fa6"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cfg-expr",
|
||||
@@ -892,18 +951,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.26"
|
||||
version = "1.0.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2"
|
||||
checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.26"
|
||||
version = "1.0.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745"
|
||||
checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -912,9 +971,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.8.0"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "570c2eb13b3ab38208130eccd41be92520388791207fde783bda7c1e8ace28d4"
|
||||
checksum = "b4efe6fc2395938c8155973d7be49fe8d03a843726e285e100a8a383cc0154ce"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"bytes",
|
||||
@@ -925,9 +984,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "1.2.0"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c49e3df43841dafb86046472506755d8501c5615673955f6aa17181125d13c37"
|
||||
checksum = "54473be61f4ebe4efd09cec9bd5d16fa51d70ea0192213d754d2d500457db110"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -945,9 +1004,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tui"
|
||||
version = "0.15.0"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "861d8f3ad314ede6219bcb2ab844054b1de279ee37a9bc38e3d606f9d3fb2a71"
|
||||
checksum = "39c8ce4e27049eed97cfa363a5048b09d995e209994634a0efc26a14ab6c0c23"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cassowary",
|
||||
@@ -956,6 +1015,12 @@ dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ucd-trie"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.8.0"
|
||||
@@ -964,9 +1029,9 @@ checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.8"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
|
||||
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "audio-conv"
|
||||
version = "1.2.1"
|
||||
version = "1.2.2"
|
||||
edition = "2018"
|
||||
description = "Copies directory structure and converts audio files in it"
|
||||
authors = ["Thomas Heck <t@b128.net>"]
|
||||
@@ -36,7 +36,7 @@ serde_yaml = "0.8"
|
||||
regex = "1"
|
||||
globset = "0.4"
|
||||
derive_more = "0.99"
|
||||
tui = { version = "0.15", default-features = false, features = ["crossterm"] }
|
||||
tui = { version = "0.16", default-features = false, features = ["crossterm"] }
|
||||
|
||||
[dependencies.tokio]
|
||||
version = "1"
|
||||
|
||||
@@ -13,10 +13,6 @@ matches:
|
||||
bitrate: 160
|
||||
bitrate_type: vbr # or cbr
|
||||
|
||||
# for copy (copies file without transcoding it):
|
||||
# to:
|
||||
# codec: copy
|
||||
|
||||
# for mp3:
|
||||
# to:
|
||||
# codec: mp3
|
||||
@@ -29,3 +25,12 @@ matches:
|
||||
# codec: flac
|
||||
# # effort spend for the compression. 0 (fastes compression) to 9 (highest compression)
|
||||
# compression: 8
|
||||
|
||||
# copies the whole file without transcoding it or extracting audio from it. Using Copy on Write
|
||||
# if supported by the filesystem.
|
||||
# to:
|
||||
# codec: copy
|
||||
|
||||
# extracts the audio without transcoding it
|
||||
# to:
|
||||
# codec: copyaudio
|
||||
|
||||
12
flake.lock
generated
12
flake.lock
generated
@@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1623875721,
|
||||
"narHash": "sha256-A8BU7bjS5GirpAUv4QA+QnJ4CceLHkcXdRp4xITDB0s=",
|
||||
"lastModified": 1629481132,
|
||||
"narHash": "sha256-JHgasjPR0/J1J3DRm4KxM4zTyAj4IOJY8vIl75v/kPI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "f7e004a55b120c02ecb6219596820fcd32ca8772",
|
||||
"rev": "997f7efcb746a9c140ce1f13c72263189225f482",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -32,11 +32,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1625503609,
|
||||
"narHash": "sha256-g5uv+BoL+GnT4nnCziiXNuKp0UMWtjNdss5AY/GZBzY=",
|
||||
"lastModified": 1629897889,
|
||||
"narHash": "sha256-YoY/umk+NUtLFJgvTJkup6nLJb+sGEZ21hrupKTp7EI=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a00a31df2fe83ccf0a9fb6ab6934ff4e71dc0b37",
|
||||
"rev": "6248814b6892af7dc0cf973b49690fd102088e02",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
484
src/config.rs
484
src/config.rs
@@ -3,318 +3,322 @@ use globset::GlobBuilder;
|
||||
use regex::bytes::{Regex, RegexBuilder};
|
||||
use serde::Deserialize;
|
||||
use std::{
|
||||
io::Write,
|
||||
path::{Path, PathBuf},
|
||||
io::Write,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Config {
|
||||
pub from: PathBuf,
|
||||
pub to: PathBuf,
|
||||
pub matches: Vec<TranscodeMatch>,
|
||||
pub jobs: Option<usize>,
|
||||
pub from: PathBuf,
|
||||
pub to: PathBuf,
|
||||
pub matches: Vec<TranscodeMatch>,
|
||||
pub jobs: Option<usize>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TranscodeMatch {
|
||||
pub regexes: Vec<Regex>,
|
||||
pub to: Transcode,
|
||||
pub regexes: Vec<Regex>,
|
||||
pub to: Transcode,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(tag = "codec")]
|
||||
pub enum Transcode {
|
||||
#[serde(rename = "opus")]
|
||||
Opus {
|
||||
#[serde(default = "default_opus_bitrate")]
|
||||
bitrate: u16,
|
||||
#[serde(rename = "opus")]
|
||||
Opus {
|
||||
#[serde(default = "default_opus_bitrate")]
|
||||
bitrate: u16,
|
||||
|
||||
#[serde(default = "bitrate_type_vbr")]
|
||||
bitrate_type: BitrateType,
|
||||
},
|
||||
#[serde(default = "bitrate_type_vbr")]
|
||||
bitrate_type: BitrateType,
|
||||
},
|
||||
|
||||
#[serde(rename = "flac")]
|
||||
Flac {
|
||||
#[serde(default = "default_flac_compression")]
|
||||
compression: u8,
|
||||
},
|
||||
#[serde(rename = "flac")]
|
||||
Flac {
|
||||
#[serde(default = "default_flac_compression")]
|
||||
compression: u8,
|
||||
},
|
||||
|
||||
#[serde(rename = "mp3")]
|
||||
Mp3 {
|
||||
#[serde(default = "default_mp3_bitrate")]
|
||||
bitrate: u16,
|
||||
#[serde(rename = "mp3")]
|
||||
Mp3 {
|
||||
#[serde(default = "default_mp3_bitrate")]
|
||||
bitrate: u16,
|
||||
|
||||
#[serde(default = "bitrate_type_vbr")]
|
||||
bitrate_type: BitrateType,
|
||||
},
|
||||
#[serde(default = "bitrate_type_vbr")]
|
||||
bitrate_type: BitrateType,
|
||||
},
|
||||
|
||||
#[serde(rename = "copy")]
|
||||
Copy,
|
||||
#[serde(rename = "copy")]
|
||||
Copy,
|
||||
|
||||
#[serde(rename = "copyaudio")]
|
||||
CopyAudio,
|
||||
}
|
||||
|
||||
impl Transcode {
|
||||
pub fn extension(&self) -> &'static str {
|
||||
match self {
|
||||
Transcode::Opus { .. } => "opus",
|
||||
Transcode::Flac { .. } => "flac",
|
||||
Transcode::Mp3 { .. } => "mp3",
|
||||
Transcode::Copy => "",
|
||||
}
|
||||
}
|
||||
pub fn extension(&self) -> &'static str {
|
||||
match self {
|
||||
Transcode::Opus { .. } => "opus",
|
||||
Transcode::Flac { .. } => "flac",
|
||||
Transcode::Mp3 { .. } => "mp3",
|
||||
Transcode::Copy => "",
|
||||
Transcode::CopyAudio => "",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn default_opus_bitrate() -> u16 {
|
||||
160
|
||||
160
|
||||
}
|
||||
|
||||
fn default_flac_compression() -> u8 {
|
||||
5
|
||||
5
|
||||
}
|
||||
|
||||
fn bitrate_type_vbr() -> BitrateType {
|
||||
BitrateType::Vbr
|
||||
BitrateType::Vbr
|
||||
}
|
||||
|
||||
fn default_mp3_bitrate() -> u16 {
|
||||
256
|
||||
256
|
||||
}
|
||||
|
||||
impl Default for Transcode {
|
||||
fn default() -> Self {
|
||||
Transcode::Opus {
|
||||
bitrate: default_opus_bitrate(),
|
||||
bitrate_type: bitrate_type_vbr(),
|
||||
}
|
||||
}
|
||||
fn default() -> Self {
|
||||
Transcode::Opus {
|
||||
bitrate: default_opus_bitrate(),
|
||||
bitrate_type: bitrate_type_vbr(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
pub enum BitrateType {
|
||||
#[serde(rename = "cbr")]
|
||||
Cbr,
|
||||
#[serde(rename = "vbr")]
|
||||
Vbr,
|
||||
#[serde(rename = "cbr")]
|
||||
Cbr,
|
||||
#[serde(rename = "vbr")]
|
||||
Vbr,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
struct ConfigFile {
|
||||
from: Option<PathBuf>,
|
||||
to: Option<PathBuf>,
|
||||
from: Option<PathBuf>,
|
||||
to: Option<PathBuf>,
|
||||
|
||||
#[serde(default)]
|
||||
matches: Vec<TranscodeMatchFile>,
|
||||
#[serde(default)]
|
||||
matches: Vec<TranscodeMatchFile>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct TranscodeMatchFile {
|
||||
glob: Option<String>,
|
||||
regex: Option<String>,
|
||||
glob: Option<String>,
|
||||
regex: Option<String>,
|
||||
|
||||
#[serde(default)]
|
||||
extensions: Vec<String>,
|
||||
#[serde(default)]
|
||||
extensions: Vec<String>,
|
||||
|
||||
to: Transcode,
|
||||
to: Transcode,
|
||||
}
|
||||
|
||||
pub fn config() -> Result<Config> {
|
||||
use clap::{App, Arg, SubCommand};
|
||||
use clap::{App, Arg, SubCommand};
|
||||
|
||||
let arg_matches = App::new("audio-conv")
|
||||
.version(clap::crate_version!())
|
||||
.about("Converts audio files")
|
||||
.arg(
|
||||
Arg::with_name("config")
|
||||
.short("c")
|
||||
.long("config")
|
||||
.required(false)
|
||||
.takes_value(true)
|
||||
.help("Path to an audio-conv config file, defaults to \"audio-conv.yaml\""),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("from")
|
||||
.short("f")
|
||||
.long("from")
|
||||
.required(false)
|
||||
.takes_value(true)
|
||||
.help("\"from\" directory path"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("to")
|
||||
.short("t")
|
||||
.long("to")
|
||||
.required(false)
|
||||
.takes_value(true)
|
||||
.help("\"to\" directory path"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("jobs")
|
||||
.short("j")
|
||||
.long("jobs")
|
||||
.required(false)
|
||||
.takes_value(true)
|
||||
.help("Allow N jobs/transcodes at once. Defaults to number of logical cores"),
|
||||
)
|
||||
.subcommand(SubCommand::with_name("init").about("writes an example config"))
|
||||
.get_matches();
|
||||
let arg_matches = App::new("audio-conv")
|
||||
.version(clap::crate_version!())
|
||||
.about("Converts audio files")
|
||||
.arg(
|
||||
Arg::with_name("config")
|
||||
.short("c")
|
||||
.long("config")
|
||||
.required(false)
|
||||
.takes_value(true)
|
||||
.help("Path to an audio-conv config file, defaults to \"audio-conv.yaml\""),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("from")
|
||||
.short("f")
|
||||
.long("from")
|
||||
.required(false)
|
||||
.takes_value(true)
|
||||
.help("\"from\" directory path"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("to")
|
||||
.short("t")
|
||||
.long("to")
|
||||
.required(false)
|
||||
.takes_value(true)
|
||||
.help("\"to\" directory path"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("jobs")
|
||||
.short("j")
|
||||
.long("jobs")
|
||||
.required(false)
|
||||
.takes_value(true)
|
||||
.help("Allow N jobs/transcodes at once. Defaults to number of logical cores"),
|
||||
)
|
||||
.subcommand(SubCommand::with_name("init").about("writes an example config"))
|
||||
.get_matches();
|
||||
|
||||
let current_dir = std::env::current_dir().context("Could not get current directory")?;
|
||||
let current_dir = std::env::current_dir().context("Could not get current directory")?;
|
||||
|
||||
let config_path = arg_matches.value_of_os("config");
|
||||
let force_load = config_path.is_some();
|
||||
let config_path = config_path
|
||||
.map(AsRef::<Path>::as_ref)
|
||||
.unwrap_or_else(|| AsRef::<Path>::as_ref("audio-conv.yaml"));
|
||||
let config_path = current_dir.join(config_path);
|
||||
let config_path = arg_matches.value_of_os("config");
|
||||
let force_load = config_path.is_some();
|
||||
let config_path = config_path
|
||||
.map(AsRef::<Path>::as_ref)
|
||||
.unwrap_or_else(|| AsRef::<Path>::as_ref("audio-conv.yaml"));
|
||||
let config_path = current_dir.join(config_path);
|
||||
|
||||
if let Some("init") = arg_matches.subcommand_name() {
|
||||
std::fs::OpenOptions::new()
|
||||
.write(true)
|
||||
.create_new(true)
|
||||
.open(&config_path)
|
||||
.and_then(|mut f| f.write_all(std::include_bytes!("../example.audio-conv.yaml")))
|
||||
.with_context(|| format!("Unable to write config file to {}", config_path.display()))?;
|
||||
if let Some("init") = arg_matches.subcommand_name() {
|
||||
std::fs::OpenOptions::new()
|
||||
.write(true)
|
||||
.create_new(true)
|
||||
.open(&config_path)
|
||||
.and_then(|mut f| f.write_all(std::include_bytes!("../example.audio-conv.yaml")))
|
||||
.with_context(|| format!("Unable to write config file to {}", config_path.display()))?;
|
||||
|
||||
std::process::exit(0);
|
||||
}
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
let config_dir = config_path
|
||||
.parent()
|
||||
.context("Could not get parent directory of the config file")?;
|
||||
let config_dir = config_path
|
||||
.parent()
|
||||
.context("Could not get parent directory of the config file")?;
|
||||
|
||||
let config_file = load_config_file(&config_path)
|
||||
.with_context(|| format!("Failed loading config file {}", config_path.display()))?;
|
||||
let config_file = load_config_file(&config_path)
|
||||
.with_context(|| format!("Failed loading config file {}", config_path.display()))?;
|
||||
|
||||
if force_load && config_file.is_none() {
|
||||
return Err(Error::msg(format!(
|
||||
"could not find config file \"{}\"",
|
||||
config_path.display()
|
||||
)));
|
||||
}
|
||||
if force_load && config_file.is_none() {
|
||||
return Err(Error::msg(format!(
|
||||
"could not find config file \"{}\"",
|
||||
config_path.display()
|
||||
)));
|
||||
}
|
||||
|
||||
let default_regex = RegexBuilder::new("\\.(flac|wav)$")
|
||||
.case_insensitive(true)
|
||||
.build()
|
||||
.expect("Failed compiling default match regex");
|
||||
let default_regex = RegexBuilder::new("\\.(flac|wav)$")
|
||||
.case_insensitive(true)
|
||||
.build()
|
||||
.expect("Failed compiling default match regex");
|
||||
|
||||
let transcode_matches = config_file
|
||||
.as_ref()
|
||||
.map(|config_file| {
|
||||
config_file
|
||||
.matches
|
||||
.iter()
|
||||
.map(|m| {
|
||||
let glob = m.glob.iter().map(|glob| {
|
||||
let glob = GlobBuilder::new(glob)
|
||||
.case_insensitive(true)
|
||||
.build()
|
||||
.context("Failed building glob")?;
|
||||
let regex = Regex::new(glob.regex()).context("Failed compiling regex")?;
|
||||
Ok(regex)
|
||||
});
|
||||
let transcode_matches = config_file
|
||||
.as_ref()
|
||||
.map(|config_file| {
|
||||
config_file
|
||||
.matches
|
||||
.iter()
|
||||
.map(|m| {
|
||||
let glob = m.glob.iter().map(|glob| {
|
||||
let glob = GlobBuilder::new(glob)
|
||||
.case_insensitive(true)
|
||||
.build()
|
||||
.context("Failed building glob")?;
|
||||
let regex = Regex::new(glob.regex()).context("Failed compiling regex")?;
|
||||
Ok(regex)
|
||||
});
|
||||
|
||||
let regex = m.regex.iter().map(|regex| {
|
||||
let regex = RegexBuilder::new(regex)
|
||||
.case_insensitive(true)
|
||||
.build()
|
||||
.context("Failed compiling regex")?;
|
||||
Ok(regex)
|
||||
});
|
||||
let regex = m.regex.iter().map(|regex| {
|
||||
let regex = RegexBuilder::new(regex)
|
||||
.case_insensitive(true)
|
||||
.build()
|
||||
.context("Failed compiling regex")?;
|
||||
Ok(regex)
|
||||
});
|
||||
|
||||
let extensions = m.extensions.iter().map(|ext| {
|
||||
let mut ext = regex::escape(ext);
|
||||
ext.insert_str(0, &"\\.");
|
||||
ext.push_str("$");
|
||||
let extensions = m.extensions.iter().map(|ext| {
|
||||
let mut ext = regex::escape(ext);
|
||||
ext.insert_str(0, &"\\.");
|
||||
ext.push_str("$");
|
||||
|
||||
let regex = RegexBuilder::new(&ext)
|
||||
.case_insensitive(true)
|
||||
.build()
|
||||
.context("Failed compiling regex")?;
|
||||
Ok(regex)
|
||||
});
|
||||
let regex = RegexBuilder::new(&ext)
|
||||
.case_insensitive(true)
|
||||
.build()
|
||||
.context("Failed compiling regex")?;
|
||||
Ok(regex)
|
||||
});
|
||||
|
||||
let mut regexes = glob
|
||||
.chain(regex)
|
||||
.chain(extensions)
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
let mut regexes = glob
|
||||
.chain(regex)
|
||||
.chain(extensions)
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
|
||||
if regexes.is_empty() {
|
||||
regexes.push(default_regex.clone());
|
||||
}
|
||||
if regexes.is_empty() {
|
||||
regexes.push(default_regex.clone());
|
||||
}
|
||||
|
||||
Ok(TranscodeMatch {
|
||||
regexes,
|
||||
to: m.to.clone(),
|
||||
})
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()
|
||||
})
|
||||
.transpose()?
|
||||
.filter(|matches| !matches.is_empty())
|
||||
.unwrap_or_else(|| {
|
||||
vec![TranscodeMatch {
|
||||
regexes: vec![default_regex],
|
||||
to: Transcode::default(),
|
||||
}]
|
||||
});
|
||||
Ok(TranscodeMatch {
|
||||
regexes,
|
||||
to: m.to.clone(),
|
||||
})
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()
|
||||
})
|
||||
.transpose()?
|
||||
.filter(|matches| !matches.is_empty())
|
||||
.unwrap_or_else(|| {
|
||||
vec![TranscodeMatch {
|
||||
regexes: vec![default_regex],
|
||||
to: Transcode::default(),
|
||||
}]
|
||||
});
|
||||
|
||||
Ok(Config {
|
||||
from: {
|
||||
arg_matches
|
||||
.value_of_os("from")
|
||||
.map(|p| current_dir.join(p))
|
||||
.or_else(|| {
|
||||
config_file
|
||||
.as_ref()
|
||||
.map(|c| c.from.as_ref())
|
||||
.flatten()
|
||||
.map(|p| config_dir.join(p))
|
||||
})
|
||||
.ok_or_else(|| Error::msg("\"from\" not configured"))?
|
||||
.canonicalize()
|
||||
.context("Could not canonicalize \"from\" path")?
|
||||
},
|
||||
to: arg_matches
|
||||
.value_of_os("to")
|
||||
.map(|p| current_dir.join(p))
|
||||
.or_else(|| {
|
||||
config_file
|
||||
.as_ref()
|
||||
.map(|c| c.to.as_ref())
|
||||
.flatten()
|
||||
.map(|p| config_dir.join(p))
|
||||
})
|
||||
.ok_or_else(|| Error::msg("\"to\" not configured"))?
|
||||
.canonicalize()
|
||||
.context("Could not canonicalize \"to\" path")?,
|
||||
matches: transcode_matches,
|
||||
jobs: arg_matches
|
||||
.value_of_os("jobs")
|
||||
.map(|jobs_os_str| {
|
||||
let jobs_str = jobs_os_str.to_str().with_context(|| {
|
||||
// TODO: use `OsStr.display` when it lands
|
||||
// https://github.com/rust-lang/rust/pull/80841
|
||||
format!(
|
||||
"Could not convert \"jobs\" argument to string due to invalid characters",
|
||||
)
|
||||
})?;
|
||||
jobs_str.parse().with_context(|| {
|
||||
format!(
|
||||
"Could not parse \"jobs\" argument \"{}\" to a number",
|
||||
&jobs_str
|
||||
)
|
||||
})
|
||||
})
|
||||
.transpose()?,
|
||||
})
|
||||
Ok(Config {
|
||||
from: {
|
||||
arg_matches
|
||||
.value_of_os("from")
|
||||
.map(|p| current_dir.join(p))
|
||||
.or_else(|| {
|
||||
config_file
|
||||
.as_ref()
|
||||
.map(|c| c.from.as_ref())
|
||||
.flatten()
|
||||
.map(|p| config_dir.join(p))
|
||||
})
|
||||
.ok_or_else(|| Error::msg("\"from\" not configured"))?
|
||||
.canonicalize()
|
||||
.context("Could not canonicalize \"from\" path")?
|
||||
},
|
||||
to: arg_matches
|
||||
.value_of_os("to")
|
||||
.map(|p| current_dir.join(p))
|
||||
.or_else(|| {
|
||||
config_file
|
||||
.as_ref()
|
||||
.map(|c| c.to.as_ref())
|
||||
.flatten()
|
||||
.map(|p| config_dir.join(p))
|
||||
})
|
||||
.ok_or_else(|| Error::msg("\"to\" not configured"))?
|
||||
.canonicalize()
|
||||
.context("Could not canonicalize \"to\" path")?,
|
||||
matches: transcode_matches,
|
||||
jobs: arg_matches
|
||||
.value_of_os("jobs")
|
||||
.map(|jobs_os_str| {
|
||||
let jobs_str = jobs_os_str.to_str().with_context(|| {
|
||||
// TODO: use `OsStr.display` when it lands
|
||||
// https://github.com/rust-lang/rust/pull/80841
|
||||
format!(
|
||||
"Could not convert \"jobs\" argument to string due to invalid characters",
|
||||
)
|
||||
})?;
|
||||
jobs_str.parse().with_context(|| {
|
||||
format!(
|
||||
"Could not parse \"jobs\" argument \"{}\" to a number",
|
||||
&jobs_str
|
||||
)
|
||||
})
|
||||
})
|
||||
.transpose()?,
|
||||
})
|
||||
}
|
||||
|
||||
fn load_config_file(path: &Path) -> Result<Option<ConfigFile>> {
|
||||
let mut file = match std::fs::File::open(path) {
|
||||
Ok(file) => file,
|
||||
Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(None),
|
||||
Err(err) => return Err(Error::new(err)),
|
||||
};
|
||||
let config: ConfigFile =
|
||||
serde_yaml::from_reader(&mut file).context("Could not parse config file")?;
|
||||
Ok(Some(config))
|
||||
let mut file = match std::fs::File::open(path) {
|
||||
Ok(file) => file,
|
||||
Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(None),
|
||||
Err(err) => return Err(Error::new(err)),
|
||||
};
|
||||
let config: ConfigFile =
|
||||
serde_yaml::from_reader(&mut file).context("Could not parse config file")?;
|
||||
Ok(Some(config))
|
||||
}
|
||||
|
||||
1110
src/main.rs
1110
src/main.rs
File diff suppressed because it is too large
Load Diff
440
src/ui.rs
440
src/ui.rs
@@ -2,8 +2,8 @@ use crate::ConversionArgs;
|
||||
use anyhow::{Context, Result};
|
||||
use futures::Future;
|
||||
use std::{
|
||||
borrow::Cow, cell::RefCell, collections::HashMap, io, mem, path::PathBuf, rc::Rc,
|
||||
time::Duration,
|
||||
borrow::Cow, cell::RefCell, collections::HashMap, io, mem, path::PathBuf, rc::Rc,
|
||||
time::Duration,
|
||||
};
|
||||
use tokio::{task, time::interval};
|
||||
use tui::{backend::CrosstermBackend, Terminal};
|
||||
@@ -12,272 +12,272 @@ pub const UPDATE_INTERVAL_MILLIS: u64 = 100;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Msg {
|
||||
Init { task_len: usize, log_path: PathBuf },
|
||||
Exit,
|
||||
TaskStart { id: usize, args: ConversionArgs },
|
||||
TaskEnd { id: usize },
|
||||
TaskProgress { id: usize, ratio: f64 },
|
||||
TaskError { id: usize },
|
||||
Init { task_len: usize, log_path: PathBuf },
|
||||
Exit,
|
||||
TaskStart { id: usize, args: ConversionArgs },
|
||||
TaskEnd { id: usize },
|
||||
TaskProgress { id: usize, ratio: f64 },
|
||||
TaskError { id: usize },
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct MsgQueue {
|
||||
inner: Rc<RefCell<Vec<Msg>>>,
|
||||
inner: Rc<RefCell<Vec<Msg>>>,
|
||||
}
|
||||
|
||||
impl MsgQueue {
|
||||
fn new() -> MsgQueue {
|
||||
MsgQueue {
|
||||
inner: Rc::new(RefCell::new(Vec::new())),
|
||||
}
|
||||
}
|
||||
fn new() -> MsgQueue {
|
||||
MsgQueue {
|
||||
inner: Rc::new(RefCell::new(Vec::new())),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn push(&self, msg: Msg) {
|
||||
self.inner.borrow_mut().push(msg);
|
||||
}
|
||||
pub fn push(&self, msg: Msg) {
|
||||
self.inner.borrow_mut().push(msg);
|
||||
}
|
||||
|
||||
fn swap_inner(&self, other: &mut Vec<Msg>) {
|
||||
let mut inner = self.inner.borrow_mut();
|
||||
mem::swap(&mut *inner, other)
|
||||
}
|
||||
fn swap_inner(&self, other: &mut Vec<Msg>) {
|
||||
let mut inner = self.inner.borrow_mut();
|
||||
mem::swap(&mut *inner, other)
|
||||
}
|
||||
}
|
||||
|
||||
struct State {
|
||||
terminal: Terminal<CrosstermBackend<io::Stdout>>,
|
||||
log_path: Option<PathBuf>,
|
||||
task_len: Option<usize>,
|
||||
ended_tasks: usize,
|
||||
running_tasks: HashMap<usize, Task>,
|
||||
has_rendered: bool,
|
||||
has_errored: bool,
|
||||
terminal: Terminal<CrosstermBackend<io::Stdout>>,
|
||||
log_path: Option<PathBuf>,
|
||||
task_len: Option<usize>,
|
||||
ended_tasks: usize,
|
||||
running_tasks: HashMap<usize, Task>,
|
||||
has_rendered: bool,
|
||||
has_errored: bool,
|
||||
}
|
||||
|
||||
impl State {
|
||||
fn new() -> Result<State> {
|
||||
let terminal = Terminal::new(CrosstermBackend::new(io::stdout()))
|
||||
.context("Unable to create ui terminal")?;
|
||||
fn new() -> Result<State> {
|
||||
let terminal = Terminal::new(CrosstermBackend::new(io::stdout()))
|
||||
.context("Unable to create ui terminal")?;
|
||||
|
||||
Ok(State {
|
||||
terminal,
|
||||
log_path: None,
|
||||
task_len: None,
|
||||
ended_tasks: 0,
|
||||
running_tasks: HashMap::new(),
|
||||
has_rendered: false,
|
||||
has_errored: false,
|
||||
})
|
||||
}
|
||||
Ok(State {
|
||||
terminal,
|
||||
log_path: None,
|
||||
task_len: None,
|
||||
ended_tasks: 0,
|
||||
running_tasks: HashMap::new(),
|
||||
has_rendered: false,
|
||||
has_errored: false,
|
||||
})
|
||||
}
|
||||
|
||||
fn process_msg(&mut self, msg: Msg) -> Result<bool> {
|
||||
match msg {
|
||||
Msg::Init { task_len, log_path } => {
|
||||
self.task_len = Some(task_len);
|
||||
self.log_path = Some(log_path);
|
||||
}
|
||||
Msg::Exit => return Ok(false),
|
||||
Msg::TaskStart { id, args } => {
|
||||
self.running_tasks.insert(
|
||||
id,
|
||||
Task {
|
||||
id,
|
||||
ratio: None,
|
||||
args,
|
||||
},
|
||||
);
|
||||
}
|
||||
Msg::TaskEnd { id } => {
|
||||
self.running_tasks
|
||||
.remove(&id)
|
||||
.context("Unable to remove finished task; could't find task")?;
|
||||
self.ended_tasks += 1;
|
||||
}
|
||||
Msg::TaskProgress { id, ratio } => {
|
||||
let mut task = self
|
||||
.running_tasks
|
||||
.get_mut(&id)
|
||||
.context("Unable to update task progress; could't find task")?;
|
||||
task.ratio = Some(ratio);
|
||||
}
|
||||
Msg::TaskError { id } => {
|
||||
// TODO
|
||||
self.running_tasks
|
||||
.remove(&id)
|
||||
.context("Unable to remove errored task; could't find task")?;
|
||||
self.ended_tasks += 1;
|
||||
self.has_errored = true;
|
||||
}
|
||||
}
|
||||
fn process_msg(&mut self, msg: Msg) -> Result<bool> {
|
||||
match msg {
|
||||
Msg::Init { task_len, log_path } => {
|
||||
self.task_len = Some(task_len);
|
||||
self.log_path = Some(log_path);
|
||||
}
|
||||
Msg::Exit => return Ok(false),
|
||||
Msg::TaskStart { id, args } => {
|
||||
self.running_tasks.insert(
|
||||
id,
|
||||
Task {
|
||||
id,
|
||||
ratio: None,
|
||||
args,
|
||||
},
|
||||
);
|
||||
}
|
||||
Msg::TaskEnd { id } => {
|
||||
self.running_tasks
|
||||
.remove(&id)
|
||||
.context("Unable to remove finished task; could't find task")?;
|
||||
self.ended_tasks += 1;
|
||||
}
|
||||
Msg::TaskProgress { id, ratio } => {
|
||||
let mut task = self
|
||||
.running_tasks
|
||||
.get_mut(&id)
|
||||
.context("Unable to update task progress; could't find task")?;
|
||||
task.ratio = Some(ratio);
|
||||
}
|
||||
Msg::TaskError { id } => {
|
||||
// TODO
|
||||
self.running_tasks
|
||||
.remove(&id)
|
||||
.context("Unable to remove errored task; could't find task")?;
|
||||
self.ended_tasks += 1;
|
||||
self.has_errored = true;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(true)
|
||||
}
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn render(&mut self) -> Result<()> {
|
||||
use tui::{
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
style::{Color, Modifier, Style},
|
||||
text::Text,
|
||||
widgets::{Block, Borders, Gauge, Paragraph},
|
||||
};
|
||||
fn render(&mut self) -> Result<()> {
|
||||
use tui::{
|
||||
layout::{Constraint, Direction, Layout, Rect},
|
||||
style::{Color, Modifier, Style},
|
||||
text::Text,
|
||||
widgets::{Block, Borders, Gauge, Paragraph},
|
||||
};
|
||||
|
||||
let task_len = if let Some(task_len) = self.task_len {
|
||||
task_len
|
||||
} else {
|
||||
return Ok(());
|
||||
};
|
||||
let task_len = if let Some(task_len) = self.task_len {
|
||||
task_len
|
||||
} else {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
if task_len == 0 {
|
||||
return Ok(());
|
||||
}
|
||||
if task_len == 0 {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let tasks_ended = self.ended_tasks;
|
||||
let tasks_ended = self.ended_tasks;
|
||||
|
||||
let mut running_tasks: Vec<_> = self.running_tasks.values().cloned().collect();
|
||||
let mut running_tasks: Vec<_> = self.running_tasks.values().cloned().collect();
|
||||
|
||||
running_tasks.sort_by_key(|task| task.id);
|
||||
running_tasks.sort_by_key(|task| task.id);
|
||||
|
||||
if !self.has_rendered {
|
||||
self.terminal.clear().context("Clearing ui failed")?;
|
||||
self.has_rendered = true;
|
||||
}
|
||||
if !self.has_rendered {
|
||||
self.terminal.clear().context("Clearing ui failed")?;
|
||||
self.has_rendered = true;
|
||||
}
|
||||
|
||||
let error_text = match self.has_errored {
|
||||
true => {
|
||||
let text: Cow<'static, str> = self
|
||||
.log_path
|
||||
.as_ref()
|
||||
.map(|lp| {
|
||||
let text = format!("Error(s) occurred and were logged to {}", lp.display());
|
||||
Cow::Owned(text)
|
||||
})
|
||||
.unwrap_or_else(|| Cow::Borrowed("Error(s) occurred"));
|
||||
Some(text)
|
||||
}
|
||||
false => None,
|
||||
};
|
||||
let error_text = match self.has_errored {
|
||||
true => {
|
||||
let text: Cow<'static, str> = self
|
||||
.log_path
|
||||
.as_ref()
|
||||
.map(|lp| {
|
||||
let text = format!("Error(s) occurred and were logged to {}", lp.display());
|
||||
Cow::Owned(text)
|
||||
})
|
||||
.unwrap_or_else(|| Cow::Borrowed("Error(s) occurred"));
|
||||
Some(text)
|
||||
}
|
||||
false => None,
|
||||
};
|
||||
|
||||
self.terminal
|
||||
.draw(|f| {
|
||||
let chunks = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.margin(1)
|
||||
.constraints([Constraint::Percentage(90), Constraint::Percentage(10)].as_ref())
|
||||
.split(f.size());
|
||||
self.terminal
|
||||
.draw(|f| {
|
||||
let chunks = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.margin(1)
|
||||
.constraints([Constraint::Percentage(90), Constraint::Percentage(10)].as_ref())
|
||||
.split(f.size());
|
||||
|
||||
let mut task_rect = chunks[0];
|
||||
let mut task_rect = chunks[0];
|
||||
|
||||
if error_text.is_some() {
|
||||
task_rect.height -= 3;
|
||||
}
|
||||
if error_text.is_some() {
|
||||
task_rect.height -= 3;
|
||||
}
|
||||
|
||||
for (row, task) in running_tasks
|
||||
.into_iter()
|
||||
.take(task_rect.height as usize / 2)
|
||||
.enumerate()
|
||||
{
|
||||
f.render_widget(
|
||||
Gauge::default()
|
||||
.label(task.args.rel_from_path.to_string_lossy().as_ref())
|
||||
.gauge_style(
|
||||
Style::default()
|
||||
.fg(Color::White)
|
||||
.bg(Color::Black)
|
||||
.add_modifier(Modifier::ITALIC),
|
||||
)
|
||||
.ratio(task.ratio.unwrap_or(0.0)),
|
||||
Rect::new(
|
||||
task_rect.x,
|
||||
task_rect.y + row as u16 * 2,
|
||||
task_rect.width,
|
||||
1,
|
||||
),
|
||||
);
|
||||
}
|
||||
for (row, task) in running_tasks
|
||||
.into_iter()
|
||||
.take(task_rect.height as usize / 2)
|
||||
.enumerate()
|
||||
{
|
||||
f.render_widget(
|
||||
Gauge::default()
|
||||
.label(task.args.rel_from_path.to_string_lossy().as_ref())
|
||||
.gauge_style(
|
||||
Style::default()
|
||||
.fg(Color::White)
|
||||
.bg(Color::Black)
|
||||
.add_modifier(Modifier::ITALIC),
|
||||
)
|
||||
.ratio(task.ratio.unwrap_or(0.0)),
|
||||
Rect::new(
|
||||
task_rect.x,
|
||||
task_rect.y + row as u16 * 2,
|
||||
task_rect.width,
|
||||
1,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(error_text) = error_text {
|
||||
f.render_widget(
|
||||
Paragraph::new(Text::raw(error_text)).style(
|
||||
Style::default()
|
||||
.fg(Color::Red)
|
||||
.bg(Color::Black)
|
||||
.add_modifier(Modifier::BOLD),
|
||||
),
|
||||
Rect::new(task_rect.x, task_rect.height + 1, task_rect.width, 2),
|
||||
);
|
||||
}
|
||||
if let Some(error_text) = error_text {
|
||||
f.render_widget(
|
||||
Paragraph::new(Text::raw(error_text)).style(
|
||||
Style::default()
|
||||
.fg(Color::Red)
|
||||
.bg(Color::Black)
|
||||
.add_modifier(Modifier::BOLD),
|
||||
),
|
||||
Rect::new(task_rect.x, task_rect.height + 1, task_rect.width, 2),
|
||||
);
|
||||
}
|
||||
|
||||
f.render_widget(
|
||||
Gauge::default()
|
||||
.block(
|
||||
Block::default()
|
||||
.borders(Borders::ALL)
|
||||
.title("Overall Progress"),
|
||||
)
|
||||
.gauge_style(
|
||||
Style::default()
|
||||
.fg(Color::White)
|
||||
.bg(Color::Black)
|
||||
.add_modifier(Modifier::ITALIC),
|
||||
)
|
||||
.ratio(tasks_ended as f64 / task_len as f64),
|
||||
chunks[1],
|
||||
);
|
||||
})
|
||||
.context("Rendering ui failed")?;
|
||||
f.render_widget(
|
||||
Gauge::default()
|
||||
.block(
|
||||
Block::default()
|
||||
.borders(Borders::ALL)
|
||||
.title("Overall Progress"),
|
||||
)
|
||||
.gauge_style(
|
||||
Style::default()
|
||||
.fg(Color::White)
|
||||
.bg(Color::Black)
|
||||
.add_modifier(Modifier::ITALIC),
|
||||
)
|
||||
.ratio(tasks_ended as f64 / task_len as f64),
|
||||
chunks[1],
|
||||
);
|
||||
})
|
||||
.context("Rendering ui failed")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct Task {
|
||||
id: usize,
|
||||
ratio: Option<f64>,
|
||||
args: ConversionArgs,
|
||||
id: usize,
|
||||
ratio: Option<f64>,
|
||||
args: ConversionArgs,
|
||||
}
|
||||
|
||||
pub fn init() -> (MsgQueue, impl Future<Output = Result<()>>) {
|
||||
let queue = MsgQueue::new();
|
||||
let queue = MsgQueue::new();
|
||||
|
||||
let queue_clone = queue.clone();
|
||||
let fut = async move {
|
||||
let mut interval = interval(Duration::from_millis(UPDATE_INTERVAL_MILLIS));
|
||||
let mut wrapped = Some((Vec::new(), State::new()?));
|
||||
let queue_clone = queue.clone();
|
||||
let fut = async move {
|
||||
let mut interval = interval(Duration::from_millis(UPDATE_INTERVAL_MILLIS));
|
||||
let mut wrapped = Some((Vec::new(), State::new()?));
|
||||
|
||||
loop {
|
||||
interval.tick().await;
|
||||
loop {
|
||||
interval.tick().await;
|
||||
|
||||
let (mut current_queue, mut state) = wrapped.take().context("`wrapped` is None")?;
|
||||
let (mut current_queue, mut state) = wrapped.take().context("`wrapped` is None")?;
|
||||
|
||||
queue_clone.swap_inner(&mut current_queue);
|
||||
queue_clone.swap_inner(&mut current_queue);
|
||||
|
||||
let render_res = task::spawn_blocking(move || -> Result<_> {
|
||||
let mut exit = false;
|
||||
for msg in current_queue.drain(..) {
|
||||
if !state.process_msg(msg)? {
|
||||
exit = true;
|
||||
}
|
||||
}
|
||||
let render_res = task::spawn_blocking(move || -> Result<_> {
|
||||
let mut exit = false;
|
||||
for msg in current_queue.drain(..) {
|
||||
if !state.process_msg(msg)? {
|
||||
exit = true;
|
||||
}
|
||||
}
|
||||
|
||||
state.render()?;
|
||||
state.render()?;
|
||||
|
||||
if exit {
|
||||
Ok(None)
|
||||
} else {
|
||||
Ok(Some((current_queue, state)))
|
||||
}
|
||||
})
|
||||
.await
|
||||
.context("Ui update task failed")?
|
||||
.context("Ui update failed")?;
|
||||
if exit {
|
||||
Ok(None)
|
||||
} else {
|
||||
Ok(Some((current_queue, state)))
|
||||
}
|
||||
})
|
||||
.await
|
||||
.context("Ui update task failed")?
|
||||
.context("Ui update failed")?;
|
||||
|
||||
match render_res {
|
||||
Some(s) => wrapped = Some(s),
|
||||
None => break,
|
||||
}
|
||||
}
|
||||
match render_res {
|
||||
Some(s) => wrapped = Some(s),
|
||||
None => break,
|
||||
}
|
||||
}
|
||||
|
||||
Result::<_>::Ok(())
|
||||
};
|
||||
Result::<_>::Ok(())
|
||||
};
|
||||
|
||||
(queue, fut)
|
||||
(queue, fut)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user