diff --git a/Cargo.lock b/Cargo.lock index 70e7a98e..8ccc8f75 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,6 +16,16 @@ dependencies = [ "nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "async-trait" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "atty" version = "0.2.13" @@ -137,12 +147,14 @@ dependencies = [ name = "cool_thing" version = "0.1.0" dependencies = [ + "async-trait 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "cargo-fuzz 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -363,6 +375,88 @@ name = "futures" version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "futures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-channel" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-executor" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-io" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-macro" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-sink" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-task" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fxhash" version = "0.2.1" @@ -679,6 +773,11 @@ dependencies = [ "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "pin-utils" +version = "0.1.0-alpha.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "pre-commit" version = "0.5.2" @@ -693,6 +792,21 @@ name = "precomputed-hash" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "proc-macro-hack" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro-nested" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "proc-macro2" version = "1.0.6" @@ -1551,6 +1665,7 @@ dependencies = [ [metadata] "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" +"checksum async-trait 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "b64ebe56ac5fbe89417328eeb4291984d138056dcf694f1414ab0f26d49a6290" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" "checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea" @@ -1587,6 +1702,15 @@ dependencies = [ "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futf 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7c9c1ce3fa9336301af935ab852c437817d14cd33690446569392e65170aac3b" "checksum futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" +"checksum futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6f16056ecbb57525ff698bb955162d0cd03bee84e6241c27ff75c08d8ca5987" +"checksum futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fcae98ca17d102fd8a3603727b9259fcf7fa4239b603d2142926189bc8999b86" +"checksum futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866" +"checksum futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e274736563f686a837a0568b478bdabfeaec2dca794b5649b04e2fe1627c231" +"checksum futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e676577d229e70952ab25f3945795ba5b16d63ca794ca9d2c860e5595d20b5ff" +"checksum futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "52e7c56c15537adb4f76d0b7a76ad131cb4d2f4f32d3b0bcabcbe1c7c5e87764" +"checksum futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "171be33efae63c2d59e6dbba34186fe0d6394fb378069a76dfd80fdcffd43c16" +"checksum futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9" +"checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" "checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" "checksum getopts 0.2.21 (registry+https://github.com/rust-lang/crates.io-index)" = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" "checksum getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "e7db7ca94ed4cd01190ceee0d8a8052f08a247aa1b469a7f68c6a3b71afcf407" @@ -1625,8 +1749,11 @@ dependencies = [ "checksum phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" "checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" "checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" +"checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" "checksum pre-commit 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d0f2b9887f84ec91cd86f71c193b883209d744bc8c2a3363c6b1df88efa5af8f" "checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +"checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" +"checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" "checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" "checksum procedural-masquerade 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9a1574a51c3fd37b26d2c0032b649d08a7d51d4cca9c41bbc5bf7118fa4509d0" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" diff --git a/Cargo.toml b/Cargo.toml index dfa2108d..d3f6f491 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "cool_thing" version = "0.1.0" authors = ["Ivan Nikulin "] license = "BSD-3-Clause" -description = "Streaming HTML rewriter/parser with CSS-selector based API" +description = "Streaming HTML rewriter/parser with CSS selector-based API" repository = "https://github.com/cloudflare/cool-thing" documentation = "https://docs.rs/cool-thing" categories = ["parser-implementations", "web-programming"] @@ -13,7 +13,10 @@ include = [ "/Cargo.toml", "/LICENSE", "/README.md", - "/src/**", + "/src", + "/media", + "/tests", + "/benches" ] autotests = false edition = "2018" @@ -31,10 +34,12 @@ harness = false name = "bench" [dependencies] +async-trait = "0.1.17" bitflags = "1.0.4" cfg-if = "0.1" cssparser = "0.25.5" encoding_rs = "0.8.13" +futures = "0.3.1" lazycell = "1.2" lazy_static = "1.3.0" memchr = "2.1.2" diff --git a/DEVELOPING.md b/DEVELOPING.md index 907f9a6e..5f8ced77 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -54,33 +54,29 @@ The tool prints selector VM's program AST for the given list of CSS selectors. C ## Fuzzing -### Fuzzing with cargo-fuzz -https://rust-fuzz.github.io/book/cargo-fuzz.html -cargo-fuzz requires Rust nightly. +### Fuzzing with [cargo-fuzz](https://rust-fuzz.github.io/book/cargo-fuzz.html) +**NOTE:** requires Rust nightly. -Run fuzzing of `c-api` +Run fuzzing for the crate: ``` -./scripts/fuzz_c_api_with_libfuzzer.sh +./scripts/fuzz_with_libfuzzer.sh ``` -Run fuzzing of rust library +Run fuzzing for C API: ``` -./scripts/fuzz_with_libfuzzer.sh +./scripts/fuzz_c_api_with_libfuzzer.sh ``` -### Fuzzing with afl -https://rust-fuzz.github.io/book/afl.html - +### Fuzzing with [afl](https://rust-fuzz.github.io/book/afl.html) ``` ./scripts/fuzz_with_afl.sh ``` -### Fuzzing with honggfuzz -https://github.com/rust-fuzz/honggfuzz-rs +### Fuzzing with [honggfuzz](https://github.com/rust-fuzz/honggfuzz-rs) ``` ./scripts/fuzz_with_hongg.sh -``` \ No newline at end of file +``` diff --git a/README.md b/README.md index 0193f4da..bf79a67f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Cool Thing +![Banner](media/banner.png) *Cool Thing is a streaming HTML rewriter/parser with CSS-selector based API.* diff --git a/c-api/Cargo.lock b/c-api/Cargo.lock index f14752f4..eb4d8220 100644 --- a/c-api/Cargo.lock +++ b/c-api/Cargo.lock @@ -1,5 +1,15 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "async-trait" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "autocfg" version = "0.1.7" @@ -37,10 +47,12 @@ dependencies = [ name = "cool_thing" version = "0.1.0" dependencies = [ + "async-trait 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -114,6 +126,88 @@ name = "fuchsia-cprng" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "futures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-channel" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-executor" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-io" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-macro" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-sink" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-task" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fxhash" version = "0.2.1" @@ -199,11 +293,31 @@ dependencies = [ "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "pin-utils" +version = "0.1.0-alpha.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "precomputed-hash" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "proc-macro-hack" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro-nested" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "proc-macro2" version = "1.0.6" @@ -366,6 +480,11 @@ name = "siphasher" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "smallvec" version = "0.6.10" @@ -434,6 +553,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] +"checksum async-trait 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "b64ebe56ac5fbe89417328eeb4291984d138056dcf694f1414ab0f26d49a6290" "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" @@ -446,6 +566,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum dtoa-short 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "59020b8513b76630c49d918c33db9f4c91638e7d3404a28084083b87e33f76f2" "checksum encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)" = "87240518927716f79692c2ed85bfe6e98196d18c6401ec75355760233a7e12e9" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +"checksum futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6f16056ecbb57525ff698bb955162d0cd03bee84e6241c27ff75c08d8ca5987" +"checksum futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fcae98ca17d102fd8a3603727b9259fcf7fa4239b603d2142926189bc8999b86" +"checksum futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866" +"checksum futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e274736563f686a837a0568b478bdabfeaec2dca794b5649b04e2fe1627c231" +"checksum futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e676577d229e70952ab25f3945795ba5b16d63ca794ca9d2c860e5595d20b5ff" +"checksum futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "52e7c56c15537adb4f76d0b7a76ad131cb4d2f4f32d3b0bcabcbe1c7c5e87764" +"checksum futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "171be33efae63c2d59e6dbba34186fe0d6394fb378069a76dfd80fdcffd43c16" +"checksum futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9" +"checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" "checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" @@ -459,7 +588,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" "checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" "checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" +"checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" "checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +"checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" +"checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" "checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" "checksum procedural-masquerade 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9a1574a51c3fd37b26d2c0032b649d08a7d51d4cca9c41bbc5bf7118fa4509d0" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" @@ -478,6 +610,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum selectors 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b86b100bede4f651059740afc3b6cb83458d7401cb7c1ad96d8a11e91742c86" "checksum servo_arc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d98238b800e0d1576d8b6e3de32827c2d74bee68bb97748dcf5071fb53965432" "checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" +"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" diff --git a/c-api/tests/Cargo.lock b/c-api/tests/Cargo.lock index 4841a506..1d9a0c74 100644 --- a/c-api/tests/Cargo.lock +++ b/c-api/tests/Cargo.lock @@ -1,5 +1,15 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "async-trait" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "autocfg" version = "0.1.7" @@ -37,10 +47,12 @@ dependencies = [ name = "cool_thing" version = "0.1.0" dependencies = [ + "async-trait 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -125,6 +137,88 @@ name = "fuchsia-cprng" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "futures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-channel" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-executor" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-io" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-macro" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-sink" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-task" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fxhash" version = "0.2.1" @@ -215,11 +309,31 @@ dependencies = [ "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "pin-utils" +version = "0.1.0-alpha.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "precomputed-hash" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "proc-macro-hack" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro-nested" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "proc-macro2" version = "1.0.6" @@ -382,6 +496,11 @@ name = "siphasher" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "smallvec" version = "0.6.10" @@ -450,6 +569,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] +"checksum async-trait 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "b64ebe56ac5fbe89417328eeb4291984d138056dcf694f1414ab0f26d49a6290" "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" @@ -462,6 +582,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum dtoa-short 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "59020b8513b76630c49d918c33db9f4c91638e7d3404a28084083b87e33f76f2" "checksum encoding_rs 0.8.20 (registry+https://github.com/rust-lang/crates.io-index)" = "87240518927716f79692c2ed85bfe6e98196d18c6401ec75355760233a7e12e9" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +"checksum futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6f16056ecbb57525ff698bb955162d0cd03bee84e6241c27ff75c08d8ca5987" +"checksum futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fcae98ca17d102fd8a3603727b9259fcf7fa4239b603d2142926189bc8999b86" +"checksum futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866" +"checksum futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e274736563f686a837a0568b478bdabfeaec2dca794b5649b04e2fe1627c231" +"checksum futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e676577d229e70952ab25f3945795ba5b16d63ca794ca9d2c860e5595d20b5ff" +"checksum futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "52e7c56c15537adb4f76d0b7a76ad131cb4d2f4f32d3b0bcabcbe1c7c5e87764" +"checksum futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "171be33efae63c2d59e6dbba34186fe0d6394fb378069a76dfd80fdcffd43c16" +"checksum futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9" +"checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" "checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" @@ -476,7 +605,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" "checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" "checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" +"checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" "checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +"checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" +"checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" "checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" "checksum procedural-masquerade 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9a1574a51c3fd37b26d2c0032b649d08a7d51d4cca9c41bbc5bf7118fa4509d0" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" @@ -495,6 +627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum selectors 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b86b100bede4f651059740afc3b6cb83458d7401cb7c1ad96d8a11e91742c86" "checksum servo_arc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d98238b800e0d1576d8b6e3de32827c2d74bee68bb97748dcf5071fb53965432" "checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" +"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index 97d49bef..e3b96611 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -21,6 +21,16 @@ name = "arbitrary" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "async-trait" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "atty" version = "0.2.13" @@ -150,10 +160,12 @@ dependencies = [ name = "cool_thing" version = "0.1.0" dependencies = [ + "async-trait 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -246,6 +258,88 @@ name = "fuchsia-cprng" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "futures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-channel" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-executor" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-io" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-macro" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-sink" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-task" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fxhash" version = "0.2.1" @@ -386,6 +480,11 @@ dependencies = [ "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "pin-utils" +version = "0.1.0-alpha.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "ppv-lite86" version = "0.2.5" @@ -396,6 +495,21 @@ name = "precomputed-hash" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "proc-macro-hack" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro-nested" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "proc-macro2" version = "0.4.30" @@ -642,6 +756,11 @@ name = "siphasher" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "smallvec" version = "0.6.10" @@ -804,6 +923,7 @@ dependencies = [ "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum arbitrary 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c7d1523aa3a127adf8b27af2404c03c12825b4c4d0698f01648d63fa9df62ee" +"checksum async-trait 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "b64ebe56ac5fbe89417328eeb4291984d138056dcf694f1414ab0f26d49a6290" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" "checksum backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "5180c5a20655b14a819b652fd2378fa5f1697b6c9ddad3e695c2f9cedf6df4e2" @@ -826,6 +946,15 @@ dependencies = [ "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +"checksum futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6f16056ecbb57525ff698bb955162d0cd03bee84e6241c27ff75c08d8ca5987" +"checksum futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fcae98ca17d102fd8a3603727b9259fcf7fa4239b603d2142926189bc8999b86" +"checksum futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866" +"checksum futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e274736563f686a837a0568b478bdabfeaec2dca794b5649b04e2fe1627c231" +"checksum futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e676577d229e70952ab25f3945795ba5b16d63ca794ca9d2c860e5595d20b5ff" +"checksum futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "52e7c56c15537adb4f76d0b7a76ad131cb4d2f4f32d3b0bcabcbe1c7c5e87764" +"checksum futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "171be33efae63c2d59e6dbba34186fe0d6394fb378069a76dfd80fdcffd43c16" +"checksum futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9" +"checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" "checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" "checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" @@ -846,8 +975,11 @@ dependencies = [ "checksum phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" "checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" "checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" +"checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +"checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" +"checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e98a83a9f9b331f54b924e68a66acb1bb35cb01fb0a23645139967abefb697e8" "checksum procedural-masquerade 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9a1574a51c3fd37b26d2c0032b649d08a7d51d4cca9c41bbc5bf7118fa4509d0" @@ -877,6 +1009,7 @@ dependencies = [ "checksum servo_arc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d98238b800e0d1576d8b6e3de32827c2d74bee68bb97748dcf5071fb53965432" "checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" "checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" +"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" diff --git a/fuzz/test_case/Cargo.lock b/fuzz/test_case/Cargo.lock index fcbde6e5..bf98f930 100644 --- a/fuzz/test_case/Cargo.lock +++ b/fuzz/test_case/Cargo.lock @@ -16,6 +16,16 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "async-trait" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "atty" version = "0.2.13" @@ -145,10 +155,12 @@ dependencies = [ name = "cool_thing" version = "0.1.0" dependencies = [ + "async-trait 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)", "encoding_rs 0.8.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -233,6 +245,88 @@ name = "fuchsia-cprng" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "futures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-channel" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-executor" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-io" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-macro" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-sink" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-task" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fxhash" version = "0.2.1" @@ -364,6 +458,11 @@ dependencies = [ "siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "pin-utils" +version = "0.1.0-alpha.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "ppv-lite86" version = "0.2.5" @@ -374,6 +473,21 @@ name = "precomputed-hash" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "proc-macro-hack" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro-nested" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "proc-macro2" version = "0.4.30" @@ -620,6 +734,11 @@ name = "siphasher" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "smallvec" version = "0.6.10" @@ -781,6 +900,7 @@ dependencies = [ [metadata] "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum async-trait 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "b64ebe56ac5fbe89417328eeb4291984d138056dcf694f1414ab0f26d49a6290" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" "checksum backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "5180c5a20655b14a819b652fd2378fa5f1697b6c9ddad3e695c2f9cedf6df4e2" @@ -803,6 +923,15 @@ dependencies = [ "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +"checksum futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6f16056ecbb57525ff698bb955162d0cd03bee84e6241c27ff75c08d8ca5987" +"checksum futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fcae98ca17d102fd8a3603727b9259fcf7fa4239b603d2142926189bc8999b86" +"checksum futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "79564c427afefab1dfb3298535b21eda083ef7935b4f0ecbfcb121f0aec10866" +"checksum futures-executor 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1e274736563f686a837a0568b478bdabfeaec2dca794b5649b04e2fe1627c231" +"checksum futures-io 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e676577d229e70952ab25f3945795ba5b16d63ca794ca9d2c860e5595d20b5ff" +"checksum futures-macro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "52e7c56c15537adb4f76d0b7a76ad131cb4d2f4f32d3b0bcabcbe1c7c5e87764" +"checksum futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "171be33efae63c2d59e6dbba34186fe0d6394fb378069a76dfd80fdcffd43c16" +"checksum futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9" +"checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" "checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" "checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" @@ -822,8 +951,11 @@ dependencies = [ "checksum phf_codegen 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "b03e85129e324ad4166b06b2c7491ae27fe3ec353af72e72cd1654c7225d517e" "checksum phf_generator 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" "checksum phf_shared 0.7.24 (registry+https://github.com/rust-lang/crates.io-index)" = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" +"checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" "checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +"checksum proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)" = "ecd45702f76d6d3c75a80564378ae228a85f0b59d2f3ed43c91b4a69eb2ebfc5" +"checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" "checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" "checksum proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e98a83a9f9b331f54b924e68a66acb1bb35cb01fb0a23645139967abefb697e8" "checksum procedural-masquerade 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9a1574a51c3fd37b26d2c0032b649d08a7d51d4cca9c41bbc5bf7118fa4509d0" @@ -853,6 +985,7 @@ dependencies = [ "checksum servo_arc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d98238b800e0d1576d8b6e3de32827c2d74bee68bb97748dcf5071fb53965432" "checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" "checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" +"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ab606a9c5e214920bb66c458cd7be8ef094f813f20fe77a54cc7dbfff220d4b7" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" diff --git a/media/banner.png b/media/banner.png new file mode 100644 index 00000000..87929c9e Binary files /dev/null and b/media/banner.png differ diff --git a/src/base/async_closure.rs b/src/base/async_closure.rs new file mode 100644 index 00000000..d3130f68 --- /dev/null +++ b/src/base/async_closure.rs @@ -0,0 +1,9 @@ +macro_rules! async_closure { + (|$($args:tt),+| $($body:tt)*) => { + |$($args),+| { + Box::pin(async { + $($body)* + }) + } + }; +} diff --git a/src/base/bytes.rs b/src/base/bytes.rs index 6796b3a3..3b211645 100644 --- a/src/base/bytes.rs +++ b/src/base/bytes.rs @@ -11,11 +11,6 @@ use std::str; pub struct Bytes<'b>(Cow<'b, [u8]>); impl<'b> Bytes<'b> { - #[inline] - pub fn empty() -> Self { - Bytes(Cow::Borrowed(&[])) - } - #[inline] pub fn from_str(string: &'b str, encoding: &'static Encoding) -> Self { encoding.encode(string).0.into() diff --git a/src/base/mod.rs b/src/base/mod.rs index 28b0e617..0dd051ee 100644 --- a/src/base/mod.rs +++ b/src/base/mod.rs @@ -1,6 +1,9 @@ #[macro_use] mod debug_trace; +#[macro_use] +mod async_closure; + mod align; mod bytes; mod range; diff --git a/src/lib.rs b/src/lib.rs index 63246104..ac820480 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,10 +1,10 @@ -//! Cool Thing is an HTML rewriter/parser with CSS-selector based API. +//! Cool Thing is a streaming HTML rewriter/parser with CSS-selector based API. //! -//! It is designed to provide a low output latency, quickly handle big amounts of data and operate -//! in environments with the limited memory resources. +//! It is designed to provide low output latency, quickly handle big amounts of data and operate in +//! environments with limited memory resources. //! -//! The crate serves as a back-end for the HTML rewriting functionality of [Cloudflare Workers], -//! but can be used as a standalone library with the convenient API for a wide variety of HTML +//! The crate serves as a back-end for the HTML rewriting functionality of [Cloudflare Workers], but +//! can be used as a standalone library with the convenient API for a wide variety of HTML //! rewriting/analyzis tasks. //! //! The crate provides two main API entry points: diff --git a/src/rewritable_units/element.rs b/src/rewritable_units/element.rs index 586381e7..b5abdf95 100644 --- a/src/rewritable_units/element.rs +++ b/src/rewritable_units/element.rs @@ -2,6 +2,7 @@ use super::{Attribute, AttributeNameError, ContentType, EndTag, Mutations, Start use crate::base::Bytes; use crate::rewriter::EndTagHandler; use encoding_rs::Encoding; +use futures::future; use std::any::Any; use std::fmt::{self, Debug}; use thiserror::Error; @@ -471,7 +472,7 @@ impl<'r, 't> Element<'r, 't> { end_tag.mutations = mutations; } - Ok(()) + Box::pin(future::ok(())) })) } else { None @@ -757,22 +758,12 @@ mod tests { el.remove_attribute("Foo1இ"); assert_eq!(el.attributes().len(), 1, "Encoding: {}", enc.name()); - assert_eq!( - el.get_attribute("foo1இ"), - None, - "Encoding: {}", - enc.name() - ); + assert_eq!(el.get_attribute("foo1இ"), None, "Encoding: {}", enc.name()); el.remove_attribute("FoO2இ"); assert!(el.attributes().is_empty(), "Encoding: {}", enc.name()); - assert_eq!( - el.get_attribute("foo2இ"), - None, - "Encoding: {}", - enc.name() - ); + assert_eq!(el.get_attribute("foo2இ"), None, "Encoding: {}", enc.name()); }); } } diff --git a/src/rewritable_units/tokens/capturer.rs b/src/rewritable_units/tokens/capturer.rs deleted file mode 100644 index 0a001e4b..00000000 --- a/src/rewritable_units/tokens/capturer.rs +++ /dev/null @@ -1,229 +0,0 @@ -use super::*; -use crate::base::Bytes; -use crate::html::TextType; -use crate::parser::{ - Lexeme, NonTagContentLexeme, NonTagContentTokenOutline, TagLexeme, TagTokenOutline, -}; -use crate::rewriter::RewritingError; -use bitflags::bitflags; -use encoding_rs::{CoderResult, Decoder, Encoding}; -use std::rc::Rc; - -bitflags! { - pub struct TokenCaptureFlags: u8 { - const TEXT = 0b0000_0001; - const COMMENTS = 0b0000_0010; - const NEXT_START_TAG = 0b0000_0100; - const NEXT_END_TAG = 0b0000_1000; - const DOCTYPES = 0b0001_0000; - } -} - -#[derive(Debug)] -pub enum TokenCapturerEvent<'i> { - LexemeConsumed, - TokenProduced(Box>), -} - -pub enum ToTokenResult<'i> { - Token(Box>), - Text(TextType), - None, -} - -impl<'i> From> for ToTokenResult<'i> { - #[inline] - fn from(token: Token<'i>) -> Self { - ToTokenResult::Token(Box::new(token)) - } -} - -pub trait ToToken { - fn to_token( - &self, - capture_flags: &mut TokenCaptureFlags, - encoding: &'static Encoding, - ) -> ToTokenResult; -} - -impl ToToken for TagLexeme<'_> { - fn to_token( - &self, - capture_flags: &mut TokenCaptureFlags, - encoding: &'static Encoding, - ) -> ToTokenResult { - match *self.token_outline() { - TagTokenOutline::StartTag { - name, - ref attributes, - ns, - self_closing, - .. - } if capture_flags.contains(TokenCaptureFlags::NEXT_START_TAG) => { - // NOTE: clear the flag once we've seen required start tag. - capture_flags.remove(TokenCaptureFlags::NEXT_START_TAG); - - StartTag::new_token( - self.part(name), - Attributes::new(self.input(), Rc::clone(attributes), encoding), - ns, - self_closing, - self.raw(), - encoding, - ) - .into() - } - - TagTokenOutline::EndTag { name, .. } - if capture_flags.contains(TokenCaptureFlags::NEXT_END_TAG) => - { - // NOTE: clear the flag once we've seen required end tag. - capture_flags.remove(TokenCaptureFlags::NEXT_END_TAG); - - EndTag::new_token(self.part(name), self.raw(), encoding).into() - } - _ => ToTokenResult::None, - } - } -} - -impl ToToken for NonTagContentLexeme<'_> { - fn to_token( - &self, - capture_flags: &mut TokenCaptureFlags, - encoding: &'static Encoding, - ) -> ToTokenResult { - match *self.token_outline() { - Some(NonTagContentTokenOutline::Text(text_type)) => ToTokenResult::Text(text_type), - Some(NonTagContentTokenOutline::Comment(text)) - if capture_flags.contains(TokenCaptureFlags::COMMENTS) => - { - Comment::new_token(self.part(text), self.raw(), encoding).into() - } - - Some(NonTagContentTokenOutline::Doctype { - name, - public_id, - system_id, - force_quirks, - }) if capture_flags.contains(TokenCaptureFlags::DOCTYPES) => Doctype::new_token( - self.opt_part(name), - self.opt_part(public_id), - self.opt_part(system_id), - force_quirks, - self.raw(), - encoding, - ) - .into(), - _ => ToTokenResult::None, - } - } -} - -pub struct TokenCapturer { - encoding: &'static Encoding, - pending_text_decoder: Option, - text_buffer: String, - capture_flags: TokenCaptureFlags, - last_text_type: TextType, -} - -impl TokenCapturer { - pub fn new(capture_flags: TokenCaptureFlags, encoding: &'static Encoding) -> Self { - TokenCapturer { - encoding, - pending_text_decoder: None, - // TODO make adjustable - text_buffer: String::from_utf8(vec![0u8; 1024]).unwrap(), - capture_flags, - last_text_type: TextType::Data, - } - } - - #[inline] - pub fn has_captures(&self) -> bool { - !self.capture_flags.is_empty() - } - - #[inline] - pub fn set_capture_flags(&mut self, flags: TokenCaptureFlags) { - self.capture_flags = flags; - } - - #[inline] - pub fn flush_pending_text( - &mut self, - event_handler: &mut dyn FnMut(TokenCapturerEvent) -> Result<(), RewritingError>, - ) -> Result<(), RewritingError> { - if self.pending_text_decoder.is_some() { - self.emit_text(&Bytes::empty(), true, event_handler)?; - self.pending_text_decoder = None; - } - - Ok(()) - } - - fn emit_text( - &mut self, - raw: &Bytes, - last: bool, - event_handler: &mut dyn FnMut(TokenCapturerEvent) -> Result<(), RewritingError>, - ) -> Result<(), RewritingError> { - let encoding = self.encoding; - let buffer = self.text_buffer.as_mut_str(); - - let decoder = self - .pending_text_decoder - .get_or_insert_with(|| encoding.new_decoder_without_bom_handling()); - - let mut consumed = 0; - - loop { - let (status, read, written, ..) = decoder.decode_to_str(&raw[consumed..], buffer, last); - - consumed += read; - - if written > 0 || last { - let token = - TextChunk::new_token(&buffer[..written], self.last_text_type, last, encoding); - - event_handler(TokenCapturerEvent::TokenProduced(Box::new(token)))?; - } - - if let CoderResult::InputEmpty = status { - break; - } - } - - Ok(()) - } - - pub fn feed<'i, T>( - &mut self, - lexeme: &Lexeme<'i, T>, - mut event_handler: impl FnMut(TokenCapturerEvent) -> Result<(), RewritingError>, - ) -> Result<(), RewritingError> - where - Lexeme<'i, T>: ToToken, - { - match lexeme.to_token(&mut self.capture_flags, self.encoding) { - ToTokenResult::Token(token) => { - self.flush_pending_text(&mut event_handler)?; - event_handler(TokenCapturerEvent::LexemeConsumed)?; - event_handler(TokenCapturerEvent::TokenProduced(token)) - } - ToTokenResult::Text(text_type) => { - if self.capture_flags.contains(TokenCaptureFlags::TEXT) { - self.last_text_type = text_type; - - event_handler(TokenCapturerEvent::LexemeConsumed)?; - - self.emit_text(&lexeme.raw(), false, &mut event_handler)?; - } - - Ok(()) - } - ToTokenResult::None => self.flush_pending_text(&mut event_handler), - } - } -} diff --git a/src/rewritable_units/tokens/capturer/mod.rs b/src/rewritable_units/tokens/capturer/mod.rs new file mode 100644 index 00000000..9964c419 --- /dev/null +++ b/src/rewritable_units/tokens/capturer/mod.rs @@ -0,0 +1,93 @@ +mod text_decoder; +mod to_token; + +use self::text_decoder::TextDecoder; +use super::*; +use crate::parser::Lexeme; +use crate::rewriter::{AsyncRewritingResult, RewritingResult}; +use bitflags::bitflags; +use encoding_rs::Encoding; + +pub use self::to_token::{ToToken, ToTokenResult}; + +bitflags! { + pub struct TokenCaptureFlags: u8 { + const TEXT = 0b0000_0001; + const COMMENTS = 0b0000_0010; + const NEXT_START_TAG = 0b0000_0100; + const NEXT_END_TAG = 0b0000_1000; + const DOCTYPES = 0b0001_0000; + } +} + +#[derive(Debug)] +pub enum TokenCapturerEvent<'i> { + LexemeConsumed, + TokenProduced(Box>), +} + +type CapturerEventHandler<'h, 'i> = + &'h mut dyn FnMut(TokenCapturerEvent<'i>) -> AsyncRewritingResult; + +pub struct TokenCapturer { + encoding: &'static Encoding, + text_decoder: TextDecoder, + capture_flags: TokenCaptureFlags, +} + +impl TokenCapturer { + pub fn new(capture_flags: TokenCaptureFlags, encoding: &'static Encoding) -> Self { + TokenCapturer { + encoding, + text_decoder: TextDecoder::new(encoding), + capture_flags, + } + } + + #[inline] + pub fn has_captures(&self) -> bool { + !self.capture_flags.is_empty() + } + + #[inline] + pub fn set_capture_flags(&mut self, flags: TokenCaptureFlags) { + self.capture_flags = flags; + } + + #[inline] + pub async fn flush_pending_text<'c>( + &'c mut self, + event_handler: CapturerEventHandler<'_, 'c>, + ) -> RewritingResult { + self.text_decoder.flush_pending(event_handler).await + } + + pub async fn feed<'i, 'l, 'c: 'l, T>( + &'c mut self, + lexeme: &'l Lexeme<'i, T>, + mut event_handler: impl FnMut(TokenCapturerEvent<'l>) -> AsyncRewritingResult, + ) -> RewritingResult + where + Lexeme<'i, T>: ToToken, + { + match lexeme.to_token(&mut self.capture_flags, self.encoding) { + ToTokenResult::Token(token) => { + self.flush_pending_text(&mut event_handler).await?; + event_handler(TokenCapturerEvent::LexemeConsumed).await?; + event_handler(TokenCapturerEvent::TokenProduced(token)).await + } + ToTokenResult::Text(text_type) => { + if self.capture_flags.contains(TokenCaptureFlags::TEXT) { + event_handler(TokenCapturerEvent::LexemeConsumed).await?; + + self.text_decoder + .feed_text(&lexeme.raw(), text_type, &mut event_handler) + .await?; + } + + Ok(()) + } + ToTokenResult::None => self.flush_pending_text(&mut event_handler).await, + } + } +} diff --git a/src/rewritable_units/tokens/capturer/text_decoder.rs b/src/rewritable_units/tokens/capturer/text_decoder.rs new file mode 100644 index 00000000..6e83d2e8 --- /dev/null +++ b/src/rewritable_units/tokens/capturer/text_decoder.rs @@ -0,0 +1,92 @@ +use super::*; +use crate::html::TextType; +use crate::rewriter::RewritingResult; +use encoding_rs::{CoderResult, Decoder, Encoding}; + +// NOTE: this can't be refactored into method, because we hold a mutable reference for `self` +// during the decoding loop in `feed_text`. +macro_rules! emit { + ($self:tt, $text:expr, $last:ident, $event_handler:ident) => {{ + let token = TextChunk::new_token($text, $self.last_text_type, $last, $self.encoding); + + $event_handler(TokenCapturerEvent::TokenProduced(Box::new(token))) + }}; +} + +pub struct TextDecoder { + encoding: &'static Encoding, + pending_text_streaming_decoder: Option, + text_buffer: String, + last_text_type: TextType, +} + +impl TextDecoder { + pub fn new(encoding: &'static Encoding) -> Self { + TextDecoder { + encoding, + pending_text_streaming_decoder: None, + // TODO make adjustable + text_buffer: String::from_utf8(vec![0u8; 1024]).unwrap(), + last_text_type: TextType::Data, + } + } + + #[inline] + pub async fn flush_pending<'d>( + &'d mut self, + event_handler: CapturerEventHandler<'_, 'd>, + ) -> RewritingResult { + if self.pending_text_streaming_decoder.is_some() { + self.decode_with_streaming_decoder(&[], true, event_handler) + .await?; + self.pending_text_streaming_decoder = None; + } + + Ok(()) + } + + async fn decode_with_streaming_decoder<'d>( + &'d mut self, + raw: &[u8], + last: bool, + event_handler: CapturerEventHandler<'_, 'd>, + ) -> RewritingResult { + let encoding = self.encoding; + let buffer = self.text_buffer.as_mut_str(); + + let decoder = self + .pending_text_streaming_decoder + .get_or_insert_with(|| encoding.new_decoder_without_bom_handling()); + + let mut consumed = 0; + + loop { + let (status, read, written, ..) = decoder.decode_to_str(&raw[consumed..], buffer, last); + + if written > 0 || last { + emit!(self, &buffer[..written], last, event_handler).await?; + } + + if let CoderResult::InputEmpty = status { + break; + } + + consumed += read; + } + + Ok(()) + } + + #[inline] + pub async fn feed_text<'d>( + &'d mut self, + raw: &[u8], + text_type: TextType, + event_handler: CapturerEventHandler<'_, 'd>, + ) -> RewritingResult { + self.last_text_type = text_type; + + self.decode_with_streaming_decoder(raw, false, event_handler) + .await + } +} diff --git a/src/rewritable_units/tokens/capturer/to_token.rs b/src/rewritable_units/tokens/capturer/to_token.rs new file mode 100644 index 00000000..ec3000d3 --- /dev/null +++ b/src/rewritable_units/tokens/capturer/to_token.rs @@ -0,0 +1,100 @@ +use super::*; +use crate::html::TextType; +use crate::parser::{NonTagContentLexeme, NonTagContentTokenOutline, TagLexeme, TagTokenOutline}; +use encoding_rs::Encoding; +use std::rc::Rc; + +pub enum ToTokenResult<'i> { + Token(Box>), + Text(TextType), + None, +} + +impl<'i> From> for ToTokenResult<'i> { + #[inline] + fn from(token: Token<'i>) -> Self { + ToTokenResult::Token(Box::new(token)) + } +} + +pub trait ToToken { + fn to_token( + &self, + capture_flags: &mut TokenCaptureFlags, + encoding: &'static Encoding, + ) -> ToTokenResult; +} + +impl ToToken for TagLexeme<'_> { + fn to_token( + &self, + capture_flags: &mut TokenCaptureFlags, + encoding: &'static Encoding, + ) -> ToTokenResult { + match *self.token_outline() { + TagTokenOutline::StartTag { + name, + ref attributes, + ns, + self_closing, + .. + } if capture_flags.contains(TokenCaptureFlags::NEXT_START_TAG) => { + // NOTE: clear the flag once we've seen required start tag. + capture_flags.remove(TokenCaptureFlags::NEXT_START_TAG); + + StartTag::new_token( + self.part(name), + Attributes::new(self.input(), Rc::clone(attributes), encoding), + ns, + self_closing, + self.raw(), + encoding, + ) + .into() + } + + TagTokenOutline::EndTag { name, .. } + if capture_flags.contains(TokenCaptureFlags::NEXT_END_TAG) => + { + // NOTE: clear the flag once we've seen required end tag. + capture_flags.remove(TokenCaptureFlags::NEXT_END_TAG); + + EndTag::new_token(self.part(name), self.raw(), encoding).into() + } + _ => ToTokenResult::None, + } + } +} + +impl ToToken for NonTagContentLexeme<'_> { + fn to_token( + &self, + capture_flags: &mut TokenCaptureFlags, + encoding: &'static Encoding, + ) -> ToTokenResult { + match *self.token_outline() { + Some(NonTagContentTokenOutline::Text(text_type)) => ToTokenResult::Text(text_type), + Some(NonTagContentTokenOutline::Comment(text)) + if capture_flags.contains(TokenCaptureFlags::COMMENTS) => + { + Comment::new_token(self.part(text), self.raw(), encoding).into() + } + + Some(NonTagContentTokenOutline::Doctype { + name, + public_id, + system_id, + force_quirks, + }) if capture_flags.contains(TokenCaptureFlags::DOCTYPES) => Doctype::new_token( + self.opt_part(name), + self.opt_part(public_id), + self.opt_part(system_id), + force_quirks, + self.raw(), + encoding, + ) + .into(), + _ => ToTokenResult::None, + } + } +} diff --git a/src/rewritable_units/tokens/mod.rs b/src/rewritable_units/tokens/mod.rs index 1ee07b8d..ce08f8d9 100644 --- a/src/rewritable_units/tokens/mod.rs +++ b/src/rewritable_units/tokens/mod.rs @@ -1,10 +1,11 @@ mod attributes; mod capturer; +use super::Mutations; + pub(super) use self::attributes::Attributes; pub use self::attributes::{Attribute, AttributeNameError}; pub use self::capturer::*; -use super::Mutations; pub trait Serialize { fn to_bytes(&self, output_handler: &mut dyn FnMut(&[u8])); diff --git a/src/rewriter/handlers_dispatcher.rs b/src/rewriter/handlers_dispatcher.rs index bdfa0158..28465329 100644 --- a/src/rewriter/handlers_dispatcher.rs +++ b/src/rewriter/handlers_dispatcher.rs @@ -64,13 +64,13 @@ impl HandlerVec { } #[inline] - pub fn for_each_active( + pub async fn for_each_active( &mut self, - mut cb: impl FnMut(&mut H) -> HandlerResult, + mut cb: impl FnMut(&mut H) -> AsyncHandlerResult, ) -> HandlerResult { for item in self.items.iter_mut() { if item.user_count > 0 { - cb(&mut item.handler)?; + cb(&mut item.handler).await?; } } @@ -78,13 +78,13 @@ impl HandlerVec { } #[inline] - pub fn do_for_each_active_and_deactivate( + pub async fn do_for_each_active_and_deactivate( &mut self, - mut cb: impl FnMut(&mut H) -> HandlerResult, + mut cb: impl FnMut(&mut H) -> AsyncHandlerResult, ) -> HandlerResult { for item in self.items.iter_mut() { if item.user_count > 0 { - cb(&mut item.handler)?; + cb(&mut item.handler).await?; self.user_count -= item.user_count; item.user_count = 0; } @@ -94,9 +94,9 @@ impl HandlerVec { } #[inline] - pub fn do_for_each_active_and_remove( + pub async fn do_for_each_active_and_remove( &mut self, - mut cb: impl FnMut(H) -> HandlerResult, + mut cb: impl FnMut(H) -> AsyncHandlerResult, ) -> HandlerResult { for i in (0..self.items.len()).rev() { if self.items[i].user_count > 0 { @@ -104,7 +104,7 @@ impl HandlerVec { self.user_count -= item.user_count; - cb(item.handler)?; + cb(item.handler).await?; } } @@ -207,9 +207,9 @@ impl<'h> ContentHandlersDispatcher<'h> { } } - pub fn handle_start_tag( + pub async fn handle_start_tag( &mut self, - start_tag: &mut StartTag, + start_tag: &mut StartTag<'_>, current_element_data: Option<&mut ElementDescriptor>, ) -> HandlerResult { if self.matched_elements_with_removed_content > 0 { @@ -219,7 +219,8 @@ impl<'h> ContentHandlersDispatcher<'h> { let mut element = Element::new(start_tag, self.next_element_can_have_content); self.element_handlers - .do_for_each_active_and_deactivate(|h| h(&mut element))?; + .do_for_each_active_and_deactivate(|h| h(&mut element)) + .await?; if self.next_element_can_have_content { if let Some(elem_desc) = current_element_data { @@ -239,19 +240,23 @@ impl<'h> ContentHandlersDispatcher<'h> { Ok(()) } - pub fn handle_token( + pub async fn handle_token( &mut self, - token: &mut Token, + token: &mut Token<'_>, current_element_data: Option<&mut ElementDescriptor>, ) -> HandlerResult { match token { - Token::Doctype(doctype) => self.doctype_handlers.for_each_active(|h| h(doctype)), - Token::StartTag(start_tag) => self.handle_start_tag(start_tag, current_element_data), - Token::EndTag(end_tag) => self - .end_tag_handlers - .do_for_each_active_and_remove(|h| h(end_tag)), - Token::TextChunk(text) => self.text_handlers.for_each_active(|h| h(text)), - Token::Comment(comment) => self.comment_handlers.for_each_active(|h| h(comment)), + Token::Doctype(doctype) => self.doctype_handlers.for_each_active(|h| h(doctype)).await, + Token::StartTag(start_tag) => { + self.handle_start_tag(start_tag, current_element_data).await + } + Token::EndTag(end_tag) => { + self.end_tag_handlers + .do_for_each_active_and_remove(|h| h(end_tag)) + .await + } + Token::TextChunk(text) => self.text_handlers.for_each_active(|h| h(text)).await, + Token::Comment(comment) => self.comment_handlers.for_each_active(|h| h(comment)).await, } } diff --git a/src/rewriter/mod.rs b/src/rewriter/mod.rs index c274fa11..1256be72 100644 --- a/src/rewriter/mod.rs +++ b/src/rewriter/mod.rs @@ -12,6 +12,7 @@ use crate::parser::ParsingAmbiguityError; use crate::selectors_vm::{self, SelectorMatchingVm}; use crate::transform_stream::*; use encoding_rs::Encoding; +use futures::future::LocalBoxFuture; use std::error::Error as StdError; use std::fmt::{self, Debug}; use std::rc::Rc; @@ -75,6 +76,9 @@ pub enum RewritingError { ContentHandlerError(Box), } +pub type RewritingResult = Result<(), RewritingError>; +pub type AsyncRewritingResult<'f> = LocalBoxFuture<'f, RewritingResult>; + /// A streaming HTML rewriter. /// /// # Example diff --git a/src/rewriter/rewrite_controller.rs b/src/rewriter/rewrite_controller.rs index 1feda9bc..5ef44d33 100644 --- a/src/rewriter/rewrite_controller.rs +++ b/src/rewriter/rewrite_controller.rs @@ -1,9 +1,10 @@ use super::handlers_dispatcher::{ContentHandlersDispatcher, SelectorHandlersLocator}; -use super::RewritingError; +use super::{RewritingError, RewritingResult}; use crate::html::{LocalName, Namespace}; use crate::rewritable_units::{Token, TokenCaptureFlags}; use crate::selectors_vm::{AuxStartTagInfoRequest, ElementData, SelectorMatchingVm, VmError}; use crate::transform_stream::*; +use async_trait::async_trait; use std::cell::RefCell; use std::collections::HashSet; use std::rc::Rc; @@ -77,6 +78,7 @@ impl<'h> HtmlRewriteController<'h> { } } +#[async_trait(?Send)] impl TransformController for HtmlRewriteController<'_> { #[inline] fn initial_capture_flags(&self) -> TokenCaptureFlags { @@ -119,7 +121,7 @@ impl TransformController for HtmlRewriteController<'_> { } #[inline] - fn handle_token(&mut self, token: &mut Token) -> Result<(), RewritingError> { + async fn handle_token(&mut self, token: &mut Token<'_>) -> RewritingResult { let current_element_data = self .selector_matching_vm .as_mut() @@ -128,6 +130,7 @@ impl TransformController for HtmlRewriteController<'_> { self.handlers_dispatcher .borrow_mut() .handle_token(token, current_element_data) + .await .map_err(RewritingError::ContentHandlerError) } diff --git a/src/rewriter/settings.rs b/src/rewriter/settings.rs index 61828954..b284c2c8 100644 --- a/src/rewriter/settings.rs +++ b/src/rewriter/settings.rs @@ -1,13 +1,16 @@ use crate::rewritable_units::{Comment, Doctype, Element, EndTag, TextChunk}; use crate::selectors_vm::Selector; +use futures::future::LocalBoxFuture; use std::error::Error; pub(super) type HandlerResult = Result<(), Box>; -pub type DoctypeHandler<'h> = Box HandlerResult + 'h>; -pub type CommentHandler<'h> = Box HandlerResult + 'h>; -pub type TextHandler<'h> = Box HandlerResult + 'h>; -pub type ElementHandler<'h> = Box HandlerResult + 'h>; -pub type EndTagHandler<'h> = Box HandlerResult + 'h>; +pub(super) type AsyncHandlerResult = LocalBoxFuture<'static, HandlerResult>; + +pub type DoctypeHandler<'h> = Box AsyncHandlerResult + 'h>; +pub type CommentHandler<'h> = Box AsyncHandlerResult + 'h>; +pub type TextHandler<'h> = Box AsyncHandlerResult + 'h>; +pub type ElementHandler<'h> = Box AsyncHandlerResult + 'h>; +pub type EndTagHandler<'h> = Box AsyncHandlerResult + 'h>; /// Specifies element content handlers associated with a selector. #[derive(Default)] @@ -20,7 +23,7 @@ pub struct ElementContentHandlers<'h> { impl<'h> ElementContentHandlers<'h> { /// Sets a handler for elements matched by a selector. #[inline] - pub fn element(mut self, handler: impl FnMut(&mut Element) -> HandlerResult + 'h) -> Self { + pub fn element(mut self, handler: impl FnMut(&mut Element) -> AsyncHandlerResult + 'h) -> Self { self.element = Some(Box::new(handler)); self @@ -28,7 +31,10 @@ impl<'h> ElementContentHandlers<'h> { /// Sets a handler for HTML comments in the inner content of elements matched by a selector. #[inline] - pub fn comments(mut self, handler: impl FnMut(&mut Comment) -> HandlerResult + 'h) -> Self { + pub fn comments( + mut self, + handler: impl FnMut(&mut Comment) -> AsyncHandlerResult + 'h, + ) -> Self { self.comments = Some(Box::new(handler)); self @@ -36,7 +42,7 @@ impl<'h> ElementContentHandlers<'h> { /// Sets a handler for text chunks in the inner content of elements matched by a selector. #[inline] - pub fn text(mut self, handler: impl FnMut(&mut TextChunk) -> HandlerResult + 'h) -> Self { + pub fn text(mut self, handler: impl FnMut(&mut TextChunk) -> AsyncHandlerResult + 'h) -> Self { self.text = Some(Box::new(handler)); self @@ -70,7 +76,7 @@ impl<'h> DocumentContentHandlers<'h> { /// /// [document type declaration]: https://developer.mozilla.org/en-US/docs/Glossary/Doctype #[inline] - pub fn doctype(mut self, handler: impl FnMut(&mut Doctype) -> HandlerResult + 'h) -> Self { + pub fn doctype(mut self, handler: impl FnMut(&mut Doctype) -> AsyncHandlerResult + 'h) -> Self { self.doctype = Some(Box::new(handler)); self @@ -78,7 +84,10 @@ impl<'h> DocumentContentHandlers<'h> { /// Sets a handler for all HTML comments present in the input HTML markup. #[inline] - pub fn comments(mut self, handler: impl FnMut(&mut Comment) -> HandlerResult + 'h) -> Self { + pub fn comments( + mut self, + handler: impl FnMut(&mut Comment) -> AsyncHandlerResult + 'h, + ) -> Self { self.comments = Some(Box::new(handler)); self @@ -86,7 +95,7 @@ impl<'h> DocumentContentHandlers<'h> { /// Sets a handler for all text chunks present in the input HTML markup. #[inline] - pub fn text(mut self, handler: impl FnMut(&mut TextChunk) -> HandlerResult + 'h) -> Self { + pub fn text(mut self, handler: impl FnMut(&mut TextChunk) -> AsyncHandlerResult + 'h) -> Self { self.text = Some(Box::new(handler)); self diff --git a/src/selectors_vm/compiler.rs b/src/selectors_vm/compiler.rs index 29bde1ad..d5014773 100644 --- a/src/selectors_vm/compiler.rs +++ b/src/selectors_vm/compiler.rs @@ -795,7 +795,10 @@ mod tests { r#"#foo1.c1.c2[foo3][foo2$="barЫ"]"#, encoding, &[ - ("
", true), + ( + "
", + true, + ), ( "
", true, @@ -821,7 +824,10 @@ mod tests { r#"div#foo1.c1.c2[foo3੦][foo2$="bar"]"#, encoding, &[ - ("
", true), + ( + "
", + true, + ), ( "", false, diff --git a/src/selectors_vm/mod.rs b/src/selectors_vm/mod.rs index 3ab99a60..9e6efb9e 100644 --- a/src/selectors_vm/mod.rs +++ b/src/selectors_vm/mod.rs @@ -1482,5 +1482,4 @@ mod tests { } ); } - } diff --git a/src/selectors_vm/stack.rs b/src/selectors_vm/stack.rs index 1c5f26e4..0e58928d 100644 --- a/src/selectors_vm/stack.rs +++ b/src/selectors_vm/stack.rs @@ -1,6 +1,6 @@ use super::program::AddressRange; -use crate::memory::{MemoryLimitExceededError, LimitedVec, SharedMemoryLimiter}; use crate::html::{LocalName, Namespace, Tag}; +use crate::memory::{LimitedVec, MemoryLimitExceededError, SharedMemoryLimiter}; use std::collections::HashSet; use std::fmt::Debug; use std::hash::Hash; diff --git a/src/transform_stream/dispatcher.rs b/src/transform_stream/dispatcher.rs index 5c7b2e8f..c911c6ef 100644 --- a/src/transform_stream/dispatcher.rs +++ b/src/transform_stream/dispatcher.rs @@ -8,7 +8,8 @@ use crate::parser::{ use crate::rewritable_units::{ Serialize, ToToken, Token, TokenCaptureFlags, TokenCapturer, TokenCapturerEvent, }; -use crate::rewriter::RewritingError; +use crate::rewriter::{RewritingError, RewritingResult}; +use async_trait::async_trait; use encoding_rs::Encoding; use std::rc::Rc; @@ -30,11 +31,12 @@ pub enum DispatcherError { pub type StartTagHandlingResult = Result>; +#[async_trait(?Send)] pub trait TransformController: Sized { fn initial_capture_flags(&self) -> TokenCaptureFlags; fn handle_start_tag(&mut self, name: LocalName, ns: Namespace) -> StartTagHandlingResult; fn handle_end_tag(&mut self, name: LocalName) -> TokenCaptureFlags; - fn handle_token(&mut self, token: &mut Token) -> Result<(), RewritingError>; + async fn handle_token(&mut self, token: &mut Token<'_>) -> RewritingResult; fn should_emit_content(&self) -> bool; } @@ -109,10 +111,10 @@ where self.output_sink.handle_chunk(&[]); } - fn try_produce_token_from_lexeme<'i, T>( + async fn try_produce_token_from_lexeme<'i, T>( &mut self, lexeme: &Lexeme<'i, T>, - ) -> Result<(), RewritingError> + ) -> RewritingResult where Lexeme<'i, T>: ToToken, { @@ -123,32 +125,38 @@ where let remaining_content_start = self.remaining_content_start; let mut lexeme_consumed = false; - self.token_capturer.feed(lexeme, |event| { - match event { - TokenCapturerEvent::LexemeConsumed => { - let chunk = lexeme.input().slice(Range { - start: remaining_content_start, - end: lexeme_range.start, - }); + self.token_capturer + .feed( + lexeme, + async_closure!(|event| { + match event { + TokenCapturerEvent::LexemeConsumed => { + let chunk = lexeme.input().slice(Range { + start: remaining_content_start, + end: lexeme_range.start, + }); + + lexeme_consumed = true; + + if emission_enabled && chunk.len() > 0 { + output_sink.handle_chunk(&chunk); + } + } + TokenCapturerEvent::TokenProduced(mut token) => { + trace!(@output token); - lexeme_consumed = true; + transform_controller.handle_token(&mut token).await?; - if emission_enabled && chunk.len() > 0 { - output_sink.handle_chunk(&chunk); + if emission_enabled { + token.to_bytes(&mut |c| output_sink.handle_chunk(c)); + } + } } - } - TokenCapturerEvent::TokenProduced(mut token) => { - trace!(@output token); - transform_controller.handle_token(&mut token)?; - - if emission_enabled { - token.to_bytes(&mut |c| output_sink.handle_chunk(c)); - } - } - } - Ok(()) - })?; + Ok(()) + }), + ) + .await?; if lexeme_consumed { self.remaining_content_start = lexeme_range.end; diff --git a/tests/harness/mod.rs b/tests/harness/mod.rs index 324a156e..0599d47d 100644 --- a/tests/harness/mod.rs +++ b/tests/harness/mod.rs @@ -76,4 +76,4 @@ macro_rules! test_modules { tests } }; -} \ No newline at end of file +} diff --git a/tests/harness/suites/html5lib_tests/mod.rs b/tests/harness/suites/html5lib_tests/mod.rs index cfb20c71..75b0125e 100644 --- a/tests/harness/suites/html5lib_tests/mod.rs +++ b/tests/harness/suites/html5lib_tests/mod.rs @@ -6,9 +6,9 @@ mod unescape; pub use self::unescape::Unescape; use super::for_each_test_file; use crate::harness::Input; +use cool_thing::test_utils::ASCII_COMPATIBLE_ENCODINGS; use serde_json::{self, from_reader}; use std::fmt::Write; -use cool_thing::test_utils::ASCII_COMPATIBLE_ENCODINGS; pub use self::test_token::{TestToken, TestTokenList}; diff --git a/tests/harness/suites/selectors_tests.rs b/tests/harness/suites/selectors_tests.rs index 8bea7cb0..243c0ab1 100644 --- a/tests/harness/suites/selectors_tests.rs +++ b/tests/harness/suites/selectors_tests.rs @@ -1,10 +1,10 @@ use super::{for_each_test_file, get_test_file_reader}; use crate::harness::Input; +use cool_thing::test_utils::ASCII_COMPATIBLE_ENCODINGS; use cool_thing::Selector; use serde_json::{self, from_reader}; use std::collections::HashMap; use std::io::prelude::*; -use cool_thing::test_utils::ASCII_COMPATIBLE_ENCODINGS; fn read_test_file(suite: &'static str, name: &str) -> String { let mut data = String::new();