commit 6c9a20bf593e0702aea6f23acd0f40a17ca1923a Author: Schuwi Date: Tue Mar 3 23:26:05 2026 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..37fd90c --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +cache + +# Generated by Cargo +# will have compiled files and executables +debug +target + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +# Generated by cargo mutants +# Contains mutation testing data +**/mutants.out*/ + +# RustRover +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..605f47e --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1810 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "bytemuck" +version = "1.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8efb64bd706a16a1bdde310ae86b351e4d21550d98d056f22f8a7f7a2183fec" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "bzip2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" +dependencies = [ + "bzip2-sys", + "libc", +] + +[[package]] +name = "bzip2-sys" +version = "0.1.13+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225bff33b2141874fe80d71e07d6eec4f85c5c216453dd96388240f96e1acc14" +dependencies = [ + "cc", + "pkg-config", +] + +[[package]] +name = "cc" +version = "1.2.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "chrono" +version = "0.4.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" +dependencies = [ + "iana-time-zone", + "num-traits", + "windows-link", +] + +[[package]] +name = "clap" +version = "4.5.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2797f34da339ce31042b27d23607e051786132987f595b02ba4f6a6dffb7030a" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24a241312cea5059b13574bb9b3861cabf758b879c15190b37b6d6fd63ab6876" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" + +[[package]] +name = "cloud_cover" +version = "0.1.0" +dependencies = [ + "anyhow", + "bzip2", + "chrono", + "clap", + "font8x8", + "plotters", + "reqwest", +] + +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "crc32fast" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "fdeflate" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "flate2" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "font8x8" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e63201c624b8c8883921b1a1accc8916c4fa9dbfb15d122b26e4dde945b86bbf" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi", + "wasip2", + "wasm-bindgen", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "hyper" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", + "webpki-roots", +] + +[[package]] +name = "hyper-util" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "image" +version = "0.24.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" +dependencies = [ + "bytemuck", + "byteorder", + "color_quant", + "jpeg-decoder", + "num-traits", + "png", +] + +[[package]] +name = "ipnet" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" + +[[package]] +name = "iri-string" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c91338f0783edbd6195decb37bae672fd3b165faffb89bf7b9e6942f8b1a731a" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "jpeg-decoder" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00810f1d8b74be64b13dbf3db89ac67740615d6c891f0e7b6179326533011a07" + +[[package]] +name = "js-sys" +version = "0.3.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.182" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6800badb6cb2082ffd7b6a67e6125bb39f18782f793520caee8cb8846be06112" + +[[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "lru-slab" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "mio" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "plotters" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-bitmap", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" + +[[package]] +name = "plotters-bitmap" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ce181e3f6bf82d6c1dc569103ca7b1bd964c60ba03d7e6cdfbb3e3eb7f7405" +dependencies = [ + "image", + "plotters-backend", +] + +[[package]] +name = "png" +version = "0.17.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526" +dependencies = [ + "bitflags 1.3.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide", +] + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quinn" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1906b49b0c3bc04b5fe5d86a77925ae6524a19b816ae38ce1e426255f1d8a31" +dependencies = [ + "bytes", + "getrandom 0.3.4", + "lru-slab", + "rand", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "addec6a0dcad8a8d96a771f815f0eaf55f9d1805756410b39f5fa81332574cbd" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.60.2", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "reqwest" +version = "0.12.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "js-sys", + "log", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + +[[package]] +name = "rustls" +version = "0.23.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "758025cb5fccfd3bc2fd74708fd4682be41d99e5dff73c377c0646c6012c73a4" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" +dependencies = [ + "web-time", + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "simd-adler32" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e320a6c5ad31d271ad523dcf3ad13e2767ad8b1cb8f047f75a8aeaf8da139da2" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" +dependencies = [ + "bitflags 2.11.0", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9c5522b3a28661442748e09d40924dfb9ca614b21c00d3fd135720e48b67db8" +dependencies = [ + "cfg-if", + "futures-util", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854ba17bb104abfb26ba36da9729addc7ce7f06f5c0f90f3c391f8461cca21f9" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cfaf3c063993ff62e73cb4311efde4db1efb31ab78a3e5c457939ad5cc0bed" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "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.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a789c6e490b576db9f7e6b6d661bcc9799f7c0ac8352f56ea20193b2681532e5" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f65c489a7071a749c849713807783f70672b28094011623e200cb86dcb835953" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..3cbe801 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "cloud_cover" +version = "0.1.0" +edition = "2021" + +[[bin]] +name = "cloud_cover" +path = "src/main.rs" + +[dependencies] +reqwest = { version = "0.12", default-features = false, features = ["blocking", "rustls-tls"] } +bzip2 = "0.4" +plotters = { version = "0.3", default-features = false, features = ["bitmap_backend", "bitmap_encoder"] } +font8x8 = "0.2" +clap = { version = "4", features = ["derive"] } +chrono = { version = "0.4", default-features = false, features = ["std", "clock"] } +anyhow = "1" diff --git a/README.md b/README.md new file mode 100644 index 0000000..218b00f --- /dev/null +++ b/README.md @@ -0,0 +1,97 @@ +# cloud_cover + +Downloads total cloud cover (CLCT) predictions from the [DWD open-data +server](https://opendata.dwd.de/weather/nwp/icon-d2/grib/) and renders +one PNG map per forecast hour, centred on the Brandenburg / Berlin area. + +This is a Rust port of `../cloud_cover_prediction.py`. The output format +differs: instead of using PyNGL's contour renderer the Rust version does a +direct point-by-point orthographic projection of the ICON-D2 grid onto a +bitmap, which avoids every system-library dependency (no CDO, no PyNIO, no +PyNGL, no libssl, no libbz2 — the binary is fully self-contained). + +## Usage + +``` +cloud_cover +``` + +| Argument | Description | +|---|---| +| `ISO_TIMESTAMP` | Model run time in ISO 8601, e.g. `2026-03-03T18:00:00Z` | +| `HOURS` | Number of forecast steps to render (0–48) | + +The timestamp must correspond to an ICON-D2 model run, which is issued +every 3 hours starting at 00 UTC (00, 03, 06, 09, 12, 15, 18, 21). + +### Example + +```sh +cargo run --release -- "2026-03-03T18:00:00Z" 12 +``` + +Output PNGs are written to `cache/_UTC/clct_000001.png` … +`clct_NNNNNN.png`. Downloaded GRIB2 files are cached in the same directory +so that re-running the same timestamp skips the network requests. + +## How it works + +1. **Download** — `reqwest` fetches the bzip2-compressed GRIB2 files from + the DWD server. Two coordinate files (`clat`, `clon`) give the latitude + and longitude of every point on the ICON-D2 icosahedral grid (~542 000 + points for Germany). One `clct` file per forecast step contains the + total cloud cover percentage at each point. + +2. **Decompress** — `bzip2` decompresses the files in-memory. + +3. **Parse** — A minimal built-in GRIB2 decoder extracts the data values. + Only simple packing (data representation template 0) is supported, which + is what DWD uses. Grid points that are flagged as absent by the section-6 + bitmap are set to `NaN` and skipped during rendering. + +4. **Project & render** — Each grid point is projected onto the image plane + using an orthographic projection centred on Falkensee (52.56 °N, + 13.08 °E). Points are painted as 2 × 2 pixel squares, colour-coded by + cloud cover percentage. City markers and labels are drawn on top, and a + colour-scale legend is shown on the right. `plotters` writes the final + PNG. + +## Cloud cover colour scale + +| Cloud cover | Colour | +|---|---| +| < 1 % | Land background (clear) | +| 1–2 % | Very light blue | +| 2–5 % | Light blue | +| 5–10 % | Medium blue | +| 10–20 % | Blue | +| 20–50 % | Dark blue | +| 50–100 % | Very dark blue | + +## Marked locations + +Falkensee · Pausin · Nauen · Hennigsdorf · Ketzin/Brückenkopf · Potsdam · +Berlin (Mitte) + +## Dependencies + +All dependencies are pure Rust or vendored C code compiled into the binary. +No system shared libraries are required at runtime beyond libc. + +| Crate | Role | +|---|---| +| `reqwest` (rustls-tls) | HTTP client with pure-Rust TLS | +| `bzip2` | bzip2 decompression (vendors libbzip2) | +| `plotters` + `plotters-bitmap` | PNG rendering with built-in bitmap font | +| `clap` | CLI argument parsing | +| `chrono` | Date/time handling | +| `anyhow` | Error propagation | + +## Building + +```sh +cd cloud_cover_rs +cargo build --release +``` + +The compiled binary ends up at `target/release/cloud_cover`. diff --git a/src/download.rs b/src/download.rs new file mode 100644 index 0000000..bd0b3ad --- /dev/null +++ b/src/download.rs @@ -0,0 +1,48 @@ +use anyhow::{bail, Context, Result}; +use bzip2::read::BzDecoder; +use std::fs; +use std::io::Read; +use std::path::Path; + +/// Download a bzip2-compressed GRIB2 file and return its raw (decompressed) bytes. +/// +/// If `cache_path` already exists on disk, reads from disk instead of downloading. +/// On a successful download, the decompressed bytes are written to `cache_path`. +pub fn fetch_grib(url: &str, cache_path: &Path) -> Result> { + if cache_path.exists() { + let bytes = fs::read(cache_path) + .with_context(|| format!("Failed to read cached file {}", cache_path.display()))?; + return Ok(bytes); + } + + eprintln!(" Downloading {}", url); + + let response = reqwest::blocking::get(url) + .with_context(|| format!("HTTP request failed for {}", url))?; + + let status = response.status(); + if !status.is_success() { + bail!("HTTP {} for {}", status, url); + } + + let compressed_bytes = response + .bytes() + .with_context(|| format!("Failed to read response body from {}", url))?; + + // Decompress bzip2 + let mut decoder = BzDecoder::new(compressed_bytes.as_ref()); + let mut decompressed = Vec::new(); + decoder + .read_to_end(&mut decompressed) + .context("bzip2 decompression failed")?; + + // Write to cache + if let Some(parent) = cache_path.parent() { + fs::create_dir_all(parent) + .with_context(|| format!("Failed to create cache directory {}", parent.display()))?; + } + fs::write(cache_path, &decompressed) + .with_context(|| format!("Failed to write cache file {}", cache_path.display()))?; + + Ok(decompressed) +} diff --git a/src/grib.rs b/src/grib.rs new file mode 100644 index 0000000..58ec429 --- /dev/null +++ b/src/grib.rs @@ -0,0 +1,287 @@ +/// Minimal GRIB2 decoder targeting DWD ICON-D2 files. +/// +/// We only handle data representation template 0 (simple packing), which is +/// what DWD uses for CLCT, CLAT, and CLON fields. We don't need to understand +/// the grid definition template because lat/lon are provided in separate files. +/// +/// GRIB2 section layout (WMO Manual on Codes): +/// Section 0: Indicator – "GRIB", discipline, edition=2, total length +/// Section 1: Identification +/// Section 2: (optional) Local Use +/// Section 3: Grid Definition +/// Section 4: Product Definition +/// Section 5: Data Representation – packing parameters +/// Section 6: Bit-Map +/// Section 7: Data – packed values (only for non-missing points) +/// Section 8: End Marker – "7777" + +use anyhow::{bail, Context, Result}; + +/// Decode all data values from a GRIB2 message using simple packing. +/// +/// Returns one `f32` per grid point (length == section-3 num_data_points). +/// Grid points marked absent by the section-6 bitmap are set to `f32::NAN`. +pub fn decode(data: &[u8]) -> Result> { + // Verify GRIB magic + if data.len() < 16 || &data[0..4] != b"GRIB" { + bail!("Not a GRIB file (missing magic bytes)"); + } + if data[7] != 2 { + bail!("Only GRIB edition 2 is supported (got {})", data[7]); + } + + let total_len = read_u64(&data[8..16]) as usize; + if data.len() < total_len { + bail!("GRIB data truncated: expected {} bytes, got {}", total_len, data.len()); + } + + let mut pos = 16; // after section 0 + + // Collected from sections + let mut num_data_points: u32 = 0; // section 3: total grid points (incl. missing) + let mut n_packed: u32 = 0; // section 5: number of actually packed values + let mut sec5_payload: Option<&[u8]> = None; + let mut bitmap: Option<&[u8]> = None; // raw bitmap bytes from section 6 (if present) + let mut sec7_payload: Option<&[u8]> = None; + + while pos < total_len { + // Check for end marker "7777" + if pos + 4 <= total_len && &data[pos..pos + 4] == b"7777" { + break; + } + if pos + 5 > total_len { + bail!("Truncated section header at offset {}", pos); + } + let sec_len = read_u32(&data[pos..pos + 4]) as usize; + if sec_len < 5 { + bail!("Invalid section length {} at offset {}", sec_len, pos); + } + if pos + sec_len > total_len { + bail!("Section extends past end of GRIB message at offset {}", pos); + } + let sec_num = data[pos + 4]; + + match sec_num { + 3 => { + // Grid Definition Section: bytes 6..9 = number of data points (uint32) + if sec_len >= 10 { + num_data_points = read_u32(&data[pos + 6..pos + 10]); + } + } + 5 => { + // Data Representation Section + // bytes 5..8: number of packed values (may be < num_data_points when bitmap present) + // bytes 9..10: data representation template number + if sec_len < 11 { + bail!("Section 5 too short"); + } + n_packed = read_u32(&data[pos + 5..pos + 9]); + let tmpl = read_u16(&data[pos + 9..pos + 11]); + if tmpl != 0 { + bail!( + "Unsupported data representation template {}; \ + only template 0 (simple packing) is supported", + tmpl + ); + } + sec5_payload = Some(&data[pos + 11..pos + sec_len]); + } + 6 => { + // Bit-Map Section + // byte 5: bitmap indicator (0 = bitmap follows, 255 = no bitmap) + if sec_len < 6 { + bail!("Section 6 too short"); + } + let indicator = data[pos + 5]; + if indicator == 0 { + // Bitmap bytes follow from byte 6 onward + bitmap = Some(&data[pos + 6..pos + sec_len]); + } + // indicator == 255 means "no bitmap" — leave bitmap as None + } + 7 => { + // Data Section: payload starts at byte 5 + sec7_payload = Some(&data[pos + 5..pos + sec_len]); + } + _ => {} + } + + pos += sec_len; + } + + let sec5 = sec5_payload.context("Section 5 (Data Representation) not found")?; + let sec7 = sec7_payload.context("Section 7 (Data) not found")?; + + // Fall back to n_packed if section 3 was absent or zero + if num_data_points == 0 { + num_data_points = n_packed; + } + + // Decode the n_packed values that are actually stored in section 7 + let packed_values = decode_simple_packing(sec5, sec7, n_packed)?; + + // If there is a bitmap, expand packed_values to num_data_points, + // inserting NaN for every bit that is 0. + if let Some(bm) = bitmap { + expand_with_bitmap(packed_values, bm, num_data_points) + } else { + // No bitmap: packed_values should already cover all grid points + if packed_values.len() != num_data_points as usize { + bail!( + "Packed value count ({}) does not match grid size ({}) and no bitmap was found", + packed_values.len(), + num_data_points + ); + } + Ok(packed_values) + } +} + +/// Expand `packed` (length == number of set bits in bitmap) to `total` values, +/// placing NaN at positions where the bitmap bit is 0. +fn expand_with_bitmap(packed: Vec, bitmap: &[u8], total: u32) -> Result> { + let mut out = vec![f32::NAN; total as usize]; + let mut packed_iter = packed.into_iter(); + + for i in 0..total as usize { + let byte = i / 8; + let bit = 7 - (i % 8); // GRIB2 bitmaps are MSB-first + if byte < bitmap.len() && (bitmap[byte] >> bit) & 1 == 1 { + out[i] = packed_iter.next().unwrap_or(f32::NAN); + } + // else: bit == 0 → missing, already NaN + } + + Ok(out) +} + +/// Decode simple packing (template 0). +/// +/// Template 0 layout (offsets within section 5 payload, after section+template header): +/// bytes 0.. 3: R – reference value (IEEE 754 f32, big-endian) +/// bytes 4.. 5: E – binary scale factor (int16, big-endian) +/// bytes 6.. 7: D – decimal scale factor (int16, big-endian) +/// byte 8: nBits – bits per packed value +/// +/// Decoding: value[i] = (R + X[i] × 2^E) × 10^(-D) +fn decode_simple_packing(sec5: &[u8], sec7: &[u8], n: u32) -> Result> { + if sec5.len() < 9 { + bail!("Section 5 template 0 payload too short ({} bytes)", sec5.len()); + } + + let r_bytes: [u8; 4] = sec5[0..4].try_into().unwrap(); + let r = f32::from_bits(u32::from_be_bytes(r_bytes)); + let e = read_i16(&sec5[4..6]); + let d = read_i16(&sec5[6..8]); + let n_bits = sec5[8] as u32; + + if n_bits == 0 { + // All values equal the reference value + return Ok(vec![r * 10f32.powi(-(d as i32)); n as usize]); + } + if n_bits > 32 { + bail!("Implausible n_bits = {}", n_bits); + } + + let scale_e = 2f32.powi(e as i32); + let scale_d = 10f32.powi(-(d as i32)); + + let mut values = Vec::with_capacity(n as usize); + let mut bit_offset: u64 = 0; + + for _ in 0..n { + let packed = read_bits(sec7, bit_offset, n_bits)?; + let v = (r + packed as f32 * scale_e) * scale_d; + values.push(v); + bit_offset += n_bits as u64; + } + + Ok(values) +} + +/// Read `count` bits from `data` starting at `bit_offset` (MSB first). +fn read_bits(data: &[u8], bit_offset: u64, count: u32) -> Result { + let byte_start = (bit_offset / 8) as usize; + let bit_start = (bit_offset % 8) as u32; + + // We need at most 5 bytes to read up to 32 bits at any bit alignment + let bytes_needed = ((bit_start + count + 7) / 8) as usize; + if byte_start + bytes_needed > data.len() { + bail!( + "Bit read out of bounds: offset={}, count={}, data_len={}", + bit_offset, count, data.len() + ); + } + + // Accumulate into a u64 + let mut acc: u64 = 0; + for i in 0..bytes_needed { + acc = (acc << 8) | data[byte_start + i] as u64; + } + + // Shift right to remove trailing bits, then mask to `count` bits + let shift = (bytes_needed as u32) * 8 - bit_start - count; + let mask = (1u64 << count) - 1; + Ok(((acc >> shift) & mask) as u32) +} + +// ---- byte-order helpers ---- + +fn read_u64(b: &[u8]) -> u64 { + u64::from_be_bytes(b[0..8].try_into().unwrap()) +} + +fn read_u32(b: &[u8]) -> u32 { + u32::from_be_bytes(b[0..4].try_into().unwrap()) +} + +fn read_u16(b: &[u8]) -> u16 { + u16::from_be_bytes(b[0..2].try_into().unwrap()) +} + +fn read_i16(b: &[u8]) -> i16 { + i16::from_be_bytes(b[0..2].try_into().unwrap()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_read_bits_basic() { + let data = [0xCAu8]; // 0b11001010 + assert_eq!(read_bits(&data, 0, 4).unwrap(), 12); // 0b1100 + assert_eq!(read_bits(&data, 4, 4).unwrap(), 10); // 0b1010 + } + + #[test] + fn test_read_bits_cross_byte() { + // 0xCA 0xBD = 0b11001010_10111101; 8 bits from offset 4 = 0b10101011 = 0xAB + let data = [0xCAu8, 0xBDu8]; + assert_eq!(read_bits(&data, 4, 8).unwrap(), 0xAB); + } + + #[test] + fn test_zero_nbits() { + let r: u32 = 5.0f32.to_bits(); + let mut sec5 = vec![0u8; 10]; + sec5[0..4].copy_from_slice(&r.to_be_bytes()); + let result = decode_simple_packing(&sec5, &[], 3).unwrap(); + assert_eq!(result, vec![5.0f32, 5.0, 5.0]); + } + + #[test] + fn test_expand_with_bitmap() { + // bitmap: 0b10110000 → positions 0, 2, 3 are present; 1, 4-7 are missing + let bitmap = [0b10110000u8]; + let packed = vec![1.0f32, 2.0, 3.0]; + let out = expand_with_bitmap(packed, &bitmap, 8).unwrap(); + assert_eq!(out[0], 1.0); + assert!(out[1].is_nan()); + assert_eq!(out[2], 2.0); + assert_eq!(out[3], 3.0); + for i in 4..8 { + assert!(out[i].is_nan()); + } + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..0ec9d1c --- /dev/null +++ b/src/main.rs @@ -0,0 +1,204 @@ +mod download; +mod grib; +mod projection; +mod render; + +use anyhow::{bail, Context, Result}; +use chrono::{DateTime, Datelike, Timelike, Utc}; +use clap::Parser; +use std::path::PathBuf; + +const BASE_URL: &str = "https://opendata.dwd.de/weather/nwp/icon-d2/grib/"; +const GRIB_NAME_BASE: &str = "icon-d2_germany_icosahedral_"; +const CACHE_DIR: &str = "cache"; + +#[derive(Parser)] +#[command( + name = "cloud_cover", + about = "Download and visualise DWD ICON-D2 cloud cover predictions as PNG maps", + long_about = "Downloads total cloud cover (CLCT) predictions from the DWD open-data server \ + and renders one PNG map per forecast hour.\n\n\ + The timestamp must correspond to an ICON-D2 model run (every 3 hours, \ + starting at 00 UTC). Example: \"2022-03-04T09:00:00Z\"" +)] +struct Args { + /// Model run timestamp in ISO 8601 format, e.g. "2022-03-04T09:00:00Z" + iso_timestamp: String, + + /// Number of forecast hours to download and render (0–48) + #[arg(value_name = "HOURS")] + prediction_hours: u32, +} + +fn main() -> Result<()> { + let args = Args::parse(); + + // Parse timestamp + let dt: DateTime = args + .iso_timestamp + .parse::>() + .with_context(|| format!("Could not parse timestamp {:?}", args.iso_timestamp))?; + + // Validate hour: ICON-D2 runs at 00, 03, 06, 09, 12, 15, 18, 21 UTC + if dt.hour() % 3 != 0 { + bail!( + "ICON-D2 only runs every 3 hours starting at 00 UTC. \ + Got hour={}, which is not a multiple of 3.", + dt.hour() + ); + } + + if args.prediction_hours > 48 { + bail!( + "ICON-D2 predicts at most 48 hours into the future (requested {}).", + args.prediction_hours + ); + } + + // Build cache directory, e.g. cache/2022-03-04_09UTC/ + let cache_subdir = format!( + "{:04}-{:02}-{:02}_{:02}UTC", + dt.year(), + dt.month(), + dt.day(), + dt.hour() + ); + let cache_dir = PathBuf::from(CACHE_DIR).join(&cache_subdir); + std::fs::create_dir_all(&cache_dir) + .with_context(|| format!("Cannot create cache directory {}", cache_dir.display()))?; + + // URL prefix for this model run: BASE_URL + "{HH}/" + let run_url = format!("{}{:02}/", BASE_URL, dt.hour()); + let date_str = format!( + "{:04}{:02}{:02}{:02}", + dt.year(), + dt.month(), + dt.day(), + dt.hour() + ); + + // Download & decode coordinate grids + eprintln!("Downloading coordinate grids (clat / clon)..."); + let lats = download_and_decode( + &run_url, + &date_str, + "clat", + "time-invariant", + None, + &cache_dir, + ) + .context("clat")?; + let lons = download_and_decode( + &run_url, + &date_str, + "clon", + "time-invariant", + None, + &cache_dir, + ) + .context("clon")?; + + if lats.len() != lons.len() { + bail!( + "clat and clon grids have different lengths ({} vs {})", + lats.len(), + lons.len() + ); + } + eprintln!(" Grid has {} points.", lats.len()); + + // Download, decode, and render each forecast hour + eprintln!("Rendering {} frame(s)...", args.prediction_hours); + let mut output_paths = Vec::new(); + + for step in 0..args.prediction_hours { + let cloud = download_and_decode( + &run_url, + &date_str, + "clct", + "single-level", + Some(step), + &cache_dir, + ) + .with_context(|| format!("clct step {}", step))?; + + if cloud.len() != lats.len() { + bail!( + "clct step {} has {} values but coordinate grids have {}", + step, + cloud.len(), + lats.len() + ); + } + + let forecast_dt = dt + chrono::Duration::hours(step as i64); + let title = if step == 0 { + format!( + "Conditions at {} UTC", + forecast_dt.format("%Y-%m-%d %H:%M") + ) + } else { + format!( + "Prediction at {} UTC (+{:02}h)", + forecast_dt.format("%Y-%m-%d %H:%M"), + step + ) + }; + + let out_name = format!("clct_{:06}.png", step + 1); + let out_path = cache_dir.join(&out_name); + + render::render_frame(&out_path, &lats, &lons, &cloud, &title) + .with_context(|| format!("Rendering frame {}", step))?; + + eprintln!(" [{:02}/{:02}] {}", step + 1, args.prediction_hours, out_name); + output_paths.push(out_path); + } + + eprintln!("\nDone. {} PNG(s) written to {}:", output_paths.len(), cache_dir.display()); + for p in &output_paths { + eprintln!(" {}", p.display()); + } + + Ok(()) +} + +/// Build the DWD URL, download the bzip2-compressed GRIB2 file, and decode it. +/// +/// `param` – variable name ("clat", "clon", "clct") +/// `kind` – "time-invariant" or "single-level" +/// `step` – forecast step in hours (None for time-invariant files) +fn download_and_decode( + run_url: &str, + date_str: &str, + param: &str, + kind: &str, + step: Option, + cache_dir: &PathBuf, +) -> Result> { + let step_str = step.map(|s| format!("{:03}", s)).unwrap_or_else(|| "000".to_string()); + // DWD filename pattern: + // icon-d2_germany_icosahedral_time-invariant_YYYYMMDDHH_000_0_clat.grib2.bz2 + // icon-d2_germany_icosahedral_single-level_YYYYMMDDHH_NNN_2d_clct.grib2.bz2 + let file_name_bz2 = format!( + "{}{}_{}_{}_{}_{}.grib2.bz2", + GRIB_NAME_BASE, kind, date_str, step_str, + if kind == "time-invariant" { "0" } else { "2d" }, + param + ); + + let url = format!("{}{}/{}", run_url, param, file_name_bz2); + let cache_path = cache_dir.join(format!("{}.grib2", { + // cache as e.g. clat.grib2 or clct_003.grib2 + if let Some(s) = step { + format!("{}_{:03}", param, s) + } else { + param.to_string() + } + })); + + let grib_bytes = download::fetch_grib(&url, &cache_path)?; + let values = grib::decode(&grib_bytes) + .with_context(|| format!("GRIB2 decode failed for {}", cache_path.display()))?; + Ok(values) +} diff --git a/src/projection.rs b/src/projection.rs new file mode 100644 index 0000000..fad9739 --- /dev/null +++ b/src/projection.rs @@ -0,0 +1,71 @@ +/// Orthographic map projection. +/// +/// Projects a geographic point (lat, lon) onto a 2-D plane as seen from directly +/// above the centre point (center_lat, center_lon). +/// +/// Returns (x, y) normalised so that an angular distance of 1° from the centre +/// equals 1.0 in output units. Returns `None` when the point is on the far side +/// of the globe (not visible from the projection centre). + +pub struct OrthoProjection { + /// Centre of projection in radians + phi0: f64, + lam0: f64, + /// Half-extents of the visible window in "projected units" (degrees of arc) + pub half_width: f64, + pub half_height: f64, +} + +impl OrthoProjection { + /// `center_lat`, `center_lon` in degrees. + /// `half_width`, `half_height` are the angular half-extents of the view window + /// in degrees (e.g. 0.8 and 0.4 to match the original Python script). + pub fn new(center_lat: f64, center_lon: f64, half_width: f64, half_height: f64) -> Self { + Self { + phi0: center_lat.to_radians(), + lam0: center_lon.to_radians(), + half_width, + half_height, + } + } + + /// Project `(lat, lon)` in degrees. + /// + /// Returns `Some((x, y))` in degrees of arc from the centre (same units as + /// `half_width`/`half_height`), or `None` if the point is not visible. + pub fn project(&self, lat: f64, lon: f64) -> Option<(f64, f64)> { + let phi = lat.to_radians(); + let lam = lon.to_radians(); + let dlam = lam - self.lam0; + + let cos_c = self.phi0.sin() * phi.sin() + self.phi0.cos() * phi.cos() * dlam.cos(); + if cos_c <= 0.0 { + return None; // back of globe + } + + // x and y are in radians; convert to degrees so they match the half_width unit + let x = phi.cos() * dlam.sin(); + let y = self.phi0.cos() * phi.sin() - self.phi0.sin() * phi.cos() * dlam.cos(); + + Some((x.to_degrees(), y.to_degrees())) + } + + /// Convert projected (x, y) in degrees-of-arc to pixel (col, row). + /// + /// Returns `None` if the point falls outside the image boundary. + pub fn to_pixel(&self, x: f64, y: f64, width: u32, height: u32) -> Option<(i32, i32)> { + // Map [-half_width, +half_width] → [0, width] + // Map [+half_height, -half_height] → [0, height] (y flipped: north = up = row 0) + let col = (x + self.half_width) / (2.0 * self.half_width) * width as f64; + let row = (-y + self.half_height) / (2.0 * self.half_height) * height as f64; + + let col_i = col as i32; + let row_i = row as i32; + + if col_i < 0 || col_i >= width as i32 || row_i < 0 || row_i >= height as i32 { + None + } else { + Some((col_i, row_i)) + } + } +} diff --git a/src/render.rs b/src/render.rs new file mode 100644 index 0000000..7b13907 --- /dev/null +++ b/src/render.rs @@ -0,0 +1,227 @@ +use crate::projection::OrthoProjection; +use anyhow::{Context, Result}; +use font8x8::{UnicodeFonts, BASIC_FONTS}; +use plotters::prelude::*; +use std::path::Path; + +const IMG_WIDTH: u32 = 900; +const IMG_HEIGHT: u32 = 600; + +/// Map image centre and view window (must match what the Python script used). +const CENTER_LAT: f64 = 52.56; +const CENTER_LON: f64 = 13.08; +const HALF_W_DEG: f64 = 0.8; // horizontal half-extent in degrees of arc +const HALF_H_DEG: f64 = 0.4; // vertical half-extent + +/// Cloud-cover thresholds and their associated RGB colours. +/// Values below the first threshold are drawn as the background colour. +const LEVELS: [(f32, (u8, u8, u8)); 7] = [ + (1.0, (208, 232, 248)), // very thin + (2.0, (160, 200, 232)), + (5.0, (112, 168, 216)), + (10.0, ( 64, 128, 192)), + (20.0, ( 32, 80, 160)), + (50.0, ( 16, 32, 96)), + (100.0, ( 5, 10, 48)), +]; + +const BACKGROUND: RGBColor = RGBColor(240, 248, 255); // pale sky-blue +const LAND_BG: RGBColor = RGBColor(232, 236, 220); // muted green for land +const BLACK: RGBColor = RGBColor( 0, 0, 0); +const RED: RGBColor = RGBColor(220, 30, 30); + +/// Locations to mark on the map: (label, longitude, latitude) +const LOCATIONS: &[(&str, f64, f64)] = &[ + ("Falkensee", 13.08, 52.56), + ("Pausin", 13.04, 52.64), + ("Nauen", 12.88, 52.605), + ("Hennigsdorf", 13.205, 52.64), + ("Ketzin/Brueckenkopf", 12.82, 52.49), + ("Potsdam", 13.06, 52.40), + ("Berlin (Mitte)", 13.39, 52.52), +]; + +fn cloud_color(cover: f32) -> Option { + if cover < 1.0 { + return None; // clear sky — use background + } + for &(threshold, (r, g, b)) in LEVELS.iter().rev() { + if cover >= threshold { + return Some(RGBColor(r, g, b)); + } + } + Some(RGBColor(LEVELS[0].1 .0, LEVELS[0].1 .1, LEVELS[0].1 .2)) +} + +/// Draw ASCII text using the built-in 8×8 pixel font. +/// +/// Coordinates are in the drawing area's local coordinate system. +/// `scale` is the pixel-multiplier: 1 → 8×8 px/glyph, 2 → 16×16, etc. +/// Characters outside Basic Latin are rendered as '?'. +fn draw_pixel_text( + area: &DrawingArea, + text: &str, + x: i32, + y: i32, + scale: i32, + color: &RGBColor, +) { + let mut cx = x; + for ch in text.chars() { + let glyph_ch = if BASIC_FONTS.get(ch).is_some() { ch } else { '?' }; + if let Some(glyph) = BASIC_FONTS.get(glyph_ch) { + for (row, &bits) in glyph.iter().enumerate() { + for col in 0i32..8 { + if bits & (1 << col) != 0 { + for dy in 0..scale { + for dx in 0..scale { + area.draw_pixel( + (cx + col * scale + dx, y + row as i32 * scale + dy), + color, + ) + .ok(); + } + } + } + } + } + } + cx += 8 * scale; + } +} + +/// Render one forecast frame as a PNG. +/// +/// - `lats`, `lons`, `cloud_cover` must all have the same length. +/// - `title` is displayed at the top of the image. +/// - Output is written to `output_path`. +pub fn render_frame( + output_path: &Path, + lats: &[f32], + lons: &[f32], + cloud_cover: &[f32], + title: &str, +) -> Result<()> { + let proj = OrthoProjection::new(CENTER_LAT, CENTER_LON, HALF_W_DEG, HALF_H_DEG); + + let root = BitMapBackend::new(output_path, (IMG_WIDTH, IMG_HEIGHT)).into_drawing_area(); + root.fill(&BACKGROUND).context("fill background")?; + + const LEGEND_W: u32 = 130; + const TITLE_H: u32 = 40; + const MARGIN: u32 = 8; + + let map_area = root.margin(TITLE_H, MARGIN, MARGIN, LEGEND_W + MARGIN); + + let map_w = IMG_WIDTH - LEGEND_W - MARGIN * 2; + let map_h = IMG_HEIGHT - TITLE_H - MARGIN * 2; + + map_area.fill(&LAND_BG).context("fill map area")?; + + // Plot grid points + for i in 0..lats.len() { + let lat = lats[i] as f64; + let lon = lons[i] as f64; + + let Some((px, py)) = proj.project(lat, lon) else { continue }; + let Some((col, row)) = proj.to_pixel(px, py, map_w, map_h) else { continue }; + + let cover = cloud_cover[i]; + if cover.is_nan() { + continue; // missing value (bitmap) — keep background + } + let color = match cloud_color(cover) { + Some(c) => c, + None => continue, // clear sky — keep land background + }; + + // Paint a 2×2 block to avoid gaps between grid points + for dy in 0..2i32 { + for dx in 0..2i32 { + let c = col + dx; + let r = row + dy; + if c >= 0 && c < map_w as i32 && r >= 0 && r < map_h as i32 { + map_area.draw_pixel((c, r), &color).ok(); + } + } + } + } + + // Draw city markers and labels + for &(label, lon, lat) in LOCATIONS { + let Some((px, py)) = proj.project(lat, lon) else { continue }; + let Some((col, row)) = proj.to_pixel(px, py, map_w, map_h) else { continue }; + + // Small cross marker + for d in -3i32..=3i32 { + map_area.draw_pixel((col + d, row), &RED).ok(); + map_area.draw_pixel((col, row + d), &RED).ok(); + } + + // Label offset slightly above and to the right of the marker + draw_pixel_text(&map_area, label, col + 5, row - 9, 1, &BLACK); + } + + // Draw title (scale=2 → 16px tall) + draw_pixel_text(&root, title, MARGIN as i32, (TITLE_H / 2 - 8) as i32, 2, &BLACK); + + // Draw legend + draw_legend(&root, IMG_WIDTH - LEGEND_W, TITLE_H)?; + + root.present().context("write PNG")?; + Ok(()) +} + +fn draw_legend( + root: &DrawingArea, + x: u32, + y: u32, +) -> Result<()> { + draw_pixel_text(root, "Cloud cover", x as i32 + 4, y as i32 + 4, 1, &BLACK); + + let box_h = 18i32; + let box_w = 24i32; + + // Helper: draw one legend entry + let draw_entry = |label: &str, color: RGBColor, row_y: i32| { + root.draw(&Rectangle::new( + [(x as i32 + 4, row_y), (x as i32 + 4 + box_w, row_y + box_h)], + ShapeStyle { color: color.to_rgba(), filled: true, stroke_width: 0 }, + )) + .ok(); + root.draw(&Rectangle::new( + [(x as i32 + 4, row_y), (x as i32 + 4 + box_w, row_y + box_h)], + ShapeStyle { color: BLACK.to_rgba(), filled: false, stroke_width: 1 }, + )) + .ok(); + draw_pixel_text( + root, + label, + x as i32 + 4 + box_w + 4, + row_y + (box_h - 8) / 2, + 1, + &BLACK, + ); + }; + + // "< 1%" row (clear sky) + draw_entry("< 1%", LAND_BG, y as i32 + 22); + + // Remaining threshold rows — use ASCII hyphen instead of en-dash + let entries = [ + (1.0f32, "1-2%"), + (2.0, "2-5%"), + (5.0, "5-10%"), + (10.0, "10-20%"), + (20.0, "20-50%"), + (50.0, "50-100%"), + ]; + + for (i, &(lo, label)) in entries.iter().enumerate() { + let row_y = y as i32 + 22 + (i as i32 + 1) * (box_h + 2); + let color = cloud_color(lo).unwrap_or(BACKGROUND); + draw_entry(label, color, row_y); + } + + Ok(()) +}