From fb3aec03f48ef89c1eb28a225e30df8d92cea882 Mon Sep 17 00:00:00 2001 From: vin Date: Sat, 15 Nov 2025 19:10:20 -0500 Subject: update dependencies --- Cargo.lock | 622 +++++++++++++++++++++++++++++++++++++-------------------- Cargo.toml | 11 +- pyproject.toml | 4 +- src/lib.rs | 251 ++++++++--------------- 4 files changed, 502 insertions(+), 386 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 999805e..47d1579 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,275 +1,372 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "adblock" -version = "0.5.6" +version = "0.7.0" +dependencies = [ + "adblock 0.11.1", + "pyo3", +] + +[[package]] +name = "adblock" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27785ef5b89bc88fd2def3e1ecfefdf5ec1583795b916667afd15b13058f8315" +checksum = "5d6a431e8b3c95fa49574ed925b85fe34978f5917168c8ce4dcf729af861fc87" dependencies = [ "addr", "base64", "bitflags", - "flate2", + "flatbuffers", "idna", "itertools", + "memchr", "once_cell", "percent-encoding", + "precomputed-hash", "regex", - "rmp-serde 0.13.7", - "rmp-serde 0.15.5", + "rmp-serde", + "rustc-hash", "seahash", "serde", - "twoway", + "serde_json", + "thiserror", "url", ] -[[package]] -name = "adblock" -version = "0.6.0" -dependencies = [ - "adblock 0.5.6", - "pyo3", -] - [[package]] name = "addr" -version = "0.14.0" +version = "0.15.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54ccac949a2afafdfc889e15c753bbc6ee8783e026bbe3d057b00b13907db70" +checksum = "a93b8a41dbe230ad5087cc721f8d41611de654542180586b315d9f4cf6b72bef" dependencies = [ "psl", "psl-types", ] -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "aho-corasick" -version = "0.7.18" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ "memchr", ] [[package]] name = "autocfg" -version = "1.1.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "base64" -version = "0.13.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" -version = "1.3.2" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" +dependencies = [ + "serde_core", +] [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] -name = "crc32fast" -version = "1.3.2" +name = "displaydoc" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ - "cfg-if", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "either" -version = "1.7.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] -name = "flate2" -version = "1.0.24" +name = "flatbuffers" +version = "25.9.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" +checksum = "09b6620799e7340ebd9968d2e0708eb82cf1971e9a16821e2091b6d6e475eed5" dependencies = [ - "crc32fast", - "miniz_oxide", + "bitflags", + "rustc_version", ] [[package]] name = "form_urlencoded" -version = "1.0.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" dependencies = [ - "matches", "percent-encoding", ] [[package]] -name = "idna" -version = "0.2.3" +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "icu_collections" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", ] [[package]] -name = "indoc" -version = "1.0.6" +name = "icu_locale_core" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05a0bd019339e5d968b37855180087b7b9d512c5046fbd244cf8c95687927d6e" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] [[package]] -name = "itertools" -version = "0.10.3" +name = "icu_normalizer" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" dependencies = [ - "either", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", ] [[package]] -name = "libc" -version = "0.2.126" +name = "icu_normalizer_data" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" [[package]] -name = "lock_api" -version = "0.4.7" +name = "icu_properties" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +checksum = "e93fcd3157766c0c8da2f8cff6ce651a31f0810eaa1c51ec363ef790bbb5fb99" dependencies = [ - "autocfg", - "scopeguard", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", ] [[package]] -name = "matches" -version = "0.1.9" +name = "icu_properties_data" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" +checksum = "02845b3647bb045f1100ecd6480ff52f34c35f82d9880e029d329c21d1054899" [[package]] -name = "memchr" -version = "2.5.0" +name = "icu_provider" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] [[package]] -name = "miniz_oxide" -version = "0.5.3" +name = "idna" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" dependencies = [ - "adler", + "idna_adapter", + "smallvec", + "utf8_iter", ] [[package]] -name = "num-traits" -version = "0.2.15" +name = "idna_adapter" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" dependencies = [ - "autocfg", + "icu_normalizer", + "icu_properties", ] [[package]] -name = "once_cell" -version = "1.13.0" +name = "indoc" +version = "2.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" +checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706" +dependencies = [ + "rustversion", +] [[package]] -name = "parking_lot" -version = "0.12.1" +name = "itertools" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ - "lock_api", - "parking_lot_core", + "either", ] [[package]] -name = "parking_lot_core" -version = "0.9.3" +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "libc" +version = "0.2.177" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" + +[[package]] +name = "litemap" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] +name = "memchr" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-sys", + "autocfg", ] +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + [[package]] name = "paste" -version = "1.0.7" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "percent-encoding" -version = "2.1.0" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + +[[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "proc-macro2" -version = "1.0.40" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" dependencies = [ "unicode-ident", ] [[package]] name = "psl" -version = "2.0.90" +version = "2.1.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9c7d362659b525758d09e2a3ae965e371b347605e5fb2bc5bec5c2a1ecf41b" +checksum = "96f36d5dda1aa6585ce2a74b0ae1a85e530db47b0186cd06b63f09dbd8035fc6" dependencies = [ "psl-types", ] [[package]] name = "psl-types" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8eda7c62d9ecaafdf8b62374c006de0adf61666ae96a96ba74a37134aa4e470" +checksum = "33cb294fe86a74cbcf50d4445b37da762029549ebeea341421c7c70370f86cac" [[package]] name = "pyo3" -version = "0.16.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e6302e85060011447471887705bb7838f14aba43fcb06957d823739a496b3dc" +checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884" dependencies = [ "cfg-if", "indoc", "libc", - "parking_lot", + "memoffset", + "once_cell", + "portable-atomic", "pyo3-build-config", "pyo3-ffi", "pyo3-macros", @@ -278,9 +375,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.16.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b65b546c35d8a3b1b2f0ddbac7c6a569d759f357f2b9df884f5d6b719152c8" +checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38" dependencies = [ "once_cell", "target-lexicon", @@ -288,9 +385,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.16.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c275a07127c1aca33031a563e384ffdd485aee34ef131116fcd58e3430d1742b" +checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636" dependencies = [ "libc", "pyo3-build-config", @@ -298,9 +395,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.16.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284fc4485bfbcc9850a6d661d627783f18d19c2ab55880b021671c4ba83e90f7" +checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -310,38 +407,43 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.16.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53bda0f58f73f5c5429693c96ed57f7abdb38fdfc28ae06da4101a257adb7faf" +checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe" dependencies = [ + "heck", "proc-macro2", + "pyo3-build-config", "quote", "syn", ] [[package]] name = "quote" -version = "1.0.20" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" +checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" dependencies = [ "proc-macro2", ] [[package]] -name = "redox_syscall" -version = "0.2.13" +name = "regex" +version = "1.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" dependencies = [ - "bitflags", + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", ] [[package]] -name = "regex" -version = "1.6.0" +name = "regex-automata" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" dependencies = [ "aho-corasick", "memchr", @@ -350,15 +452,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" [[package]] name = "rmp" -version = "0.8.11" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44519172358fd6d58656c86ab8e7fbc9e1490c3e8f14d35ed78ca0dd07403c9f" +checksum = "228ed7c16fa39782c3b3468e974aec2795e9089153cd08ee2e9aefb3613334c4" dependencies = [ "byteorder", "num-traits", @@ -367,9 +469,9 @@ dependencies = [ [[package]] name = "rmp-serde" -version = "0.13.7" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "011e1d58446e9fa3af7cdc1fb91295b10621d3ac4cb3a85cc86385ee9ca50cd3" +checksum = "723ecff9ad04f4ad92fe1c8ca6c20d2196d9286e9c60727c4cb5511629260e9d" dependencies = [ "byteorder", "rmp", @@ -377,180 +479,266 @@ dependencies = [ ] [[package]] -name = "rmp-serde" -version = "0.15.5" +name = "rustc-hash" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723ecff9ad04f4ad92fe1c8ca6c20d2196d9286e9c60727c4cb5511629260e9d" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ - "byteorder", - "rmp", - "serde", + "semver", ] [[package]] -name = "scopeguard" -version = "1.1.0" +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "seahash" -version = "3.0.7" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58f57ca1d128a43733fd71d583e837b1f22239a37ebea09cde11d8d9a9080f47" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" [[package]] name = "serde" -version = "1.0.139" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0171ebb889e45aa68b44aee0859b3eede84c6f5f5c228e6f140c0b2a0a46cad6" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.139" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1d3230c1de7932af58ad8ffbe1d784bd55efd5a9d84ac24f69c72d83543dfb" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "serde_json" +version = "1.0.145" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", + "serde_core", +] + [[package]] name = "smallvec" -version = "1.9.0" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "syn" -version = "1.0.98" +version = "2.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" +checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[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 = "target-lexicon" -version = "0.12.4" +version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02424087780c9b71cc96799eaeddff35af2bc513278cda5c99fc1f5d026d3c1" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] -name = "tinyvec" -version = "1.6.0" +name = "thiserror" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "tinyvec_macros", + "thiserror-impl", ] [[package]] -name = "tinyvec_macros" -version = "0.1.0" +name = "thiserror-impl" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] -name = "twoway" -version = "0.2.2" +name = "tinystr" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c57ffb460d7c24cd6eda43694110189030a3d1dfe418416d9468fd1c1d290b47" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" dependencies = [ - "memchr", - "unchecked-index", + "displaydoc", + "zerovec", ] [[package]] -name = "unchecked-index" -version = "0.2.2" +name = "unicode-ident" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeba86d422ce181a719445e51872fa30f1f7413b62becb52e95ec91aa262d85c" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] -name = "unicode-bidi" -version = "0.3.8" +name = "unindent" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3" [[package]] -name = "unicode-ident" -version = "1.0.2" +name = "url" +version = "2.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" +checksum = "08bc136a29a3d1758e07a9cca267be308aeebf5cfd5a10f3f67ab2097683ef5b" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] [[package]] -name = "unicode-normalization" -version = "0.1.21" +name = "utf8_iter" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6" -dependencies = [ - "tinyvec", -] +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] -name = "unindent" -version = "0.1.9" +name = "writeable" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52fee519a3e570f7df377a06a1a7775cdbfb7aa460be7e08de2b1f0e69973a44" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" [[package]] -name = "url" -version = "2.2.2" +name = "yoke" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" dependencies = [ - "form_urlencoded", - "idna", - "matches", - "percent-encoding", + "stable_deref_trait", + "yoke-derive", + "zerofrom", ] [[package]] -name = "windows-sys" -version = "0.36.1" +name = "yoke-derive" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "proc-macro2", + "quote", + "syn", + "synstructure", ] [[package]] -name = "windows_aarch64_msvc" -version = "0.36.1" +name = "zerofrom" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] [[package]] -name = "windows_i686_gnu" -version = "0.36.1" +name = "zerofrom-derive" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] [[package]] -name = "windows_i686_msvc" -version = "0.36.1" +name = "zerotrie" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] [[package]] -name = "windows_x86_64_gnu" -version = "0.36.1" +name = "zerovec" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] [[package]] -name = "windows_x86_64_msvc" -version = "0.36.1" +name = "zerovec-derive" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index dc2f5f9..e90e35f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] publish = false name = "adblock" -version = "0.6.0" -edition = "2018" +version = "0.7.0" +edition = "2021" authors = ["Árni Dagur "] license = "MIT OR Apache-2.0" readme = "README.md" @@ -13,9 +13,12 @@ repository = "https://github.com/ArniDagur/python-adblock" debug = true [dependencies] -adblock = { version = "=0.5.6", default-features = false, features = ["full-regex-handling", "embedded-domain-resolver"] } -pyo3 = { version = "0.16", features = ["abi3-py37", "extension-module"] } +adblock = { version = "0.11.1", default-features = false, features = ["full-regex-handling", "embedded-domain-resolver"] } +pyo3 = { version = "0.22", features = ["abi3-py38", "extension-module"] } [lib] name = "adblock" crate-type = ["rlib", "cdylib"] + +[[tool.maturin.python-packages]] +name = "adblock" diff --git a/pyproject.toml b/pyproject.toml index 564e100..24448ce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "adblock" -version = "0.6.0" +version = "0.7.0" description = "Brave's adblocking in Python" requires-python = ">=3.7" authors = [{ name = "Árni Dagur", email = "arni@dagur.eu" }] @@ -13,7 +13,7 @@ classifiers = [ [tool.poetry] name = "adblock" -version = "0.6.0" +version = "0.7.0" description = "Brave's adblocking in Python" authors = ["Árni Dagur "] diff --git a/src/lib.rs b/src/lib.rs index e8797d2..7aa2ade 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,21 +12,18 @@ )] use adblock::blocker::BlockerResult as RustBlockerResult; -use adblock::blocker::{BlockerError as RustBlockerError, Redirection}; use adblock::cosmetic_filter_cache::UrlSpecificResources as RustUrlSpecificResources; use adblock::engine::Engine as RustEngine; use adblock::lists::FilterSet as RustFilterSet; use adblock::lists::{FilterFormat, ParseOptions, RuleTypes}; +use adblock::request::Request; use pyo3::create_exception; use pyo3::exceptions::PyException; use pyo3::prelude::*; use pyo3::types::PyBytes; use pyo3::PyErr; -use adblock::resources::{ - AddResourceError as RustAddResourceError, MimeType, Resource, ResourceType, -}; -use std::collections::HashMap; +use adblock::resources::{MimeType, PermissionMask, Resource, ResourceType}; use std::collections::HashSet; use std::error::Error; use std::fmt::{self, Display}; @@ -35,39 +32,39 @@ use std::io::{Read, Write}; /// Brave's adblocking library in Python! #[pymodule] -fn adblock(py: Python<'_>, m: &PyModule) -> PyResult<()> { +fn adblock_py(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add("__version__", env!("CARGO_PKG_VERSION"))?; m.add_class::()?; m.add_class::()?; m.add_class::()?; m.add_class::()?; - m.add("AdblockException", py.get_type::())?; - m.add("BlockerException", py.get_type::())?; - m.add("SerializationError", py.get_type::())?; + m.add("AdblockException", m.py().get_type_bound::())?; + m.add("BlockerException", m.py().get_type_bound::())?; + m.add("SerializationError", m.py().get_type_bound::())?; m.add( "DeserializationError", - py.get_type::(), + m.py().get_type_bound::(), )?; m.add( "OptimizedFilterExistence", - py.get_type::(), + m.py().get_type_bound::(), )?; m.add( "BadFilterAddUnsupported", - py.get_type::(), + m.py().get_type_bound::(), )?; - m.add("FilterExists", py.get_type::())?; + m.add("FilterExists", m.py().get_type_bound::())?; m.add( "AddResourceException", - py.get_type::(), + m.py().get_type_bound::(), )?; m.add( "InvalidBase64ContentError", - py.get_type::(), + m.py().get_type_bound::(), )?; m.add( "InvalidUtf8ContentError", - py.get_type::(), + m.py().get_type_bound::(), )?; Ok(()) } @@ -94,14 +91,11 @@ pub struct BlockerResult { /// /// [1]: https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#redirect #[pyo3(get)] - pub redirect_type: Option, - /// Exception is not `None` when the blocker matched on an exception rule. - /// Effectively this means that there was a match, but the request should - /// not be blocked. It is a non-empty string if the blocker was initialized - /// from a list of rules with debugging enabled, otherwise the original - /// string representation is discarded to reduce memory use. - #[pyo3(get)] pub redirect: Option, + /// `removeparam` may remove URL parameters. If the original request URL was + /// modified at all, the new version will be here. + #[pyo3(get)] + pub rewritten_url: Option, /// Exception is not `None` when the blocker matched on an exception rule. /// Effectively this means that there was a match, but the request should /// not be blocked. It is a non-empty string if the blocker was initialized @@ -114,32 +108,17 @@ pub struct BlockerResult { /// a match, it is not `None`. #[pyo3(get)] pub filter: Option, - /// The `error` field is only used to signal that there was an error in - /// parsing the provided URLs when using the simpler - /// `check_network_urls` method. - #[pyo3(get)] - pub error: Option, } impl From for BlockerResult { fn from(br: RustBlockerResult) -> Self { - let (redirect, redirect_type) = if let Some(resource) = br.redirect { - match resource { - Redirection::Resource(resource) => (Some(resource), Some("resource".to_string())), - Redirection::Url(url) => (Some(url), Some("url".to_string())), - } - } else { - (None, None) - }; - Self { matched: br.matched, important: br.important, + redirect: br.redirect, + rewritten_url: br.rewritten_url, exception: br.exception, filter: br.filter, - error: br.error, - redirect_type, - redirect, } } } @@ -148,13 +127,13 @@ impl From for BlockerResult { impl BlockerResult { fn __repr__(&self) -> PyResult { Ok(format!( - "BlockerResult(matched={}, important={}, redirect={}, exception={}, filter={}, error={})", + "BlockerResult(matched={}, important={}, redirect={}, rewritten_url={}, exception={}, filter={})", self.matched.diy_python_repr(), self.important.diy_python_repr(), self.redirect.diy_python_repr(), + self.rewritten_url.diy_python_repr(), self.exception.diy_python_repr(), self.filter.diy_python_repr(), - self.error.diy_python_repr(), )) } } @@ -214,17 +193,6 @@ impl From for PyErr { } } -impl From for BlockerError { - fn from(err: RustBlockerError) -> Self { - match err { - RustBlockerError::SerializationError => Self::SerializationError, - RustBlockerError::DeserializationError => Self::DeserializationError, - RustBlockerError::OptimizedFilterExistence => Self::OptimizedFilterExistence, - RustBlockerError::BadFilterAddUnsupported => Self::BadFilterAddUnsupported, - RustBlockerError::FilterExists => Self::FilterExists, - } - } -} fn filter_format_from_string(filter_format: &str) -> PyResult { match filter_format { @@ -252,7 +220,6 @@ fn rule_types_from_string(rule_types: &str) -> PyResult { /// created. FilterSet allows assembling a compound list from multiple /// different sources before compiling the rules into an Engine. #[pyclass] -#[pyo3(text_signature = "($self, debug)")] #[derive(Clone)] pub struct FilterSet { filter_set: RustFilterSet, @@ -266,7 +233,7 @@ impl FilterSet { /// the more compact internal representation. If enabled, this information /// will be passed to the corresponding Engine. #[new] - #[args(debug = false)] + #[pyo3(signature = (debug = false))] pub fn new(debug: bool) -> Self { Self { filter_set: RustFilterSet::new(debug), @@ -279,18 +246,11 @@ impl FilterSet { /// /// The format is a string containing either "standard" (ABP/uBO-style) /// or "hosts". - #[pyo3(text_signature = "($self, filter_list, format, include_redirect_urls, rule_types)")] - #[args( - filter_list, - format = "\"standard\"", - include_redirect_urls = "false", - rule_types = "\"all\"" - )] + #[pyo3(signature = (filter_list, format = "standard", rule_types = "all"))] pub fn add_filter_list( &mut self, filter_list: &str, format: &str, - include_redirect_urls: bool, rule_types: &str, ) -> PyResult<()> { let filter_format = filter_format_from_string(format)?; @@ -299,8 +259,8 @@ impl FilterSet { filter_list, ParseOptions { format: filter_format, - include_redirect_urls, rule_types, + permissions: PermissionMask::default(), }, ); Ok(()) @@ -311,18 +271,11 @@ impl FilterSet { /// /// The format is a string containing either "standard" (ABP/uBO-style) /// or "hosts". - #[pyo3(text_signature = "($self, filters, format, include_redirect_urls, rule_types)")] - #[args( - filters, - format = "\"standard\"", - include_redirect_urls = "false", - rule_types = "\"all\"" - )] + #[pyo3(signature = (filters, format = "standard", rule_types = "all"))] pub fn add_filters( &mut self, filters: Vec, format: &str, - include_redirect_urls: bool, rule_types: &str, ) -> PyResult<()> { let filter_format = filter_format_from_string(format)?; @@ -331,8 +284,8 @@ impl FilterSet { &filters, ParseOptions { format: filter_format, - include_redirect_urls, rule_types, + permissions: PermissionMask::default(), }, ); Ok(()) @@ -351,10 +304,9 @@ pub struct UrlSpecificResources { /// styled as `{ display: none !important; }`. #[pyo3(get)] pub hide_selectors: HashSet, - /// A map of CSS selectors on the page to respective non-hide style rules, - /// i.e. any required styles other than `display: none`. + /// Set of JSON-encoded procedural filters or filters with an action. #[pyo3(get)] - pub style_selectors: HashMap>, + pub procedural_actions: HashSet, /// A set of any class or id CSS selectors that should not have generic /// rules applied. // In practice, these should be passed to `class_id_stylesheet` and not @@ -376,7 +328,7 @@ impl From for UrlSpecificResources { fn from(r: RustUrlSpecificResources) -> Self { Self { hide_selectors: r.hide_selectors, - style_selectors: r.style_selectors, + procedural_actions: r.procedural_actions, exceptions: r.exceptions, injected_script: r.injected_script, generichide: r.generichide, @@ -388,9 +340,9 @@ impl From for UrlSpecificResources { impl UrlSpecificResources { fn __repr__(&self) -> PyResult { Ok(format!( - "UrlSpecificResources<{} hide selectors, {} style selectors, {} exceptions, injected_javascript={}, generichide={}>", + "UrlSpecificResources<{} hide selectors, {} procedural actions, {} exceptions, injected_javascript={}, generichide={}>", self.hide_selectors.len(), - self.style_selectors.len(), + self.procedural_actions.len(), self.exceptions.len(), self.injected_script.diy_python_repr(), self.generichide.diy_python_repr(), @@ -418,7 +370,6 @@ impl UrlSpecificResources { /// /// [1]: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/ResourceType #[pyclass] -#[pyo3(text_signature = "($self, filter_set, optimize)")] pub struct Engine { engine: RustEngine, optimize: bool, @@ -428,7 +379,7 @@ pub struct Engine { impl Engine { /// Create a new adblocking engine #[new] - #[args(filter_set, optimize = true)] + #[pyo3(signature = (filter_set, optimize = true))] pub fn new(filter_set: FilterSet, optimize: bool) -> Self { let engine = RustEngine::from_filter_set(filter_set.filter_set, optimize); Self { engine, optimize } @@ -442,17 +393,26 @@ impl Engine { /// * `url` - The URL of the request to check /// * `source_url` - The URL from where the request is made /// * `request_type` - The resource type that the request points to - #[pyo3(text_signature = "($self, url, source_url, request_type)")] pub fn check_network_urls( &self, url: &str, source_url: &str, request_type: &str, ) -> BlockerResult { - let blocker_result = self - .engine - .check_network_urls(url, source_url, request_type); - blocker_result.into() + match Request::new(url, source_url, request_type) { + Ok(request) => { + let blocker_result = self.engine.check_network_request(&request); + blocker_result.into() + } + Err(_) => BlockerResult { + matched: false, + important: false, + redirect: None, + rewritten_url: None, + exception: None, + filter: None, + } + } } /// Check if a request should be blocked based on the given parameters. @@ -465,9 +425,7 @@ impl Engine { /// * `third_party_request` - Is the given request to a third-party? Here, /// `None` can be given and the engine will figure it out based on the /// `hostname` and `source_hostname`. - #[pyo3( - text_signature = "($self, url, hostname, source_hostname, requsest_type, third_party_request)" - )] + #[pyo3(signature = (url, hostname, source_hostname, request_type, third_party_request = None))] pub fn check_network_urls_with_hostnames( &self, url: &str, @@ -476,13 +434,11 @@ impl Engine { request_type: &str, third_party_request: Option, ) -> BlockerResult { - let blocker_result = self.engine.check_network_urls_with_hostnames( - url, - hostname, - source_hostname, - request_type, - third_party_request, - ); + let third_party = third_party_request.unwrap_or_else(|| { + hostname != source_hostname + }); + let request = Request::preparsed(url, hostname, source_hostname, request_type, third_party); + let blocker_result = self.engine.check_network_request(&request); blocker_result.into() } @@ -499,10 +455,7 @@ impl Engine { /// * `previously_matched_rule` - Return a match as long as there are no /// exceptions /// * `force_check_exceptions` - Check exceptions even if no other rule matches - #[pyo3( - text_signature = "($self, url, hostname, source_hostname, request_type, \ - third_party_request, previously_matched_rule, force_check_exceptions)" - )] + #[pyo3(signature = (url, hostname, source_hostname, request_type, third_party_request = None, previously_matched_rule = false, force_check_exceptions = false))] #[allow(clippy::too_many_arguments)] pub fn check_network_urls_with_hostnames_subset( &self, @@ -514,12 +467,12 @@ impl Engine { previously_matched_rule: bool, force_check_exceptions: bool, ) -> BlockerResult { - let blocker_result = self.engine.check_network_urls_with_hostnames_subset( - url, - hostname, - source_hostname, - request_type, - third_party_request, + let third_party = third_party_request.unwrap_or_else(|| { + hostname != source_hostname + }); + let request = Request::preparsed(url, hostname, source_hostname, request_type, third_party); + let blocker_result = self.engine.check_network_request_subset( + &request, previously_matched_rule, force_check_exceptions, ); @@ -534,7 +487,7 @@ impl Engine { /// Use `"template"` if wanting to specify a template resource type. /// * `content`: The resource data, encoded using standard base64 configuration /// * `aliases`: List of aliases for the resource - #[pyo3(text_signature = "($self, name, content_type, content, aliases)")] + #[pyo3(signature = (name, content_type, content, aliases = None))] pub fn add_resource( &mut self, name: &str, @@ -542,7 +495,7 @@ impl Engine { content: &str, aliases: Option>, ) -> PyResult<()> { - let result = self.engine.add_resource(Resource { + let resource = Resource { name: name.to_string(), aliases: aliases.unwrap_or_default(), kind: match content_type { @@ -552,47 +505,27 @@ impl Engine { ))), }, content: content.to_string(), - }); + dependencies: Vec::new(), + permission: PermissionMask::default(), + }; - match result { - Ok(_) => Ok(()), - Err(err) => match err { - RustAddResourceError::InvalidBase64Content => Err( - InvalidBase64ContentError::new_err("invalid base64 content".to_string()), - ), - RustAddResourceError::InvalidUtf8Content => Err(InvalidUtf8ContentError::new_err( - "invalid utf content".to_string(), - )), - }, - } + self.engine.use_resources(std::iter::once(resource)); + Ok(()) } /// Serialize this blocking engine to bytes. They can then be deserialized /// using `deserialize()` to get the same engine again. - #[pyo3(text_signature = "($self)")] - pub fn serialize<'p>(&mut self, py: Python<'p>) -> PyResult<&'p PyBytes> { - let bytes = self.serialize_inner()?; - let py_bytes = PyBytes::new(py, &bytes); + pub fn serialize<'p>(&self, py: Python<'p>) -> PyResult> { + let bytes = self.engine.serialize(); + let py_bytes = PyBytes::new_bound(py, &bytes); Ok(py_bytes) } - fn serialize_inner(&mut self) -> PyResult> { - let result = self.engine.serialize_raw(); - match result { - Ok(x) => Ok(x), - Err(error) => { - let my_blocker_error: BlockerError = error.into(); - Err(my_blocker_error.into()) - } - } - } - /// Serialize this blocking engine to a file. The file can then be /// deserialized using `deserialize_from_file()` to get the same engine /// again. - #[pyo3(text_signature = "($self, file)")] - pub fn serialize_to_file(&mut self, file: &str) -> PyResult<()> { - let data = self.serialize_inner()?; + pub fn serialize_to_file(&self, file: &str) -> PyResult<()> { + let data = self.engine.serialize(); let mut fd = fs::OpenOptions::new() .create(true) .truncate(true) @@ -603,21 +536,14 @@ impl Engine { } /// Deserialize a blocking engine from bytes produced with `serialize()`. - #[pyo3(text_signature = "($self, serialized)")] pub fn deserialize(&mut self, serialized: &[u8]) -> PyResult<()> { - let result = self.engine.deserialize(serialized); - match result { - Ok(_) => Ok(()), - Err(error) => { - let my_blocker_error: BlockerError = error.into(); - Err(my_blocker_error.into()) - } - } + self.engine.deserialize(serialized).map_err(|_| { + DeserializationError::new_err("Failed to deserialize engine data") + }) } /// Deserialize a blocking engine from file produced with /// `serialize_to_file()`. - #[pyo3(text_signature = "($self, file)")] pub fn deserialize_from_file(&mut self, file: &str) -> PyResult<()> { let mut fd = fs::File::open(file)?; let mut data: Vec = Vec::new(); @@ -626,18 +552,20 @@ impl Engine { } /// Checks if the given filter exists in the blocking engine. - #[pyo3(text_signature = "($self, filter)")] - pub fn filter_exists(&self, filter: &str) -> bool { - self.engine.filter_exists(filter) + /// Note: This method has been removed in the latest version of adblock-rust. + /// It will always return false. + pub fn filter_exists(&self, _filter: &str) -> bool { + // This method no longer exists in the adblock-rust API + false } /// Sets this engine's tags to be _only_ the ones provided in tags. /// /// Tags can be used to cheaply enable or disable network rules with a /// corresponding $tag option. - #[pyo3(text_signature = "($self, tags)")] - pub fn use_tags(&mut self, tags: Vec<&str>) { - self.engine.use_tags(&tags); + pub fn use_tags(&mut self, tags: Vec) { + let tag_refs: Vec<&str> = tags.iter().map(|s| s.as_str()).collect(); + self.engine.use_tags(&tag_refs); } /// Sets this engine's tags to additionally include the ones provided in @@ -645,9 +573,9 @@ impl Engine { /// /// Tags can be used to cheaply enable or disable network rules with a /// corresponding $tag option. - #[pyo3(text_signature = "($self, tags)")] - pub fn enable_tags(&mut self, tags: Vec<&str>) { - self.engine.enable_tags(&tags); + pub fn enable_tags(&mut self, tags: Vec) { + let tag_refs: Vec<&str> = tags.iter().map(|s| s.as_str()).collect(); + self.engine.enable_tags(&tag_refs); } /// Sets this engine's tags to no longer include the ones provided in @@ -655,16 +583,15 @@ impl Engine { /// /// Tags can be used to cheaply enable or disable network rules with a /// corresponding $tag option. - #[pyo3(text_signature = "($self, tags)")] - pub fn disable_tags(&mut self, tags: Vec<&str>) { - self.engine.disable_tags(&tags); + pub fn disable_tags(&mut self, tags: Vec) { + let tag_refs: Vec<&str> = tags.iter().map(|s| s.as_str()).collect(); + self.engine.disable_tags(&tag_refs); } /// Checks if a given tag exists in this engine. /// /// Tags can be used to cheaply enable or disable network rules with a /// corresponding $tag option. - #[pyo3(text_signature = "($self, tag)")] pub fn tag_exists(&self, tag: &str) -> bool { self.engine.tag_exists(tag) } @@ -673,7 +600,6 @@ impl Engine { /// url. Once this has been called, all CSS ids and classes on a /// page should be passed to hidden_class_id_selectors to obtain any /// stylesheets consisting of generic rules. - #[pyo3(text_signature = "($self, url)")] pub fn url_cosmetic_resources(&self, url: &str) -> UrlSpecificResources { self.engine.url_cosmetic_resources(url).into() } @@ -685,7 +611,6 @@ impl Engine { /// are not excepted. /// /// Exceptions should be passed directly from UrlSpecificResources. - #[pyo3(text_signature = "($self, classes, ids, exceptions)")] pub fn hidden_class_id_selectors( &self, classes: Vec, -- cgit v1.2.3