diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:19 +0000 |
commit | a0b8f38ab54ac451646aa00cd5e91b6c76f22a84 (patch) | |
tree | fc451898ccaf445814e26b46664d78702178101d /vendor/flate2 | |
parent | Adding debian version 1.71.1+dfsg1-2. (diff) | |
download | rustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.tar.xz rustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/flate2')
48 files changed, 259 insertions, 167 deletions
diff --git a/vendor/flate2/.cargo-checksum.json b/vendor/flate2/.cargo-checksum.json index 287b01bdb..28ab25882 100644 --- a/vendor/flate2/.cargo-checksum.json +++ b/vendor/flate2/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.lock":"a70316ff2059a2809363ab44ebe3e80f443b5127bc772750313869381e349863","Cargo.toml":"4e65bf00fbe95389960ae6b847fa84f600405c620b53fe5b51b5862330f326d0","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"b9fa7ea44625cd15b942c9ae748f8f35197f9c19f5deb7087a5fc115064d19d3","examples/compress_file.rs":"65cac39f50420861cb86120b0e7edce4704eb5afd1e27f790a66b8138176fc4d","examples/deflatedecoder-bufread.rs":"59aaa1dcf999da7909ea0a01bef757b80e366f8adf60984cc2e2c70acc774e1a","examples/deflatedecoder-read.rs":"7784b03156600d9a0efadb830920439a8a8f7fe70250090ee8c637033c1338eb","examples/deflatedecoder-write.rs":"6e6952cef15adbf465d4985802d315a3b51f3137be36e62bbcaed0bb27a8d5a6","examples/deflateencoder-bufread.rs":"0cefcb1edef04834e684c9c3d4048a32c7831617e51a102a7bd6a7351d4799be","examples/deflateencoder-read.rs":"d1718c60bb527a2ca15fd208e22c1df51ed972ea48b9d506536635effdbc4847","examples/deflateencoder-write.rs":"79203d1db1128df2a3fa5cbd61d60776e02959c4da67a473f3b96dfb5f01f964","examples/gzbuilder.rs":"e7435090c86db3133d19f7a2bfb7d49bb60ebbd1e0acaf74c2d0d27375d0c41d","examples/gzdecoder-bufread.rs":"8ad927ad5761e4b31bec5c2b4e5429dd9370e25f35be6e60a29149ed834c97a1","examples/gzdecoder-read.rs":"e63ae23a6188ab9831758178a86a36b8693de27e291725d2d5274df4cb93566c","examples/gzdecoder-write.rs":"a8843c75fa725de84b8eb75b08525e61586f60f9f8bfd874fbfd44039d119c5f","examples/gzencoder-bufread.rs":"aaad311ad799c2e739b58fc4e570225d8f52d3bc407f9c71c28023b321e02100","examples/gzencoder-read.rs":"797522cd3d5815321bbb5c26fdfeae027807219e429e36a1b99fff50fcdf0a64","examples/gzencoder-write.rs":"2eea8a8c8bf22f060d8749d786835ce9454abe2cfd24bf0f7a23b5a8d1030121","examples/gzmultidecoder-bufread.rs":"1e4b31da4f1352e748b4516ba60dcd52e5d5e62733fa1c8e7da7bee4efcce1c4","examples/gzmultidecoder-read.rs":"3976274ac8b8190b3f7ed9fd855a193c38458bd40a2dba6a7de21986f78682f6","examples/hello_world.txt":"d2a84f4b8b650937ec8f73cd8be2c74add5a911ba64df27458ed8229da804a26","examples/zlibdecoder-bufread.rs":"e57a597030e6bd87e79329d87b3743b7fb0ff4c217846b0ba2c2d32264208ff1","examples/zlibdecoder-read.rs":"83b3abd1c12586f820d55e4d86c328fdccbdec963e90c44a44cd7d5f1caa4c8f","examples/zlibdecoder-write.rs":"e7cbec46414eb5d67fee95bf1e4a4e6a1ba2a41f4ce9542dd4481035d3f8070d","examples/zlibencoder-bufread.rs":"13d79baeffb6080b4b4f837e23092b52b92b85466ed9e42b0a33a864232e693f","examples/zlibencoder-read.rs":"7f95783b38e0005740f05dbcc03af3bbf28dfe7c9f0542d3fb015d09554163bd","examples/zlibencoder-write.rs":"47c25fb6711e22f95bdc89309c6e367d1060a0120d4259011e97908563e2b8bc","src/bufreader.rs":"2d6a59330e8f838eb6474d19104f21cb98236125c189f36bdff75a069a4cea8f","src/crc.rs":"bfc96a0df325e8fb0005b008a52f1227546c2a4f72f422d4dd40769a8317eb37","src/deflate/bufread.rs":"7dd1c1a5a74abbf32537285c286551c20b3ed62c99e28a67b7d4d7eaeee73570","src/deflate/mod.rs":"ebaa68e75d0c7470c7a2afd7af0f8cc5413654f7c35ac1cb6af3df0144eeb2cf","src/deflate/read.rs":"dc0d080b0a4ab3aa3f2870b69f7cb5380e49baab4eb5fdfe98f7a0a9fb6b32b9","src/deflate/write.rs":"fef4deebc0dc29d4ad481718613c694f6d1b733199e241a1f7f064e2707e4908","src/ffi/c.rs":"387bba48532bb90f13b38f685f68c0e0b3bb2b3a84e6e915abb2fd571ce9c1e9","src/ffi/mod.rs":"d90bfe6150d905c06755a3bf9355be69a7ffb664ca701d51ee1ffe93229abee1","src/ffi/rust.rs":"235cf72391d4077b569f88854b6468e371c19c417b4815468070e155268d83dd","src/gz/bufread.rs":"62881dd14a736cf5fc3d5006e83afd6e5462808f4e8eeb5844ae07d67ad28f16","src/gz/mod.rs":"77d10acd6e923f35cc6434e70cc33002006a8cf5923ebb3105531d4f05542327","src/gz/read.rs":"275150a42ae3a39cc56a83ef212bffce32c74eae1bc6ede33945370bb555ad4d","src/gz/write.rs":"41b9c738bcf64dec44cef591b42e1cb5ef0316aa33d621816fbdd5484e51037b","src/lib.rs":"a1cdcc834b6cc7e470c397578142eca0872840ceb594603264b0aa92b73b94fa","src/mem.rs":"e66a546c83c723dc13320f791de5f43f6683f5549e6d8d0e53fda6108762cc8a","src/zio.rs":"066238023d9c931498d996b6bcd135ba58bc9e916dbaaeddec26a20ad07c698e","src/zlib/bufread.rs":"2c6440dd8958469bb07644a50d3170988a5d75f17788d5bfbf03adfd30e50f4a","src/zlib/mod.rs":"fffaea011fc774756f5392cffb1d2d06c05767e7bbbe306fa5fbe95108b9b06b","src/zlib/read.rs":"11dc6a4072b5d99490f7e5ea8eca9da67b4e77981b05eb3ed56067caaffb3a27","src/zlib/write.rs":"330d6ebe93939c8a045c72fb2c8106bfad92e0ed80c60f729ebba40d11090338","tests/corrupt-gz-file.bin":"083dd284aa1621916a2d0f66ea048c8d3ba7a722b22d0d618722633f51e7d39c","tests/early-flush.rs":"5ed4b0f8e66cab9209e079d5636e5f1b780606cd553a182c809cf73a24e77e8e","tests/empty-read.rs":"45477d316f77a048d747e9d18292abfec0cac667768385c8a061e18fd1240238","tests/good-file.gz":"87296963e53024a74752179ce7e54087565d358a85d3e65c3b37ef36eaa3d4a6","tests/good-file.txt":"bc4e03658a441fe2ad2df7cd2197144b87e41696f01e327b380e869cd9b485a0","tests/gunzip.rs":"a67f2e2dc2e6fbdc42f9ea003eae70f862478a5226d961658b30c8c7928fb7f5","tests/multi.gz":"efa3341da052f95056314cc6920e02a3da15bdef30234b2552fb407812db5cc6","tests/multi.txt":"dbea9325179efe46ea2add94f7b6b745ca983fabb208dc6d34aa064623d7ee23","tests/zero-write.rs":"ff8d0349a540b54363c55807c5fd7fbbdc363d08a536d35a3a40f0ce92c16489"},"package":"a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841"}
\ No newline at end of file +{"files":{"Cargo.lock":"0a017c2f667f52674287c7fa4fdebf43b6916f3df7d3f1d2e3b846fd8e2deaab","Cargo.toml":"59957475135594c9cc8a3f386d19e16badc96ae18947feb0c8ea9f46b0c92247","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"66e58be9308956987363ebbbea391ca48010bc1d87c738a56acac1aced940281","examples/compress_file.rs":"cbdb8b0c556409b82f894ad5326babb6dba42c219d2d675927e7f5820053b295","examples/decompress_file.rs":"cd50dfbaccc905b3e02d6c50b26586196a682880203a8694343e0391799b70d5","examples/deflatedecoder-bufread.rs":"5b8abebce157f9b7cc3f6b5c90b9d533890a514e5f8d91bb43439f52fdc9ddce","examples/deflatedecoder-read.rs":"921e13031c5436494d8af0a8705a0adda2da536edefef2e1e311dffa8acd120f","examples/deflatedecoder-write.rs":"cfce37e8758c6d543dd130c7bdff571af3c8cd11bafcc933740107a3576832df","examples/deflateencoder-bufread.rs":"9fdd7d632d861f099d19a3ec1de539d9600f8004a119dd2a70f6aba5965b2e1c","examples/deflateencoder-read.rs":"8740a942ec7d07ccb4b57c5baac7a4d649817bffe4e37ce9a06c7d6d70378e4c","examples/deflateencoder-write.rs":"8e45425684b2368ef95f3704dce6f8077f38b9a90a38d147594c7c570f0d1c6c","examples/gzbuilder.rs":"d09c83417e4a01a8593ce3462a33340e6fe17fa51b4b0b3a6005b68959df4d8c","examples/gzdecoder-bufread.rs":"76880f3e6e10ed4a0bf564be9ddae1c50811aeabf61fb573039538b81805f390","examples/gzdecoder-read.rs":"d99e9a9ce03a27f280244a24e8f5a3282e5af15b455270d99c4bfecd19238d0d","examples/gzdecoder-write.rs":"d0a982377ca1d2fd1786bb32f16454b4f0afdba5e1c7f0ab97e15e8827d351d5","examples/gzencoder-bufread.rs":"760670c124b1c5776b63c300c7e8a1dcd5e0ae633017dcf2e3d2d6e997dcc9c4","examples/gzencoder-read.rs":"27ec68675418bb7d1a110b8d1f33e7b1069f42bcce6f21f8d9235bde405cdf9f","examples/gzencoder-write.rs":"f127f2e398231d03269770fa18ac5d465f8d56d283f1118055f04f1d03369c31","examples/gzmultidecoder-bufread.rs":"bfa6c5554c3da5a61a7d1e1dad115b7ee784d136e2ac61272c87ad3e1eb4ec4c","examples/gzmultidecoder-read.rs":"c058d5eee5bf45b38132f8e487a714c9521191c7dabe2459362d2f8de689c6bf","examples/hello_world.txt":"d2a84f4b8b650937ec8f73cd8be2c74add5a911ba64df27458ed8229da804a26","examples/hello_world.txt.gz":"8b4c5972b92b8ee8dc99116e278afb9165276ddb13c0d334c8da2770fd4d1f7d","examples/zlibdecoder-bufread.rs":"0f541ec64c635d45fc206a02718c0b90c49123a0441a95455d6a8a9e0d20e011","examples/zlibdecoder-read.rs":"bbd85b47b8b804c3294b3f23f978eaf6fb09a187cb46eb86ae1ae2790dfab8d9","examples/zlibdecoder-write.rs":"f347a831d7201d3efd604b006c88421fa2a5906c6377b47c7ae391d0809186e6","examples/zlibencoder-bufread.rs":"e0e05686ad4521ba18b742a5cbbc5937cec1fd8b9e8313070b32c6f178dfbaf6","examples/zlibencoder-read.rs":"4a3156dc73cd77e6ac56700680652be63a1270d95ce384ebcd5c014cce2d5179","examples/zlibencoder-write.rs":"822d4cd326ac7402ff8f828c1dbb3aa108c68a89fc04488da252ca6a74e624b0","src/bufreader.rs":"2d6a59330e8f838eb6474d19104f21cb98236125c189f36bdff75a069a4cea8f","src/crc.rs":"f02b9ffbedf06360c8164f98ecf51fe7f70c48cdb3bfc72e176421419c1de030","src/deflate/bufread.rs":"76af1e22d74571304f7a632751bf80ad946808ff516138696cc6b3d6c586529b","src/deflate/mod.rs":"d33ef6a3d502d599a4ba6ac99c6312b414002dba43c388d271fc1f8c9c609363","src/deflate/read.rs":"bfaf1b5b86bfd2255095cd8de27142e6ea8eec1432e1cd8448121f42a638fb10","src/deflate/write.rs":"fef4deebc0dc29d4ad481718613c694f6d1b733199e241a1f7f064e2707e4908","src/ffi/c.rs":"f564f9b27278e770006ffda9b078a6a9f5219ffd3fbbc9e315c27bc134b0c32f","src/ffi/mod.rs":"d90bfe6150d905c06755a3bf9355be69a7ffb664ca701d51ee1ffe93229abee1","src/ffi/rust.rs":"0a69aac9bd08728d212f503a16c0e7fb64a7822a7531bc3a96e78c89c09b6e80","src/gz/bufread.rs":"bb126633df2e56c5dad1871a056e25acb340dd024a94c9aa692b9f0cc44d6f08","src/gz/mod.rs":"367225fd0cc69f8234966c40340869b7bed869217e344d7385ca0316818258fc","src/gz/read.rs":"5f40c51bc4deb866552bdb65fffcc2d85384774d7d829c192600c8eb3970d849","src/gz/write.rs":"783834209030bf20598732f87a6b9aac0f76be1333436f15c8b349cb9ba0f579","src/lib.rs":"875426503cd8c1c70c45e7ff5b5cf58c46bd2ca396ce3b6495a99f6c5540ab15","src/mem.rs":"e563f95d7ab3343b4c86c968c8810b96d74d8cf7612818dd60cd1f6bc4f63eb3","src/zio.rs":"ed5f375f5d6c4f094dfdd43185c9af5e91d1129bfbfa31edc6902a1f7496920b","src/zlib/bufread.rs":"51abcf514cb4108d37e509f37d16cbcc0d061f98e3a5820a0a9cc027642dde37","src/zlib/mod.rs":"18ea5785b913d90191c6ad8483f57d0c5f98599137659e72f3c0c78324b4f8fa","src/zlib/read.rs":"6c4c15b154bda74bc11345ac6a32da7faf1b42113c4e2d41e99eed96fed200f4","src/zlib/write.rs":"330d6ebe93939c8a045c72fb2c8106bfad92e0ed80c60f729ebba40d11090338","tests/corrupt-gz-file.bin":"083dd284aa1621916a2d0f66ea048c8d3ba7a722b22d0d618722633f51e7d39c","tests/early-flush.rs":"9a4db8fcbac659c52cafe5e1ab647d86781cf8b1f298d8dee34223c0292e0d74","tests/empty-read.rs":"39143ff0383655bb115e995b2a953f11e82d0ac03b4bec080973be7c2d421054","tests/good-file.gz":"87296963e53024a74752179ce7e54087565d358a85d3e65c3b37ef36eaa3d4a6","tests/good-file.txt":"bc4e03658a441fe2ad2df7cd2197144b87e41696f01e327b380e869cd9b485a0","tests/gunzip.rs":"c00946db2147b23c4300c77fedf0a04e65c774101575e9828433831311416a50","tests/multi.gz":"efa3341da052f95056314cc6920e02a3da15bdef30234b2552fb407812db5cc6","tests/multi.txt":"dbea9325179efe46ea2add94f7b6b745ca983fabb208dc6d34aa064623d7ee23","tests/zero-write.rs":"cde1a675491d88e59a711103d3b0df4c77b60e8152b90d5a4f01b97879f8f8dc"},"package":"3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743"}
\ No newline at end of file diff --git a/vendor/flate2/Cargo.lock b/vendor/flate2/Cargo.lock index 5389eecb0..26edba2bf 100644 --- a/vendor/flate2/Cargo.lock +++ b/vendor/flate2/Cargo.lock @@ -10,9 +10,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "cc" -version = "1.0.77" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" [[package]] name = "cfg-if" @@ -31,9 +31,9 @@ dependencies = [ [[package]] name = "cmake" -version = "0.1.49" +version = "0.1.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db34956e100b30725f2eb215f90d4871051239535632f84fea3bc92722c66b7c" +checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a" dependencies = [ "cc", ] @@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.25" +version = "1.0.26" dependencies = [ "cloudflare-zlib-sys", "crc32fast", @@ -62,9 +62,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ "cfg-if", "libc", @@ -73,9 +73,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.137" +version = "0.2.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" +checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" [[package]] name = "libz-ng-sys" @@ -102,24 +102,24 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.6.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", ] [[package]] name = "pkg-config" -version = "0.3.26" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "quickcheck" @@ -153,9 +153,9 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.4" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ "getrandom", ] @@ -168,6 +168,6 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" diff --git a/vendor/flate2/Cargo.toml b/vendor/flate2/Cargo.toml index 68516e5e7..1cc1577d3 100644 --- a/vendor/flate2/Cargo.toml +++ b/vendor/flate2/Cargo.toml @@ -12,7 +12,7 @@ [package] edition = "2018" name = "flate2" -version = "1.0.25" +version = "1.0.26" authors = [ "Alex Crichton <alex@alexcrichton.com>", "Josh Triplett <josh@joshtriplett.org>", @@ -39,6 +39,13 @@ categories = [ license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/flate2-rs" +[package.metadata.docs.rs] +all-features = true +rustdoc-args = [ + "--cfg", + "docsrs", +] + [dependencies.cloudflare-zlib-sys] version = "0.3.0" optional = true @@ -56,7 +63,7 @@ optional = true default-features = false [dependencies.miniz_oxide] -version = "0.6.0" +version = "0.7.1" features = ["with-alloc"] optional = true default-features = false @@ -81,6 +88,10 @@ zlib = [ "any_zlib", "libz-sys", ] +zlib-default = [ + "any_zlib", + "libz-sys/default", +] zlib-ng = [ "any_zlib", "libz-ng-sys", @@ -91,6 +102,6 @@ zlib-ng-compat = [ ] [target."cfg(all(target_arch = \"wasm32\", not(target_os = \"emscripten\")))".dependencies.miniz_oxide] -version = "0.6.0" +version = "0.7.1" features = ["with-alloc"] default-features = false diff --git a/vendor/flate2/README.md b/vendor/flate2/README.md index d4763a458..7e7239a6d 100644 --- a/vendor/flate2/README.md +++ b/vendor/flate2/README.md @@ -21,6 +21,12 @@ Supported formats: flate2 = "1.0" ``` +## MSRV (Minimum Supported Rust Version) Policy + +This crate supports the current stable and the last stable for the latest version. +For example, if the current stable is 1.64, this crate supports 1.64 and 1.63. +Older stables may work, but we don't guarantee these will continue to work. + ## Compression ```rust diff --git a/vendor/flate2/examples/compress_file.rs b/vendor/flate2/examples/compress_file.rs index 39ed8eed4..be4b81e69 100644 --- a/vendor/flate2/examples/compress_file.rs +++ b/vendor/flate2/examples/compress_file.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::write::GzEncoder; use flate2::Compression; use std::env::args; diff --git a/vendor/flate2/examples/decompress_file.rs b/vendor/flate2/examples/decompress_file.rs new file mode 100644 index 000000000..6b2ede95c --- /dev/null +++ b/vendor/flate2/examples/decompress_file.rs @@ -0,0 +1,23 @@ +use flate2::bufread; +use std::env::args; +use std::fs::File; +use std::io::copy; +use std::io::BufReader; +use std::time::Instant; + +fn main() { + // E.g. `cargo run --example decompress_file examples/hello_world.txt.gz hello_world.txt` + if args().len() != 3 { + eprintln!("Usage: ./decompress_file `source` `target`"); + return; + } + let input = BufReader::new(File::open(args().nth(1).unwrap()).unwrap()); + let mut output = File::create(args().nth(2).unwrap()).unwrap(); + let source_len = input.get_ref().metadata().unwrap().len(); + let start = Instant::now(); + let mut decoder = bufread::GzDecoder::new(input); + copy(&mut decoder, &mut output).unwrap(); + println!("Source len: {:?}", source_len); + println!("Target len: {:?}", output.metadata().unwrap().len()); + println!("Elapsed: {:?}", start.elapsed()); +} diff --git a/vendor/flate2/examples/deflatedecoder-bufread.rs b/vendor/flate2/examples/deflatedecoder-bufread.rs index 7d1cb6fd9..6b8e7fea1 100644 --- a/vendor/flate2/examples/deflatedecoder-bufread.rs +++ b/vendor/flate2/examples/deflatedecoder-bufread.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::bufread::DeflateDecoder; use flate2::write::DeflateEncoder; use flate2::Compression; diff --git a/vendor/flate2/examples/deflatedecoder-read.rs b/vendor/flate2/examples/deflatedecoder-read.rs index cc5d435be..1bc83bc3c 100644 --- a/vendor/flate2/examples/deflatedecoder-read.rs +++ b/vendor/flate2/examples/deflatedecoder-read.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::read::DeflateDecoder; use flate2::write::DeflateEncoder; use flate2::Compression; diff --git a/vendor/flate2/examples/deflatedecoder-write.rs b/vendor/flate2/examples/deflatedecoder-write.rs index 276490bac..b9ba7a319 100644 --- a/vendor/flate2/examples/deflatedecoder-write.rs +++ b/vendor/flate2/examples/deflatedecoder-write.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::write::DeflateDecoder; use flate2::write::DeflateEncoder; use flate2::Compression; diff --git a/vendor/flate2/examples/deflateencoder-bufread.rs b/vendor/flate2/examples/deflateencoder-bufread.rs index 6240f3997..bff1848c3 100644 --- a/vendor/flate2/examples/deflateencoder-bufread.rs +++ b/vendor/flate2/examples/deflateencoder-bufread.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::bufread::DeflateEncoder; use flate2::Compression; use std::fs::File; diff --git a/vendor/flate2/examples/deflateencoder-read.rs b/vendor/flate2/examples/deflateencoder-read.rs index ffb628e48..366c60c99 100644 --- a/vendor/flate2/examples/deflateencoder-read.rs +++ b/vendor/flate2/examples/deflateencoder-read.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::read::DeflateEncoder; use flate2::Compression; use std::io; diff --git a/vendor/flate2/examples/deflateencoder-write.rs b/vendor/flate2/examples/deflateencoder-write.rs index 243b9dfdd..f998e1aec 100644 --- a/vendor/flate2/examples/deflateencoder-write.rs +++ b/vendor/flate2/examples/deflateencoder-write.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::write::DeflateEncoder; use flate2::Compression; use std::io::prelude::*; diff --git a/vendor/flate2/examples/gzbuilder.rs b/vendor/flate2/examples/gzbuilder.rs index d6ec2f4ce..c07250851 100644 --- a/vendor/flate2/examples/gzbuilder.rs +++ b/vendor/flate2/examples/gzbuilder.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::Compression; use flate2::GzBuilder; use std::fs::File; diff --git a/vendor/flate2/examples/gzdecoder-bufread.rs b/vendor/flate2/examples/gzdecoder-bufread.rs index 855119739..06d0448da 100644 --- a/vendor/flate2/examples/gzdecoder-bufread.rs +++ b/vendor/flate2/examples/gzdecoder-bufread.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::write::GzEncoder; use flate2::{bufread, Compression}; use std::io; diff --git a/vendor/flate2/examples/gzdecoder-read.rs b/vendor/flate2/examples/gzdecoder-read.rs index 705d28c2e..fbd05be72 100644 --- a/vendor/flate2/examples/gzdecoder-read.rs +++ b/vendor/flate2/examples/gzdecoder-read.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::write::GzEncoder; use flate2::{read, Compression}; use std::io; diff --git a/vendor/flate2/examples/gzdecoder-write.rs b/vendor/flate2/examples/gzdecoder-write.rs index 766bb5e75..6cee8f8d7 100644 --- a/vendor/flate2/examples/gzdecoder-write.rs +++ b/vendor/flate2/examples/gzdecoder-write.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::write::{GzDecoder, GzEncoder}; use flate2::Compression; use std::io; diff --git a/vendor/flate2/examples/gzencoder-bufread.rs b/vendor/flate2/examples/gzencoder-bufread.rs index 015ae0a82..2214e2dcd 100644 --- a/vendor/flate2/examples/gzencoder-bufread.rs +++ b/vendor/flate2/examples/gzencoder-bufread.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::bufread::GzEncoder; use flate2::Compression; use std::fs::File; diff --git a/vendor/flate2/examples/gzencoder-read.rs b/vendor/flate2/examples/gzencoder-read.rs index 3f1262b99..ee1384833 100644 --- a/vendor/flate2/examples/gzencoder-read.rs +++ b/vendor/flate2/examples/gzencoder-read.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::read::GzEncoder; use flate2::Compression; use std::io; diff --git a/vendor/flate2/examples/gzencoder-write.rs b/vendor/flate2/examples/gzencoder-write.rs index 275b010c5..cee01d14a 100644 --- a/vendor/flate2/examples/gzencoder-write.rs +++ b/vendor/flate2/examples/gzencoder-write.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::write::GzEncoder; use flate2::Compression; use std::io::prelude::*; diff --git a/vendor/flate2/examples/gzmultidecoder-bufread.rs b/vendor/flate2/examples/gzmultidecoder-bufread.rs index c6bb2c550..692b6f532 100644 --- a/vendor/flate2/examples/gzmultidecoder-bufread.rs +++ b/vendor/flate2/examples/gzmultidecoder-bufread.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::bufread::MultiGzDecoder; use flate2::write::GzEncoder; use flate2::Compression; diff --git a/vendor/flate2/examples/gzmultidecoder-read.rs b/vendor/flate2/examples/gzmultidecoder-read.rs index 7c8a8e316..c59561dde 100644 --- a/vendor/flate2/examples/gzmultidecoder-read.rs +++ b/vendor/flate2/examples/gzmultidecoder-read.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::read::MultiGzDecoder; use flate2::write::GzEncoder; use flate2::Compression; diff --git a/vendor/flate2/examples/hello_world.txt.gz b/vendor/flate2/examples/hello_world.txt.gz Binary files differnew file mode 100644 index 000000000..bab979960 --- /dev/null +++ b/vendor/flate2/examples/hello_world.txt.gz diff --git a/vendor/flate2/examples/zlibdecoder-bufread.rs b/vendor/flate2/examples/zlibdecoder-bufread.rs index 30f168a7b..82620c54b 100644 --- a/vendor/flate2/examples/zlibdecoder-bufread.rs +++ b/vendor/flate2/examples/zlibdecoder-bufread.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::bufread::ZlibDecoder; use flate2::write::ZlibEncoder; use flate2::Compression; diff --git a/vendor/flate2/examples/zlibdecoder-read.rs b/vendor/flate2/examples/zlibdecoder-read.rs index f7e5fb0af..3d4cda7d9 100644 --- a/vendor/flate2/examples/zlibdecoder-read.rs +++ b/vendor/flate2/examples/zlibdecoder-read.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::read::ZlibDecoder; use flate2::write::ZlibEncoder; use flate2::Compression; diff --git a/vendor/flate2/examples/zlibdecoder-write.rs b/vendor/flate2/examples/zlibdecoder-write.rs index 358e9035b..7f5afbea1 100644 --- a/vendor/flate2/examples/zlibdecoder-write.rs +++ b/vendor/flate2/examples/zlibdecoder-write.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::write::ZlibDecoder; use flate2::write::ZlibEncoder; use flate2::Compression; diff --git a/vendor/flate2/examples/zlibencoder-bufread.rs b/vendor/flate2/examples/zlibencoder-bufread.rs index 0321d8d38..e5e17f52e 100644 --- a/vendor/flate2/examples/zlibencoder-bufread.rs +++ b/vendor/flate2/examples/zlibencoder-bufread.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::bufread::ZlibEncoder; use flate2::Compression; use std::fs::File; diff --git a/vendor/flate2/examples/zlibencoder-read.rs b/vendor/flate2/examples/zlibencoder-read.rs index 779eb1d31..f833a50bd 100644 --- a/vendor/flate2/examples/zlibencoder-read.rs +++ b/vendor/flate2/examples/zlibencoder-read.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::read::ZlibEncoder; use flate2::Compression; use std::fs::File; diff --git a/vendor/flate2/examples/zlibencoder-write.rs b/vendor/flate2/examples/zlibencoder-write.rs index 76bcf17b1..3e3548f01 100644 --- a/vendor/flate2/examples/zlibencoder-write.rs +++ b/vendor/flate2/examples/zlibencoder-write.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::write::ZlibEncoder; use flate2::Compression; use std::io::prelude::*; diff --git a/vendor/flate2/src/crc.rs b/vendor/flate2/src/crc.rs index cd00cebe1..16f560196 100644 --- a/vendor/flate2/src/crc.rs +++ b/vendor/flate2/src/crc.rs @@ -63,13 +63,13 @@ impl Crc { /// Combine the CRC with the CRC for the subsequent block of bytes. pub fn combine(&mut self, additional_crc: &Crc) { - self.amt += additional_crc.amt; + self.amt = self.amt.wrapping_add(additional_crc.amt); self.hasher.combine(&additional_crc.hasher); } } impl<R: Read> CrcReader<R> { - /// Create a new CrcReader. + /// Create a new `CrcReader`. pub fn new(r: R) -> CrcReader<R> { CrcReader { inner: r, @@ -79,27 +79,27 @@ impl<R: Read> CrcReader<R> { } impl<R> CrcReader<R> { - /// Get the Crc for this CrcReader. + /// Get the Crc for this `CrcReader`. pub fn crc(&self) -> &Crc { &self.crc } - /// Get the reader that is wrapped by this CrcReader. + /// Get the reader that is wrapped by this `CrcReader`. pub fn into_inner(self) -> R { self.inner } - /// Get the reader that is wrapped by this CrcReader by reference. + /// Get the reader that is wrapped by this `CrcReader` by reference. pub fn get_ref(&self) -> &R { &self.inner } - /// Get a mutable reference to the reader that is wrapped by this CrcReader. + /// Get a mutable reference to the reader that is wrapped by this `CrcReader`. pub fn get_mut(&mut self) -> &mut R { &mut self.inner } - /// Reset the Crc in this CrcReader. + /// Reset the Crc in this `CrcReader`. pub fn reset(&mut self) { self.crc.reset(); } @@ -135,34 +135,34 @@ pub struct CrcWriter<W> { } impl<W> CrcWriter<W> { - /// Get the Crc for this CrcWriter. + /// Get the Crc for this `CrcWriter`. pub fn crc(&self) -> &Crc { &self.crc } - /// Get the writer that is wrapped by this CrcWriter. + /// Get the writer that is wrapped by this `CrcWriter`. pub fn into_inner(self) -> W { self.inner } - /// Get the writer that is wrapped by this CrcWriter by reference. + /// Get the writer that is wrapped by this `CrcWriter` by reference. pub fn get_ref(&self) -> &W { &self.inner } - /// Get a mutable reference to the writer that is wrapped by this CrcWriter. + /// Get a mutable reference to the writer that is wrapped by this `CrcWriter`. pub fn get_mut(&mut self) -> &mut W { &mut self.inner } - /// Reset the Crc in this CrcWriter. + /// Reset the Crc in this `CrcWriter`. pub fn reset(&mut self) { self.crc.reset(); } } impl<W: Write> CrcWriter<W> { - /// Create a new CrcWriter. + /// Create a new `CrcWriter`. pub fn new(w: W) -> CrcWriter<W> { CrcWriter { inner: w, diff --git a/vendor/flate2/src/deflate/bufread.rs b/vendor/flate2/src/deflate/bufread.rs index f0b29e0b4..e375952d0 100644 --- a/vendor/flate2/src/deflate/bufread.rs +++ b/vendor/flate2/src/deflate/bufread.rs @@ -202,7 +202,7 @@ impl<R> DeflateDecoder<R> { /// Acquires a mutable reference to the underlying stream /// /// Note that mutation of the stream may result in surprising results if - /// this encoder is continued to be used. + /// this decoder is continued to be used. pub fn get_mut(&mut self) -> &mut R { &mut self.obj } diff --git a/vendor/flate2/src/deflate/mod.rs b/vendor/flate2/src/deflate/mod.rs index 51758b30a..7f3bf70fd 100644 --- a/vendor/flate2/src/deflate/mod.rs +++ b/vendor/flate2/src/deflate/mod.rs @@ -18,14 +18,14 @@ mod tests { let v = crate::random_bytes().take(1024).collect::<Vec<_>>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0..v.len())]; - real.extend(to_write.iter().map(|x| *x)); + real.extend(to_write.iter().copied()); w.write_all(to_write).unwrap(); } let result = w.finish().unwrap(); let mut r = read::DeflateDecoder::new(&result[..]); let mut ret = Vec::new(); r.read_to_end(&mut ret).unwrap(); - assert!(ret == real); + assert_eq!(ret, real); } #[test] @@ -37,7 +37,7 @@ mod tests { let mut r = read::DeflateDecoder::new(&data[..]); let mut ret = Vec::new(); r.read_to_end(&mut ret).unwrap(); - assert!(ret == b"foo"); + assert_eq!(ret, b"foo"); } #[test] @@ -47,7 +47,7 @@ mod tests { let v = crate::random_bytes().take(1024).collect::<Vec<_>>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0..v.len())]; - real.extend(to_write.iter().map(|x| *x)); + real.extend(to_write.iter().copied()); w.write_all(to_write).unwrap(); } let mut result = w.finish().unwrap(); @@ -55,13 +55,13 @@ mod tests { let result_len = result.len(); for _ in 0..200 { - result.extend(v.iter().map(|x| *x)); + result.extend(v.iter().copied()); } let mut r = read::DeflateDecoder::new(&result[..]); let mut ret = Vec::new(); r.read_to_end(&mut ret).unwrap(); - assert!(ret == real); + assert_eq!(ret, real); assert_eq!(r.total_in(), result_len as u64); } @@ -84,7 +84,7 @@ mod tests { ); w.write_all(&v).unwrap(); let w = w.finish().unwrap().finish().unwrap(); - assert!(w == v); + assert_eq!(w, v); } #[test] @@ -159,7 +159,7 @@ mod tests { let mut d = read::DeflateDecoder::new(&result[..]); let mut data = Vec::new(); - assert!(d.read(&mut data).unwrap() == 0); + assert_eq!(d.read(&mut data).unwrap(), 0); } #[test] diff --git a/vendor/flate2/src/deflate/read.rs b/vendor/flate2/src/deflate/read.rs index fd17a894a..e6af130a3 100644 --- a/vendor/flate2/src/deflate/read.rs +++ b/vendor/flate2/src/deflate/read.rs @@ -196,7 +196,7 @@ impl<R> DeflateDecoder<R> { /// Acquires a mutable reference to the underlying stream /// /// Note that mutation of the stream may result in surprising results if - /// this encoder is continued to be used. + /// this decoder is continued to be used. pub fn get_mut(&mut self) -> &mut R { self.inner.get_mut().get_mut() } diff --git a/vendor/flate2/src/ffi/c.rs b/vendor/flate2/src/ffi/c.rs index 59e20118f..48acd438c 100644 --- a/vendor/flate2/src/ffi/c.rs +++ b/vendor/flate2/src/ffi/c.rs @@ -215,9 +215,9 @@ impl InflateBackend for Inflate { let raw = &mut *self.inner.stream_wrapper; raw.msg = ptr::null_mut(); raw.next_in = input.as_ptr() as *mut u8; - raw.avail_in = cmp::min(input.len(), c_uint::max_value() as usize) as c_uint; + raw.avail_in = cmp::min(input.len(), c_uint::MAX as usize) as c_uint; raw.next_out = output.as_mut_ptr(); - raw.avail_out = cmp::min(output.len(), c_uint::max_value() as usize) as c_uint; + raw.avail_out = cmp::min(output.len(), c_uint::MAX as usize) as c_uint; let rc = unsafe { mz_inflate(raw, flush as c_int) }; @@ -303,9 +303,9 @@ impl DeflateBackend for Deflate { let raw = &mut *self.inner.stream_wrapper; raw.msg = ptr::null_mut(); raw.next_in = input.as_ptr() as *mut _; - raw.avail_in = cmp::min(input.len(), c_uint::max_value() as usize) as c_uint; + raw.avail_in = cmp::min(input.len(), c_uint::MAX as usize) as c_uint; raw.next_out = output.as_mut_ptr(); - raw.avail_out = cmp::min(output.len(), c_uint::max_value() as usize) as c_uint; + raw.avail_out = cmp::min(output.len(), c_uint::MAX as usize) as c_uint; let rc = unsafe { mz_deflate(raw, flush as c_int) }; diff --git a/vendor/flate2/src/ffi/rust.rs b/vendor/flate2/src/ffi/rust.rs index eadd6ec18..bed6629a2 100644 --- a/vendor/flate2/src/ffi/rust.rs +++ b/vendor/flate2/src/ffi/rust.rs @@ -1,4 +1,4 @@ -//! Implementation for miniz_oxide rust backend. +//! Implementation for `miniz_oxide` rust backend. use std::convert::TryInto; use std::fmt; diff --git a/vendor/flate2/src/gz/bufread.rs b/vendor/flate2/src/gz/bufread.rs index 6be144d0c..c6ac5a98b 100644 --- a/vendor/flate2/src/gz/bufread.rs +++ b/vendor/flate2/src/gz/bufread.rs @@ -74,7 +74,7 @@ fn read_gz_header_part<'a, R: Read>(r: &'a mut Buffer<'a, R>) -> io::Result<()> } GzHeaderParsingState::Filename => { if r.part.flg & FNAME != 0 { - if None == r.part.header.filename { + if r.part.header.filename.is_none() { r.part.header.filename = Some(Vec::new()); }; for byte in r.bytes() { @@ -88,7 +88,7 @@ fn read_gz_header_part<'a, R: Read>(r: &'a mut Buffer<'a, R>) -> io::Result<()> } GzHeaderParsingState::Comment => { if r.part.flg & FCOMMENT != 0 { - if None == r.part.header.comment { + if r.part.header.comment.is_none() { r.part.header.comment = Some(Vec::new()); }; for byte in r.bytes() { @@ -483,7 +483,7 @@ impl<R> GzDecoder<R> { /// Acquires a mutable reference to the underlying stream. /// /// Note that mutation of the stream may result in surprising results if - /// this encoder is continued to be used. + /// this decoder is continued to be used. pub fn get_mut(&mut self) -> &mut R { self.reader.get_mut().get_mut() } @@ -681,7 +681,7 @@ impl<R> MultiGzDecoder<R> { /// Acquires a mutable reference to the underlying stream. /// /// Note that mutation of the stream may result in surprising results if - /// this encoder is continued to be used. + /// this decoder is continued to be used. pub fn get_mut(&mut self) -> &mut R { self.0.get_mut() } @@ -718,20 +718,20 @@ pub mod tests { } pub fn set_position(&mut self, pos: u64) { - return self.cursor.set_position(pos); + self.cursor.set_position(pos) } pub fn position(&mut self) -> u64 { - return self.cursor.position(); + self.cursor.position() } } impl Write for BlockingCursor { fn write(&mut self, buf: &[u8]) -> io::Result<usize> { - return self.cursor.write(buf); + self.cursor.write(buf) } fn flush(&mut self) -> io::Result<()> { - return self.cursor.flush(); + self.cursor.flush() } } @@ -751,7 +751,7 @@ pub mod tests { } Ok(_n) => {} } - return r; + r } } #[test] diff --git a/vendor/flate2/src/gz/mod.rs b/vendor/flate2/src/gz/mod.rs index 505450e3e..d31aa60be 100644 --- a/vendor/flate2/src/gz/mod.rs +++ b/vendor/flate2/src/gz/mod.rs @@ -218,11 +218,11 @@ impl GzBuilder { } if let Some(filename) = filename { flg |= FNAME; - header.extend(filename.as_bytes_with_nul().iter().map(|x| *x)); + header.extend(filename.as_bytes_with_nul().iter().copied()); } if let Some(comment) = comment { flg |= FCOMMENT; - header.extend(comment.as_bytes_with_nul().iter().map(|x| *x)); + header.extend(comment.as_bytes_with_nul().iter().copied()); } header[0] = 0x1f; header[1] = 0x8b; @@ -285,14 +285,14 @@ mod tests { let v = crate::random_bytes().take(1024).collect::<Vec<_>>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0..v.len())]; - real.extend(to_write.iter().map(|x| *x)); + real.extend(to_write.iter().copied()); w.write_all(to_write).unwrap(); } let result = w.finish().unwrap(); let mut r = read::GzDecoder::new(&result[..]); let mut v = Vec::new(); r.read_to_end(&mut v).unwrap(); - assert!(v == real); + assert_eq!(v, real); } #[test] @@ -301,7 +301,7 @@ mod tests { let mut r = read::GzDecoder::new(read::GzEncoder::new(&v[..], Compression::default())); let mut res = Vec::new(); r.read_to_end(&mut res).unwrap(); - assert!(res == v); + assert_eq!(res, v); } #[test] diff --git a/vendor/flate2/src/gz/read.rs b/vendor/flate2/src/gz/read.rs index dbbe63282..cfeb992e8 100644 --- a/vendor/flate2/src/gz/read.rs +++ b/vendor/flate2/src/gz/read.rs @@ -153,7 +153,7 @@ impl<R> GzDecoder<R> { /// Acquires a mutable reference to the underlying stream. /// /// Note that mutation of the stream may result in surprising results if - /// this encoder is continued to be used. + /// this decoder is continued to be used. pub fn get_mut(&mut self) -> &mut R { self.inner.get_mut().get_mut() } @@ -250,7 +250,7 @@ impl<R> MultiGzDecoder<R> { /// Acquires a mutable reference to the underlying stream. /// /// Note that mutation of the stream may result in surprising results if - /// this encoder is continued to be used. + /// this decoder is continued to be used. pub fn get_mut(&mut self) -> &mut R { self.inner.get_mut().get_mut() } diff --git a/vendor/flate2/src/gz/write.rs b/vendor/flate2/src/gz/write.rs index 7cf1a7cd4..83eebb757 100644 --- a/vendor/flate2/src/gz/write.rs +++ b/vendor/flate2/src/gz/write.rs @@ -92,7 +92,7 @@ impl<W: Write> GzEncoder<W> { self.inner.finish()?; while self.crc_bytes_written < 8 { - let (sum, amt) = (self.crc.sum() as u32, self.crc.amount()); + let (sum, amt) = (self.crc.sum(), self.crc.amount()); let buf = [ (sum >> 0) as u8, (sum >> 8) as u8, @@ -169,7 +169,7 @@ impl<W: Write> Drop for GzEncoder<W> { /// A gzip streaming decoder /// -/// This structure exposes a [`Write`] interface that will emit compressed data +/// This structure exposes a [`Write`] interface that will emit uncompressed data /// to the underlying writer `W`. /// /// [`Write`]: https://doc.rust-lang.org/std/io/trait.Write.html @@ -296,7 +296,7 @@ impl<W: Write> GzDecoder<W> { | ((self.crc_bytes[5] as u32) << 8) | ((self.crc_bytes[6] as u32) << 16) | ((self.crc_bytes[7] as u32) << 24); - if crc != self.inner.get_ref().crc().sum() as u32 { + if crc != self.inner.get_ref().crc().sum() { return Err(corrupt()); } if amt != self.inner.get_ref().crc().amount() { @@ -373,11 +373,117 @@ impl<W: Read + Write> Read for GzDecoder<W> { } } +/// A gzip streaming decoder that decodes all members of a multistream +/// +/// A gzip member consists of a header, compressed data and a trailer. The [gzip +/// specification](https://tools.ietf.org/html/rfc1952), however, allows multiple +/// gzip members to be joined in a single stream. `MultiGzDecoder` will +/// decode all consecutive members while `GzDecoder` will only decompress +/// the first gzip member. The multistream format is commonly used in +/// bioinformatics, for example when using the BGZF compressed data. +/// +/// This structure exposes a [`Write`] interface that will consume all gzip members +/// from the written buffers and write uncompressed data to the writer. +#[derive(Debug)] +pub struct MultiGzDecoder<W: Write> { + inner: GzDecoder<W>, +} + +impl<W: Write> MultiGzDecoder<W> { + /// Creates a new decoder which will write uncompressed data to the stream. + /// If the gzip stream contains multiple members all will be decoded. + pub fn new(w: W) -> MultiGzDecoder<W> { + MultiGzDecoder { + inner: GzDecoder::new(w), + } + } + + /// Returns the header associated with the current member. + pub fn header(&self) -> Option<&GzHeader> { + self.inner.header() + } + + /// Acquires a reference to the underlying writer. + pub fn get_ref(&self) -> &W { + self.inner.get_ref() + } + + /// Acquires a mutable reference to the underlying writer. + /// + /// Note that mutating the output/input state of the stream may corrupt this + /// object, so care must be taken when using this method. + pub fn get_mut(&mut self) -> &mut W { + self.inner.get_mut() + } + + /// Attempt to finish this output stream, writing out final chunks of data. + /// + /// Note that this function can only be used once data has finished being + /// written to the output stream. After this function is called then further + /// calls to `write` may result in a panic. + /// + /// # Panics + /// + /// Attempts to write data to this stream may result in a panic after this + /// function is called. + /// + /// # Errors + /// + /// This function will perform I/O to finish the stream, returning any + /// errors which happen. + pub fn try_finish(&mut self) -> io::Result<()> { + self.inner.try_finish() + } + + /// Consumes this decoder, flushing the output stream. + /// + /// This will flush the underlying data stream and then return the contained + /// writer if the flush succeeded. + /// + /// Note that this function may not be suitable to call in a situation where + /// the underlying stream is an asynchronous I/O stream. To finish a stream + /// the `try_finish` (or `shutdown`) method should be used instead. To + /// re-acquire ownership of a stream it is safe to call this method after + /// `try_finish` or `shutdown` has returned `Ok`. + /// + /// # Errors + /// + /// This function will perform I/O to complete this stream, and any I/O + /// errors which occur will be returned from this function. + pub fn finish(self) -> io::Result<W> { + self.inner.finish() + } +} + +impl<W: Write> Write for MultiGzDecoder<W> { + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { + if buf.is_empty() { + Ok(0) + } else { + match self.inner.write(buf) { + Ok(0) => { + // When the GzDecoder indicates that it has finished + // create a new GzDecoder to handle additional data. + self.inner.try_finish()?; + let w = self.inner.inner.take_inner().into_inner(); + self.inner = GzDecoder::new(w); + self.inner.write(buf) + } + res => res, + } + } + } + + fn flush(&mut self) -> io::Result<()> { + self.inner.flush() + } +} + #[cfg(test)] mod tests { use super::*; - const STR: &'static str = "Hello World Hello World Hello World Hello World Hello World \ + const STR: &str = "Hello World Hello World Hello World Hello World Hello World \ Hello World Hello World Hello World Hello World Hello World \ Hello World Hello World Hello World Hello World Hello World \ Hello World Hello World Hello World Hello World Hello World \ @@ -447,4 +553,26 @@ mod tests { let return_string = String::from_utf8(writer).expect("String parsing error"); assert_eq!(return_string, STR); } + + // Two or more gzip files concatenated form a multi-member gzip file. MultiGzDecoder will + // concatenate the decoded contents of all members. + #[test] + fn decode_multi_writer() { + let mut e = GzEncoder::new(Vec::new(), Compression::default()); + e.write(STR.as_ref()).unwrap(); + let bytes = e.finish().unwrap().repeat(2); + + let mut writer = Vec::new(); + let mut decoder = MultiGzDecoder::new(writer); + let mut count = 0; + while count < bytes.len() { + let n = decoder.write(&bytes[count..]).unwrap(); + assert!(n != 0); + count += n; + } + writer = decoder.finish().unwrap(); + let return_string = String::from_utf8(writer).expect("String parsing error"); + let expected = STR.repeat(2); + assert_eq!(return_string, expected); + } } diff --git a/vendor/flate2/src/lib.rs b/vendor/flate2/src/lib.rs index 23a783e55..6789c5b76 100644 --- a/vendor/flate2/src/lib.rs +++ b/vendor/flate2/src/lib.rs @@ -76,6 +76,7 @@ #![deny(missing_debug_implementations)] #![allow(trivial_numeric_casts)] #![cfg_attr(test, deny(warnings))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] pub use crate::crc::{Crc, CrcReader, CrcWriter}; pub use crate::gz::GzBuilder; @@ -115,6 +116,7 @@ pub mod write { pub use crate::deflate::write::DeflateEncoder; pub use crate::gz::write::GzDecoder; pub use crate::gz::write::GzEncoder; + pub use crate::gz::write::MultiGzDecoder; pub use crate::zlib::write::ZlibDecoder; pub use crate::zlib::write::ZlibEncoder; } diff --git a/vendor/flate2/src/mem.rs b/vendor/flate2/src/mem.rs index 5f1d6d8c1..6313c220d 100644 --- a/vendor/flate2/src/mem.rs +++ b/vendor/flate2/src/mem.rs @@ -40,9 +40,10 @@ pub struct Decompress { inner: Inflate, } -#[derive(Copy, Clone, PartialEq, Eq, Debug)] /// Values which indicate the form of flushing to be used when compressing /// in-memory data. +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[non_exhaustive] pub enum FlushCompress { /// A typical parameter for passing to compression/decompression functions, /// this indicates that the underlying stream to decide how much data to @@ -80,14 +81,12 @@ pub enum FlushCompress { /// The return value may indicate that the stream is not yet done and more /// data has yet to be processed. Finish = ffi::MZ_FINISH as isize, - - #[doc(hidden)] - _Nonexhaustive, } -#[derive(Copy, Clone, PartialEq, Eq, Debug)] /// Values which indicate the form of flushing to be used when /// decompressing in-memory data. +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[non_exhaustive] pub enum FlushDecompress { /// A typical parameter for passing to compression/decompression functions, /// this indicates that the underlying stream to decide how much data to @@ -108,9 +107,6 @@ pub enum FlushDecompress { /// The return value may indicate that the stream is not yet done and more /// data has yet to be processed. Finish = ffi::MZ_FINISH as isize, - - #[doc(hidden)] - _Nonexhaustive, } /// The inner state for an error when decompressing @@ -215,11 +211,6 @@ impl Compress { /// /// If `window_bits` does not fall into the range 9 ..= 15, /// `new_with_window_bits` will panic. - /// - /// # Note - /// - /// This constructor is only available when the `zlib` feature is used. - /// Other backends currently do not support custom window bits. #[cfg(feature = "any_zlib")] pub fn new_with_window_bits( level: Compression, @@ -247,11 +238,6 @@ impl Compress { /// /// If `window_bits` does not fall into the range 9 ..= 15, /// `new_with_window_bits` will panic. - /// - /// # Note - /// - /// This constructor is only available when the `zlib` feature is used. - /// Other backends currently do not support gzip headers for Compress. #[cfg(feature = "any_zlib")] pub fn new_gzip(level: Compression, window_bits: u8) -> Compress { assert!( @@ -362,7 +348,7 @@ impl Compress { unsafe { let before = self.total_out(); let ret = { - let ptr = output.as_mut_ptr().offset(len as isize); + let ptr = output.as_mut_ptr().add(len); let out = slice::from_raw_parts_mut(ptr, cap - len); self.compress(input, out, flush) }; @@ -393,11 +379,6 @@ impl Decompress { /// /// If `window_bits` does not fall into the range 9 ..= 15, /// `new_with_window_bits` will panic. - /// - /// # Note - /// - /// This constructor is only available when the `zlib` feature is used. - /// Other backends currently do not support custom window bits. #[cfg(feature = "any_zlib")] pub fn new_with_window_bits(zlib_header: bool, window_bits: u8) -> Decompress { assert!( @@ -418,11 +399,6 @@ impl Decompress { /// /// If `window_bits` does not fall into the range 9 ..= 15, /// `new_with_window_bits` will panic. - /// - /// # Note - /// - /// This constructor is only available when the `zlib` feature is used. - /// Other backends currently do not support gzip headers for Decompress. #[cfg(feature = "any_zlib")] pub fn new_gzip(window_bits: u8) -> Decompress { assert!( @@ -503,7 +479,7 @@ impl Decompress { unsafe { let before = self.total_out(); let ret = { - let ptr = output.as_mut_ptr().offset(len as isize); + let ptr = output.as_mut_ptr().add(len); let out = slice::from_raw_parts_mut(ptr, cap - len); self.decompress(input, out, flush) }; diff --git a/vendor/flate2/src/zio.rs b/vendor/flate2/src/zio.rs index 50beacbd0..ea25922ab 100644 --- a/vendor/flate2/src/zio.rs +++ b/vendor/flate2/src/zio.rs @@ -143,10 +143,8 @@ where // then we need to keep asking for more data because if we // return that 0 bytes of data have been read then it will // be interpreted as EOF. - Ok(Status::Ok) | Ok(Status::BufError) if read == 0 && !eof && !dst.is_empty() => { - continue - } - Ok(Status::Ok) | Ok(Status::BufError) | Ok(Status::StreamEnd) => return Ok(read), + Ok(Status::Ok | Status::BufError) if read == 0 && !eof && !dst.is_empty() => continue, + Ok(Status::Ok | Status::BufError | Status::StreamEnd) => return Ok(read), Err(..) => { return Err(io::Error::new( diff --git a/vendor/flate2/src/zlib/bufread.rs b/vendor/flate2/src/zlib/bufread.rs index f1d323165..61d12525c 100644 --- a/vendor/flate2/src/zlib/bufread.rs +++ b/vendor/flate2/src/zlib/bufread.rs @@ -192,7 +192,7 @@ impl<R> ZlibDecoder<R> { /// Acquires a mutable reference to the underlying stream /// /// Note that mutation of the stream may result in surprising results if - /// this encoder is continued to be used. + /// this decoder is continued to be used. pub fn get_mut(&mut self) -> &mut R { &mut self.obj } diff --git a/vendor/flate2/src/zlib/mod.rs b/vendor/flate2/src/zlib/mod.rs index 9d3de95c5..1a293ba08 100644 --- a/vendor/flate2/src/zlib/mod.rs +++ b/vendor/flate2/src/zlib/mod.rs @@ -19,14 +19,14 @@ mod tests { let v = crate::random_bytes().take(1024).collect::<Vec<_>>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0..v.len())]; - real.extend(to_write.iter().map(|x| *x)); + real.extend(to_write.iter().copied()); w.write_all(to_write).unwrap(); } let result = w.finish().unwrap(); let mut r = read::ZlibDecoder::new(&result[..]); let mut ret = Vec::new(); r.read_to_end(&mut ret).unwrap(); - assert!(ret == real); + assert_eq!(ret, real); } #[test] @@ -38,7 +38,7 @@ mod tests { let mut r = read::ZlibDecoder::new(&data[..]); let mut ret = Vec::new(); r.read_to_end(&mut ret).unwrap(); - assert!(ret == b"foo"); + assert_eq!(ret, b"foo"); } #[test] @@ -48,7 +48,7 @@ mod tests { let v = crate::random_bytes().take(1024).collect::<Vec<_>>(); for _ in 0..200 { let to_write = &v[..thread_rng().gen_range(0..v.len())]; - real.extend(to_write.iter().map(|x| *x)); + real.extend(to_write.iter().copied()); w.write_all(to_write).unwrap(); } let mut result = w.finish().unwrap(); @@ -56,13 +56,13 @@ mod tests { let result_len = result.len(); for _ in 0..200 { - result.extend(v.iter().map(|x| *x)); + result.extend(v.iter().copied()); } let mut r = read::ZlibDecoder::new(&result[..]); let mut ret = Vec::new(); r.read_to_end(&mut ret).unwrap(); - assert!(ret == real); + assert_eq!(ret, real); assert_eq!(r.total_in(), result_len as u64); } @@ -82,7 +82,7 @@ mod tests { write::ZlibEncoder::new(write::ZlibDecoder::new(Vec::new()), Compression::default()); w.write_all(&v).unwrap(); let w = w.finish().unwrap().finish().unwrap(); - assert!(w == v); + assert_eq!(w, v); } #[test] diff --git a/vendor/flate2/src/zlib/read.rs b/vendor/flate2/src/zlib/read.rs index 509493166..330213049 100644 --- a/vendor/flate2/src/zlib/read.rs +++ b/vendor/flate2/src/zlib/read.rs @@ -195,7 +195,7 @@ impl<R> ZlibDecoder<R> { /// Acquires a mutable reference to the underlying stream /// /// Note that mutation of the stream may result in surprising results if - /// this encoder is continued to be used. + /// this decoder is continued to be used. pub fn get_mut(&mut self) -> &mut R { self.inner.get_mut().get_mut() } diff --git a/vendor/flate2/tests/early-flush.rs b/vendor/flate2/tests/early-flush.rs index e717adaa5..b43f47450 100644 --- a/vendor/flate2/tests/early-flush.rs +++ b/vendor/flate2/tests/early-flush.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use std::io::{Read, Write}; use flate2::read::GzDecoder; diff --git a/vendor/flate2/tests/empty-read.rs b/vendor/flate2/tests/empty-read.rs index 755123833..3724c23d7 100644 --- a/vendor/flate2/tests/empty-read.rs +++ b/vendor/flate2/tests/empty-read.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use std::io::{Read, Write}; #[test] diff --git a/vendor/flate2/tests/gunzip.rs b/vendor/flate2/tests/gunzip.rs index c3820328a..f7d413213 100644 --- a/vendor/flate2/tests/gunzip.rs +++ b/vendor/flate2/tests/gunzip.rs @@ -1,5 +1,3 @@ -extern crate flate2; - use flate2::read::GzDecoder; use flate2::read::MultiGzDecoder; use std::fs::File; @@ -16,7 +14,7 @@ fn test_extract_success() { .unwrap() .read_to_end(&mut expected) .unwrap(); - assert!(content == expected); + assert_eq!(content, expected); } // // test partial extraction of a multistream gzipped file diff --git a/vendor/flate2/tests/zero-write.rs b/vendor/flate2/tests/zero-write.rs index f0db86cb8..22be8eec2 100644 --- a/vendor/flate2/tests/zero-write.rs +++ b/vendor/flate2/tests/zero-write.rs @@ -1,5 +1,3 @@ -extern crate flate2; - #[test] fn zero_write_is_error() { let mut buf = [0u8]; |