From b0bb52a6a37e3331a2d84514eb3bc700e84f9e5b Mon Sep 17 00:00:00 2001 From: KhooLy <73142442+KhooLy@users.noreply.github.com> Date: Fri, 3 Jul 2026 16:05:52 +0300 Subject: [PATCH] feat: update desktop core API support --- Cargo.lock | 2658 ++++++++++++++++- Cargo.toml | 49 +- docs/building.md | 16 +- fluxa-streaming-engine/Cargo.toml | 22 +- fluxa-streaming-engine/src/bindings/jni.rs | 48 +- .../src/companion_server.rs | 94 +- fluxa-streaming-engine/src/dv_rewrite.rs | 332 +- fluxa-streaming-engine/src/ffmpeg_locator.rs | 11 +- fluxa-streaming-engine/src/local_stream.rs | 76 +- fluxa-streaming-engine/src/torrent_engine.rs | 250 +- src/addon_protocol.rs | 35 +- src/addon_resource.rs | 2 +- src/addon_store.rs | 3 +- src/app_state.rs | 4 +- src/bindings/jni.rs | 2190 +++++++------- src/bindings/uniffi.rs | 16 +- src/calendar_plan.rs | 91 +- src/cast_protocol.rs | 74 +- src/content_identity.rs | 25 +- src/core_api.rs | 107 +- src/dolby_vision_rpu.rs | 11 +- src/external_sync.rs | 217 +- src/ffi.rs | 369 ++- src/headless_adapter_plan.rs | 6 +- src/headless_engine/addons.rs | 3 +- src/headless_engine/auth.rs | 24 +- src/headless_engine/calendar.rs | 40 +- src/headless_engine/contracts.rs | 5 + src/headless_engine/detail.rs | 149 +- src/headless_engine/discover.rs | 14 +- src/headless_engine/helpers.rs | 4 +- src/headless_engine/home.rs | 75 +- src/headless_engine/library.rs | 163 +- src/headless_engine/mod.rs | 101 +- src/headless_engine/navigation.rs | 6 +- src/headless_engine/offline.rs | 7 +- src/headless_engine/player.rs | 130 +- src/headless_engine/search.rs | 9 +- src/headless_engine/settings.rs | 18 +- src/headless_engine/sync.rs | 6 +- src/home_ranking.rs | 92 +- src/intro_segments.rs | 185 +- src/lib.rs | 54 +- src/library_state.rs | 349 ++- src/platform_plan.rs | 176 +- src/player_flow.rs | 5 +- src/player_policy.rs | 406 ++- src/player_scrobble.rs | 6 +- src/profile_contract.rs | 43 +- src/profile_prefs.rs | 4 +- src/runtime/effects.rs | 4 + src/search_plan.rs | 186 +- src/stream_policy.rs | 136 +- src/tmdb_plan.rs | 90 +- src/watchlist_plan.rs | 93 +- 55 files changed, 7190 insertions(+), 2099 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa64fcc..d7ba350 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,12 @@ # 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 = "aho-corasick" version = "1.1.4" @@ -11,6 +17,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -32,6 +44,15 @@ version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" +[[package]] +name = "arc-swap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c049c0be4daef0b145cb3555416b3b8ef5b7888a38aea1a3a155801fe7b0810b" +dependencies = [ + "rustversion", +] + [[package]] name = "askama" version = "0.14.0" @@ -74,12 +95,159 @@ dependencies = [ "winnow 0.7.15", ] +[[package]] +name = "assert_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04e2651f366b7ee3f97729fded1441539b49d5f39eeb05b842689e11e84501b2" +dependencies = [ + "const_panic", +] + +[[package]] +name = "async-compression" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79b3f8a79cccc2898f31920fc69f304859b3bd567490f75ebf51ae1c792a9ac" +dependencies = [ + "compression-codecs", + "compression-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "async-stream" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +[[package]] +name = "aws-lc-rs" +version = "1.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4342d8937fc7e5dd9b1c60292261c0670c882a2cd1719cfc11b1af41731e32ad" +dependencies = [ + "aws-lc-sys", + "untrusted 0.7.1", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d9ceb1da931507a12f4fccea479dccd00da1943e1b4ae72d8e502d707361444" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", + "pkg-config", +] + +[[package]] +name = "axum" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31b698c5f9a010f6573133b09e0de5408834d0c82f8d7475a89fc1867a71cd90" +dependencies = [ + "axum-core", + "bytes", + "form_urlencoded", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "serde_core", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c78f31d7b1291f7ee735c1c6780ccde7785daae9a9206026862dab7d8792d1" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "sync_wrapper", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "backoff" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62ddb9cb1ec0a098ad4bbf9344d0713fa193ae1a80af55febcff2627b6a00c1" +dependencies = [ + "getrandom 0.2.17", + "instant", + "rand 0.8.6", +] + [[package]] name = "base64" version = "0.22.1" @@ -95,6 +263,35 @@ dependencies = [ "serde", ] +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bincode" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740" +dependencies = [ + "bincode_derive", + "serde", + "unty", +] + +[[package]] +name = "bincode_derive" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf95709a440f45e986983918d0e8a1f30a9b1df04918fc828670606804ac3c09" +dependencies = [ + "virtue", +] + [[package]] name = "bitflags" version = "2.11.1" @@ -103,12 +300,9 @@ checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" [[package]] name = "bitstream-io" -version = "4.10.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eff00be299a18769011411c9def0d827e8f2d7bf0c3dbf53633147a8867fd1f" -dependencies = [ - "no_std_io2", -] +checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2" [[package]] name = "bitvec" @@ -124,19 +318,45 @@ dependencies = [ [[package]] name = "bitvec_helpers" -version = "4.0.2" +version = "3.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e5938870db620c26a8f329f5735aa3450cedd30f4a4bb98475b1b076d8edae" +checksum = "d9a6aff977a34114f146bd3379c9d170a8eafcffcdeecbb7cc3bd2470a39709a" dependencies = [ "bitstream-io", ] +[[package]] +name = "bs58" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "bstr" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cee35f73844aa3014bb606320a6c1f010249dbdf43342fe54b5a4f6a8ed4b79" +dependencies = [ + "memchr", + "regex-automata", + "serde_core", +] + [[package]] name = "bumpalo" version = "3.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" +[[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" @@ -182,6 +402,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "556e016178bb5662a08681bbe0f00f8e17631781a4dfc8c45e466e4b185ec27f" dependencies = [ "find-msvc-tools", + "jobserver", + "libc", "shlex", ] @@ -197,6 +419,12 @@ 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.45" @@ -250,6 +478,15 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" +[[package]] +name = "cmake" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" +dependencies = [ + "cc", +] + [[package]] name = "combine" version = "4.6.7" @@ -260,6 +497,42 @@ dependencies = [ "memchr", ] +[[package]] +name = "compression-codecs" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce2548391e9c1929c21bf6aa2680af86fe4c1b33e6cea9ac1cfeec0bd11218cf" +dependencies = [ + "compression-core", + "flate2", + "memchr", +] + +[[package]] +name = "compression-core" +version = "0.4.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc14f565cf027a105f7a44ccf9e5b424348421a1d8952a8fc9d499d313107789" + +[[package]] +name = "const_panic" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e262cdaac42494e3ae34c43969f9cdeb7da178bdb4b66fa6a1ea2edb4c8ae652" +dependencies = [ + "typewit", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -281,10 +554,122 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "217698eaf96b4a3f0bc4f3662aaa55bdf913cd54d7204591faa790070c6d0853" +[[package]] +name = "crc32fast" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "darling" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25ae13da2f202d56bd7f91c25fba009e7717a1e4a1cc98a76d844b65ae912e9d" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9865a50f7c335f53564bb694ef660825eb8610e0a53d3e11bf1b0d3df31e03b0" +dependencies = [ + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "dashmap" +version = "6.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6361d5c062261c78a176addb82d4c821ae42bed6089de0e12603cd25de2059c" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", + "serde", +] + +[[package]] +name = "data-encoding" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8" + +[[package]] +name = "deranged" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" +dependencies = [ + "serde_core", +] + +[[package]] +name = "directories" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.61.2", +] + +[[package]] +name = "displaydoc" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "dolby_vision" version = "3.3.2" -source = "git+https://github.com/quietvoid/dovi_tool.git?rev=ccf640939377ee19035bbf871040bf79d437fb6b#ccf640939377ee19035bbf871040bf79d437fb6b" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "533d9f32336f4d03822e87fcee32277fd4a52e3f1278549bf42c8b28e3b0f798" dependencies = [ "anyhow", "bitvec", @@ -293,6 +678,24 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "dyn-clone" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" + +[[package]] +name = "either" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e" + [[package]] name = "equivalent" version = "1.0.2" @@ -321,6 +724,16 @@ 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 = "fluxa_core" version = "0.1.0" @@ -328,7 +741,7 @@ dependencies = [ "base64", "chrono", "dolby_vision", - "jni", + "jni 0.21.1", "regex", "serde", "serde_json", @@ -337,12 +750,45 @@ dependencies = [ "web-time", ] +[[package]] +name = "fluxa_streaming_engine" +version = "0.1.0" +dependencies = [ + "axum", + "dolby_vision", + "fluxa_core", + "jni 0.21.1", + "librqbit", + "reqwest 0.13.4", + "serde", + "serde_json", + "tokio", + "tokio-util", + "tower-http", + "url", +] + [[package]] name = "foldhash" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[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 = "fs-err" version = "2.11.0" @@ -352,36 +798,148 @@ dependencies = [ "autocfg", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "funty" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" +[[package]] +name = "futures" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[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-executor" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-macro" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[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-timer" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af43fadb8a98512d547e37b4e92e0ced13e205c061b87b4623eff01d918d6968" + [[package]] name = "futures-util" version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" dependencies = [ + "futures-channel", "futures-core", + "futures-io", + "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "slab", ] +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[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 5.3.0", + "wasip2", + "wasm-bindgen", +] + [[package]] name = "getrandom" version = "0.4.2" @@ -390,7 +948,7 @@ checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" dependencies = [ "cfg-if", "libc", - "r-efi", + "r-efi 6.0.0", "wasip2", "wasip3", ] @@ -412,13 +970,59 @@ dependencies = [ "scroll", ] +[[package]] +name = "governor" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9efcab3c1958580ff1f25a2a41be1668f7603d849bb63af523b208a3cc1223b8" +dependencies = [ + "cfg-if", + "dashmap", + "futures-sink", + "futures-timer", + "futures-util", + "getrandom 0.3.4", + "hashbrown 0.16.1", + "nonzero_ext", + "parking_lot", + "portable-atomic", + "quanta", + "rand 0.9.4", + "smallvec", + "spinning_top", + "web-time", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + [[package]] name = "hashbrown" version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" dependencies = [ - "foldhash", + "foldhash 0.1.5", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash 0.2.0", ] [[package]] @@ -433,6 +1037,117 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "http" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6970f50e31d6fc17d3fa27329444bfa74e196cf62e95052a3f6fee181dba6425" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55281c53a1894c864990125767da440a4e630446785086f52523b20033b74498" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "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" @@ -457,12 +1172,132 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38" + +[[package]] +name = "icu_properties" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14" + +[[package]] +name = "icu_provider" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + [[package]] name = "id-arena" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + [[package]] name = "indexmap" version = "2.14.0" @@ -475,6 +1310,39 @@ dependencies = [ "serde_core", ] +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "intervaltree" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "270bc34e57047cab801a8c871c124d9dc7132f6473c6401f645524f4e6edd111" +dependencies = [ + "smallvec", +] + +[[package]] +name = "ipnet" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.18" @@ -497,6 +1365,36 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "jni" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498" +dependencies = [ + "cfg-if", + "combine", + "jni-macros", + "jni-sys 0.4.1", + "log", + "simd_cesu8", + "thiserror 2.0.18", + "walkdir", + "windows-link", +] + +[[package]] +name = "jni-macros" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "simd_cesu8", + "syn", +] + [[package]] name = "jni-sys" version = "0.3.1" @@ -525,6 +1423,16 @@ dependencies = [ "syn", ] +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.4", + "libc", +] + [[package]] name = "js-sys" version = "0.3.99" @@ -537,6 +1445,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "leaky-bucket" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a396bb213c2d09ed6c5495fd082c991b6ab39c9daf4fff59e6727f85c73e4c5" +dependencies = [ + "parking_lot", + "pin-project-lite", + "tokio", +] + [[package]] name = "leb128fmt" version = "0.1.0" @@ -549,24 +1468,301 @@ version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" +[[package]] +name = "libredox" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f02ab6bace2054fb888a3c16f990117b579d14a3088e472d63c6011fa185c9d3" +dependencies = [ + "libc", +] + +[[package]] +name = "librqbit" +version = "8.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dadca8f521242010a4c846ef5f224c217009c92e272709cdc08ba9cdabe62983" +dependencies = [ + "anyhow", + "arc-swap", + "async-compression", + "async-stream", + "async-trait", + "backoff", + "base64", + "bincode 2.0.1", + "bitvec", + "byteorder", + "bytes", + "dashmap", + "futures", + "governor", + "hex", + "http", + "intervaltree", + "itertools", + "librqbit-bencode", + "librqbit-buffers", + "librqbit-clone-to-owned", + "librqbit-core", + "librqbit-dht", + "librqbit-peer-protocol", + "librqbit-sha1-wrapper", + "librqbit-tracker-comms", + "librqbit-upnp", + "memmap2", + "mime_guess", + "parking_lot", + "rand 0.9.4", + "regex", + "reqwest 0.12.28", + "rlimit", + "serde", + "serde_json", + "serde_urlencoded", + "serde_with", + "size_format", + "tokio", + "tokio-socks", + "tokio-stream", + "tokio-util", + "tracing", + "url", + "urlencoding", + "uuid", + "walkdir", +] + +[[package]] +name = "librqbit-bencode" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "606dff526ba81e3eca33e2bb28b53afa2bc0b2c41d252333fa44e6c11abb37da" +dependencies = [ + "anyhow", + "bytes", + "librqbit-buffers", + "librqbit-clone-to-owned", + "librqbit-sha1-wrapper", + "serde", +] + +[[package]] +name = "librqbit-buffers" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78c78b907d6171a7191c162b2b60db46d254ebde6a95282b77372af556c1463" +dependencies = [ + "bytes", + "librqbit-clone-to-owned", + "serde", +] + +[[package]] +name = "librqbit-clone-to-owned" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbd1e66d773ba9c475ff89286dc1d6f9d167cbb898603797467dd0ea6844c445" +dependencies = [ + "bytes", +] + +[[package]] +name = "librqbit-core" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55a02cc6fce6743ad38661ccd6fafc6cf1ae5e0106a9922836b0524dbe752378" +dependencies = [ + "anyhow", + "assert_cfg", + "bytes", + "data-encoding", + "directories", + "hex", + "itertools", + "librqbit-bencode", + "librqbit-buffers", + "librqbit-clone-to-owned", + "parking_lot", + "rand 0.9.4", + "serde", + "tokio", + "tokio-util", + "tracing", + "url", +] + +[[package]] +name = "librqbit-dht" +version = "5.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7cc129194337771a86b0399956c4d9bf1cd97c5f24d14a50be38e170f76a54b" +dependencies = [ + "anyhow", + "backoff", + "byteorder", + "bytes", + "chrono", + "dashmap", + "futures", + "hex", + "indexmap 2.14.0", + "leaky-bucket", + "librqbit-bencode", + "librqbit-clone-to-owned", + "librqbit-core", + "parking_lot", + "rand 0.9.4", + "serde", + "serde_json", + "tokio", + "tokio-stream", + "tokio-util", + "tracing", +] + +[[package]] +name = "librqbit-peer-protocol" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a73129497b500505f33d1dc0426319b6a6a208f13fdfaae56224ab8c2346a773" +dependencies = [ + "anyhow", + "bincode 1.3.3", + "bitvec", + "byteorder", + "bytes", + "itertools", + "librqbit-bencode", + "librqbit-buffers", + "librqbit-clone-to-owned", + "librqbit-core", + "serde", +] + +[[package]] +name = "librqbit-sha1-wrapper" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79373a02db73159e4de7ca5d27b6eeae2d540df66c6801db2b01c5513d087524" +dependencies = [ + "assert_cfg", + "aws-lc-rs", +] + +[[package]] +name = "librqbit-tracker-comms" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08204944c5be677a5de8e1230e0249fce5c14abef23048e26452c6fb03f1b260" +dependencies = [ + "anyhow", + "async-stream", + "byteorder", + "futures", + "librqbit-bencode", + "librqbit-buffers", + "librqbit-core", + "parking_lot", + "rand 0.9.4", + "reqwest 0.12.28", + "serde", + "tokio", + "tokio-util", + "tracing", + "url", + "urlencoding", +] + +[[package]] +name = "librqbit-upnp" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "545aad6124c97201055983137e12a19f34acad565120c3cd30596cbd72e8fa86" +dependencies = [ + "anyhow", + "bstr", + "futures", + "httparse", + "network-interface", + "quick-xml", + "reqwest 0.12.28", + "serde", + "tokio", + "tracing", + "url", +] + [[package]] name = "linux-raw-sys" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" +[[package]] +name = "litemap" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + [[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 = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + [[package]] name = "memchr" version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" +[[package]] +name = "memmap2" +version = "0.9.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1219ed1b7f229ee7104d281dd01d6802fe28bb6e95d292942c4daacdeb798c0" +dependencies = [ + "libc", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -574,12 +1770,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] -name = "no_std_io2" -version = "0.9.4" +name = "miniz_oxide" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418abd1b6d34fbf6cae440dc874771b0525a604428704c76e48b29a5e67b8003" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ - "memchr", + "adler2", + "simd-adler32", +] + +[[package]] +name = "mio" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02bd0af71c67b473010cbbc60715ee815645a4dc942899111f494b4b737d6fda" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "network-interface" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ddcb8865ad3d9950f22f42ffa0ef0aecbfbf191867b3122413602b0a360b2a6" +dependencies = [ + "cc", + "libc", + "thiserror 2.0.18", + "winapi", ] [[package]] @@ -592,6 +1812,72 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nonzero_ext" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38bf9645c8b145698bb0b18a4637dcacbc421ea49bef2317e4fd8065a387cf21" + +[[package]] +name = "num" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36" +dependencies = [ + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -607,6 +1893,41 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + [[package]] name = "percent-encoding" version = "2.3.2" @@ -619,12 +1940,48 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" +[[package]] +name = "pkg-config" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" + [[package]] name = "plain" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + +[[package]] +name = "potential_utf" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564" +dependencies = [ + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + [[package]] name = "prettyplease" version = "0.2.37" @@ -644,6 +2001,87 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "quanta" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3ab5a9d756f0d97bdc89019bd2e4ea098cf9cde50ee7564dde6b81ccc8f06c7" +dependencies = [ + "crossbeam-utils", + "libc", + "once_cell", + "raw-cpuid", + "wasi", + "web-sys", + "winapi", +] + +[[package]] +name = "quick-xml" +version = "0.37.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "331e97a1af0bf59823e6eadffe373d7b27f485be8748f71471c662c1f269b7fb" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "quinn" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c1a41e437b6bbd489372cd4971de128e85c855f56c57f283d20ff016cf7c0a8" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror 2.0.18", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fcb935c5bec503c2f0e306bdd3e58bb9029dcb14fa8d9ac76e3a5256ac0763e" +dependencies = [ + "aws-lc-rs", + "bytes", + "getrandom 0.3.4", + "lru-slab", + "rand 0.9.4", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.18", + "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" @@ -653,6 +2091,12 @@ 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 = "r-efi" version = "6.0.0" @@ -665,6 +2109,114 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" +[[package]] +name = "rand" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[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 0.9.5", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "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 = "raw-cpuid" +version = "11.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "498cd0dc59d73224351ee52a95fee0f1a617a2eae0e7d9d720cc622c73a54186" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac" +dependencies = [ + "getrandom 0.2.17", + "libredox", + "thiserror 2.0.18", +] + +[[package]] +name = "ref-cast" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "regex" version = "1.12.3" @@ -694,12 +2246,125 @@ version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" +[[package]] +name = "reqwest" +version = "0.12.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" +dependencies = [ + "base64", + "bytes", + "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", + "tokio-util", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "webpki-roots", +] + +[[package]] +name = "reqwest" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "219c5811de6525e5416c7d5d53bb656d3afdbc6c5af816e0802bcfa42dbdc1c3" +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", + "rustls-platform-verifier", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[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 0.9.0", + "windows-sys 0.52.0", +] + +[[package]] +name = "rlimit" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7043b63bd0cd1aaa628e476b80e6d4023a3b50eb32789f2728908107bd0c793a" +dependencies = [ + "libc", +] + [[package]] name = "rustc-hash" version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + [[package]] name = "rustix" version = "1.1.4" @@ -713,12 +2378,94 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "rustls" +version = "0.23.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b92b125634d9b795e7beca796cc790df15a7fb38323bf3196fda83292d06b1f" +dependencies = [ + "aws-lc-rs", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dab5152771c58876a2146916e53e35057e1a4dfa2b9df0f0305b07f611fdea4d" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pki-types" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "764899a24af3980067ee14bc143654f297b22eaebfe3c7b6b211920a5a59b046" +dependencies = [ + "web-time", + "zeroize", +] + +[[package]] +name = "rustls-platform-verifier" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d1e2536ce4f35f4846aa13bff16bd0ff40157cdb14cc056c7b14ba41233ba0" +dependencies = [ + "core-foundation", + "core-foundation-sys", + "jni 0.22.4", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" + +[[package]] +name = "rustls-webpki" +version = "0.103.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" +dependencies = [ + "aws-lc-rs", + "ring", + "rustls-pki-types", + "untrusted 0.9.0", +] + [[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 = "same-file" version = "1.0.6" @@ -728,6 +2475,45 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "schemars" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2b42f36aa1cd011945615b92222f6bf73c599a102a300334cd7f8dbeec726cc" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "scroll" version = "0.12.0" @@ -748,6 +2534,29 @@ dependencies = [ "syn", ] +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "1.0.28" @@ -801,6 +2610,17 @@ dependencies = [ "zmij", ] +[[package]] +name = "serde_path_to_error" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" +dependencies = [ + "itoa", + "serde", + "serde_core", +] + [[package]] name = "serde_spanned" version = "1.1.1" @@ -810,30 +2630,147 @@ dependencies = [ "serde_core", ] +[[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 = "serde_with" +version = "3.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a5c54c7310e7b8b9577c286d7e399ddd876c3e12b3ed917a8aabc4b96e9e8c" +dependencies = [ + "base64", + "bs58", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.14.0", + "schemars 0.9.0", + "schemars 1.2.1", + "serde_core", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84d57bc0c8b9a17920c178daa6bb924850d54a9c97ab45194bb8c17ad66bb660" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "shlex" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "simd-adler32" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" + +[[package]] +name = "simd_cesu8" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94f90157bb87cddf702797c5dadfa0be7d266cdf49e22da2fcaa32eff75b2c33" +dependencies = [ + "rustc_version", + "simdutf8", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + [[package]] name = "siphasher" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ee5873ec9cce0195efcb7a4e9507a04cd49aec9c83d0389df45b1ef7ba2e649" +[[package]] +name = "size_format" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed5f6ab2122c6dec69dca18c72fa4590a27e581ad20d44960fe74c032a0b23b" +dependencies = [ + "generic-array", + "num", +] + [[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.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" + [[package]] name = "smawk" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" +[[package]] +name = "socket2" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52d1cfed4120b4d927bf7c0f86d2087a4a7d6027c906d9f9d525a80573b9be51" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "spinning_top" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96d2d1d716fb500937168cc09353ffdc7a012be8475ac7308e1bdf0e3923300" +dependencies = [ + "lock_api", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + [[package]] name = "static_assertions" version = "1.1.0" @@ -846,6 +2783,12 @@ 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" @@ -857,6 +2800,26 @@ dependencies = [ "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 = "tap" version = "1.0.1" @@ -870,7 +2833,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom", + "getrandom 0.4.2", "once_cell", "rustix", "windows-sys 0.61.2", @@ -925,11 +2888,134 @@ dependencies = [ "syn", ] +[[package]] +name = "time" +version = "0.3.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e48db7b415311b615f910b3dcaa4557bcd4bf1982379c95c223fd8c2a20e210" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" + +[[package]] +name = "time-macros" +version = "0.2.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c431b87111666e491a90baa837f914fb45cd5dc3c268591b0220ff5057f2085f" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinyvec" version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3" +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.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-socks" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7e2948f60dbe26b35f2c7fb74ac2854c1fddded0fe9d7548fcc674a246f7615" +dependencies = [ + "either", + "futures-util", + "thiserror 1.0.69", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32da49809aab5c3bc678af03902d4ccddea2a87d028d86392a4b1560c6906c70" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", + "tokio-util", +] + +[[package]] +name = "tokio-util" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] [[package]] name = "toml" @@ -937,7 +3023,7 @@ version = "0.9.12+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf92845e79fc2e2def6a5d828f0801e29a2f8acc037becc5ab08595c7d5e9863" dependencies = [ - "indexmap", + "indexmap 2.14.0", "serde_core", "serde_spanned", "toml_datetime", @@ -970,6 +3056,108 @@ version = "1.1.1+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "756daf9b1013ebe47a8776667b466417e2d4c5679d441c26230efd9ef78692db" +[[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", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", + "url", +] + +[[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 = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +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 = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "typewit" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "214ca0b2191785cbc06209b9ca1861e048e39b5ba33574b3cedd58363d5bb5f6" + +[[package]] +name = "unicase" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142" + [[package]] name = "unicode-ident" version = "1.0.24" @@ -1012,7 +3200,7 @@ dependencies = [ "glob", "goblin", "heck", - "indexmap", + "indexmap 2.14.0", "once_cell", "serde", "tempfile", @@ -1043,7 +3231,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4b42137524f4be6400fcaca9d02c1d4ecb6ad917e4013c0b93235526d8396e5" dependencies = [ "anyhow", - "indexmap", + "indexmap 2.14.0", "proc-macro2", "quote", "syn", @@ -1086,7 +3274,7 @@ checksum = "761ef74f6175e15603d0424cc5f98854c5baccfe7bf4ccb08e5816f9ab8af689" dependencies = [ "anyhow", "heck", - "indexmap", + "indexmap 2.14.0", "tempfile", "uniffi_internal_macros", ] @@ -1103,6 +3291,66 @@ dependencies = [ "weedle2", ] +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "unty" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" + +[[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", + "serde_derive", +] + +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.23.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf80a72845275afea99e7f2b434723d3bc7e38470fcd1c7ed39a599c73319a53" +dependencies = [ + "getrandom 0.4.2", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "virtue" +version = "0.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1" + [[package]] name = "walkdir" version = "2.5.0" @@ -1113,6 +3361,21 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + [[package]] name = "wasip2" version = "1.0.3+wasi-0.2.9" @@ -1144,6 +3407,16 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9473dbd2991ae90b6291c3c32c30c6187ac49aa32f9905d1cce280ec1e110b0f" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.122" @@ -1193,11 +3466,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" dependencies = [ "anyhow", - "indexmap", + "indexmap 2.14.0", "wasm-encoder", "wasmparser", ] +[[package]] +name = "wasm-streams" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "wasmparser" version = "0.244.0" @@ -1206,10 +3492,20 @@ checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" dependencies = [ "bitflags", "hashbrown 0.15.5", - "indexmap", + "indexmap 2.14.0", "semver", ] +[[package]] +name = "web-sys" +version = "0.3.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621441cfc37b84979402712047321980c178f299193a3589d05b99e8763436" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "web-time" version = "1.1.0" @@ -1220,6 +3516,24 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-root-certs" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d46a5a140e6f7afeccd8eae97eff335163939eac8b929834875168b29b3d267" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "webpki-roots" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf85cb06032201fa7c6f829d7db5a7e5aa45bcc0655327713065f6f0576731bf" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "weedle2" version = "5.0.0" @@ -1229,6 +3543,22 @@ dependencies = [ "nom", ] +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + [[package]] name = "winapi-util" version = "0.1.11" @@ -1238,6 +3568,12 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + [[package]] name = "windows-core" version = "0.62.2" @@ -1303,7 +3639,25 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", +] + +[[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]] @@ -1321,13 +3675,46 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[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]] @@ -1336,42 +3723,138 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +[[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.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +[[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.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +[[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.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +[[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.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +[[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.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +[[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.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +[[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 = "winnow" version = "0.7.15" @@ -1421,7 +3904,7 @@ checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" dependencies = [ "anyhow", "heck", - "indexmap", + "indexmap 2.14.0", "prettyplease", "syn", "wasm-metadata", @@ -1452,7 +3935,7 @@ checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" dependencies = [ "anyhow", "bitflags", - "indexmap", + "indexmap 2.14.0", "log", "serde", "serde_derive", @@ -1471,7 +3954,7 @@ checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" dependencies = [ "anyhow", "id-arena", - "indexmap", + "indexmap 2.14.0", "log", "semver", "serde", @@ -1481,6 +3964,12 @@ dependencies = [ "wasmparser", ] +[[package]] +name = "writeable" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" + [[package]] name = "wyz" version = "0.5.1" @@ -1490,6 +3979,109 @@ dependencies = [ "tap", ] +[[package]] +name = "yoke" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce1022995ff5ff5d841ad7d994facc23098cd40152f2c1d11cd607c6f530653f" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ae7f38b72ec2a254e2b87ef277cf2cd4fb97cbebf944faa6f33354da0867930" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" + +[[package]] +name = "zerotrie" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "zmij" version = "1.0.21" diff --git a/Cargo.toml b/Cargo.toml index 1642b56..04efa53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,22 @@ +[workspace] +members = ["fluxa-streaming-engine"] +exclude = ["fuzz"] +resolver = "2" + +[workspace.dependencies] +dolby_vision = { version = "3.3.2", default-features = false } +fluxa_core = { path = ".", default-features = false } +jni = { version = "0.21" } +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" + +[profile.release] +opt-level = 3 +lto = true +codegen-units = 1 +strip = "debuginfo" +panic = "unwind" + [package] name = "fluxa_core" version = "0.1.0" @@ -14,37 +33,27 @@ required-features = ["uniffi-cli"] [features] default = ["native"] native = [ + "full-api", "dep:jni", "dep:dolby_vision", "uniffi-bindings", ] -uniffi-bindings = ["dep:uniffi"] +desktop = ["full-api"] +full-api = [] +streaming-shared = [] +uniffi-bindings = ["dep:uniffi", "full-api"] uniffi-cli = ["uniffi-bindings", "uniffi/cli"] -wasm = ["dep:wasm-bindgen", "chrono/wasmbind"] +wasm = ["full-api", "dep:wasm-bindgen", "chrono/wasmbind"] fuzzing = [] [dependencies] base64 = "0.22" chrono = { version = "0.4.45", features = ["serde"] } -dolby_vision = { git = "https://github.com/quietvoid/dovi_tool.git", rev = "ccf640939377ee19035bbf871040bf79d437fb6b", package = "dolby_vision", default-features = false, optional = true } -jni = { version = "0.21", optional = true } +dolby_vision = { workspace = true, optional = true } +jni = { workspace = true, optional = true } regex = "1" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" +serde = { workspace = true } +serde_json = { workspace = true } uniffi = { version = "0.31.1", optional = true } wasm-bindgen = { version = "0.2", optional = true } -# std::time::Instant panics on wasm32-unknown-unknown (no OS clock without JS -# interop) — web-time is a drop-in replacement: std re-export on every other -# target, performance.now() under the hood on wasm. web-time = "1" - -[profile.release] -opt-level = 3 -lto = true -codegen-units = 1 -strip = "debuginfo" -# Must stay "unwind" — bindings/jni.rs and ffi.rs::core_invoke catch_unwind at -# the FFI boundary so a panic in business logic becomes a safe error/null -# return instead of aborting the whole host process. "abort" would silently -# defeat that (and UniFFI's own built-in panic-to-exception handling too). -panic = "unwind" diff --git a/docs/building.md b/docs/building.md index 55dc29c..c0c6ffb 100644 --- a/docs/building.md +++ b/docs/building.md @@ -4,7 +4,10 @@ | Feature | What it enables | |---|---| -| `native` (default) | JNI bindings, Dolby Vision RPU, UniFFI Kotlin bindings | +| `native` (default) | Full Android/native surface: JNI bindings, Dolby Vision RPU, UniFFI Kotlin bindings | +| `full-api` | Complete domain/helper API surface used by JNI, `core_invoke`, UniFFI, WASM, and desktop | +| `desktop` | Named alias for the full desktop/Tauri-compatible API surface | +| `streaming-shared` | Minimal `FluxaCore` stream policy facade used by `fluxa-streaming-engine` | | `uniffi-bindings` | UniFFI runtime support (pulled in by `native`) | | `uniffi-cli` | Adds the `uniffi-bindgen` binary for generating Kotlin/Swift source | | `wasm` | `wasm-bindgen` exports for webOS | @@ -22,6 +25,9 @@ cargo test --lib # check the webOS/WASM path compiles cargo check --no-default-features --features wasm +# check the narrow surface used by fluxa-streaming-engine +cargo check --no-default-features --features streaming-shared + # generate UniFFI Kotlin bindings cargo run --bin uniffi-bindgen --features uniffi-cli -- generate \ --library target/debug/libfluxa_core.so \ @@ -50,11 +56,11 @@ cargo build --release --target x86_64-linux-android The Android project (`Fluxa`) picks up the resulting `.so` files from `target//release/libfluxa_core.so`. -## WASM warnings are expected +## Partial API builds -Under `--no-default-features --features wasm`, roughly 240 "never used" warnings appear. This is correct: most of the crate is Android-only logic with no `core_invoke` route and no WASM wrapper. Don't add blanket `#[allow(dead_code)]` to silence them — they accurately show which functions are Android-only. +Non-native consumers intentionally compile partial API surfaces: desktop uses direct Rust/Tauri calls plus `core_invoke`, WASM exposes a small JS bridge, and `fluxa-streaming-engine` only needs stream policy helpers. These builds suppress dead-code noise from API functions that are only reachable through Android/JNI. -Under the default `native` build there are no warnings, because `bindings/jni.rs` uses almost every domain function. +The default `native` build keeps normal dead-code checking because it compiles the exhaustive Android JNI surface. ## Panic policy @@ -70,3 +76,5 @@ cargo build # native features (tokio, axum, librqbit, j cargo build --bin torrent_serve # local torrent HTTP proxy cargo build --bin companion_server # fluxa-web's local companion process ``` + +Its dependency on `fluxa_core` enables only `streaming-shared`, so streaming builds do not compile the full Android/desktop helper surface just to call stream playback and torrent runtime planning. diff --git a/fluxa-streaming-engine/Cargo.toml b/fluxa-streaming-engine/Cargo.toml index 41470cf..d5f329d 100644 --- a/fluxa-streaming-engine/Cargo.toml +++ b/fluxa-streaming-engine/Cargo.toml @@ -23,23 +23,13 @@ native = [ [dependencies] axum = { version = "0.8", optional = true } tower-http = { version = "0.6", features = ["cors"], optional = true } -dolby_vision = { git = "https://github.com/quietvoid/dovi_tool.git", package = "dolby_vision", default-features = false } -fluxa_core = { path = "..", default-features = false, optional = true } -jni = { version = "0.21", optional = true } +dolby_vision = { workspace = true } +fluxa_core = { workspace = true, features = ["streaming-shared"], optional = true } +jni = { workspace = true, optional = true } librqbit = { version = "8.1.1", default-features = false, features = ["rust-tls", "disable-upload"], optional = true } -reqwest = { version = "0.12", default-features = false, features = ["blocking", "json", "rustls-tls"], optional = true } -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" +reqwest = { version = "0.13", default-features = false, features = ["blocking", "json", "form", "rustls"], optional = true } +serde = { workspace = true } +serde_json = { workspace = true } tokio = { version = "1", features = ["rt-multi-thread", "net", "time", "io-util", "sync", "process", "fs", "macros"], optional = true } tokio-util = { version = "0.7", features = ["io"], optional = true } url = { version = "2", optional = true } - -[profile.release] -opt-level = 3 -lto = true -codegen-units = 1 -strip = "debuginfo" -# Must stay "unwind" — bindings/jni.rs catch_unwind at the FFI boundary so a -# panic in the streaming/rewrite logic becomes a safe null/false return -# instead of aborting the host app. "abort" would silently defeat that. -panic = "unwind" diff --git a/fluxa-streaming-engine/src/bindings/jni.rs b/fluxa-streaming-engine/src/bindings/jni.rs index d8cf7a1..ff0d447 100644 --- a/fluxa-streaming-engine/src/bindings/jni.rs +++ b/fluxa-streaming-engine/src/bindings/jni.rs @@ -1,5 +1,5 @@ use crate::chapters::parse_mkv_chapters_json; -use crate::dv_rewrite::{dv_auto_detect_was_iptpqc2, dv_get_stream_stats_json, dv_rewrite_segment_bytes, dv_rpu_self_test, start_dv_rewrite_local_stream_server}; +use crate::dv_rewrite::{dv_auto_detect_was_iptpqc2, dv_get_current_l1_json, dv_get_stream_stats_json, dv_rewrite_segment_bytes, dv_rpu_self_test, start_dv_rewrite_local_stream_server}; use crate::local_stream::{start_local_stream_server, stop_local_stream_server}; use crate::torrent_engine; use jni::objects::{JByteArray, JClass, JString}; @@ -24,6 +24,9 @@ fn write_jstring(env: &mut JNIEnv<'_>, value: Option) -> JStringReturn { } #[no_mangle] +/// # Safety +/// Called by the JVM with JNI-managed arguments. The function validates JNI +/// conversions, catches panics, and returns null on failure. pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_startLocalStreamServerNative( mut env: JNIEnv<'_>, _class: JObject<'_>, @@ -47,6 +50,9 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_ } #[no_mangle] +/// # Safety +/// Called by the JVM with JNI-managed arguments. The function validates JNI +/// conversions, catches panics, and returns null on failure. pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_startDvRewriteLocalStreamServerNative( mut env: JNIEnv<'_>, _class: JObject<'_>, @@ -70,6 +76,9 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_ } #[no_mangle] +/// # Safety +/// Called by the JVM with JNI-managed arguments. The function validates JNI +/// conversions, catches panics, and returns false on failure. pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_stopLocalStreamServerNative( mut env: JNIEnv<'_>, _class: JObject<'_>, @@ -85,21 +94,29 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_ } #[no_mangle] +/// # Safety +/// Called by the JVM with JNI-managed arguments. The function validates JNI +/// conversions, catches panics, and returns null on failure. pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_startTorrentServerNative( mut env: JNIEnv<'_>, _class: JObject<'_>, cache_dir: JString<'_>, preferred_port: JInt, + access_token: JString<'_>, ) -> JStringReturn { std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &cache_dir) - .and_then(|cache_dir| torrent_engine::start_torrent_server(&cache_dir, preferred_port)); + let output = read_jstring(&mut env, &cache_dir).and_then(|cache_dir| { + let access_token = read_jstring(&mut env, &access_token).unwrap_or_default(); + torrent_engine::start_torrent_server(&cache_dir, preferred_port, &access_token) + }); write_jstring(&mut env, output) })) .unwrap_or(ptr::null_mut()) } #[no_mangle] +/// # Safety +/// Called by the JVM. The function catches panics and returns false on failure. pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_stopTorrentServerNative( _env: JNIEnv<'_>, _class: JObject<'_>, @@ -111,6 +128,8 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_ } #[no_mangle] +/// # Safety +/// Called by the JVM. The function catches panics and returns false on failure. pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_dvRpuSelfTestNative( _env: JNIEnv<'_>, _class: JObject<'_>, @@ -122,6 +141,8 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_ } #[no_mangle] +/// # Safety +/// Called by the JVM. The function catches panics and returns false on failure. pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_dvAutoDetectWasIptPqc2Native( _env: JNIEnv<'_>, _class: JObject<'_>, @@ -133,6 +154,9 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_ } #[no_mangle] +/// # Safety +/// Called by the JVM with JNI-managed arguments. The function validates byte +/// array conversions, catches panics, and returns null on unrecoverable failure. pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_dvRewriteSegmentBytesNative( env: JNIEnv<'_>, _class: JObject<'_>, @@ -178,6 +202,8 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_ } #[no_mangle] +/// # Safety +/// Called by the JVM. The function catches panics and returns null on failure. pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_dvGetStreamStatsJsonNative( mut env: JNIEnv<'_>, _class: JObject<'_>, @@ -189,6 +215,22 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_ } #[no_mangle] +/// # Safety +/// Called by the JVM. The function catches panics and returns null on failure. +pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_dvGetCurrentL1JsonNative( + mut env: JNIEnv<'_>, + _class: JObject<'_>, +) -> JStringReturn { + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + write_jstring(&mut env, Some(dv_get_current_l1_json())) + })) + .unwrap_or(ptr::null_mut()) +} + +#[no_mangle] +/// # Safety +/// Called by the JVM with JNI-managed arguments. The function validates byte +/// array conversions, catches panics, and returns null on unrecoverable failure. pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaStreamingNative_parseMkvChaptersNative( mut env: JNIEnv<'_>, _class: JObject<'_>, diff --git a/fluxa-streaming-engine/src/companion_server.rs b/fluxa-streaming-engine/src/companion_server.rs index df1e8b1..554726c 100644 --- a/fluxa-streaming-engine/src/companion_server.rs +++ b/fluxa-streaming-engine/src/companion_server.rs @@ -4,8 +4,9 @@ /// Tauri commands in fluxa-desktop/src-tauri/src/lib.rs and oauth.rs, just /// exposed over HTTP instead of IPC. Used by both the standalone /// `companion_server` binary and the `fluxa-companion` tray app. -use axum::extract::State; -use axum::http::{HeaderValue, Method, StatusCode}; +use axum::extract::{Request, State}; +use axum::http::{header, HeaderMap, HeaderValue, Method, StatusCode}; +use axum::middleware::{self, Next}; use axum::response::{IntoResponse, Response}; use axum::routing::{get, post}; use axum::{Json, Router}; @@ -34,6 +35,45 @@ async fn health() -> &'static str { "ok" } +fn companion_token() -> Option { + std::env::var("FLUXA_COMPANION_TOKEN") + .ok() + .map(|token| token.trim().to_string()) + .filter(|token| !token.is_empty()) +} + +fn token_authorized( + expected: &str, + authorization: Option<&HeaderValue>, + x_token: Option<&HeaderValue>, +) -> bool { + authorization + .and_then(|value| value.to_str().ok()) + .and_then(|value| value.strip_prefix("Bearer ")) + .is_some_and(|token| token == expected) + || x_token + .and_then(|value| value.to_str().ok()) + .is_some_and(|token| token == expected) +} + +async fn require_companion_token(request: Request, next: Next) -> Response { + if request.method() == Method::OPTIONS || request.uri().path() == "/health" { + return next.run(request).await; + } + let Some(expected) = companion_token() else { + return next.run(request).await; + }; + let headers: &HeaderMap = request.headers(); + if token_authorized( + &expected, + headers.get(header::AUTHORIZATION), + headers.get("x-fluxa-companion-token"), + ) { + return next.run(request).await; + } + (StatusCode::UNAUTHORIZED, Json(json!({ "error": "unauthorized" }))).into_response() +} + async fn start_torrent( State(state): State>, Json(body): Json, @@ -50,7 +90,12 @@ async fn start_torrent_inner(state: &AppState, body: StartTorrentBody) -> Result Some(url) => url.clone(), None => { let cache_dir = std::env::temp_dir().join("fluxa-web-torrent-cache"); - let server_json = crate::start_torrent_server(&cache_dir.to_string_lossy(), 0) + let access_token = std::env::var("FLUXA_COMPANION_TORRENT_TOKEN").unwrap_or_default(); + let server_json = crate::start_torrent_server( + &cache_dir.to_string_lossy(), + 0, + &access_token, + ) .ok_or_else(|| "failed to start torrent server".to_string())?; let server: Value = serde_json::from_str(&server_json) .map_err(|e| format!("invalid torrent server response: {e}"))?; @@ -157,8 +202,12 @@ fn cors_layer() -> CorsLayer { CorsLayer::new() .allow_origin(origins) - .allow_methods([Method::GET, Method::POST]) - .allow_headers([axum::http::header::CONTENT_TYPE]) + .allow_methods([Method::GET, Method::POST, Method::OPTIONS]) + .allow_headers([ + header::CONTENT_TYPE, + header::AUTHORIZATION, + axum::http::HeaderName::from_static("x-fluxa-companion-token"), + ]) } pub fn router() -> Router { @@ -170,6 +219,7 @@ pub fn router() -> Router { .with_state(state) .merge(crate::transcode::router()) .merge(crate::oauth_proxy::router()) + .layer(middleware::from_fn(require_companion_token)) .layer(cors_layer()) } @@ -180,3 +230,37 @@ pub async fn serve(port: u16) -> std::io::Result<()> { eprintln!("[companion-server] listening on http://127.0.0.1:{port}"); axum::serve(listener, router()).await } + +#[cfg(test)] +mod tests { + use super::token_authorized; + use axum::http::HeaderValue; + + #[test] + fn companion_token_accepts_bearer_header() { + assert!(token_authorized( + "secret", + Some(&HeaderValue::from_static("Bearer secret")), + None, + )); + } + + #[test] + fn companion_token_accepts_custom_header() { + assert!(token_authorized( + "secret", + None, + Some(&HeaderValue::from_static("secret")), + )); + } + + #[test] + fn companion_token_rejects_missing_or_wrong_headers() { + assert!(!token_authorized("secret", None, None)); + assert!(!token_authorized( + "secret", + Some(&HeaderValue::from_static("Bearer other")), + None, + )); + } +} diff --git a/fluxa-streaming-engine/src/dv_rewrite.rs b/fluxa-streaming-engine/src/dv_rewrite.rs index 4e74442..67d7d12 100644 --- a/fluxa-streaming-engine/src/dv_rewrite.rs +++ b/fluxa-streaming-engine/src/dv_rewrite.rs @@ -1,4 +1,5 @@ use dolby_vision::rpu::dovi_rpu::DoviRpu; +use dolby_vision::rpu::extension_metadata::blocks::ExtMetadataBlock; use serde::Deserialize; // Startup self-test @@ -15,11 +16,36 @@ pub(crate) fn dv_rpu_self_test() -> bool { // Set to true by stream_auto_detect when it strips a P5 CID≠1 (IPTPQc2) stream. // Read by Kotlin in onVideoInputFormatChanged to activate the IPTPQc2 → SDR shader. static DV_LAST_AUTO_DETECT_IPTPQC2: AtomicBool = AtomicBool::new(false); +static LAST_L1_VALID: AtomicBool = AtomicBool::new(false); +static LAST_L1_MIN_PQ: AtomicU32 = AtomicU32::new(0); +static LAST_L1_MAX_PQ: AtomicU32 = AtomicU32::new(2048); +static LAST_L1_AVG_PQ: AtomicU32 = AtomicU32::new(1024); pub(crate) fn dv_auto_detect_was_iptpqc2() -> bool { DV_LAST_AUTO_DETECT_IPTPQC2.load(Ordering::Relaxed) } +pub(crate) fn dv_get_current_l1_json() -> String { + if !LAST_L1_VALID.load(Ordering::Relaxed) { + return "{\"available\":false}".to_string(); + } + format!( + "{{\"available\":true,\"min_pq\":{},\"max_pq\":{},\"avg_pq\":{}}}", + LAST_L1_MIN_PQ.load(Ordering::Relaxed), + LAST_L1_MAX_PQ.load(Ordering::Relaxed), + LAST_L1_AVG_PQ.load(Ordering::Relaxed), + ) +} + +fn store_l1_from_rpu(rpu: &DoviRpu) { + let Some(dm) = &rpu.vdr_dm_data else { return }; + let Some(ExtMetadataBlock::Level1(l1)) = dm.get_block(1) else { return }; + LAST_L1_MIN_PQ.store(l1.min_pq as u32, Ordering::Relaxed); + LAST_L1_MAX_PQ.store(l1.max_pq as u32, Ordering::Relaxed); + LAST_L1_AVG_PQ.store(l1.avg_pq as u32, Ordering::Relaxed); + LAST_L1_VALID.store(true, Ordering::Relaxed); +} + // Synchronous byte-buffer segment rewriter // // Used by the Kotlin OkHttp interceptor to convert HLS segments (fMP4 .m4s or @@ -100,14 +126,14 @@ use serde_json::json; use std::collections::HashMap; use std::io::{Read, Write}; use std::net::{TcpListener, TcpStream}; -use std::sync::atomic::{AtomicBool, AtomicU32, Ordering}; +use std::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering}; use std::sync::Arc; use std::thread; use std::time::Duration; use crate::local_stream::{ - build_proxy_client, local_stream_servers, parse_request, send_upstream_request, - write_simple_response, LocalStreamConfig, LocalStreamHandle, LOCAL_STREAM_ID, + build_proxy_client, local_stream_servers, next_local_stream_id, parse_request, + send_upstream_request, write_simple_response, LocalStreamConfig, LocalStreamHandle, }; // Public config @@ -163,11 +189,9 @@ pub(crate) fn start_dv_rewrite_local_stream_server( serde_json::from_str::>(headers_json).unwrap_or_default(); let dv_config = Arc::new(serde_json::from_str::(dv_config_json).ok()?); - let id = LOCAL_STREAM_ID - .fetch_add(1, Ordering::Relaxed) - .to_string(); + let id = next_local_stream_id(); let bind_port = preferred_port.clamp(0, u16::MAX as i32) as u16; - let listener = TcpListener::bind(("127.0.0.1", bind_port)).ok()?; + let listener = TcpListener::bind(("0.0.0.0", bind_port)).ok()?; let port = listener.local_addr().ok()?.port(); listener.set_nonblocking(true).ok()?; @@ -178,6 +202,8 @@ pub(crate) fn start_dv_rewrite_local_stream_server( target_url: target_url.to_string(), headers, client: Arc::new(build_proxy_client()), + active_connections: Arc::new(AtomicUsize::new(0)), + port, }; let thread = thread::spawn(move || { @@ -209,7 +235,6 @@ pub(crate) fn start_dv_rewrite_local_stream_server( .ok() } -// Per-connection handler fn handle_dv_stream(mut stream: TcpStream, config: LocalStreamConfig, dv: &DvRewriteConfig) { let Some(request) = parse_request(&mut stream) else { write_simple_response(&mut stream, "400 Bad Request"); @@ -224,6 +249,11 @@ fn handle_dv_stream(mut stream: TcpStream, config: LocalStreamConfig, dv: &DvRew return; } + if dv.action == "hls_rpu_convert" { + handle_hls_rpu_convert(stream, config, dv, &request); + return; + } + let mut response = match send_upstream_request(&config.client, &config, &request.method, &request.headers) { Ok(r) => r, @@ -264,6 +294,289 @@ fn handle_dv_stream(mut stream: TcpStream, config: LocalStreamConfig, dv: &DvRew } } +fn handle_hls_rpu_convert( + mut downstream: TcpStream, + config: LocalStreamConfig, + dv: &DvRewriteConfig, + request: &crate::local_stream::ParsedLocalRequest, +) { + let seg_prefix = format!("/stream/{}/seg", config.id); + let stream_path = format!("/stream/{}", config.id); + + if request.path.starts_with(&seg_prefix) { + let query = request.path[seg_prefix.len()..].trim_start_matches('?'); + let seg_url = query + .split('&') + .find_map(|p| p.strip_prefix("u=")) + .map(hls_percent_decode) + .unwrap_or_default(); + + if seg_url.is_empty() { + write_simple_response(&mut downstream, "400 Bad Request"); + return; + } + + let url_lower = seg_url.to_ascii_lowercase(); + if url_lower.contains(".m3u8") { + serve_hls_manifest_rewritten(&mut downstream, &config, dv, &seg_url, request); + } else { + serve_hls_segment_rpu_convert(&mut downstream, &config, dv, &seg_url, request); + } + } else if request.path == stream_path + || request.path.starts_with(&format!("{}?", stream_path)) + { + serve_hls_manifest_rewritten(&mut downstream, &config, dv, &config.target_url.clone(), request); + } else { + write_simple_response(&mut downstream, "404 Not Found"); + } +} + +fn serve_hls_manifest_rewritten( + downstream: &mut TcpStream, + config: &LocalStreamConfig, + _dv: &DvRewriteConfig, + manifest_url: &str, + request: &crate::local_stream::ParsedLocalRequest, +) { + let mut upstream = match fetch_arbitrary_url(&config.client, manifest_url, &config.headers, &request.headers) { + Ok(r) => r, + Err(_) => { + write_simple_response(downstream, "502 Bad Gateway"); + return; + } + }; + let ct = upstream + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/vnd.apple.mpegurl") + .to_owned(); + let body = match upstream.text() { + Ok(t) => t, + Err(_) => { + write_simple_response(downstream, "502 Bad Gateway"); + return; + } + }; + + let proxy_seg_base = format!("http://127.0.0.1:{}/stream/{}/seg?u=", config.port, config.id); + let rewritten = rewrite_hls_manifest_for_dv(&body, manifest_url, &proxy_seg_base); + let bytes = rewritten.as_bytes(); + + let _ = write!( + downstream, + "HTTP/1.1 200 OK\r\nContent-Type: {ct}\r\nContent-Length: {}\r\nConnection: close\r\n\r\n", + bytes.len() + ); + if request.method != "HEAD" { + let _ = downstream.write_all(bytes); + } +} + +fn serve_hls_segment_rpu_convert( + downstream: &mut TcpStream, + config: &LocalStreamConfig, + dv: &DvRewriteConfig, + seg_url: &str, + request: &crate::local_stream::ParsedLocalRequest, +) { + let mut response = match fetch_arbitrary_url(&config.client, seg_url, &config.headers, &request.headers) { + Ok(r) => r, + Err(_) => { + write_simple_response(downstream, "502 Bad Gateway"); + return; + } + }; + + let status = response.status(); + let _ = write!(downstream, "HTTP/1.1 {} {}\r\n", status.as_u16(), status.canonical_reason().unwrap_or("OK")); + for name in ["content-type", "content-range", "accept-ranges"] { + if let Some(v) = response.headers().get(name).and_then(|v| v.to_str().ok()) { + let _ = write!(downstream, "{name}: {v}\r\n"); + } + } + let _ = write!(downstream, "Connection: close\r\n\r\n"); + + if request.method != "HEAD" { + stream_rpu_convert(&mut response, downstream, dv.rpu_mode, dv.zero_level5, dv.remove_hdr10plus); + } +} + +fn fetch_arbitrary_url( + client: &reqwest::blocking::Client, + url: &str, + stream_headers: &HashMap, + request_headers: &HashMap, +) -> Result { + let mut req = client.get(url); + for (k, v) in stream_headers { + req = req.header(k, v); + } + if let Some(range) = request_headers.get("range") { + req = req.header("Range", range); + } + req.send() +} + +fn rewrite_hls_manifest_for_dv(manifest: &str, base_url: &str, proxy_seg_base: &str) -> String { + manifest + .lines() + .map(|line| { + if line.is_empty() { + return line.to_string(); + } + if line.starts_with('#') { + let line = rewrite_hls_p7_codecs(line); + rewrite_hls_uri_attributes(&line, base_url, proxy_seg_base) + } else { + let abs = hls_resolve_url(base_url, line); + format!("{}{}", proxy_seg_base, hls_percent_encode(&abs)) + } + }) + .collect::>() + .join("\n") +} + +fn rewrite_hls_p7_codecs(line: &str) -> String { + let lower = line.to_ascii_lowercase(); + if !lower.contains("dvhe.07") && !lower.contains("dvh1.07") { + return line.to_string(); + } + let mut result = String::with_capacity(line.len()); + let bytes = line.as_bytes(); + let lower_bytes = lower.as_bytes(); + let mut i = 0; + while i < bytes.len() { + if lower_bytes[i..].starts_with(b"dvhe.07") { + result.push_str("dvhe.08"); + i += 7; + } else if lower_bytes[i..].starts_with(b"dvh1.07") { + result.push_str("dvh1.08"); + i += 7; + } else { + let ch = line[i..].chars().next().unwrap(); + result.push(ch); + i += ch.len_utf8(); + } + } + result +} + +fn rewrite_hls_uri_attributes(line: &str, base_url: &str, proxy_seg_base: &str) -> String { + let lower = line.to_ascii_lowercase(); + if !lower.contains("uri=\"") { + return line.to_string(); + } + let mut result = String::with_capacity(line.len() + 128); + let mut rest = line; + loop { + let rest_lower = rest.to_ascii_lowercase(); + let Some(pos) = rest_lower.find("uri=\"") else { + result.push_str(rest); + break; + }; + result.push_str(&rest[..pos]); + let after = &rest[pos + 5..]; + if let Some(end) = after.find('"') { + let inner = &after[..end]; + let abs = hls_resolve_url(base_url, inner); + result.push_str("URI=\""); + result.push_str(&format!("{}{}", proxy_seg_base, hls_percent_encode(&abs))); + result.push('"'); + rest = &after[end + 1..]; + } else { + result.push_str(&rest[pos..]); + break; + } + } + result +} + +fn hls_resolve_url(base_url: &str, relative: &str) -> String { + let rel_lower = relative.to_ascii_lowercase(); + if rel_lower.starts_with("http://") || rel_lower.starts_with("https://") { + return relative.to_string(); + } + if relative.starts_with('/') { + if let Some(scheme_end) = base_url.find("://") { + let rest = &base_url[scheme_end + 3..]; + let authority_end = rest.find('/').unwrap_or(rest.len()); + let origin = &base_url[..scheme_end + 3 + authority_end]; + return format!("{}{}", origin, relative); + } + } + let base_dir = if let Some(pos) = base_url.rfind('/') { + if base_url[..pos].contains("://") || pos == 0 { + &base_url[..pos + 1] + } else { + &base_url[..pos + 1] + } + } else { + base_url + }; + let combined = format!("{}{}", base_dir, relative); + hls_normalize_url_path(combined) +} + +fn hls_normalize_url_path(url: String) -> String { + let path_start = if let Some(pos) = url.find("://") { + let rest = &url[pos + 3..]; + pos + 3 + rest.find('/').unwrap_or(rest.len()) + } else { + return url; + }; + let (prefix, path) = url.split_at(path_start); + let mut parts: Vec<&str> = Vec::new(); + for seg in path.split('/') { + match seg { + ".." => { parts.pop(); } + "." | "" => {} + s => parts.push(s), + } + } + let trailing = if path.ends_with('/') { "/" } else { "" }; + format!("{}/{}{}", prefix, parts.join("/"), trailing) +} + +fn hls_percent_encode(s: &str) -> String { + let mut out = String::with_capacity(s.len() * 3); + for byte in s.bytes() { + match byte { + b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' + | b'-' | b'_' | b'.' | b'~' | b':' | b'/' | b'?' | b'#' | b'@' | b'!' | b'$' + | b'&' | b'\'' | b'(' | b')' | b'*' | b'+' | b',' | b';' | b'=' => { + out.push(byte as char); + } + b => { + out.push('%'); + out.push(char::from_digit((b >> 4) as u32, 16).unwrap().to_ascii_uppercase()); + out.push(char::from_digit((b & 0xf) as u32, 16).unwrap().to_ascii_uppercase()); + } + } + } + out +} + +fn hls_percent_decode(s: &str) -> String { + let mut out = Vec::with_capacity(s.len()); + let bytes = s.as_bytes(); + let mut i = 0; + while i < bytes.len() { + if bytes[i] == b'%' && i + 2 < bytes.len() { + let hi = char::from(bytes[i + 1]).to_digit(16); + let lo = char::from(bytes[i + 2]).to_digit(16); + if let (Some(h), Some(l)) = (hi, lo) { + out.push(((h << 4) | l) as u8); + i += 3; + continue; + } + } + out.push(bytes[i]); + i += 1; + } + String::from_utf8_lossy(&out).into_owned() +} + // DVCC strip (MKV / MP4 container) // // Searches the first 64 KiB of the stream for the DVCC or DVHE ISO-BMFF box @@ -1055,10 +1368,9 @@ fn emit_nal(nal_with_sc: &[u8], mode: &NalProcessMode, out: &mut Vec) -> (u3 fn convert_rpu_nal(nal: &[u8], mode: u8, zero_level5: bool) -> Option> { let mut rpu = DoviRpu::parse_unspec62_nalu(nal).ok()?; + store_l1_from_rpu(&rpu); rpu.convert_with_mode(mode).ok()?; if zero_level5 { - // Zero all Level 5 active-area offsets — mirrors Kodi's SetDoviZeroLevel5. - // crop() calls set_active_area_offsets(0, 0, 0, 0) internally. let _ = rpu.crop(); } rpu.write_hevc_unspec62_nalu().ok() diff --git a/fluxa-streaming-engine/src/ffmpeg_locator.rs b/fluxa-streaming-engine/src/ffmpeg_locator.rs index 3d0a14a..2a36a7e 100644 --- a/fluxa-streaming-engine/src/ffmpeg_locator.rs +++ b/fluxa-streaming-engine/src/ffmpeg_locator.rs @@ -13,16 +13,13 @@ fn platform_dir() -> &'static str { fn bundled_path(name: &str) -> Option { let exe_dir = std::env::current_exe().ok()?.parent()?.to_path_buf(); let exe_name = if cfg!(windows) { format!("{name}.exe") } else { name.to_string() }; - for candidate in [ + [ exe_dir.join("resources/ffmpeg").join(platform_dir()).join(&exe_name), // cargo run / cargo test layout: target// -> crate root/resources exe_dir.join("../../resources/ffmpeg").join(platform_dir()).join(&exe_name), - ] { - if candidate.is_file() { - return Some(candidate); - } - } - None + ] + .into_iter() + .find(|candidate| candidate.is_file()) } /// Resolves the ffmpeg/ffprobe binary to run: the bundled static build next to diff --git a/fluxa-streaming-engine/src/local_stream.rs b/fluxa-streaming-engine/src/local_stream.rs index e440ddb..176513f 100644 --- a/fluxa-streaming-engine/src/local_stream.rs +++ b/fluxa-streaming-engine/src/local_stream.rs @@ -1,13 +1,16 @@ use serde_json::json; use std::collections::HashMap; +use std::collections::hash_map::DefaultHasher; +use std::hash::{Hash, Hasher}; use std::io::{BufRead, BufReader, Write}; use std::net::{TcpListener, TcpStream}; -use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; +use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}; use std::sync::{Arc, Mutex, OnceLock}; use std::thread; use std::time::Duration; const PROXY_USER_AGENT: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"; +const MAX_LOCAL_STREAM_CONNECTIONS: usize = 32; pub(crate) fn build_proxy_client() -> reqwest::blocking::Client { reqwest::blocking::Client::builder() @@ -25,6 +28,8 @@ pub(crate) struct LocalStreamConfig { pub(crate) target_url: String, pub(crate) headers: HashMap, pub(crate) client: Arc, + pub(crate) active_connections: Arc, + pub(crate) port: u16, } pub(crate) struct LocalStreamHandle { @@ -46,6 +51,40 @@ pub(crate) fn local_stream_servers() -> &'static Mutex String { + let counter = LOCAL_STREAM_ID.fetch_add(1, Ordering::Relaxed); + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map(|duration| duration.as_nanos()) + .unwrap_or_default(); + let mut hasher = DefaultHasher::new(); + counter.hash(&mut hasher); + now.hash(&mut hasher); + std::process::id().hash(&mut hasher); + format!("{:016x}", hasher.finish()) +} + +struct ActiveConnectionGuard { + counter: Arc, +} + +impl ActiveConnectionGuard { + fn try_acquire(counter: Arc) -> Option { + let previous = counter.fetch_add(1, Ordering::AcqRel); + if previous >= MAX_LOCAL_STREAM_CONNECTIONS { + counter.fetch_sub(1, Ordering::AcqRel); + return None; + } + Some(Self { counter }) + } +} + +impl Drop for ActiveConnectionGuard { + fn drop(&mut self) { + self.counter.fetch_sub(1, Ordering::AcqRel); + } +} + pub(crate) fn parse_request(stream: &mut TcpStream) -> Option { let mut reader = BufReader::new(stream.try_clone().ok()?); let mut request_line = String::new(); @@ -125,6 +164,13 @@ pub(crate) fn send_upstream_request( } pub(crate) fn handle_local_stream(mut stream: TcpStream, config: LocalStreamConfig) { + let Some(_connection_guard) = + ActiveConnectionGuard::try_acquire(config.active_connections.clone()) + else { + write_simple_response(&mut stream, "503 Service Unavailable"); + return; + }; + let Some(request) = parse_request(&mut stream) else { write_simple_response(&mut stream, "400 Bad Request"); return; @@ -178,9 +224,9 @@ pub(crate) fn start_local_stream_server( preferred_port: i32, ) -> Option { let headers = serde_json::from_str::>(headers_json).unwrap_or_default(); - let id = LOCAL_STREAM_ID.fetch_add(1, Ordering::Relaxed).to_string(); + let id = next_local_stream_id(); let bind_port = preferred_port.clamp(0, u16::MAX as i32) as u16; - let listener = TcpListener::bind(("127.0.0.1", bind_port)).ok()?; + let listener = TcpListener::bind(("0.0.0.0", bind_port)).ok()?; let port = listener.local_addr().ok()?.port(); listener.set_nonblocking(true).ok()?; @@ -191,6 +237,8 @@ pub(crate) fn start_local_stream_server( target_url: target_url.to_string(), headers, client: Arc::new(build_proxy_client()), + active_connections: Arc::new(AtomicUsize::new(0)), + port, }; let thread = thread::spawn(move || { while !thread_stop.load(Ordering::Relaxed) { @@ -235,3 +283,25 @@ pub(crate) fn stop_local_stream_server(id: &str) -> bool { } true } + +#[cfg(test)] +mod tests { + use super::{ActiveConnectionGuard, MAX_LOCAL_STREAM_CONNECTIONS}; + use std::sync::atomic::{AtomicUsize, Ordering}; + use std::sync::Arc; + + #[test] + fn active_connection_guard_caps_and_releases_slots() { + let counter = Arc::new(AtomicUsize::new(0)); + let guards: Vec<_> = (0..MAX_LOCAL_STREAM_CONNECTIONS) + .map(|_| ActiveConnectionGuard::try_acquire(counter.clone()).unwrap()) + .collect(); + + assert!(ActiveConnectionGuard::try_acquire(counter.clone()).is_none()); + assert_eq!(counter.load(Ordering::Acquire), MAX_LOCAL_STREAM_CONNECTIONS); + + drop(guards); + assert_eq!(counter.load(Ordering::Acquire), 0); + assert!(ActiveConnectionGuard::try_acquire(counter.clone()).is_some()); + } +} diff --git a/fluxa-streaming-engine/src/torrent_engine.rs b/fluxa-streaming-engine/src/torrent_engine.rs index 0645319..88ecdef 100644 --- a/fluxa-streaming-engine/src/torrent_engine.rs +++ b/fluxa-streaming-engine/src/torrent_engine.rs @@ -1,5 +1,5 @@ use axum::body::Body; -use axum::extract::{Query, State}; +use axum::extract::{connect_info::ConnectInfo, Query, State}; use axum::http::{HeaderMap, HeaderValue, StatusCode}; use axum::response::{IntoResponse, Response}; use axum::routing::{get, post}; @@ -13,11 +13,12 @@ use serde::Deserialize; use serde_json::{json, Value}; use std::collections::{HashMap, HashSet}; use std::io::SeekFrom; +use std::net::SocketAddr; use std::path::PathBuf; use std::sync::{Arc, Mutex, OnceLock}; use std::thread; use std::time::Duration; -use tokio::io::AsyncSeekExt; +use tokio::io::{AsyncReadExt, AsyncSeekExt}; use tokio::net::TcpListener; use tokio::sync::oneshot; use tokio::sync::Mutex as AsyncMutex; @@ -48,6 +49,7 @@ struct StreamQuery { title: Option, index: Option, stat: Option, + access_token: Option, } #[derive(Clone)] @@ -56,6 +58,7 @@ struct EngineState { output_dir: PathBuf, preload_size: Arc>, known_links: Arc>>, + access_token: Arc, // Serializes the check-then-add sequence in ensure_torrent so two // near-simultaneous requests for the same new link (e.g. a stat poll // racing the stream GET) can't both call api_add_torrent for it. @@ -73,7 +76,17 @@ fn torrent_server_handle() -> &'static Mutex> { TORRENT_SERVER.get_or_init(|| Mutex::new(None)) } -pub fn start_torrent_server(cache_dir: &str, preferred_port: i32) -> Option { +fn debug_log(message: impl AsRef) { + if std::env::var_os("FLUXA_TORRENT_DEBUG").is_some() { + eprintln!("{}", message.as_ref()); + } +} + +pub fn start_torrent_server( + cache_dir: &str, + preferred_port: i32, + access_token: &str, +) -> Option { // Stop any existing server first. The mutex is the single source of truth // for whether the server is running — no separate AtomicBool needed. { @@ -97,6 +110,7 @@ pub fn start_torrent_server(cache_dir: &str, preferred_port: i32) -> Option(); let (ready_tx, ready_rx) = std::sync::mpsc::channel::>(); let thread_cache_dir = cache_dir.clone(); + let thread_access_token = access_token.trim().to_string(); let thread = thread::spawn(move || { let worker_threads = std::thread::available_parallelism() @@ -123,24 +137,26 @@ pub fn start_torrent_server(cache_dir: &str, preferred_port: i32) -> Option session, @@ -155,6 +171,7 @@ pub fn start_torrent_server(cache_dir: &str, preferred_port: i32) -> Option Option(), + ) + .with_graceful_shutdown(async move { let _ = stop_rx.await; }); let _ = ready_tx.send(Ok(())); @@ -212,17 +233,28 @@ async fn root() -> impl IntoResponse { async fn update_settings( State(state): State, + ConnectInfo(remote_addr): ConnectInfo, Json(settings): Json, ) -> impl IntoResponse { + if !request_authorized(&state, remote_addr, None) { + return error_response(StatusCode::UNAUTHORIZED, "unauthorized"); + } if let Some(preload_mb) = settings.preload_size { if let Ok(mut preload_size) = state.preload_size.lock() { *preload_size = preload_mb.saturating_mul(1024 * 1024); } } - (StatusCode::OK, Json(json!({}))) + (StatusCode::OK, Json(json!({}))).into_response() } -async fn torrents(State(state): State, Json(request): Json) -> Response { +async fn torrents( + State(state): State, + ConnectInfo(remote_addr): ConnectInfo, + Json(request): Json, +) -> Response { + if !request_authorized(&state, remote_addr, None) { + return error_response(StatusCode::UNAUTHORIZED, "unauthorized"); + } let _ = request.save_to_db; let action = request.action.to_ascii_lowercase(); match action.as_str() { @@ -278,9 +310,13 @@ async fn stream_fname( State(state): State, Query(query): Query, headers: HeaderMap, + ConnectInfo(remote_addr): ConnectInfo, ) -> Response { + if !request_authorized(&state, remote_addr, query.access_token.as_deref()) { + return error_response(StatusCode::UNAUTHORIZED, "unauthorized"); + } let range_header = headers.get("Range").and_then(|v| v.to_str().ok()).unwrap_or("none"); - eprintln!("[TorrServer] stream_fname link={} stat={} range={range_header}", &query.link[..query.link.len().min(60)], query.stat.is_some()); + debug_log(format!("[TorrServer] stream_fname link={} stat={} range={range_header}", &query.link[..query.link.len().min(60)], query.stat.is_some())); // Stat requests return immediately — no retry loop (used by Kotlin status polling) if query.stat.is_some() { @@ -300,14 +336,14 @@ async fn stream_fname( let (id, details) = match ensure_torrent(&state, Some(&query.link), query.title.as_deref(), query.index).await { Ok(value) => value, Err(error) => { - eprintln!("[TorrServer] ensure_torrent failed: {error}"); + debug_log(format!("[TorrServer] ensure_torrent failed: {error}")); return error_response(StatusCode::SERVICE_UNAVAILABLE, error); } }; let file_id = query .index .unwrap_or_else(|| largest_file_id(&details).unwrap_or(0)); - eprintln!("[TorrServer] streaming torrent={id} file={file_id} files={}", details.files.as_ref().map(|f| f.len()).unwrap_or(0)); + debug_log(format!("[TorrServer] streaming torrent={id} file={file_id} files={}", details.files.as_ref().map(|f| f.len()).unwrap_or(0))); prioritize_stream_file(&state, id, file_id).await; // Wait for rqbit to leave Initializing state before attempting to stream. @@ -321,7 +357,7 @@ async fn stream_fname( ) .await { - eprintln!("[TorrServer] wait_until_initialized timed out torrent={id}: {e}"); + debug_log(format!("[TorrServer] wait_until_initialized timed out torrent={id}: {e}")); return error_response(StatusCode::SERVICE_UNAVAILABLE, "torrent init timed out"); } } @@ -337,28 +373,29 @@ async fn stream_fname( } } let total_len = stream.len(); - if let Some((start, end)) = parse_range(headers.get("Range"), total_len) { - match stream.seek(SeekFrom::Start(start)).await { - Ok(_) => { - status = StatusCode::PARTIAL_CONTENT; - let end = end.unwrap_or_else(|| total_len.saturating_sub(1)); - let length = end.saturating_sub(start).saturating_add(1); - insert_header(&mut output_headers, "Content-Length", length.to_string()); - insert_header(&mut output_headers, "Content-Range", format!("bytes {start}-{end}/{total_len}")); - } - Err(error) => { - eprintln!("[TorrServer] seek failed torrent={id} file={file_id} start={start} len={total_len}: {error}"); - insert_header(&mut output_headers, "Content-Length", total_len.to_string()); + match parse_range(headers.get("Range"), total_len) { + Ok(Some((start, end))) => { + if let Err(error) = stream.seek(SeekFrom::Start(start)).await { + debug_log(format!("[TorrServer] seek failed torrent={id} file={file_id} start={start} len={total_len}: {error}")); + return error_response(StatusCode::INTERNAL_SERVER_ERROR, "failed to seek stream"); } + status = StatusCode::PARTIAL_CONTENT; + let length = end.saturating_sub(start).saturating_add(1); + insert_header(&mut output_headers, "Content-Length", length.to_string()); + insert_header(&mut output_headers, "Content-Range", format!("bytes {start}-{end}/{total_len}")); + let body = Body::from_stream(ReaderStream::with_capacity(stream.take(length), 65536)); + (status, output_headers, body).into_response() } - } else { - insert_header(&mut output_headers, "Content-Length", total_len.to_string()); + Ok(None) => { + insert_header(&mut output_headers, "Content-Length", total_len.to_string()); + let body = Body::from_stream(ReaderStream::with_capacity(stream, 65536)); + (status, output_headers, body).into_response() + } + Err(()) => range_not_satisfiable_response(total_len), } - let body = Body::from_stream(ReaderStream::with_capacity(stream, 65536)); - (status, output_headers, body).into_response() } Err(e) => { - eprintln!("[TorrServer] api_stream failed torrent={id} file={file_id}: {e:#}"); + debug_log(format!("[TorrServer] api_stream failed torrent={id} file={file_id}: {e:#}")); error_response(StatusCode::NOT_FOUND, format!("{e:#}")) } } @@ -395,14 +432,16 @@ async fn ensure_torrent( return Ok((id, details)); } - let mut options = AddTorrentOptions::default(); - options.overwrite = true; - options.output_folder = Some(state.output_dir.to_string_lossy().into_owned()); - options.peer_opts = Some(PeerConnectionOptions { - connect_timeout: Some(Duration::from_secs(5)), - read_write_timeout: Some(Duration::from_secs(20)), + let mut options = AddTorrentOptions { + overwrite: true, + output_folder: Some(state.output_dir.to_string_lossy().into_owned()), + peer_opts: Some(PeerConnectionOptions { + connect_timeout: Some(Duration::from_secs(5)), + read_write_timeout: Some(Duration::from_secs(20)), + ..Default::default() + }), ..Default::default() - }); + }; // Limit rqbit initialization to just the target file so the Initializing // hash-check covers one file instead of every file in the torrent. if let Some(file_id) = only_file { @@ -495,18 +534,38 @@ async fn status_response( })) } -fn parse_range(value: Option<&HeaderValue>, length: u64) -> Option<(u64, Option)> { - let raw = value?.to_str().ok()?.strip_prefix("bytes=")?; - let (start, end) = raw.split_once('-')?; - let start = start.parse::().ok()?; - if start >= length { - return None; +fn parse_range(value: Option<&HeaderValue>, length: u64) -> Result, ()> { + let Some(value) = value else { + return Ok(None); + }; + let raw = value.to_str().map_err(|_| ())?; + let spec = raw.strip_prefix("bytes=").ok_or(())?; + if spec.contains(',') || length == 0 { + return Err(()); } - let end = end - .parse::() - .ok() - .map(|end| end.min(length.saturating_sub(1))); - Some((start, end)) + let (start, end) = spec.split_once('-').ok_or(())?; + if start.is_empty() { + let suffix_len = end.parse::().map_err(|_| ())?; + if suffix_len == 0 { + return Err(()); + } + let start = length.saturating_sub(suffix_len); + return Ok(Some((start, length.saturating_sub(1)))); + } + let start = start.parse::().map_err(|_| ())?; + if start >= length { + return Err(()); + } + let end = if end.is_empty() { + length.saturating_sub(1) + } else { + let end = end.parse::().map_err(|_| ())?; + if end < start { + return Err(()); + } + end.min(length.saturating_sub(1)) + }; + Ok(Some((start, end))) } fn insert_header(headers: &mut HeaderMap, key: &'static str, value: String) { @@ -550,3 +609,68 @@ fn remember_link(state: &EngineState, link: &str, id: usize) { fn error_response(message_status: StatusCode, message: impl Into) -> Response { (message_status, Json(json!({ "error": message.into() }))).into_response() } + +fn request_authorized( + state: &EngineState, + remote_addr: SocketAddr, + access_token: Option<&str>, +) -> bool { + remote_addr.ip().is_loopback() + || (!state.access_token.is_empty() + && access_token.is_some_and(|token| token == state.access_token.as_str())) +} + +fn range_not_satisfiable_response(length: u64) -> Response { + let mut headers = HeaderMap::new(); + insert_header(&mut headers, "Content-Range", format!("bytes */{length}")); + ( + StatusCode::RANGE_NOT_SATISFIABLE, + headers, + Json(json!({ "error": "range not satisfiable" })), + ) + .into_response() +} + +#[cfg(test)] +mod tests { + use super::parse_range; + use axum::http::HeaderValue; + + fn range(value: &str, length: u64) -> Result, ()> { + parse_range(Some(&HeaderValue::from_str(value).unwrap()), length) + } + + #[test] + fn parses_open_ended_range() { + assert_eq!(range("bytes=100-", 1000), Ok(Some((100, 999)))); + } + + #[test] + fn parses_bounded_range() { + assert_eq!(range("bytes=100-199", 1000), Ok(Some((100, 199)))); + } + + #[test] + fn clamps_bounded_range_to_file_end() { + assert_eq!(range("bytes=900-2000", 1000), Ok(Some((900, 999)))); + } + + #[test] + fn parses_suffix_range() { + assert_eq!(range("bytes=-200", 1000), Ok(Some((800, 999)))); + } + + #[test] + fn rejects_unsatisfiable_and_malformed_ranges() { + assert_eq!(range("bytes=1000-", 1000), Err(())); + assert_eq!(range("bytes=200-100", 1000), Err(())); + assert_eq!(range("items=0-1", 1000), Err(())); + assert_eq!(range("bytes=0-1,2-3", 1000), Err(())); + assert_eq!(range("bytes=-0", 1000), Err(())); + } + + #[test] + fn no_range_header_means_full_response() { + assert_eq!(parse_range(None, 1000), Ok(None)); + } +} diff --git a/src/addon_protocol.rs b/src/addon_protocol.rs index ef80732..359328d 100644 --- a/src/addon_protocol.rs +++ b/src/addon_protocol.rs @@ -127,10 +127,9 @@ pub(crate) fn base_url(raw: &str) -> String { format!("{without_manifest}/") }; let lower = base.to_ascii_lowercase(); - if lower.contains("localhost") || lower.contains("127.0.0.1") { - if lower.starts_with("https://") { - base = format!("http://{}", &base[8..]); - } + if (lower.contains("localhost") || lower.contains("127.0.0.1")) && lower.starts_with("https://") + { + base = format!("http://{}", &base[8..]); } base } @@ -477,11 +476,7 @@ pub(crate) fn parse_catalogs(json: &Value) -> Vec { // pub rather than pub(crate): re-exported under fuzz_targets for the `fuzz/` // crate (see lib.rs). Not part of the supported public API otherwise. -pub fn parse_manifest( - body: &str, - transport_url: &str, - unknown_name: &str, -) -> Option { +pub fn parse_manifest(body: &str, transport_url: &str, unknown_name: &str) -> Option { let json: Value = serde_json::from_str(body).ok()?; let behavior_hints = json.get("behaviorHints"); let logo = first_text( @@ -978,7 +973,13 @@ mod tests { #[test] fn build_resource_url_appends_extra_path_segment_and_omits_blank_values() { assert_eq!( - build_resource_url("https://addon.example/manifest.json", "stream", "movie", "tt123", None), + build_resource_url( + "https://addon.example/manifest.json", + "stream", + "movie", + "tt123", + None + ), "https://addon.example/stream/movie/tt123.json" ); assert_eq!( @@ -1011,9 +1012,19 @@ mod tests { "types": ["movie"], "idPrefixes": ["tt"], }); - assert!(supports_resource(&manifest.to_string(), "streams", Some("movie"), Some("tt123"))); + assert!(supports_resource( + &manifest.to_string(), + "streams", + Some("movie"), + Some("tt123") + )); // Wrong content type for this manifest's declared types. - assert!(!supports_resource(&manifest.to_string(), "stream", Some("series"), Some("tt123"))); + assert!(!supports_resource( + &manifest.to_string(), + "stream", + Some("series"), + Some("tt123") + )); let catalog_manifest = json!({ "resources": [{ "name": "catalog", "types": ["movie"], "idPrefixes": ["tt"] }], diff --git a/src/addon_resource.rs b/src/addon_resource.rs index 71f184f..279b91f 100644 --- a/src/addon_resource.rs +++ b/src/addon_resource.rs @@ -1,7 +1,7 @@ use crate::addon_protocol; use serde_json::{json, Value}; -fn resource_payload<'a>(resource: &str, root: &'a Value) -> Option { +fn resource_payload(resource: &str, root: &Value) -> Option { match resource { "stream" | "streams" => root.get("streams").cloned(), "catalog" | "metas" => root.get("metas").cloned(), diff --git a/src/addon_store.rs b/src/addon_store.rs index 0223788..8b741c7 100644 --- a/src/addon_store.rs +++ b/src/addon_store.rs @@ -352,7 +352,8 @@ pub(crate) fn addon_store_search_policy_json(request_json: &str) -> Option &'static Regex { static REGEX: OnceLock = OnceLock::new(); REGEX.get_or_init(|| { - Regex::new(r#"https?://[^"'\\ ]+manifest\.json[^"'\\ ]*"#).expect("valid manifest url regex") + Regex::new(r#"https?://[^"'\\ ]+manifest\.json[^"'\\ ]*"#) + .expect("valid manifest url regex") }) } diff --git a/src/app_state.rs b/src/app_state.rs index 3a38762..214000b 100644 --- a/src/app_state.rs +++ b/src/app_state.rs @@ -264,7 +264,9 @@ fn store() -> &'static Mutex> { // See headless_engine::lock_engines — recovering from poison keeps this store // usable after a single caught panic instead of going dark for every handle. fn lock_store() -> std::sync::MutexGuard<'static, HashMap> { - store().lock().unwrap_or_else(|poisoned| poisoned.into_inner()) + store() + .lock() + .unwrap_or_else(|poisoned| poisoned.into_inner()) } pub fn create_app_core_state(initial_json: &str) -> u64 { diff --git a/src/bindings/jni.rs b/src/bindings/jni.rs index f034ba3..2ce1bec 100644 --- a/src/bindings/jni.rs +++ b/src/bindings/jni.rs @@ -1,3 +1,5 @@ +#![allow(clippy::missing_safety_doc)] + use crate::addon_protocol::*; use crate::addon_resource::*; use crate::addon_store::*; @@ -53,6 +55,23 @@ pub(crate) fn write_jstring(env: &mut JNIEnv<'_>, value: Option) -> JStr .unwrap_or_else(|_| ptr::null_mut()) } +#[no_mangle] +pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_coreInvokeNative( + mut env: JNIEnv<'_>, + _class: JObject<'_>, + method: JString<'_>, + args_json: JString<'_>, +) -> JStringReturn { + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &method).and_then(|method| { + let args_json = read_jstring(&mut env, &args_json)?; + Some(crate::ffi::core_invoke(&method, &args_json)) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} + macro_rules! string_fn { ($name:ident, $body:expr) => { #[no_mangle] @@ -177,13 +196,14 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_repos meta_detail_json: JString<'_>, season_number: JInt, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &meta_detail_json) - .map(|meta_detail_json| repository_season_videos_json(&meta_detail_json, season_number)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &meta_detail_json).map(|meta_detail_json| { + repository_season_videos_json(&meta_detail_json, season_number) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_sanitizeProfileJsonNative( @@ -193,18 +213,18 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_sanit mirrored_addons_json: JString<'_>, merge_mirrored_addons: JBoolean, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &profile_json).and_then(|profile_json| { - sanitize_profile_json( - &profile_json, - &read_jstring(&mut env, &mirrored_addons_json)?, - merge_mirrored_addons != 0, - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &profile_json).and_then(|profile_json| { + sanitize_profile_json( + &profile_json, + &read_jstring(&mut env, &mirrored_addons_json)?, + merge_mirrored_addons != 0, + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_pluginIsSecureRemoteUrlNative( @@ -212,18 +232,18 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_plugi _class: JObject<'_>, url: JString<'_>, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - if read_jstring(&mut env, &url) - .map(|url| is_secure_remote_url(&url)) - .unwrap_or(false) - { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + if read_jstring(&mut env, &url) + .map(|url| is_secure_remote_url(&url)) + .unwrap_or(false) + { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_pluginSameRepositoryUrlNative( @@ -232,23 +252,23 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_plugi left: JString<'_>, right: JString<'_>, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - if read_jstring(&mut env, &left) - .and_then(|left| { - Some(same_plugin_repository_url( - &left, - &read_jstring(&mut env, &right)?, - )) - }) - .unwrap_or(false) - { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + if read_jstring(&mut env, &left) + .and_then(|left| { + Some(same_plugin_repository_url( + &left, + &read_jstring(&mut env, &right)?, + )) + }) + .unwrap_or(false) + { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_addonStreamsWithProviderJsonNative( @@ -257,17 +277,17 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_addon streams_json: JString<'_>, addon_name: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &streams_json).and_then(|streams_json| { - Some(addon_streams_with_provider_json( - &streams_json, - &read_jstring(&mut env, &addon_name)?, - )) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &streams_json).and_then(|streams_json| { + Some(addon_streams_with_provider_json( + &streams_json, + &read_jstring(&mut env, &addon_name)?, + )) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_createAppCoreStateNative( @@ -275,13 +295,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_creat _class: JObject<'_>, initial_json: JString<'_>, ) -> JLong { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - read_jstring(&mut env, &initial_json) - .map(|initial_json| create_app_core_state(&initial_json) as JLong) - .unwrap_or(0) - })) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + read_jstring(&mut env, &initial_json) + .map(|initial_json| create_app_core_state(&initial_json) as JLong) .unwrap_or(0) - } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_destroyAppCoreStateNative( @@ -289,15 +309,15 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_destr _class: JObject<'_>, handle: JLong, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - if handle > 0 && destroy_app_core_state(handle as u64) { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + if handle > 0 && destroy_app_core_state(handle as u64) { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_appCoreStateJsonNative( @@ -305,16 +325,16 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_appCo _class: JObject<'_>, handle: JLong, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = if handle > 0 { - app_core_state_json(handle as u64) - } else { - None - }; - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = if handle > 0 { + app_core_state_json(handle as u64) + } else { + None + }; + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_appCoreDispatchJsonNative( @@ -323,17 +343,17 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_appCo handle: JLong, action_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = if handle > 0 { - read_jstring(&mut env, &action_json) - .and_then(|action_json| app_core_dispatch_json(handle as u64, &action_json)) - } else { - None - }; - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = if handle > 0 { + read_jstring(&mut env, &action_json) + .and_then(|action_json| app_core_dispatch_json(handle as u64, &action_json)) + } else { + None + }; + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_createHeadlessEngineNative( @@ -341,13 +361,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_creat _class: JObject<'_>, initial_json: JString<'_>, ) -> JLong { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - read_jstring(&mut env, &initial_json) - .map(|initial_json| create_headless_engine(&initial_json) as JLong) - .unwrap_or(0) - })) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + read_jstring(&mut env, &initial_json) + .map(|initial_json| create_headless_engine(&initial_json) as JLong) .unwrap_or(0) - } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_destroyHeadlessEngineNative( @@ -355,15 +375,15 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_destr _class: JObject<'_>, handle: JLong, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - if handle > 0 && destroy_headless_engine(handle as u64) { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + if handle > 0 && destroy_headless_engine(handle as u64) { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_headlessEngineSnapshotJsonNative( @@ -371,16 +391,16 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_headl _class: JObject<'_>, handle: JLong, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = if handle > 0 { - headless_engine_snapshot_json(handle as u64) - } else { - None - }; - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = if handle > 0 { + headless_engine_snapshot_json(handle as u64) + } else { + None + }; + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_headlessEngineDispatchJsonNative( @@ -389,17 +409,17 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_headl handle: JLong, action_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = if handle > 0 { - read_jstring(&mut env, &action_json) - .and_then(|action_json| headless_engine_dispatch_json(handle as u64, &action_json)) - } else { - None - }; - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = if handle > 0 { + read_jstring(&mut env, &action_json) + .and_then(|action_json| headless_engine_dispatch_json(handle as u64, &action_json)) + } else { + None + }; + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_headlessEngineCompleteEffectJsonNative( @@ -408,18 +428,18 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_headl handle: JLong, result_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = if handle > 0 { - read_jstring(&mut env, &result_json).and_then(|result_json| { - headless_engine_complete_effect_json(handle as u64, &result_json) - }) - } else { - None - }; - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = if handle > 0 { + read_jstring(&mut env, &result_json).and_then(|result_json| { + headless_engine_complete_effect_json(handle as u64, &result_json) + }) + } else { + None + }; + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_coreCapabilitiesJsonNative( @@ -427,22 +447,22 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_coreC _class: JObject<'_>, portable: JBoolean, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - write_jstring(&mut env, Some(core_capabilities_json(portable != 0))) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + write_jstring(&mut env, Some(core_capabilities_json(portable != 0))) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_headlessDirectPlaybackPolicyJsonNative( mut env: JNIEnv<'_>, _class: JObject<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - write_jstring(&mut env, Some(direct_playback_policy_json())) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + write_jstring(&mut env, Some(direct_playback_policy_json())) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_manifestCandidatesJsonNative( @@ -450,13 +470,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_manif _class: JObject<'_>, input: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &input) - .and_then(|value| serde_json::to_string(&manifest_candidates(&value)).ok()); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &input) + .and_then(|value| serde_json::to_string(&manifest_candidates(&value)).ok()); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_manifestFetchPlanJsonNative( @@ -464,12 +484,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_manif _class: JObject<'_>, input: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &input).and_then(|value| manifest_fetch_plan_json(&value)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = + read_jstring(&mut env, &input).and_then(|value| manifest_fetch_plan_json(&value)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_buildResourceUrlNative( @@ -481,20 +502,20 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_build id: JString<'_>, extra_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &transport_url).and_then(|transport_url| { - Some(build_resource_url( - &transport_url, - &read_jstring(&mut env, &resource)?, - &read_jstring(&mut env, &content_type)?, - &read_jstring(&mut env, &id)?, - read_jstring(&mut env, &extra_json).as_deref(), - )) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &transport_url).and_then(|transport_url| { + Some(build_resource_url( + &transport_url, + &read_jstring(&mut env, &resource)?, + &read_jstring(&mut env, &content_type)?, + &read_jstring(&mut env, &id)?, + read_jstring(&mut env, &extra_json).as_deref(), + )) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_parseManifestJsonNative( @@ -504,18 +525,18 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_parse transport_url: JString<'_>, unknown_name: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &body).and_then(|body| { - parse_manifest( - &body, - &read_jstring(&mut env, &transport_url)?, - &read_jstring(&mut env, &unknown_name)?, - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &body).and_then(|body| { + parse_manifest( + &body, + &read_jstring(&mut env, &transport_url)?, + &read_jstring(&mut env, &unknown_name)?, + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_resolveManifestAssetsJsonNative( @@ -523,13 +544,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_resol _class: JObject<'_>, descriptor_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &descriptor_json) - .and_then(|descriptor_json| resolve_manifest_assets_json(&descriptor_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &descriptor_json) + .and_then(|descriptor_json| resolve_manifest_assets_json(&descriptor_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_mergeLiveManifestJsonNative( @@ -539,20 +560,20 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_merge live_json: JString<'_>, unknown_name: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &descriptor_json).and_then(|descriptor_json| { - merge_live_manifest_json( - &descriptor_json, - read_jstring(&mut env, &live_json) - .filter(|value| !value.trim().is_empty()) - .as_deref(), - &read_jstring(&mut env, &unknown_name)?, - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &descriptor_json).and_then(|descriptor_json| { + merge_live_manifest_json( + &descriptor_json, + read_jstring(&mut env, &live_json) + .filter(|value| !value.trim().is_empty()) + .as_deref(), + &read_jstring(&mut env, &unknown_name)?, + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_supportsResourceNative( @@ -563,29 +584,29 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_suppo content_type: JString<'_>, id: JString<'_>, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let result = read_jstring(&mut env, &manifest_json) - .and_then(|manifest_json| { - Some(supports_resource( - &manifest_json, - &read_jstring(&mut env, &resource_name)?, - read_jstring(&mut env, &content_type) - .filter(|value| !value.is_empty()) - .as_deref(), - read_jstring(&mut env, &id) - .filter(|value| !value.is_empty()) - .as_deref(), - )) - }) - .unwrap_or(false); - if result { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let result = read_jstring(&mut env, &manifest_json) + .and_then(|manifest_json| { + Some(supports_resource( + &manifest_json, + &read_jstring(&mut env, &resource_name)?, + read_jstring(&mut env, &content_type) + .filter(|value| !value.is_empty()) + .as_deref(), + read_jstring(&mut env, &id) + .filter(|value| !value.is_empty()) + .as_deref(), + )) + }) + .unwrap_or(false); + if result { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_catalogSupportsExtraNative( @@ -594,23 +615,23 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_catal catalog_json: JString<'_>, extra_name: JString<'_>, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let result = read_jstring(&mut env, &catalog_json) - .and_then(|catalog_json| { - Some(catalog_supports_extra( - &catalog_json, - &read_jstring(&mut env, &extra_name)?, - )) - }) - .unwrap_or(false); - if result { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let result = read_jstring(&mut env, &catalog_json) + .and_then(|catalog_json| { + Some(catalog_supports_extra( + &catalog_json, + &read_jstring(&mut env, &extra_name)?, + )) + }) + .unwrap_or(false); + if result { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_catalogRequiresExtraNative( @@ -619,23 +640,23 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_catal catalog_json: JString<'_>, extra_name: JString<'_>, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let result = read_jstring(&mut env, &catalog_json) - .and_then(|catalog_json| { - Some(catalog_requires_extra( - &catalog_json, - &read_jstring(&mut env, &extra_name)?, - )) - }) - .unwrap_or(false); - if result { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let result = read_jstring(&mut env, &catalog_json) + .and_then(|catalog_json| { + Some(catalog_requires_extra( + &catalog_json, + &read_jstring(&mut env, &extra_name)?, + )) + }) + .unwrap_or(false); + if result { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_catalogHasRequiredExtraExceptNative( @@ -644,23 +665,23 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_catal catalog_json: JString<'_>, allowed_names_json: JString<'_>, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let result = read_jstring(&mut env, &catalog_json) - .and_then(|catalog_json| { - Some(catalog_has_required_extra_except( - &catalog_json, - &read_jstring(&mut env, &allowed_names_json)?, - )) - }) - .unwrap_or(false); - if result { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let result = read_jstring(&mut env, &catalog_json) + .and_then(|catalog_json| { + Some(catalog_has_required_extra_except( + &catalog_json, + &read_jstring(&mut env, &allowed_names_json)?, + )) + }) + .unwrap_or(false); + if result { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_parseEpisodeLocatorJsonNative( @@ -668,20 +689,20 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_parse _class: JObject<'_>, input: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &input).and_then(|input| { - let (base_id, season, episode) = parse_episode_locator(&input)?; - serde_json::to_string(&json!({ - "baseId": base_id, - "season": season, - "episode": episode - })) - .ok() - }); - write_jstring(&mut env, output) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &input).and_then(|input| { + let (base_id, season, episode) = parse_episode_locator(&input)?; + serde_json::to_string(&json!({ + "baseId": base_id, + "season": season, + "episode": episode })) - .unwrap_or(ptr::null_mut()) - } + .ok() + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_streamRequestIdsJsonNative( @@ -693,27 +714,27 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_strea current_series_lookup_id: JString<'_>, canonical_base_id: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &content_type).and_then(|content_type| { - serde_json::to_string(&stream_request_ids( - &content_type, - &read_jstring(&mut env, &id)?, - read_jstring(&mut env, &detail_id) - .filter(|value| !value.is_empty()) - .as_deref(), - read_jstring(&mut env, ¤t_series_lookup_id) - .filter(|value| !value.is_empty()) - .as_deref(), - read_jstring(&mut env, &canonical_base_id) - .filter(|value| !value.is_empty()) - .as_deref(), - )) - .ok() - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &content_type).and_then(|content_type| { + serde_json::to_string(&stream_request_ids( + &content_type, + &read_jstring(&mut env, &id)?, + read_jstring(&mut env, &detail_id) + .filter(|value| !value.is_empty()) + .as_deref(), + read_jstring(&mut env, ¤t_series_lookup_id) + .filter(|value| !value.is_empty()) + .as_deref(), + read_jstring(&mut env, &canonical_base_id) + .filter(|value| !value.is_empty()) + .as_deref(), + )) + .ok() + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playbackStreamRequestIdsJsonNative( @@ -723,20 +744,20 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playb id: JString<'_>, detail_id: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &content_type).and_then(|content_type| { - playback_stream_request_ids_json( - &content_type, - &read_jstring(&mut env, &id)?, - read_jstring(&mut env, &detail_id) - .filter(|value| !value.is_empty()) - .as_deref(), - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &content_type).and_then(|content_type| { + playback_stream_request_ids_json( + &content_type, + &read_jstring(&mut env, &id)?, + read_jstring(&mut env, &detail_id) + .filter(|value| !value.is_empty()) + .as_deref(), + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_streamDiscoveryEpisodeContextJsonNative( @@ -747,21 +768,21 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_strea detail_json: JString<'_>, season_episodes_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &content_type).and_then(|content_type| { - stream_discovery_episode_context_json( - &content_type, - &read_jstring(&mut env, &request_id)?, - read_jstring(&mut env, &detail_json) - .filter(|value| !value.is_empty()) - .as_deref(), - &read_jstring(&mut env, &season_episodes_json)?, - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &content_type).and_then(|content_type| { + stream_discovery_episode_context_json( + &content_type, + &read_jstring(&mut env, &request_id)?, + read_jstring(&mut env, &detail_json) + .filter(|value| !value.is_empty()) + .as_deref(), + &read_jstring(&mut env, &season_episodes_json)?, + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} string_fn!( Java_com_fluxa_app_core_rust_FluxaCoreNative_playbackIntroLookupContentIdNative, @@ -776,20 +797,20 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_direc detail_json: JString<'_>, today_iso: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &meta_json).and_then(|meta_json| { - direct_playback_plan_json( - &meta_json, - read_jstring(&mut env, &detail_json) - .filter(|value| !value.is_empty()) - .as_deref(), - &read_jstring(&mut env, &today_iso)?, - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &meta_json).and_then(|meta_json| { + direct_playback_plan_json( + &meta_json, + read_jstring(&mut env, &detail_json) + .filter(|value| !value.is_empty()) + .as_deref(), + &read_jstring(&mut env, &today_iso)?, + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_streamPlaybackInfoJsonNative( @@ -797,13 +818,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_strea _class: JObject<'_>, stream_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &stream_json) - .and_then(|stream_json| stream_playback_info_json(&stream_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &stream_json) + .and_then(|stream_json| stream_playback_info_json(&stream_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_streamRequestHeadersJsonNative( @@ -811,13 +832,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_strea _class: JObject<'_>, headers_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &headers_json) - .and_then(|headers_json| stream_request_headers_json(&headers_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &headers_json) + .and_then(|headers_json| stream_request_headers_json(&headers_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_streamRequestRefererNative( @@ -825,13 +846,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_strea _class: JObject<'_>, url: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = - read_jstring(&mut env, &url).map(|url| stream_request_referer(&url).unwrap_or_default()); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &url) + .map(|url| stream_request_referer(&url).unwrap_or_default()); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_episodeTextMatchesNative( @@ -841,18 +862,18 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_episo season: JInt, episode: JInt, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let result = read_jstring(&mut env, &text) - .map(|text| text_matches_episode(&text, season, episode)) - .unwrap_or(false); - if result { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let result = read_jstring(&mut env, &text) + .map(|text| text_matches_episode(&text, season, episode)) + .unwrap_or(false); + if result { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_streamMatchesEpisodeNative( @@ -865,29 +886,29 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_strea filename: JString<'_>, effective_filename: JString<'_>, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let result = read_jstring(&mut env, &video_id) - .map(|video_id| { - stream_matches_episode( - &video_id, - &[ - read_jstring(&mut env, &title).unwrap_or_default(), - read_jstring(&mut env, &name).unwrap_or_default(), - read_jstring(&mut env, &description).unwrap_or_default(), - read_jstring(&mut env, &filename).unwrap_or_default(), - read_jstring(&mut env, &effective_filename).unwrap_or_default(), - ], - ) - }) - .unwrap_or(false); - if result { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let result = read_jstring(&mut env, &video_id) + .map(|video_id| { + stream_matches_episode( + &video_id, + &[ + read_jstring(&mut env, &title).unwrap_or_default(), + read_jstring(&mut env, &name).unwrap_or_default(), + read_jstring(&mut env, &description).unwrap_or_default(), + read_jstring(&mut env, &filename).unwrap_or_default(), + read_jstring(&mut env, &effective_filename).unwrap_or_default(), + ], + ) + }) + .unwrap_or(false); + if result { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_selectStreamIndexNative( @@ -902,32 +923,32 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_selec regex_pattern: JString<'_>, preferred_binge_group: JString<'_>, ) -> JInt { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - read_jstring(&mut env, &streams_json) - .and_then(|streams_json| { - Some(select_stream_index( - &streams_json, - &read_jstring(&mut env, ¤t_video_id).unwrap_or_default(), - initial_stream_index, - read_jstring(&mut env, &saved_url) - .filter(|value| !value.is_empty()) - .as_deref(), - read_jstring(&mut env, &saved_title) - .filter(|value| !value.is_empty()) - .as_deref(), - &read_jstring(&mut env, &source_selection_mode)?, - read_jstring(&mut env, ®ex_pattern) - .filter(|value| !value.is_empty()) - .as_deref(), - read_jstring(&mut env, &preferred_binge_group) - .filter(|value| !value.is_empty()) - .as_deref(), - )) - }) - .unwrap_or(-1) - })) - .unwrap_or(0) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + read_jstring(&mut env, &streams_json) + .and_then(|streams_json| { + Some(select_stream_index( + &streams_json, + &read_jstring(&mut env, ¤t_video_id).unwrap_or_default(), + initial_stream_index, + read_jstring(&mut env, &saved_url) + .filter(|value| !value.is_empty()) + .as_deref(), + read_jstring(&mut env, &saved_title) + .filter(|value| !value.is_empty()) + .as_deref(), + &read_jstring(&mut env, &source_selection_mode)?, + read_jstring(&mut env, ®ex_pattern) + .filter(|value| !value.is_empty()) + .as_deref(), + read_jstring(&mut env, &preferred_binge_group) + .filter(|value| !value.is_empty()) + .as_deref(), + )) + }) + .unwrap_or(-1) + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_mergeContinueWatchingDuplicatesJsonNative( @@ -935,13 +956,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_merge _class: JObject<'_>, items_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &items_json) - .and_then(|items_json| merge_continue_watching_duplicates_json(&items_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &items_json) + .and_then(|items_json| merge_continue_watching_duplicates_json(&items_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_filterDiscoverResultsJsonNative( @@ -953,23 +974,23 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_filte has_rating: JBoolean, region: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &items_json).and_then(|items_json| { - filter_discover_results_json( - &items_json, - read_jstring(&mut env, &year) - .filter(|value| !value.trim().is_empty()) - .as_deref(), - if has_rating != 0 { Some(rating) } else { None }, - read_jstring(&mut env, ®ion) - .filter(|value| !value.trim().is_empty()) - .as_deref(), - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &items_json).and_then(|items_json| { + filter_discover_results_json( + &items_json, + read_jstring(&mut env, &year) + .filter(|value| !value.trim().is_empty()) + .as_deref(), + if has_rating != 0 { Some(rating) } else { None }, + read_jstring(&mut env, ®ion) + .filter(|value| !value.trim().is_empty()) + .as_deref(), + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_resolvePreferredAudioLanguageNative( @@ -979,22 +1000,22 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_resol preferred_audio_language: JString<'_>, original_language: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = Some(resolve_preferred_audio_language( - read_jstring(&mut env, &last_audio_language) - .filter(|value| !value.is_empty()) - .as_deref(), - read_jstring(&mut env, &preferred_audio_language) - .filter(|value| !value.is_empty()) - .as_deref(), - read_jstring(&mut env, &original_language) - .filter(|value| !value.is_empty()) - .as_deref(), - )); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = Some(resolve_preferred_audio_language( + read_jstring(&mut env, &last_audio_language) + .filter(|value| !value.is_empty()) + .as_deref(), + read_jstring(&mut env, &preferred_audio_language) + .filter(|value| !value.is_empty()) + .as_deref(), + read_jstring(&mut env, &original_language) + .filter(|value| !value.is_empty()) + .as_deref(), + )); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_subtitleLanguageMatchesNative( @@ -1004,26 +1025,26 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_subti language: JString<'_>, preferred_language: JString<'_>, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let result = read_jstring(&mut env, &label) - .and_then(|label| { - Some(subtitle_language_matches( - &label, - read_jstring(&mut env, &language) - .filter(|value| !value.is_empty()) - .as_deref(), - &read_jstring(&mut env, &preferred_language)?, - )) - }) - .unwrap_or(false); - if result { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let result = read_jstring(&mut env, &label) + .and_then(|label| { + Some(subtitle_language_matches( + &label, + read_jstring(&mut env, &language) + .filter(|value| !value.is_empty()) + .as_deref(), + &read_jstring(&mut env, &preferred_language)?, + )) + }) + .unwrap_or(false); + if result { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_findPreferredSubtitleIndexNative( @@ -1034,27 +1055,26 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_findP preferred_subtitle_language: JString<'_>, secondary_subtitle_language: JString<'_>, ) -> JInt { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - read_jstring(&mut env, &tracks_json) - .map(|tracks_json| { - find_preferred_subtitle_index( - &tracks_json, - read_jstring(&mut env, &last_subtitle_language) - .filter(|value| !value.is_empty()) - .as_deref(), - read_jstring(&mut env, &preferred_subtitle_language) - .filter(|value| !value.is_empty()) - .as_deref(), - read_jstring(&mut env, &secondary_subtitle_language) - .filter(|value| !value.is_empty()) - .as_deref(), - ) - }) - .unwrap_or(-1) - })) - .unwrap_or(0) - } - + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + read_jstring(&mut env, &tracks_json) + .map(|tracks_json| { + find_preferred_subtitle_index( + &tracks_json, + read_jstring(&mut env, &last_subtitle_language) + .filter(|value| !value.is_empty()) + .as_deref(), + read_jstring(&mut env, &preferred_subtitle_language) + .filter(|value| !value.is_empty()) + .as_deref(), + read_jstring(&mut env, &secondary_subtitle_language) + .filter(|value| !value.is_empty()) + .as_deref(), + ) + }) + .unwrap_or(-1) + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_parseAddonResourceResultJsonNative( @@ -1065,19 +1085,19 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_parse status_code: JInt, body: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &resource).and_then(|resource| { - Some(parse_addon_resource_result_json( - &resource, - &read_jstring(&mut env, &url)?, - status_code, - read_jstring(&mut env, &body).as_deref(), - )) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &resource).and_then(|resource| { + Some(parse_addon_resource_result_json( + &resource, + &read_jstring(&mut env, &url)?, + status_code, + read_jstring(&mut env, &body).as_deref(), + )) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_normalizeAddonSubtitlesJsonNative( @@ -1086,17 +1106,17 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_norma subtitles_json: JString<'_>, resource_url: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &subtitles_json).and_then(|subtitles_json| { - Some(normalize_addon_subtitles_json( - &subtitles_json, - &read_jstring(&mut env, &resource_url)?, - )) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &subtitles_json).and_then(|subtitles_json| { + Some(normalize_addon_subtitles_json( + &subtitles_json, + &read_jstring(&mut env, &resource_url)?, + )) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_torrentRuntimeInfoJsonNative( @@ -1104,13 +1124,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_torre _class: JObject<'_>, request_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &request_json) - .and_then(|request_json| torrent_runtime_info_json(&request_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &request_json) + .and_then(|request_json| torrent_runtime_info_json(&request_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_torrentStatusInfoJsonNative( @@ -1118,13 +1138,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_torre _class: JObject<'_>, status_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &status_json) - .and_then(|status_json| torrent_status_info_json(&status_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &status_json) + .and_then(|status_json| torrent_status_info_json(&status_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} string_fn!( Java_com_fluxa_app_core_rust_FluxaCoreNative_stableFeedPartNative, @@ -1152,18 +1172,18 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_trakt _class: JObject<'_>, api_key: JString<'_>, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let result = read_jstring(&mut env, &api_key) - .map(|api_key| trakt_has_client(&api_key)) - .unwrap_or(false); - if result { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let result = read_jstring(&mut env, &api_key) + .map(|api_key| trakt_has_client(&api_key)) + .unwrap_or(false); + if result { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_traktPlaybackUrlNative( @@ -1171,16 +1191,16 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_trakt _class: JObject<'_>, content_type: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = Some(trakt_playback_url( - read_jstring(&mut env, &content_type) - .filter(|value| !value.trim().is_empty()) - .as_deref(), - )); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = Some(trakt_playback_url( + read_jstring(&mut env, &content_type) + .filter(|value| !value.trim().is_empty()) + .as_deref(), + )); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_traktTokenExpiresAtNative( @@ -1189,11 +1209,11 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_trakt created_at_seconds: JLong, expires_in_seconds: JLong, ) -> JLong { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - trakt_token_expires_at(created_at_seconds, expires_in_seconds) - })) - .unwrap_or(0) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + trakt_token_expires_at(created_at_seconds, expires_in_seconds) + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_traktContentIdFromIdsNative( @@ -1201,13 +1221,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_trakt _class: JObject<'_>, ids_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &ids_json) - .and_then(|ids_json| trakt_content_id_from_ids_json(&ids_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &ids_json) + .and_then(|ids_json| trakt_content_id_from_ids_json(&ids_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_traktIdsFromContentIdJsonNative( @@ -1215,13 +1235,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_trakt _class: JObject<'_>, raw_id: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = - read_jstring(&mut env, &raw_id).and_then(|raw_id| trakt_ids_from_content_id_json(&raw_id)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &raw_id) + .and_then(|raw_id| trakt_ids_from_content_id_json(&raw_id)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_traktEpisodeLocatorJsonNative( @@ -1229,13 +1249,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_trakt _class: JObject<'_>, video_id: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &video_id) - .and_then(|video_id| trakt_episode_locator_json(&video_id)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &video_id) + .and_then(|video_id| trakt_episode_locator_json(&video_id)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_traktShowIdFromEpisodeIdNative( @@ -1243,13 +1263,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_trakt _class: JObject<'_>, video_id: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = - read_jstring(&mut env, &video_id).map(|video_id| trakt_show_id_from_episode_id(&video_id)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &video_id) + .map(|video_id| trakt_show_id_from_episode_id(&video_id)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_traktScrobbleMediaIdNative( @@ -1259,20 +1279,20 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_trakt video_id: JString<'_>, media_type: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &parent_id).and_then(|parent_id| { - Some(trakt_scrobble_media_id( - &parent_id, - read_jstring(&mut env, &video_id) - .filter(|value| !value.is_empty()) - .as_deref(), - &read_jstring(&mut env, &media_type)?, - )) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &parent_id).and_then(|parent_id| { + Some(trakt_scrobble_media_id( + &parent_id, + read_jstring(&mut env, &video_id) + .filter(|value| !value.is_empty()) + .as_deref(), + &read_jstring(&mut env, &media_type)?, + )) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} string_fn!( Java_com_fluxa_app_core_rust_FluxaCoreNative_traktOAuthErrorCodeNative, @@ -1286,14 +1306,14 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_trakt meta_json: JString<'_>, episodes_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &meta_json).and_then(|meta_json| { - trakt_history_request_json(&meta_json, &read_jstring(&mut env, &episodes_json)?) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &meta_json).and_then(|meta_json| { + trakt_history_request_json(&meta_json, &read_jstring(&mut env, &episodes_json)?) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_simklScrobbleBodyJsonNative( @@ -1306,21 +1326,21 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_simkl time_pos_sec: JDouble, duration_sec: JDouble, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &ids_json).and_then(|ids_json| { - simkl_scrobble_body_json( - &ids_json, - is_episode != 0, - season, - ep_number, - time_pos_sec, - duration_sec, - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &ids_json).and_then(|ids_json| { + simkl_scrobble_body_json( + &ids_json, + is_episode != 0, + season, + ep_number, + time_pos_sec, + duration_sec, + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_simklMatchEpisodeJsonNative( @@ -1329,14 +1349,14 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_simkl episodes_json: JString<'_>, target_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &episodes_json).and_then(|episodes_json| { - simkl_match_episode_json(&episodes_json, &read_jstring(&mut env, &target_json)?) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &episodes_json).and_then(|episodes_json| { + simkl_match_episode_json(&episodes_json, &read_jstring(&mut env, &target_json)?) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_simklWatchingToItemsJsonNative( @@ -1345,14 +1365,14 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_simkl shows_json: JString<'_>, movies_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &shows_json).and_then(|shows_json| { - simkl_watching_to_items_json(&shows_json, &read_jstring(&mut env, &movies_json)?) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &shows_json).and_then(|shows_json| { + simkl_watching_to_items_json(&shows_json, &read_jstring(&mut env, &movies_json)?) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_simklWatchlistToItemsJsonNative( @@ -1361,14 +1381,14 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_simkl shows_json: JString<'_>, movies_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &shows_json).and_then(|shows_json| { - simkl_watchlist_to_items_json(&shows_json, &read_jstring(&mut env, &movies_json)?) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &shows_json).and_then(|shows_json| { + simkl_watchlist_to_items_json(&shows_json, &read_jstring(&mut env, &movies_json)?) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_simklWatchedToIdsJsonNative( @@ -1377,14 +1397,14 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_simkl shows_json: JString<'_>, movies_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &shows_json).and_then(|shows_json| { - simkl_watched_to_ids_json(&shows_json, &read_jstring(&mut env, &movies_json)?) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &shows_json).and_then(|shows_json| { + simkl_watched_to_ids_json(&shows_json, &read_jstring(&mut env, &movies_json)?) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playbackProgressItemJsonNative( @@ -1395,19 +1415,19 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playb duration: JLong, now_utc: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &meta_json).and_then(|meta_json| { - playback_progress_item_json( - &meta_json, - time_offset, - duration, - &read_jstring(&mut env, &now_utc)?, - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &meta_json).and_then(|meta_json| { + playback_progress_item_json( + &meta_json, + time_offset, + duration, + &read_jstring(&mut env, &now_utc)?, + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_clearPlaybackProgressItemJsonNative( @@ -1415,13 +1435,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_clear _class: JObject<'_>, meta_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &meta_json) - .and_then(|meta_json| clear_playback_progress_item_json(&meta_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &meta_json) + .and_then(|meta_json| clear_playback_progress_item_json(&meta_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_watchedStateItemsJsonNative( @@ -1432,21 +1452,21 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_watch watched: JBoolean, watched_at: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &meta_json).and_then(|meta_json| { - watched_state_items_json( - &meta_json, - &read_jstring(&mut env, &episodes_json)?, - watched != 0, - read_jstring(&mut env, &watched_at) - .filter(|value| !value.is_empty()) - .as_deref(), - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &meta_json).and_then(|meta_json| { + watched_state_items_json( + &meta_json, + &read_jstring(&mut env, &episodes_json)?, + watched != 0, + read_jstring(&mut env, &watched_at) + .filter(|value| !value.is_empty()) + .as_deref(), + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_libraryContinueWatchingItemsJsonNative( @@ -1454,13 +1474,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_libra _class: JObject<'_>, items_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &items_json) - .and_then(|items_json| library_continue_watching_items_json(&items_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &items_json) + .and_then(|items_json| library_continue_watching_items_json(&items_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_filterHomeContinueWatchingJsonNative( @@ -1469,17 +1489,17 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_filte items_json: JString<'_>, trakt_watched_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &items_json).and_then(|items_json| { - filter_home_continue_watching_json( - &items_json, - &read_jstring(&mut env, &trakt_watched_json).unwrap_or_default(), - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &items_json).and_then(|items_json| { + filter_home_continue_watching_json( + &items_json, + &read_jstring(&mut env, &trakt_watched_json).unwrap_or_default(), + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_watchedVideoIdsJsonNative( @@ -1488,14 +1508,14 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_watch items_json: JString<'_>, imdb_id: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &items_json).and_then(|items_json| { - watched_video_ids_json(&items_json, &read_jstring(&mut env, &imdb_id)?) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &items_json).and_then(|items_json| { + watched_video_ids_json(&items_json, &read_jstring(&mut env, &imdb_id)?) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_parseExtraArgsJsonNative( @@ -1503,12 +1523,12 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_parse _class: JObject<'_>, extra: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &extra).and_then(|extra| parse_extra_args_json(&extra)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &extra).and_then(|extra| parse_extra_args_json(&extra)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_providerSearchTermsJsonNative( @@ -1516,13 +1536,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_provi _class: JObject<'_>, provider: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &provider) - .and_then(|provider| serde_json::to_string(&provider_search_terms(&provider)).ok()); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &provider) + .and_then(|provider| serde_json::to_string(&provider_search_terms(&provider)).ok()); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_effectiveMetadataFeedSelectionJsonNative( @@ -1531,17 +1551,17 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_effec selected_keys_json: JString<'_>, available_keys_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &selected_keys_json).and_then(|selected_keys_json| { - effective_metadata_feed_selection_json( - &selected_keys_json, - &read_jstring(&mut env, &available_keys_json)?, - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &selected_keys_json).and_then(|selected_keys_json| { + effective_metadata_feed_selection_json( + &selected_keys_json, + &read_jstring(&mut env, &available_keys_json)?, + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_toggleMetadataFeedJsonNative( @@ -1551,18 +1571,18 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_toggl available_keys_json: JString<'_>, key: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &selected_keys_json).and_then(|selected_keys_json| { - toggle_metadata_feed_json( - &selected_keys_json, - &read_jstring(&mut env, &available_keys_json)?, - &read_jstring(&mut env, &key)?, - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &selected_keys_json).and_then(|selected_keys_json| { + toggle_metadata_feed_json( + &selected_keys_json, + &read_jstring(&mut env, &available_keys_json)?, + &read_jstring(&mut env, &key)?, + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_toggleMetadataFeedLimitedJsonNative( @@ -1573,19 +1593,19 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_toggl key: JString<'_>, max_enabled: JInt, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &selected_keys_json).and_then(|selected_keys_json| { - toggle_metadata_feed_limited_json( - &selected_keys_json, - &read_jstring(&mut env, &available_keys_json)?, - &read_jstring(&mut env, &key)?, - max_enabled, - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &selected_keys_json).and_then(|selected_keys_json| { + toggle_metadata_feed_limited_json( + &selected_keys_json, + &read_jstring(&mut env, &available_keys_json)?, + &read_jstring(&mut env, &key)?, + max_enabled, + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_setMetadataFeedGroupEnabledJsonNative( @@ -1596,19 +1616,19 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_setMe group_keys_json: JString<'_>, enabled: JBoolean, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &selected_keys_json).and_then(|selected_keys_json| { - set_metadata_feed_group_enabled_json( - &selected_keys_json, - &read_jstring(&mut env, &available_keys_json)?, - &read_jstring(&mut env, &group_keys_json)?, - enabled != 0, - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &selected_keys_json).and_then(|selected_keys_json| { + set_metadata_feed_group_enabled_json( + &selected_keys_json, + &read_jstring(&mut env, &available_keys_json)?, + &read_jstring(&mut env, &group_keys_json)?, + enabled != 0, + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_orderedMetadataFeedKeysJsonNative( @@ -1617,14 +1637,14 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_order option_keys_json: JString<'_>, order_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &option_keys_json).and_then(|option_keys_json| { - ordered_metadata_feed_keys(&option_keys_json, &read_jstring(&mut env, &order_json)?) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &option_keys_json).and_then(|option_keys_json| { + ordered_metadata_feed_keys(&option_keys_json, &read_jstring(&mut env, &order_json)?) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_moveMetadataFeedOrderJsonNative( @@ -1635,19 +1655,19 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_moveM key: JString<'_>, delta: JInt, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &option_keys_json).and_then(|option_keys_json| { - move_metadata_feed_order_json( - &option_keys_json, - &read_jstring(&mut env, ¤t_order_json)?, - &read_jstring(&mut env, &key)?, - delta, - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &option_keys_json).and_then(|option_keys_json| { + move_metadata_feed_order_json( + &option_keys_json, + &read_jstring(&mut env, ¤t_order_json)?, + &read_jstring(&mut env, &key)?, + delta, + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_contentTraktKeyNative( @@ -1655,13 +1675,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_conte _class: JObject<'_>, meta_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = - read_jstring(&mut env, &meta_json).and_then(|meta_json| content_trakt_key(&meta_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = + read_jstring(&mut env, &meta_json).and_then(|meta_json| content_trakt_key(&meta_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_contentTraktKeysBatchJsonNative( @@ -1669,13 +1689,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_conte _class: JObject<'_>, metas_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &metas_json) - .and_then(|metas_json| content_trakt_keys_batch(&metas_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &metas_json) + .and_then(|metas_json| content_trakt_keys_batch(&metas_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_contentWatchedKeysBatchJsonNative( @@ -1683,13 +1703,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_conte _class: JObject<'_>, metas_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &metas_json) - .and_then(|metas_json| content_watched_keys_batch(&metas_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &metas_json) + .and_then(|metas_json| content_watched_keys_batch(&metas_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_contentMergeKeysJsonNative( @@ -1697,13 +1717,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_conte _class: JObject<'_>, meta_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &meta_json) - .and_then(|meta_json| content_keys_json(&meta_json, false)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &meta_json) + .and_then(|meta_json| content_keys_json(&meta_json, false)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_contentWatchedKeysJsonNative( @@ -1711,13 +1731,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_conte _class: JObject<'_>, meta_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &meta_json) - .and_then(|meta_json| content_keys_json(&meta_json, true)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &meta_json) + .and_then(|meta_json| content_keys_json(&meta_json, true)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_episodeFilenameCandidateNative( @@ -1726,14 +1746,14 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_episo stream_json: JString<'_>, video_id: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &stream_json).and_then(|stream_json| { - episode_filename_candidate(&stream_json, &read_jstring(&mut env, &video_id)?) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &stream_json).and_then(|stream_json| { + episode_filename_candidate(&stream_json, &read_jstring(&mut env, &video_id)?) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_streamDiscoveryCacheKeyNative( @@ -1741,13 +1761,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_strea _class: JObject<'_>, request_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &request_json) - .and_then(|request_json| stream_discovery_cache_key(&request_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &request_json) + .and_then(|request_json| stream_discovery_cache_key(&request_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_discoverCatalogCacheKeyNative( @@ -1755,13 +1775,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_disco _class: JObject<'_>, request_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &request_json) - .and_then(|request_json| discover_catalog_cache_key(&request_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &request_json) + .and_then(|request_json| discover_catalog_cache_key(&request_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_streamDiscoveryPlanJsonNative( @@ -1769,13 +1789,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_strea _class: JObject<'_>, request_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &request_json) - .and_then(|request_json| stream_discovery_plan_json(&request_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &request_json) + .and_then(|request_json| stream_discovery_plan_json(&request_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_streamDiscoveryExecutionPolicyJsonNative( @@ -1783,13 +1803,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_strea _class: JObject<'_>, request_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &request_json) - .and_then(|request_json| stream_discovery_execution_policy_json(&request_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &request_json) + .and_then(|request_json| stream_discovery_execution_policy_json(&request_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_streamDiscoveryCachePrefixNative( @@ -1799,18 +1819,18 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_strea id: JString<'_>, language: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &content_type).and_then(|content_type| { - Some(stream_discovery_cache_prefix( - &content_type, - &read_jstring(&mut env, &id)?, - &read_jstring(&mut env, &language)?, - )) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &content_type).and_then(|content_type| { + Some(stream_discovery_cache_prefix( + &content_type, + &read_jstring(&mut env, &id)?, + &read_jstring(&mut env, &language)?, + )) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_curateHomeItemsJsonNative( @@ -1818,13 +1838,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_curat _class: JObject<'_>, category_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &category_json) - .and_then(|category_json| curate_home_items_json(&category_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &category_json) + .and_then(|category_json| curate_home_items_json(&category_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_homeOverlapRatioNative( @@ -1833,15 +1853,15 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_homeO first_json: JString<'_>, second_json: JString<'_>, ) -> JFloat { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - read_jstring(&mut env, &first_json) - .and_then(|first_json| { - home_overlap_ratio_json(&first_json, &read_jstring(&mut env, &second_json)?) - }) - .unwrap_or(0.0) - })) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + read_jstring(&mut env, &first_json) + .and_then(|first_json| { + home_overlap_ratio_json(&first_json, &read_jstring(&mut env, &second_json)?) + }) .unwrap_or(0.0) - } + })) + .unwrap_or(0.0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_homePersonalizationScoreNative( @@ -1852,20 +1872,20 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_homeP preferred_types_json: JString<'_>, priority_labels_json: JString<'_>, ) -> JInt { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - read_jstring(&mut env, &category_json) - .and_then(|category_json| { - home_personalization_score_json( - &category_json, - &read_jstring(&mut env, &preferred_genres_json)?, - &read_jstring(&mut env, &preferred_types_json)?, - &read_jstring(&mut env, &priority_labels_json)?, - ) - }) - .unwrap_or(0) - })) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + read_jstring(&mut env, &category_json) + .and_then(|category_json| { + home_personalization_score_json( + &category_json, + &read_jstring(&mut env, &preferred_genres_json)?, + &read_jstring(&mut env, &preferred_types_json)?, + &read_jstring(&mut env, &priority_labels_json)?, + ) + }) .unwrap_or(0) - } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_prioritizeHomeRowsJsonNative( @@ -1877,20 +1897,20 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_prior preferred_types_json: JString<'_>, priority_labels_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &categories_json).and_then(|categories_json| { - home_prioritize_rows_json( - &categories_json, - &read_jstring(&mut env, &preferred_order_labels_json)?, - &read_jstring(&mut env, &preferred_genres_json)?, - &read_jstring(&mut env, &preferred_types_json)?, - &read_jstring(&mut env, &priority_labels_json)?, - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &categories_json).and_then(|categories_json| { + home_prioritize_rows_json( + &categories_json, + &read_jstring(&mut env, &preferred_order_labels_json)?, + &read_jstring(&mut env, &preferred_genres_json)?, + &read_jstring(&mut env, &preferred_types_json)?, + &read_jstring(&mut env, &priority_labels_json)?, + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_optimizeHomeRowsJsonNative( @@ -1898,13 +1918,13 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_optim _class: JObject<'_>, request_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &request_json) - .and_then(|request_json| optimize_home_rows_json(&request_json)); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &request_json) + .and_then(|request_json| optimize_home_rows_json(&request_json)); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playerProgressPercentNative( @@ -1913,11 +1933,11 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playe position_ms: JLong, duration_ms: JLong, ) -> f32 { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - progress_percent(position_ms, duration_ms) - })) - .unwrap_or(0.0) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + progress_percent(position_ms, duration_ms) + })) + .unwrap_or(0.0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playerShouldSendScrobbleStartNative( @@ -1928,21 +1948,21 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playe has_scrobbled_start: JBoolean, progress: f32, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let token = read_jstring(&mut env, &token); - if should_send_start( - token.as_deref(), - is_playing != 0, - has_scrobbled_start != 0, - progress, - ) { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let token = read_jstring(&mut env, &token); + if should_send_start( + token.as_deref(), + is_playing != 0, + has_scrobbled_start != 0, + progress, + ) { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playerShouldMarkScrobbleStoppedNative( @@ -1951,15 +1971,15 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playe has_scrobbled_stop: JBoolean, progress: f32, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - if should_mark_stopped(has_scrobbled_stop != 0, progress) { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + if should_mark_stopped(has_scrobbled_stop != 0, progress) { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playerShouldQueueScrobblePauseNative( @@ -1970,21 +1990,21 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playe has_scrobbled_start: JBoolean, has_scrobbled_stop: JBoolean, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let token = read_jstring(&mut env, &token); - if should_queue_pause( - token.as_deref(), - was_play_when_ready != 0, - has_scrobbled_start != 0, - has_scrobbled_stop != 0, - ) { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let token = read_jstring(&mut env, &token); + if should_queue_pause( + token.as_deref(), + was_play_when_ready != 0, + has_scrobbled_start != 0, + has_scrobbled_stop != 0, + ) { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playerShouldEnqueueDurableScrobbleNative( @@ -1994,17 +2014,17 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playe token: JString<'_>, progress: f32, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let action = read_jstring(&mut env, &action).unwrap_or_default(); - let token = read_jstring(&mut env, &token); - if should_enqueue_durable(&action, token.as_deref(), progress) { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let action = read_jstring(&mut env, &action).unwrap_or_default(); + let token = read_jstring(&mut env, &token); + if should_enqueue_durable(&action, token.as_deref(), progress) { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playerShouldSavePeriodicProgressNative( @@ -2014,15 +2034,15 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playe now_ms: JLong, last_saved_at_ms: JLong, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - if should_save_periodic_progress(is_playing != 0, now_ms, last_saved_at_ms) { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + if should_save_periodic_progress(is_playing != 0, now_ms, last_saved_at_ms) { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playerShouldSaveOnDisposeNative( @@ -2030,15 +2050,15 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playe _class: JObject<'_>, position_ms: JLong, ) -> JBoolean { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - if should_save_on_dispose(position_ms) { - 1 - } else { - 0 - } - })) - .unwrap_or(0) + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + if should_save_on_dispose(position_ms) { + 1 + } else { + 0 } + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_safePlayerBufferCacheMbNative( @@ -2047,11 +2067,11 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_safeP value: JInt, has_value: JBoolean, ) -> JInt { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - safe_player_buffer_cache_mb(if has_value != 0 { Some(value) } else { None }) - })) - .unwrap_or(0) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + safe_player_buffer_cache_mb(if has_value != 0 { Some(value) } else { None }) + })) + .unwrap_or(0) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_safeDolbyVisionFallbackModeNative( @@ -2063,26 +2083,26 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_safeD legacy_dv7_to_dv8_fallback: JBoolean, has_legacy_dv7_to_dv8_fallback: JBoolean, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let mode = read_jstring(&mut env, &mode); - let output = safe_dolby_vision_fallback_mode( - mode.as_deref().filter(|value| !value.is_empty()), - if has_legacy_dv7_fallback != 0 { - Some(legacy_dv7_fallback != 0) - } else { - None - }, - if has_legacy_dv7_to_dv8_fallback != 0 { - Some(legacy_dv7_to_dv8_fallback != 0) - } else { - None - }, - ) - .to_string(); - write_jstring(&mut env, Some(output)) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let mode = read_jstring(&mut env, &mode); + let output = safe_dolby_vision_fallback_mode( + mode.as_deref().filter(|value| !value.is_empty()), + if has_legacy_dv7_fallback != 0 { + Some(legacy_dv7_fallback != 0) + } else { + None + }, + if has_legacy_dv7_to_dv8_fallback != 0 { + Some(legacy_dv7_to_dv8_fallback != 0) + } else { + None + }, + ) + .to_string(); + write_jstring(&mut env, Some(output)) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_safeStreamSourceSelectionModeNative( @@ -2090,15 +2110,15 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_safeS _class: JObject<'_>, mode: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let mode = read_jstring(&mut env, &mode); - let output = - safe_stream_source_selection_mode(mode.as_deref().filter(|value| !value.is_empty())) - .to_string(); - write_jstring(&mut env, Some(output)) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let mode = read_jstring(&mut env, &mode); + let output = + safe_stream_source_selection_mode(mode.as_deref().filter(|value| !value.is_empty())) + .to_string(); + write_jstring(&mut env, Some(output)) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playerFlowDispatchJsonNative( @@ -2107,14 +2127,14 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_playe state_json: JString<'_>, action_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &state_json).and_then(|state_json| { - player_flow_dispatch_json(&state_json, &read_jstring(&mut env, &action_json)?) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &state_json).and_then(|state_json| { + player_flow_dispatch_json(&state_json, &read_jstring(&mut env, &action_json)?) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} string_fn!( Java_com_fluxa_app_core_rust_FluxaCoreNative_calendarContentPlanJsonNative, @@ -2232,14 +2252,14 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_build enriched_json: JString<'_>, candidates_json: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &enriched_json).and_then(|enriched_json| { - build_billboard_pool_json(&enriched_json, &read_jstring(&mut env, &candidates_json)?) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &enriched_json).and_then(|enriched_json| { + build_billboard_pool_json(&enriched_json, &read_jstring(&mut env, &candidates_json)?) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} #[no_mangle] pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_normalizeHomeCatalogItemsJsonNative( @@ -2250,18 +2270,18 @@ pub unsafe extern "system" fn Java_com_fluxa_app_core_rust_FluxaCoreNative_norma genre: JString<'_>, today_iso: JString<'_>, ) -> JStringReturn { - std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - let output = read_jstring(&mut env, &items_json).and_then(|items_json| { - normalize_home_catalog_items_json( - &items_json, - &read_jstring(&mut env, &catalog_id)?, - read_jstring(&mut env, &genre) - .filter(|v| !v.is_empty()) - .as_deref(), - &read_jstring(&mut env, &today_iso)?, - ) - }); - write_jstring(&mut env, output) - })) - .unwrap_or(ptr::null_mut()) - } + std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + let output = read_jstring(&mut env, &items_json).and_then(|items_json| { + normalize_home_catalog_items_json( + &items_json, + &read_jstring(&mut env, &catalog_id)?, + read_jstring(&mut env, &genre) + .filter(|v| !v.is_empty()) + .as_deref(), + &read_jstring(&mut env, &today_iso)?, + ) + }); + write_jstring(&mut env, output) + })) + .unwrap_or(ptr::null_mut()) +} diff --git a/src/bindings/uniffi.rs b/src/bindings/uniffi.rs index f4a2083..26c65e0 100644 --- a/src/bindings/uniffi.rs +++ b/src/bindings/uniffi.rs @@ -19,12 +19,17 @@ pub fn core_invoke(method: String, args_json: String) -> String { #[uniffi::export] pub fn create_headless_engine_json(initial_json: String) -> i64 { - guard(0, || headless_engine::create_headless_engine(&initial_json) as i64) + guard(0, || { + headless_engine::create_headless_engine(&initial_json) as i64 + }) } #[uniffi::export] pub fn destroy_headless_engine_json(handle: i64) -> bool { - handle > 0 && guard(false, || headless_engine::destroy_headless_engine(handle as u64)) + handle > 0 + && guard(false, || { + headless_engine::destroy_headless_engine(handle as u64) + }) } #[uniffi::export] @@ -43,7 +48,8 @@ pub fn headless_engine_dispatch_json(handle: i64, action_json: String) -> String return String::new(); } guard(String::new(), || { - headless_engine::headless_engine_dispatch_json(handle as u64, &action_json).unwrap_or_default() + headless_engine::headless_engine_dispatch_json(handle as u64, &action_json) + .unwrap_or_default() }) } @@ -60,7 +66,9 @@ pub fn headless_engine_complete_effect_json(handle: i64, result_json: String) -> #[uniffi::export] pub fn core_capabilities_json(portable: bool) -> String { - guard(String::new(), || core_contract::core_capabilities_json(portable)) + guard(String::new(), || { + core_contract::core_capabilities_json(portable) + }) } #[uniffi::export] diff --git a/src/calendar_plan.rs b/src/calendar_plan.rs index 9682232..ac49644 100644 --- a/src/calendar_plan.rs +++ b/src/calendar_plan.rs @@ -146,7 +146,7 @@ pub(crate) fn calendar_season_candidates_json(request_json: &str) -> Option = focused .into_iter() - .chain(full.into_iter()) + .chain(full) .collect::>() .into_iter() .collect(); @@ -217,14 +217,12 @@ pub(crate) fn calendar_notification_content_json(request_json: &str) -> Option format!("{}:season:{}:episode:{}", item.title, s, e), - _ => { - [Some(item.title.as_str()), item.subtitle.as_deref()] - .into_iter() - .flatten() - .filter(|s| !s.is_empty()) - .collect::>() - .join(" - ") - } + _ => [Some(item.title.as_str()), item.subtitle.as_deref()] + .into_iter() + .flatten() + .filter(|s| !s.is_empty()) + .collect::>() + .join(" - "), }; items_out.push(json!({ "key": key, @@ -260,23 +258,43 @@ pub(crate) fn calendar_items_from_meta_json(meta_json: &str, month_prefix: &str) let meta: Value = serde_json::from_str(meta_json).ok()?; let meta_id = meta.get("id").and_then(Value::as_str).unwrap_or(""); let meta_name = meta.get("name").and_then(Value::as_str).unwrap_or(""); - let meta_poster = meta.get("poster").and_then(Value::as_str) + let meta_poster = meta + .get("poster") + .and_then(Value::as_str) .or_else(|| meta.get("background").and_then(Value::as_str)); let videos = meta.get("videos").and_then(Value::as_array)?; let mut items: Vec = Vec::new(); for video in videos { let released = video.get("released").and_then(Value::as_str).unwrap_or(""); - let date_iso = match released.get(..10) { Some(d) => d, None => continue }; - if !month_prefix.is_empty() && !date_iso.starts_with(month_prefix) { continue; } + let date_iso = match released.get(..10) { + Some(d) => d, + None => continue, + }; + if !month_prefix.is_empty() && !date_iso.starts_with(month_prefix) { + continue; + } let season = video.get("season").and_then(Value::as_i64); - let episode = video.get("episode").or_else(|| video.get("number")).and_then(Value::as_i64); + let episode = video + .get("episode") + .or_else(|| video.get("number")) + .and_then(Value::as_i64); let episode_code = match (season, episode) { (Some(s), Some(e)) => Some(format!("S{s}:E{e}")), _ => None, }; - let video_name = video.get("name").or_else(|| video.get("title")).and_then(Value::as_str); - let subtitle = [episode_code.as_deref(), video_name].into_iter().flatten().collect::>().join(" "); - let poster = video.get("thumbnail").and_then(Value::as_str).or(meta_poster); + let video_name = video + .get("name") + .or_else(|| video.get("title")) + .and_then(Value::as_str); + let subtitle = [episode_code.as_deref(), video_name] + .into_iter() + .flatten() + .collect::>() + .join(" "); + let poster = video + .get("thumbnail") + .and_then(Value::as_str) + .or(meta_poster); let video_id = video.get("id").and_then(Value::as_str).unwrap_or(""); let key = format!("{meta_id}:{video_id}:{date_iso}"); items.push(json!({ @@ -313,9 +331,16 @@ pub(crate) fn next_unaired_episode_json(videos_json: &str, now_ms: i64) -> Optio } pub(crate) fn calendar_item_matches_month_json(item_json: &str, month_prefix: &str) -> bool { - if month_prefix.is_empty() { return true; } - serde_json::from_str::(item_json).ok() - .and_then(|v| v.get("dateIso").and_then(Value::as_str).map(|d| d.starts_with(month_prefix))) + if month_prefix.is_empty() { + return true; + } + serde_json::from_str::(item_json) + .ok() + .and_then(|v| { + v.get("dateIso") + .and_then(Value::as_str) + .map(|d| d.starts_with(month_prefix)) + }) .unwrap_or(false) } @@ -347,10 +372,8 @@ mod tests { #[test] fn season_candidates_covers_watched_next_and_last_season() { let result: Value = serde_json::from_str( - &calendar_season_candidates_json( - r#"{"seasonsCount":5,"lastVideoId":"tt1:2:3"}"#, - ) - .unwrap(), + &calendar_season_candidates_json(r#"{"seasonsCount":5,"lastVideoId":"tt1:2:3"}"#) + .unwrap(), ) .unwrap(); let seasons: Vec = result @@ -396,31 +419,35 @@ mod tests { "notificationsEnabled": true, "alertNewEpisodes": true }); - let result: Value = - serde_json::from_str(&calendar_notification_content_json(&request.to_string()).unwrap()) - .unwrap(); + let result: Value = serde_json::from_str( + &calendar_notification_content_json(&request.to_string()).unwrap(), + ) + .unwrap(); assert_eq!(result["items"].as_array().unwrap().len(), 0); } #[test] fn next_unaired_episode_picks_earliest_future_date() { - let now_ms = chrono::DateTime::parse_from_rfc3339("2026-06-16T00:00:00Z").unwrap().timestamp_millis(); + let now_ms = chrono::DateTime::parse_from_rfc3339("2026-06-16T00:00:00Z") + .unwrap() + .timestamp_millis(); let videos = json!([ {"id": "v1", "released": "2026-06-01T00:00:00Z"}, {"id": "v2", "released": "2026-07-10T00:00:00Z"}, {"id": "v3", "released": "2026-06-20T00:00:00Z"}, {"id": "v4"} ]); - let result: Value = serde_json::from_str( - &next_unaired_episode_json(&videos.to_string(), now_ms).unwrap(), - ) - .unwrap(); + let result: Value = + serde_json::from_str(&next_unaired_episode_json(&videos.to_string(), now_ms).unwrap()) + .unwrap(); assert_eq!(result["id"], "v3"); } #[test] fn next_unaired_episode_returns_none_when_nothing_upcoming() { - let now_ms = chrono::DateTime::parse_from_rfc3339("2026-06-16T00:00:00Z").unwrap().timestamp_millis(); + let now_ms = chrono::DateTime::parse_from_rfc3339("2026-06-16T00:00:00Z") + .unwrap() + .timestamp_millis(); let videos = json!([ {"id": "v1", "released": "2026-06-01T00:00:00Z"}, {"id": "v2"} diff --git a/src/cast_protocol.rs b/src/cast_protocol.rs index 97fbb2a..f475ddc 100644 --- a/src/cast_protocol.rs +++ b/src/cast_protocol.rs @@ -5,7 +5,9 @@ pub(crate) const RENDERING_CONTROL_URN: &str = "urn:schemas-upnp-org:service:Ren pub(crate) fn validate_stream_url(url: &str) -> bool { let trimmed = url.trim(); - let Some(scheme_end) = trimmed.find("://") else { return false }; + let Some(scheme_end) = trimmed.find("://") else { + return false; + }; let scheme = trimmed[..scheme_end].to_ascii_lowercase(); if scheme != "http" && scheme != "https" { return false; @@ -14,7 +16,10 @@ pub(crate) fn validate_stream_url(url: &str) -> bool { } pub(crate) fn xml_escape(value: &str) -> String { - value.replace('&', "&").replace('<', "<").replace('>', ">") + value + .replace('&', "&") + .replace('<', "<") + .replace('>', ">") } fn extract_tag(xml: &str, tag: &str) -> Option { @@ -70,7 +75,12 @@ pub(crate) fn soap_action_body(urn: &str, action: &str, args: &str) -> String { fn format_didl_metadata(title: &str, subtitle_url: Option<&str>) -> String { let subtitle_res = subtitle_url - .map(|url| format!("{}", xml_escape(url))) + .map(|url| { + format!( + "{}", + xml_escape(url) + ) + }) .unwrap_or_default(); let didl = format!( "\ @@ -80,7 +90,11 @@ fn format_didl_metadata(title: &str, subtitle_url: Option<&str>) -> String { xml_escape(&didl) } -pub(crate) fn dlna_set_av_transport_args(media_url: &str, title: &str, subtitle_url: Option<&str>) -> Option { +pub(crate) fn dlna_set_av_transport_args( + media_url: &str, + title: &str, + subtitle_url: Option<&str>, +) -> Option { if !validate_stream_url(media_url) { return None; } @@ -93,11 +107,19 @@ pub(crate) fn dlna_set_av_transport_args(media_url: &str, title: &str, subtitle_ pub(crate) fn format_hms(total_secs: f64) -> String { let total = total_secs.max(0.0) as u64; - format!("{:02}:{:02}:{:02}", total / 3600, (total % 3600) / 60, total % 60) + format!( + "{:02}:{:02}:{:02}", + total / 3600, + (total % 3600) / 60, + total % 60 + ) } pub(crate) fn dlna_seek_args(position_secs: f64) -> String { - format!("0ABS_TIME{}", format_hms(position_secs)) + format!( + "0ABS_TIME{}", + format_hms(position_secs) + ) } pub(crate) fn dlna_set_volume_args(level: f64) -> String { @@ -113,7 +135,11 @@ pub(crate) fn resolve_loopback_url(stream_url: &str, lan_ip: &str) -> String { } pub(crate) fn guess_cast_content_type(media_url: &str) -> &'static str { - let path = media_url.split(['?', '#']).next().unwrap_or(media_url).to_ascii_lowercase(); + let path = media_url + .split(['?', '#']) + .next() + .unwrap_or(media_url) + .to_ascii_lowercase(); if path.ends_with(".m3u8") { "application/x-mpegurl" } else if path.ends_with(".mkv") { @@ -147,7 +173,12 @@ fn write_string_field(buf: &mut Vec, field: u32, value: &str) { buf.extend_from_slice(value.as_bytes()); } -pub(crate) fn encode_cast_message(source_id: &str, destination_id: &str, namespace: &str, payload_utf8: &str) -> Vec { +pub(crate) fn encode_cast_message( + source_id: &str, + destination_id: &str, + namespace: &str, + payload_utf8: &str, +) -> Vec { let mut buf = Vec::new(); write_tag(&mut buf, 1, 0); write_varint(&mut buf, 0); @@ -206,14 +237,19 @@ pub(crate) fn decode_cast_message(buf: &[u8]) -> Option { _ => return None, } } - Some(DecodedCastMessage { namespace, payload_utf8 }) + Some(DecodedCastMessage { + namespace, + payload_utf8, + }) } fn roku_url_encode(value: &str) -> String { let mut out = String::new(); for byte in value.bytes() { match byte { - b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'_' | b'.' | b'~' => out.push(byte as char), + b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'_' | b'.' | b'~' => { + out.push(byte as char) + } _ => out.push_str(&format!("%{byte:02X}")), } } @@ -224,7 +260,11 @@ pub(crate) fn roku_device_name(xml: &str) -> Option { extract_tag(xml, "friendly-device-name") } -pub(crate) fn roku_launch_url(host: &str, media_url: &str, subtitle_url: Option<&str>) -> Option { +pub(crate) fn roku_launch_url( + host: &str, + media_url: &str, + subtitle_url: Option<&str>, +) -> Option { if !validate_stream_url(media_url) { return None; } @@ -234,7 +274,10 @@ pub(crate) fn roku_launch_url(host: &str, media_url: &str, subtitle_url: Option< } } const ROKU_MEDIA_PLAYER_APP_ID: &str = "2213"; - let mut url = format!("http://{host}:8060/launch/{ROKU_MEDIA_PLAYER_APP_ID}?t=v&u={}", roku_url_encode(media_url)); + let mut url = format!( + "http://{host}:8060/launch/{ROKU_MEDIA_PLAYER_APP_ID}?t=v&u={}", + roku_url_encode(media_url) + ); if let Some(sub) = subtitle_url { url.push_str(&format!("&k={}", roku_url_encode(sub))); } @@ -253,7 +296,9 @@ pub(crate) fn airplay_play_body(media_url: &str) -> Option { if !validate_stream_url(media_url) { return None; } - Some(format!("Content-Location: {media_url}\nStart-Position: 0\n")) + Some(format!( + "Content-Location: {media_url}\nStart-Position: 0\n" + )) } #[cfg(test)] @@ -275,7 +320,8 @@ mod tests { #[test] fn didl_title_with_markup_does_not_break_out_of_the_item_tag() { - let args = dlna_set_av_transport_args("http://192.168.1.5/a.mkv", "