From cfddb17c46da26efe69b0ffb92c56aaec3ac06b7 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 31 Mar 2025 16:07:31 -0400 Subject: [PATCH] Update dependencies, run Cargo format --- Cargo.lock | 462 ++++++++++++++++++------------------- Cargo.toml | 4 +- build.rs | 2 +- src/bin/auracite/bridge.rs | 49 ++-- src/bin/auracite/main.rs | 58 +++-- src/downloader.rs | 6 +- src/html.rs | 7 +- src/lib.rs | 198 +++++++++------- src/parser.rs | 2 +- 9 files changed, 413 insertions(+), 375 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c11070..a64a39a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,7 +111,7 @@ dependencies = [ "miniz_oxide", "object", "rustc-demangle", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -181,25 +181,15 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cc" -version = "1.2.16" +version = "1.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" +checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" dependencies = [ "jobserver", "libc", "shlex", ] -[[package]] -name = "cfg-expr" -version = "0.17.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d4ba6e40bd1184518716a6e1a781bf9160e286d219ccdb8ab2612e74cfe4789" -dependencies = [ - "smallvec", - "target-lexicon", -] - [[package]] name = "cfg-if" version = "1.0.0" @@ -212,23 +202,23 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "696283b40e1a39d208ee614b92e5f6521d16962edeb47c48372585ec92419943" dependencies = [ - "thiserror 1.0.69", + "thiserror", ] [[package]] name = "clap" -version = "4.5.32" +version = "4.5.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83" +checksum = "e958897981290da2a852763fe9cdb89cd36977a5d729023127095fa94d95e2ff" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.32" +version = "4.5.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8" +checksum = "83b0f35019843db2160b5bb19ae09b4e6411ac33fc6a712003c33e03090e2489" dependencies = [ "anstyle", "clap_lex", @@ -243,9 +233,9 @@ checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "cmake-package" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd90df4fa9b3350d48f1fae59cf9f13b0443af2fe4f67d20422c3bebd76d4b81" +checksum = "73c5897d471bbb66c77e97f8156416f9aa98b0e5ae41610942f585bfa6d0c791" dependencies = [ "itertools 0.14.0", "once_cell", @@ -263,7 +253,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" dependencies = [ "termcolor", - "unicode-width", + "unicode-width 0.1.14", +] + +[[package]] +name = "codespan-reporting" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81" +dependencies = [ + "serde", + "termcolor", + "unicode-width 0.2.0", ] [[package]] @@ -347,9 +348,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.143" +version = "1.0.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "050906babad73f9b32a91cecc3063ff1e2235226dd2367dd839fd6fbc941c68a" +checksum = "4b4ab2681454aacfe7ce296ebc6df86791009f237f8020b0c752e8b245ba7c1d" dependencies = [ "cc", "cxxbridge-cmd", @@ -361,11 +362,11 @@ dependencies = [ [[package]] name = "cxx-gen" -version = "0.7.143" +version = "0.7.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07f05ce81cc0d7317872e9a2b7114dc84d0b620225f35161021fb7983fb4f17a" +checksum = "eaf41c22ee2f91421f55528fc24d024581cb54fa524506b36091ed676f3bee96" dependencies = [ - "codespan-reporting", + "codespan-reporting 0.12.0", "proc-macro2", "quote", "syn 2.0.100", @@ -395,7 +396,7 @@ dependencies = [ "cxx-qt-macro", "qt-build-utils", "static_assertions", - "thiserror 1.0.69", + "thiserror", ] [[package]] @@ -405,7 +406,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15f80e109aa68795486c70c302f6c2d921f00028b3b62038a4601efb5c585c1c" dependencies = [ "cc", - "codespan-reporting", + "codespan-reporting 0.11.1", "cxx-gen", "cxx-qt-gen", "proc-macro2", @@ -467,12 +468,12 @@ dependencies = [ [[package]] name = "cxxbridge-cmd" -version = "1.0.143" +version = "1.0.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19c3062da294104183e1c34ea9887941d4d8c74f6195ce9fbb430ac4b5290ede" +checksum = "7cbc41933767955d04c2a90151806029b93df5fd8b682ba22a967433347480a9" dependencies = [ "clap", - "codespan-reporting", + "codespan-reporting 0.12.0", "proc-macro2", "quote", "syn 2.0.100", @@ -480,15 +481,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.143" +version = "1.0.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4b358173a166833ddef75fe468579f71727c789b8082d4cc77c38d08f656c59" +checksum = "9133547634329a5b76e5f58d1e53c16d627699bbcd421b9007796311165f9667" [[package]] name = "cxxbridge-macro" -version = "1.0.143" +version = "1.0.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9531217f3b5f7728244d2b7312bc6660f6b3e4cdbc118f4f1fbce48cb401a0f" +checksum = "53e89d77ad5fd6066a3d42d94de3f72a2f23f95006da808177624429b5183596" dependencies = [ "proc-macro2", "quote", @@ -601,9 +602,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" [[package]] name = "foreign-types" @@ -693,7 +694,7 @@ version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" dependencies = [ - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -711,14 +712,14 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" dependencies = [ "cfg-if", "libc", - "wasi 0.13.3+wasi-0.2.2", - "windows-targets", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", ] [[package]] @@ -748,9 +749,9 @@ dependencies = [ [[package]] name = "half" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +checksum = "7db2ff139bba50379da6aa0766b52fdcb62cb5b263009b09ed58ba604e14bbd1" dependencies = [ "cfg-if", "crunchy", @@ -762,12 +763,6 @@ version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - [[package]] name = "html5ever" version = "0.27.0" @@ -784,9 +779,9 @@ dependencies = [ [[package]] name = "http" -version = "1.2.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" dependencies = [ "bytes", "fnv", @@ -805,12 +800,12 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" dependencies = [ "bytes", - "futures-util", + "futures-core", "http", "http-body", "pin-project-lite", @@ -877,9 +872,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +checksum = "497bbc33a26fdd4af9ed9c70d63f61cf56a938375fbb32df34db9b1cd6d643f2" dependencies = [ "bytes", "futures-channel", @@ -887,6 +882,7 @@ dependencies = [ "http", "http-body", "hyper", + "libc", "pin-project-lite", "socket2", "tokio", @@ -935,9 +931,9 @@ dependencies = [ [[package]] name = "icu_locid_transform_data" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" +checksum = "7515e6d781098bf9f7205ab3fc7e9709d34554ae0b21ddbcb5febfa4bc7df11d" [[package]] name = "icu_normalizer" @@ -959,9 +955,9 @@ dependencies = [ [[package]] name = "icu_normalizer_data" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" +checksum = "c5e8338228bdc8ab83303f16b797e177953730f601a96c25d10cb3ab0daa0cb7" [[package]] name = "icu_properties" @@ -980,9 +976,9 @@ dependencies = [ [[package]] name = "icu_properties_data" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" +checksum = "85fb8799753b75aee8d2a21d7c14d9f38921b54b3dbda10f5a3c7a7b82dba5e2" [[package]] name = "icu_provider" @@ -1100,20 +1096,17 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.170" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] -name = "libz-sys" -version = "1.1.21" +name = "libz-rs-sys" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df9b68e50e6e0b26f672573834882eb57759f6db9b3be2ea3c35c91188bb4eaa" +checksum = "902bc563b5d65ad9bba616b490842ef0651066a1a1dc3ce1087113ffcb873c8d" dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", + "zlib-rs", ] [[package]] @@ -1133,9 +1126,9 @@ checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "linux-raw-sys" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9c683daf087dc577b7506e9695b3d556a9f3849903fa28186283afd6809e9" +checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413" [[package]] name = "litemap" @@ -1155,9 +1148,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.26" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "mac" @@ -1193,9 +1186,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "minijinja" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e36f1329330bb1614c94b78632b9ce45dd7d761f3304a1bed07b2990a7c5097" +checksum = "98642a6dfca91122779a307b77cd07a4aa951fbe32232aaf5bad9febc66be754" dependencies = [ "serde", ] @@ -1270,9 +1263,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.21.0" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde51589ab56b20a6f686b2c68f7a0bd6add753d697abf720d63f8db3ab7b1ad" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "openssl" @@ -1338,7 +1331,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1440,14 +1433,12 @@ dependencies = [ [[package]] name = "physis" version = "0.4.0" -source = "git+https://github.com/redstrate/Physis#fecb21cf88306969c18d63828cd1f05ed5aa5d3e" +source = "git+https://github.com/redstrate/Physis#99238d9b5a0fa9084dc1ab5dd8db9f0786b0d836" dependencies = [ "binrw", "bitflags 1.3.2", "half", - "libz-sys", - "quote", - "system-deps", + "libz-rs-sys", "tracing", ] @@ -1475,7 +1466,7 @@ version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" dependencies = [ - "zerocopy 0.8.23", + "zerocopy 0.8.24", ] [[package]] @@ -1500,19 +1491,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "efb239fdd8c036fabb95364320041ef68197cd4ab971bb3b4ca3ea0b7b93d12c" dependencies = [ "cc", - "thiserror 1.0.69", + "thiserror", "versions", ] [[package]] name = "quote" -version = "1.0.39" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1f1914ce909e1658d9907913b4b91947430c7d9be598b15a1912935b8c04801" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + [[package]] name = "rand" version = "0.8.5" @@ -1583,9 +1580,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.12" +version = "0.12.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43e734407157c3c2034e0258f5e4473ddb361b1e85f95a66690d67264d7cd1da" +checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb" dependencies = [ "base64", "bytes", @@ -1627,9 +1624,9 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.13" +version = "0.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ac5d832aa16abd7d1def883a8545280c20a60f523a370aa3a9617c2b8550ee" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", "cfg-if", @@ -1660,22 +1657,22 @@ dependencies = [ [[package]] name = "rustix" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7178faa4b75a30e269c71e61c353ce2748cf3d76f0c44c393f4e60abf49b825" +checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96" dependencies = [ "bitflags 2.9.0", "errno", "libc", - "linux-raw-sys 0.9.2", + "linux-raw-sys 0.9.3", "windows-sys 0.59.0", ] [[package]] name = "rustls" -version = "0.23.23" +version = "0.23.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47796c98c480fce5406ef69d1c76378375492c3b0a0de587be0c1d9feb12f395" +checksum = "822ee9188ac4ec04a2f0531e55d035fb2de73f18b41a63c70c2712503b6fb13c" dependencies = [ "once_cell", "rustls-pki-types", @@ -1701,9 +1698,9 @@ checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" [[package]] name = "rustls-webpki" -version = "0.102.8" +version = "0.103.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +checksum = "fef8b8769aaccf73098557a87cd1816b4f9c7c16811c9c77142aa695c16f2c03" dependencies = [ "ring", "rustls-pki-types", @@ -1827,15 +1824,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_spanned" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" -dependencies = [ - "serde", -] - [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -1892,9 +1880,9 @@ checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" [[package]] name = "socket2" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" +checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" dependencies = [ "libc", "windows-sys 0.52.0", @@ -1914,9 +1902,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "string_cache" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938d512196766101d333398efde81bc1f37b00cb42c2f8350e5df639f040bbbe" +checksum = "bf776ba3fa74f83bf4b63c3dcbbf82173db2632ed8452cb2d891d33f459de70f" dependencies = [ "new_debug_unreachable", "parking_lot", @@ -2012,36 +2000,16 @@ dependencies = [ "libc", ] -[[package]] -name = "system-deps" -version = "7.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d23aaf9f331227789a99e8de4c91bf46703add012bdfd45fdecdfb2975a005" -dependencies = [ - "cfg-expr", - "heck", - "pkg-config", - "toml", - "version-compare", -] - -[[package]] -name = "target-lexicon" -version = "0.12.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" - [[package]] name = "tempfile" -version = "3.18.0" +version = "3.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c317e0a526ee6120d8dabad239c8dadca62b24b6f168914bbbc8e2fb1f0e567" +checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" dependencies = [ - "cfg-if", "fastrand", - "getrandom 0.3.1", + "getrandom 0.3.2", "once_cell", - "rustix 1.0.2", + "rustix 1.0.3", "windows-sys 0.59.0", ] @@ -2071,16 +2039,7 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl 1.0.69", -] - -[[package]] -name = "thiserror" -version = "2.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" -dependencies = [ - "thiserror-impl 2.0.12", + "thiserror-impl", ] [[package]] @@ -2094,17 +2053,6 @@ dependencies = [ "syn 2.0.100", ] -[[package]] -name = "thiserror-impl" -version = "2.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.100", -] - [[package]] name = "tinystr" version = "0.7.6" @@ -2117,9 +2065,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.44.0" +version = "1.44.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9975ea0f48b5aa3972bf2d888c238182458437cc2a19374b81b25cdf1023fb3a" +checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a" dependencies = [ "backtrace", "bytes", @@ -2164,9 +2112,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.13" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" +checksum = "6b9590b93e6fcc1739458317cccd391ad3955e2bde8913edf6f95f9e65a8f034" dependencies = [ "bytes", "futures-core", @@ -2175,40 +2123,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "toml" -version = "0.8.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - -[[package]] -name = "toml_datetime" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_edit" -version = "0.22.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" -dependencies = [ - "indexmap", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] - [[package]] name = "tower" version = "0.5.2" @@ -2279,6 +2193,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "untrusted" version = "0.9.0" @@ -2320,12 +2240,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "version-compare" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" - [[package]] name = "version_check" version = "0.9.5" @@ -2359,9 +2273,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi" -version = "0.13.3+wasi-0.2.2" +version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" dependencies = [ "wit-bindgen-rt", ] @@ -2469,33 +2383,38 @@ dependencies = [ ] [[package]] -name = "windows-registry" -version = "0.2.0" +name = "windows-link" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" + +[[package]] +name = "windows-registry" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" dependencies = [ "windows-result", "windows-strings", - "windows-targets", + "windows-targets 0.53.0", ] [[package]] name = "windows-result" -version = "0.2.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" dependencies = [ - "windows-targets", + "windows-link", ] [[package]] name = "windows-strings" -version = "0.1.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +checksum = "87fa48cc5d406560701792be122a10132491cff9d0aeb23583cc2dcafc847319" dependencies = [ - "windows-result", - "windows-targets", + "windows-link", ] [[package]] @@ -2504,7 +2423,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -2513,7 +2432,7 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -2522,14 +2441,30 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e4c7e8ceaaf9cb7d7507c974735728ab453b67ef8f18febdd7c11fe59dca8b" +dependencies = [ + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", ] [[package]] @@ -2538,42 +2473,84 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -2581,13 +2558,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] -name = "winnow" -version = "0.7.3" +name = "windows_x86_64_msvc" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e7f4ea97f6f78012141bcdb6a216b2609f0979ada50b20ca5b52dde2eac2bb1" -dependencies = [ - "memchr", -] +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" [[package]] name = "winsafe" @@ -2597,9 +2571,9 @@ checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" [[package]] name = "wit-bindgen-rt" -version = "0.33.0" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ "bitflags 2.9.0", ] @@ -2651,11 +2625,11 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.23" +version = "0.8.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd97444d05a4328b90e75e503a34bad781f14e28a823ad3557f0750df1ebcbc6" +checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" dependencies = [ - "zerocopy-derive 0.8.23", + "zerocopy-derive 0.8.24", ] [[package]] @@ -2671,9 +2645,9 @@ dependencies = [ [[package]] name = "zerocopy-derive" -version = "0.8.23" +version = "0.8.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6352c01d0edd5db859a63e2605f4ea3183ddbd15e2c4a9e7d32184df75e4f154" +checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" dependencies = [ "proc-macro2", "quote", @@ -2731,15 +2705,19 @@ dependencies = [ [[package]] name = "zip" -version = "2.2.3" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b280484c454e74e5fff658bbf7df8fdbe7a07c6b2de4a53def232c15ef138f3a" +checksum = "27c03817464f64e23f6f37574b4fdc8cf65925b5bfd2b0f2aedf959791941f88" dependencies = [ "arbitrary", "crc32fast", "crossbeam-utils", - "displaydoc", "indexmap", "memchr", - "thiserror 2.0.12", ] + +[[package]] +name = "zlib-rs" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b20717f0917c908dc63de2e44e97f1e6b126ca58d0e391cee86d504eb8fbd05" diff --git a/Cargo.toml b/Cargo.toml index 32c8e62..cb552ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,13 +27,13 @@ serde = { version = "1.0", features = ["derive"], default-features = false } regex = { version = "1.11", default-features = false, features = ["unicode-perl"] } # Used to generate the HTML page to easily preview your exported data -minijinja = { version = "2.8", default-features = false } +minijinja = { version = "2.9", default-features = false } # Download files reqwest = { version = "0.12" } # Zip the character archive -zip = { version = "2.2", default-features = false } +zip = { version = "2.5", default-features = false } # Exporting propietary game data physis = { git = "https://github.com/redstrate/Physis" } diff --git a/build.rs b/build.rs index db654f2..6d17eeb 100644 --- a/build.rs +++ b/build.rs @@ -12,4 +12,4 @@ fn main() { }) .build(); } -} \ No newline at end of file +} diff --git a/src/bin/auracite/bridge.rs b/src/bin/auracite/bridge.rs index 74da90b..30a2750 100644 --- a/src/bin/auracite/bridge.rs +++ b/src/bin/auracite/bridge.rs @@ -22,34 +22,53 @@ pub mod bridge { unsafe extern "RustQt" { #[qinvokable] #[cxx_name = "archiveCharacter"] - fn archive_character(self: Pin<&mut Backend>, character_name: &QString, use_dalamud: bool, filename: &QString); + fn archive_character( + self: Pin<&mut Backend>, + character_name: &QString, + use_dalamud: bool, + filename: &QString, + ); } } -use std::pin::Pin; -use cxx_kde_frameworks::ki18n::i18n; use crate::archive_character_blocking; -use cxx_qt_lib::QString; use auracite::ArchiveError; +use cxx_kde_frameworks::ki18n::i18n; +use cxx_qt_lib::QString; +use std::pin::Pin; #[derive(Default)] -pub struct BackendRust { -} +pub struct BackendRust {} impl bridge::Backend { - pub fn archive_character(mut self: Pin<&mut Self>, character_name: &QString, use_dalamud: bool, filename: &QString) { - match archive_character_blocking(&character_name.to_string(), use_dalamud, &filename.to_string()) { - Ok(_) => { self.archive_successful() } + pub fn archive_character( + mut self: Pin<&mut Self>, + character_name: &QString, + use_dalamud: bool, + filename: &QString, + ) { + match archive_character_blocking( + &character_name.to_string(), + use_dalamud, + &filename.to_string(), + ) { + Ok(_) => self.archive_successful(), Err(err) => { match err { // TODO: Pass the URL up - ArchiveError::DownloadFailed(_) => { self.archive_failed(&i18n("Download failed")) } - ArchiveError::CharacterNotFound => { self.archive_failed(&i18n("Character not found")) } - ArchiveError::ParsingError => { self.archive_failed(&i18n("Parsing error")) } - ArchiveError::UnknownError => { self.archive_failed(&i18n("Unknown error")) } - ArchiveError::CouldNotConnectToDalamud => { self.archive_failed(&i18n("Could not connect to Dalamud plugin")) } + ArchiveError::DownloadFailed(_) => { + self.archive_failed(&i18n("Download failed")) + } + ArchiveError::CharacterNotFound => { + self.archive_failed(&i18n("Character not found")) + } + ArchiveError::ParsingError => self.archive_failed(&i18n("Parsing error")), + ArchiveError::UnknownError => self.archive_failed(&i18n("Unknown error")), + ArchiveError::CouldNotConnectToDalamud => { + self.archive_failed(&i18n("Could not connect to Dalamud plugin")) + } } } } } -} \ No newline at end of file +} diff --git a/src/bin/auracite/main.rs b/src/bin/auracite/main.rs index 78dbb14..42b5e4f 100644 --- a/src/bin/auracite/main.rs +++ b/src/bin/auracite/main.rs @@ -1,14 +1,21 @@ +use auracite::{ArchiveError, archive_character}; +use cxx_kde_frameworks::kcoreaddons::{KAboutData, KAboutPerson, License}; +use cxx_kde_frameworks::ki18n::{KLocalizedContext, KLocalizedString, i18n, i18nc}; +use cxx_qt_lib::{ + QByteArray, QGuiApplication, QList, QQmlApplicationEngine, QQuickStyle, QString, QStringList, + QUrl, +}; +use cxx_qt_lib_extras::{QCommandLineOption, QCommandLineParser}; use std::env::args; use std::fs::write; -use cxx_kde_frameworks::kcoreaddons::{KAboutData, KAboutPerson, License}; -use cxx_kde_frameworks::ki18n::{i18n, i18nc, KLocalizedContext, KLocalizedString}; -use cxx_qt_lib::{QByteArray, QGuiApplication, QList, QQmlApplicationEngine, QQuickStyle, QString, QStringList, QUrl}; -use cxx_qt_lib_extras::{QCommandLineOption, QCommandLineParser}; -use auracite::{archive_character, ArchiveError}; pub mod bridge; -fn archive_character_blocking(character_name: &String, use_dalamud: bool, filename: &String) -> Result<(), ArchiveError> { +fn archive_character_blocking( + character_name: &String, + use_dalamud: bool, + filename: &String, +) -> Result<(), ArchiveError> { let rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() @@ -16,7 +23,7 @@ fn archive_character_blocking(character_name: &String, use_dalamud: bool, filena let inner = rt.block_on(archive_character(&character_name.to_string(), use_dalamud))?; write(filename, inner)?; - + Ok(()) } @@ -31,7 +38,10 @@ fn main() { QString::from("zone.xiv.auracite"), i18nc("@title", "Auracite"), QString::from(env!("CARGO_PKG_VERSION")), - i18nc("@title", "Export your FFXIV character in portable, generic formats."), + i18nc( + "@title", + "Export your FFXIV character in portable, generic formats.", + ), License::GPL_V3, ); @@ -44,13 +54,15 @@ fn main() { &i18n("Maintainer"), &QString::from("josh@redstrate.com"), &QString::from("https://redstrate.com"), - &QUrl::from(&QString::from("https://redstrate.com/rss-image.png")) + &QUrl::from(&QString::from("https://redstrate.com/rss-image.png")), )); KAboutData::set_application_data(&*about_data); let mut command_line_parser = QCommandLineParser::default(); - about_data.as_mut().setup_command_line(&mut command_line_parser); + about_data + .as_mut() + .setup_command_line(&mut command_line_parser); let mut name_option = QCommandLineOption::from(&QString::from("name")); name_option.set_description(&i18n("The character's name.")); @@ -58,18 +70,30 @@ fn main() { command_line_parser.add_option(&name_option); let mut dalamud_option = QCommandLineOption::from(&QString::from("dalamud")); - dalamud_option.set_description(&i18n("Whether to import more data from the Auracite Dalamud plugin.")); + dalamud_option.set_description(&i18n( + "Whether to import more data from the Auracite Dalamud plugin.", + )); command_line_parser.add_option(&dalamud_option); - command_line_parser.process(&QStringList::from(&QList::from(&args().map(|x| QString::from(x)).collect::>()))); - about_data.as_mut().process_command_line(&mut command_line_parser); + command_line_parser.process(&QStringList::from(&QList::from( + &args().map(|x| QString::from(x)).collect::>(), + ))); + about_data + .as_mut() + .process_command_line(&mut command_line_parser); if command_line_parser.is_set(&QString::from("name")) { - let character_name = command_line_parser.value(&QString::from("name")).to_string(); + let character_name = command_line_parser + .value(&QString::from("name")) + .to_string(); println!("Downloading character data for {}...", character_name); - archive_character_blocking(&character_name, command_line_parser.is_set(&QString::from("dalamud")), &format!("{}.zip", character_name)); + archive_character_blocking( + &character_name, + command_line_parser.is_set(&QString::from("dalamud")), + &format!("{}.zip", character_name), + ); return; } @@ -79,7 +103,9 @@ fn main() { if let Some(mut engine) = engine.as_mut() { KLocalizedContext::initialize_engine(engine.as_mut().as_qqmlengine()); // TODO: replace with loadModule (requires cxx-qt changes) - engine.load(&QUrl::from("qrc:/qt/qml/zone/xiv/auracite/src/bin/auracite/Main.qml")); + engine.load(&QUrl::from( + "qrc:/qt/qml/zone/xiv/auracite/src/bin/auracite/Main.qml", + )); } if let Some(app) = app.as_mut() { diff --git a/src/downloader.rs b/src/downloader.rs index 4ae0e15..51453bc 100644 --- a/src/downloader.rs +++ b/src/downloader.rs @@ -9,10 +9,8 @@ pub async fn download(url: &Url) -> Result, reqwest::Error> { } let client = client.build()?; - - let body = client.get(url.to_string()) - .send() - .await; + + let body = client.get(url.to_string()).send().await; Ok(body?.bytes().await?.to_vec()) } diff --git a/src/html.rs b/src/html.rs index b3de328..b35bf43 100644 --- a/src/html.rs +++ b/src/html.rs @@ -1,5 +1,5 @@ use crate::data::CharacterData; -use minijinja::{context, Environment}; +use minijinja::{Environment, context}; /// Writes a visual HTML for `char_data` to `file_path`. /// This vaguely represents Lodestone and designed to visually check your character data. @@ -29,10 +29,7 @@ pub fn create_character_html(char_data: &CharacterData) -> String { /// This vaguely represents Lodestone and designed to visually check your character data. pub fn create_plate_html(char_data: &CharacterData) -> String { let mut env = Environment::new(); - env.add_template( - "plate.html", - include_str!("../templates/plate.html"), - ) + env.add_template("plate.html", include_str!("../templates/plate.html")) .unwrap(); let template = env.get_template("plate.html").unwrap(); template diff --git a/src/lib.rs b/src/lib.rs index 6653fdd..e921da3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,23 +3,23 @@ pub mod downloader; pub mod html; pub mod parser; -use serde::Deserialize; -use std::io::Write; -use std::time::{SystemTime, UNIX_EPOCH}; -use physis::race::{Gender, Race, Subrace}; -use reqwest::Url; -use zip::result::ZipError; -use zip::write::SimpleFileOptions; -use zip::ZipWriter; +use crate::data::CharacterData; use crate::downloader::download; use crate::html::{create_character_html, create_plate_html}; use crate::parser::parse_search; use base64::prelude::*; -#[cfg(target_family = "wasm")] -use wasm_bindgen::prelude::wasm_bindgen; +use physis::race::{Gender, Race, Tribe}; +use reqwest::Url; +use serde::Deserialize; +use std::io::Write; +use std::time::{SystemTime, UNIX_EPOCH}; #[cfg(target_family = "wasm")] use wasm_bindgen::JsValue; -use crate::data::CharacterData; +#[cfg(target_family = "wasm")] +use wasm_bindgen::prelude::wasm_bindgen; +use zip::ZipWriter; +use zip::result::ZipError; +use zip::write::SimpleFileOptions; /// The main Lodestone domain const LODESTONE_HOST: &str = "https://na.finalfantasyxiv.com"; @@ -92,7 +92,7 @@ pub enum ArchiveError { CharacterNotFound, ParsingError, CouldNotConnectToDalamud, - UnknownError + UnknownError, } impl From for ArchiveError { @@ -107,74 +107,46 @@ impl From for ArchiveError { } } +impl From for ArchiveError { + fn from(_: physis::Error) -> Self { + ArchiveError::UnknownError + } +} + #[cfg(target_family = "wasm")] impl From for JsValue { fn from(err: ArchiveError) -> Self { match err { // TODO: give JS the URL that failed to download - ArchiveError::DownloadFailed(_) => { JsValue::from_str(&"download_failed".to_string()) } - ArchiveError::CharacterNotFound => { JsValue::from_str(&"character_not_found".to_string()) } - ArchiveError::ParsingError => { JsValue::from_str(&"parsing_error".to_string())} - ArchiveError::UnknownError => { JsValue::from_str(&"unknown_error".to_string()) } - ArchiveError::CouldNotConnectToDalamud => { JsValue::from_str(&"could_not_connect_to_dalamud".to_string()) } + ArchiveError::DownloadFailed(_) => JsValue::from_str(&"download_failed".to_string()), + ArchiveError::CharacterNotFound => { + JsValue::from_str(&"character_not_found".to_string()) + } + ArchiveError::ParsingError => JsValue::from_str(&"parsing_error".to_string()), + ArchiveError::UnknownError => JsValue::from_str(&"unknown_error".to_string()), + ArchiveError::CouldNotConnectToDalamud => { + JsValue::from_str(&"could_not_connect_to_dalamud".to_string()) + } } } } -// FIXME: this is stupid and also just copied from physis -fn convert_dat_race(x: i32) -> Race { - match x { - 1 => Race::Hyur, - 2 => Race::Elezen, - 3 => Race::Lalafell, - 4 => Race::Miqote, - 5 => Race::Roegadyn, - 6 => Race::AuRa, - 7 => Race::Hrothgar, - 8 => Race::Viera, - _ => Race::Hyur, - } -} - -fn convert_dat_gender(x: i32) -> Gender { - match x { - 0 => Gender::Male, - 1 => Gender::Female, - _ => Gender::Male, - } -} - -fn convert_dat_subrace(x: i32) -> Subrace { - match x { - 1 => Subrace::Midlander, - 2 => Subrace::Highlander, - 3 => Subrace::Wildwood, - 4 => Subrace::Duskwight, - 5 => Subrace::Plainsfolk, - 6 => Subrace::Dunesfolk, - 7 => Subrace::Seeker, - 8 => Subrace::Keeper, - 9 => Subrace::SeaWolf, - 10 => Subrace::Hellsguard, - 11 => Subrace::Raen, - 12 => Subrace::Xaela, - 13 => Subrace::Hellion, - 14 => Subrace::Lost, - 15 => Subrace::Rava, - 16 => Subrace::Veena, - _ => Subrace::Midlander, - } -} - /// Archives the character named `character_name` and gives a ZIP file as bytes that can be written to disk. -pub async fn archive_character(character_name: &str, use_dalamud: bool) -> Result, ArchiveError> { +pub async fn archive_character( + character_name: &str, + use_dalamud: bool, +) -> Result, ArchiveError> { let lodestone_host = if cfg!(target_family = "wasm") { LODESTONE_TUNNEL_HOST } else { LODESTONE_HOST }; - let search_url = Url::parse_with_params(&format!("{lodestone_host}/lodestone/character?"), &[("q", character_name)]).map_err(|_| ArchiveError::UnknownError)?; + let search_url = Url::parse_with_params( + &format!("{lodestone_host}/lodestone/character?"), + &[("q", character_name)], + ) + .map_err(|_| ArchiveError::UnknownError)?; let search_page = download(&search_url) .await .map_err(|_| ArchiveError::DownloadFailed(search_url.to_string()))?; @@ -185,7 +157,8 @@ pub async fn archive_character(character_name: &str, use_dalamud: bool) -> Resul return Err(ArchiveError::CharacterNotFound); } - let char_page_url = Url::parse(&format!("{lodestone_host}{}", href)).map_err(|_| ArchiveError::UnknownError)?; + let char_page_url = + Url::parse(&format!("{lodestone_host}{}", href)).map_err(|_| ArchiveError::UnknownError)?; let char_page = download(&char_page_url) .await .map_err(|_| ArchiveError::DownloadFailed(char_page_url.to_string()))?; @@ -201,7 +174,9 @@ pub async fn archive_character(character_name: &str, use_dalamud: bool) -> Resul if !char_data.portrait_url.is_empty() { let portrait_url = if cfg!(target_family = "wasm") { - &char_data.portrait_url.replace(IMAGE_HOST, IMAGE_TUNNEL_HOST) + &char_data + .portrait_url + .replace(IMAGE_HOST, IMAGE_TUNNEL_HOST) } else { &char_data.portrait_url }; @@ -231,8 +206,11 @@ pub async fn archive_character(character_name: &str, use_dalamud: bool) -> Resul } if use_dalamud { - let dalamud_url = Url::parse(&"http://localhost:42072/package").map_err(|_| ArchiveError::UnknownError)?; - let package = download(&dalamud_url).await.map_err(|_| ArchiveError::CouldNotConnectToDalamud)?; + let dalamud_url = Url::parse(&"http://localhost:42072/package") + .map_err(|_| ArchiveError::UnknownError)?; + let package = download(&dalamud_url) + .await + .map_err(|_| ArchiveError::CouldNotConnectToDalamud)?; let package = String::from_utf8(package).map_err(|_| ArchiveError::ParsingError)?; // Remove BOM at the start let package = package.trim_start_matches("\u{feff}"); @@ -276,46 +254,86 @@ pub async fn archive_character(character_name: &str, use_dalamud: bool) -> Resul char_data.search_comment = package.search_comment; zip.start_file("plate-portrait.png", options)?; - zip.write_all(&*BASE64_STANDARD.decode(package.portrait.trim_start_matches("data:image/png;base64,")).unwrap())?; + zip.write_all( + &*BASE64_STANDARD + .decode( + package + .portrait + .trim_start_matches("data:image/png;base64,"), + ) + .unwrap(), + )?; if let Some(base_plate) = package.base_plate { zip.start_file("base-plate.png", options)?; - zip.write_all(&*BASE64_STANDARD.decode(base_plate.trim_start_matches("data:image/png;base64,")).unwrap())?; + zip.write_all( + &*BASE64_STANDARD + .decode(base_plate.trim_start_matches("data:image/png;base64,")) + .unwrap(), + )?; } if let Some(pattern_overlay) = package.pattern_overlay { zip.start_file("pattern-overlay.png", options)?; - zip.write_all(&*BASE64_STANDARD.decode(pattern_overlay.trim_start_matches("data:image/png;base64,")).unwrap())?; + zip.write_all( + &*BASE64_STANDARD + .decode(pattern_overlay.trim_start_matches("data:image/png;base64,")) + .unwrap(), + )?; } if let Some(backing) = package.backing { zip.start_file("backing.png", options)?; - zip.write_all(&*BASE64_STANDARD.decode(backing.trim_start_matches("data:image/png;base64,")).unwrap())?; + zip.write_all( + &*BASE64_STANDARD + .decode(backing.trim_start_matches("data:image/png;base64,")) + .unwrap(), + )?; } if let Some(top_border) = package.top_border { zip.start_file("top-border.png", options)?; - zip.write_all(&*BASE64_STANDARD.decode(top_border.trim_start_matches("data:image/png;base64,")).unwrap())?; + zip.write_all( + &*BASE64_STANDARD + .decode(top_border.trim_start_matches("data:image/png;base64,")) + .unwrap(), + )?; } if let Some(bottom_border) = package.bottom_border { zip.start_file("bottom-border.png", options)?; - zip.write_all(&*BASE64_STANDARD.decode(bottom_border.trim_start_matches("data:image/png;base64,")).unwrap())?; + zip.write_all( + &*BASE64_STANDARD + .decode(bottom_border.trim_start_matches("data:image/png;base64,")) + .unwrap(), + )?; } if let Some(portrait_frame) = package.portrait_frame { zip.start_file("portrait-frame.png", options)?; - zip.write_all(&*BASE64_STANDARD.decode(portrait_frame.trim_start_matches("data:image/png;base64,")).unwrap())?; + zip.write_all( + &*BASE64_STANDARD + .decode(portrait_frame.trim_start_matches("data:image/png;base64,")) + .unwrap(), + )?; } if let Some(plate_frame) = package.plate_frame { zip.start_file("plate-frame.png", options)?; - zip.write_all(&*BASE64_STANDARD.decode(plate_frame.trim_start_matches("data:image/png;base64,")).unwrap())?; + zip.write_all( + &*BASE64_STANDARD + .decode(plate_frame.trim_start_matches("data:image/png;base64,")) + .unwrap(), + )?; } if let Some(accent) = package.accent { zip.start_file("accent.png", options)?; - zip.write_all(&*BASE64_STANDARD.decode(accent.trim_start_matches("data:image/png;base64,")).unwrap())?; + zip.write_all( + &*BASE64_STANDARD + .decode(accent.trim_start_matches("data:image/png;base64,")) + .unwrap(), + )?; } let timestamp: u32 = SystemTime::now() @@ -328,11 +346,11 @@ pub async fn archive_character(character_name: &str, use_dalamud: bool) -> Resul let char_dat = physis::chardat::CharacterData { version: 7, customize: physis::chardat::CustomizeData { - race: convert_dat_race(package.race), - gender: convert_dat_gender(package.gender), + race: (package.race as u8).try_into()?, + gender: (package.gender as u8).try_into()?, age: package.model_type as u8, height: package.height as u8, - subrace: convert_dat_subrace(package.tribe), + tribe: (package.tribe as u8).try_into()?, face: package.face_type as u8, hair: package.hair_style as u8, enable_highlights: package.has_highlights, @@ -364,7 +382,8 @@ pub async fn archive_character(character_name: &str, use_dalamud: bool) -> Resul zip.write_all(&*char_dat.write_to_buffer().unwrap())?; // Stop the HTTP server - let stop_url = Url::parse(&"http://localhost:42072/stop").map_err(|_| ArchiveError::UnknownError)?; + let stop_url = + Url::parse(&"http://localhost:42072/stop").map_err(|_| ArchiveError::UnknownError)?; // I'm intentionally ignoring the message because it doesn't matter if it fails - and it usually does let _ = download(&stop_url).await; } @@ -373,14 +392,10 @@ pub async fn archive_character(character_name: &str, use_dalamud: bool) -> Resul zip.write_all(serde_json::to_string(&char_data).unwrap().as_ref())?; zip.start_file("character.html", options)?; - zip.write_all(create_character_html( - &char_data - ).as_ref())?; + zip.write_all(create_character_html(&char_data).as_ref())?; zip.start_file("plate.html", options)?; - zip.write_all(create_plate_html( - &char_data - ).as_ref())?; + zip.write_all(create_plate_html(&char_data).as_ref())?; zip.finish()?; @@ -390,10 +405,15 @@ pub async fn archive_character(character_name: &str, use_dalamud: bool) -> Resul /// Archives the character named `character_name` and converts the ZIP file to Base64. Useful for downloading via data URIs. #[cfg(target_family = "wasm")] #[wasm_bindgen] -pub async extern fn archive_character_base64(character_name: &str, use_dalamud: bool) -> Result { +pub async extern "C" fn archive_character_base64( + character_name: &str, + use_dalamud: bool, +) -> Result { #[cfg(feature = "debug")] console_error_panic_hook::set_once(); - let buf: String = archive_character(character_name, use_dalamud).await.map(|x| BASE64_STANDARD.encode(x))?; + let buf: String = archive_character(character_name, use_dalamud) + .await + .map(|x| BASE64_STANDARD.encode(x))?; return Ok(format!("data:application/octet-stream;charset=utf-16le;base64,{buf}").into()); } diff --git a/src/parser.rs b/src/parser.rs index 8e941e0..4ba65ee 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -9,7 +9,7 @@ const ENTRY_NAME_SELECTOR: &str = ".entry__name"; pub fn parse_search(data: &str) -> String { let document = Html::parse_document(data); let mut href = String::new(); - + for element in document.select(&Selector::parse(ENTRY_SELECTOR).unwrap()) { if let Some(block_name) = element .select(&Selector::parse(ENTRY_NAME_SELECTOR).unwrap())