From 8a150f462e18fbfeb8a98b14f45ce1fe348e1bb8 Mon Sep 17 00:00:00 2001 From: Luiz Irber Date: Sun, 9 Jun 2024 19:31:38 -0700 Subject: [PATCH 1/8] clean up feature usage --- Cargo.toml | 56 ++++++++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c211058..7127039 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,31 +13,28 @@ rust-version = "1.74" [features] default = ["bz2", "lzma", "xz", "gz", "bgz", "zstd"] -bz2 = ["bzip2"] -lzma = ["liblzma"] -gz = ["flate2"] -bgz = ["bgzip"] +bz2 = [ + "dep:bzip2", + "bzip2?/tokio", + "bzip2?/static" +] +lzma = [ + "dep:liblzma", + "liblzma?/tokio" +] +gz = [ + "dep:flate2", + "flate2?/zlib", + "flate2?/zlib-ng-compat", + "flate2?/zlib-ng", + "flate2?/cloudflare_zlib", + "flate2?/rust_backend" +] +bgz = ["dep:bgzip"] xz = ["lzma"] zstd = ["dep:zstd"] wasm = ["zstd", "lzma", "gz", "bgz"] -# bzip2 feature transitivity -bz2_tokio = ["bzip2/tokio"] -bz2_static = ["bzip2/static"] - -# lzma feature transitivity -lzma_tokio = ["liblzma/tokio"] - -# flate2 feature transitivity -gz_zlib = ["flate2/zlib"] -gz_zlib-ng-compat = ["flate2/zlib-ng-compat"] -gz_zlib-ng = ["flate2/zlib-ng"] -gz_cloudflare_zlib = ["flate2/cloudflare_zlib"] -gz_rust_backend = ["flate2/rust_backend"] - -# xz feature transitivity -xz_tokio = ["liblzma/tokio"] - [dependencies] cfg-if = "1.0" thiserror = "2.0" @@ -74,23 +71,6 @@ required-features = ["xz"] [package.metadata.cargo-feature-combinations] denylist = [ - # bzip2 feature transitivity - "bz2_tokio", - "bz2_static", - - # lzma feature transitivity - "lzma_tokio", - - # flate2 feature transitivity - "gz_zlib", - "gz_zlib-ng", - "gz_zlib-ng-compat", - "gz_cloudflare_zlib", - "gz_rust_backend", - - # xz feature transitivity - "xz_tokio", - # xz is an alias to lzma "xz", From a2a8bacb463278ab11e8429b21b220f6ab52b357 Mon Sep 17 00:00:00 2001 From: Luiz Irber Date: Wed, 5 Feb 2025 21:44:59 -0800 Subject: [PATCH 2/8] Start advanced use of features - Need https://github.com/trifectatechfoundation/bzip2-rs/pull/121 for finishing properly and https://github.com/trifectatechfoundation/bzip2-rs/pull/126 for wasm compat --- Cargo.lock | 370 +++++++++++++++++----------------------- Cargo.toml | 58 ++++--- pixi.toml | 5 +- src/send/compression.rs | 2 +- src/send/mod.rs | 1 - 5 files changed, 194 insertions(+), 242 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d9ac9d1..aa8e97e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,10 +3,10 @@ version = 3 [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aho-corasick" @@ -31,9 +31,9 @@ checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bgzip" @@ -42,14 +42,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b64fd8980fb64af5951bc05de7772b598150a6f7eac42ec17f73e8489915f99b" dependencies = [ "flate2", - "thiserror 1.0.61", + "log", + "rayon", + "thiserror 1.0.69", ] [[package]] name = "bitflags" -version = "2.5.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" [[package]] name = "bumpalo" @@ -57,32 +59,14 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "bytes" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" -dependencies = [ - "byteorder", - "iovec", -] - [[package]] name = "bzip2" -version = "0.4.4" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" +checksum = "bafdbf26611df8c14810e268ddceda071c297570a5fb360ceddf617fe417ef58" dependencies = [ "bzip2-sys", - "futures", "libc", - "tokio-io", ] [[package]] @@ -104,13 +88,13 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.99" +version = "1.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" +checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" dependencies = [ "jobserver", "libc", - "once_cell", + "shlex", ] [[package]] @@ -171,24 +155,6 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" -[[package]] -name = "cloudflare-zlib-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3185ff8c69c53ab346d5ac89f418e194b997d48393cae321cb611dd05f83c90" -dependencies = [ - "cc", -] - -[[package]] -name = "cmake" -version = "0.1.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" -dependencies = [ - "cc", -] - [[package]] name = "codspeed" version = "2.7.2" @@ -268,9 +234,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -287,9 +253,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crunchy" @@ -299,15 +265,15 @@ checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" [[package]] name = "either" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", "windows-sys", @@ -315,28 +281,30 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "flate2" -version = "1.0.30" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ - "cloudflare-zlib-sys", "crc32fast", - "libz-ng-sys", - "libz-sys", "miniz_oxide", ] [[package]] -name = "futures" -version = "0.1.31" +name = "getrandom" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] [[package]] name = "half" @@ -354,15 +322,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" -[[package]] -name = "iovec" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" -dependencies = [ - "libc", -] - [[package]] name = "is-terminal" version = "0.4.15" @@ -385,25 +344,26 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jobserver" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -415,85 +375,60 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "liblzma" -version = "0.3.2" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243510a5543c358949902b9e76daec3a32d7b03a43abce823e7c62a1a8360172" +checksum = "603222e049bf0da71529325ada5d02dc3871cbd3679cf905429f7f0de93da87b" dependencies = [ - "futures", "liblzma-sys", - "tokio-io", ] [[package]] name = "liblzma-sys" -version = "0.3.4" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83cf78d20a45b5c0f3c7da2dcac255b230efe7d8684282bd35873164c1491187" +checksum = "d87bb9f27519cd690390611ab3e23e8ac3e383c1f67b733a4b36c684211d7671" dependencies = [ "cc", "libc", "pkg-config", ] -[[package]] -name = "libz-ng-sys" -version = "1.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cee1488e961a80d172564fd6fcda11d8a4ac6672c06fe008e9213fa60520c2b" -dependencies = [ - "cmake", - "libc", -] - -[[package]] -name = "libz-sys" -version = "1.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c15da26e5af7e25c90b37a2d75cdbf940cf4a55316de9d84c679c9b8bfabf82e" -dependencies = [ - "cc", - "cmake", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "log" -version = "0.4.21" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miniz_oxide" -version = "0.7.3" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" dependencies = [ - "adler", + "adler2", ] [[package]] name = "niffler" -version = "2.7.0" +version = "3.0.0" dependencies = [ "bgzip", "bzip2", @@ -517,27 +452,27 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "oorandom" -version = "11.1.3" +version = "11.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" +checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "plotters" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" dependencies = [ "num-traits", "plotters-backend", @@ -548,15 +483,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" [[package]] name = "plotters-svg" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" dependencies = [ "plotters-backend", ] @@ -572,9 +507,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -601,9 +536,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -613,9 +548,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -624,15 +559,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ "bitflags", "errno", @@ -641,6 +576,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "rustversion" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" + [[package]] name = "ryu" version = "1.0.18" @@ -658,18 +599,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.203" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", @@ -688,6 +629,12 @@ dependencies = [ "serde", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "syn" version = "2.0.96" @@ -701,23 +648,25 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.1" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" dependencies = [ "cfg-if", "fastrand", + "getrandom", + "once_cell", "rustix", "windows-sys", ] [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl 1.0.61", + "thiserror-impl 1.0.69", ] [[package]] @@ -731,9 +680,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", @@ -761,28 +710,11 @@ dependencies = [ "serde_json", ] -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes", - "futures", - "log", -] - [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +checksum = "11cd88e12b17c6494200a9c1b683a04fcac9573ed74cd1b62aeb2727c5592243" [[package]] name = "walkdir" @@ -794,25 +726,32 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", + "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn", @@ -821,9 +760,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -831,9 +770,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", @@ -844,15 +783,18 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", @@ -860,27 +802,27 @@ dependencies = [ [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ "windows-sys", ] [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -894,66 +836,66 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "zstd" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a" +checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "7.1.0" +version = "7.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd99b45c6bc03a018c8b8a86025678c87e55526064e38f9df301989dce7ec0a" +checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059" dependencies = [ "zstd-sys", ] diff --git a/Cargo.toml b/Cargo.toml index 7127039..4243e70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "niffler" -version = "2.7.0" +version = "3.0.0" authors = ["Pierre Marijon ", "Luiz Irber "] description = "Simple and transparent support for compressed files" license = "MIT/Apache-2.0" @@ -12,24 +12,16 @@ edition = "2021" rust-version = "1.74" [features] -default = ["bz2", "lzma", "xz", "gz", "bgz", "zstd"] -bz2 = [ - "dep:bzip2", - "bzip2?/tokio", - "bzip2?/static" -] -lzma = [ - "dep:liblzma", - "liblzma?/tokio" -] -gz = [ - "dep:flate2", - "flate2?/zlib", - "flate2?/zlib-ng-compat", - "flate2?/zlib-ng", - "flate2?/cloudflare_zlib", - "flate2?/rust_backend" +default = [ + "bgz", "bgzip/default", + "bz2", "bzip2/default", #for 0.5.0 + "gz", "flate2/default", + "lzma", "xz", "liblzma/default", + "zstd", "zstd/default" ] +bz2 = ["dep:bzip2"] +lzma = ["dep:liblzma"] +gz = ["dep:flate2"] bgz = ["dep:bgzip"] xz = ["lzma"] zstd = ["dep:zstd"] @@ -38,13 +30,12 @@ wasm = ["zstd", "lzma", "gz", "bgz"] [dependencies] cfg-if = "1.0" thiserror = "2.0" -bzip2 = { version = "0.4.4", optional = true } -flate2 = { version = "1.0", optional = true } -liblzma = { version = "0.3", optional = true } -bgzip = { version = "0.3", optional = true, default-features = false, features = [ - "rust_backend", -] } -zstd = { version = "0.13", optional = true } +#bzip2 = { version = "0.4.4", optional = true, default-features = false } +bzip2 = { version = "0.5.0", optional = true, default-features = false } +flate2 = { version = "1.0", optional = true, default-features = false } +liblzma = { version = "0.3", optional = true, default-features = false } +bgzip = { version = "0.3", optional = true, default-features = false } +zstd = { version = "0.13", optional = true, default-features = false } [dev-dependencies] tempfile = "3" @@ -71,6 +62,23 @@ required-features = ["xz"] [package.metadata.cargo-feature-combinations] denylist = [ + # bzip2 feature transitivity + "bz2_libbz2-rs-sys", + "bz2_static", + + # lzma feature transitivity + "lzma_tokio", + + # flate2 feature transitivity + "gz_zlib", + "gz_zlib-ng", + "gz_zlib-ng-compat", + "gz_cloudflare_zlib", + "gz_rust_backend", + + # xz feature transitivity + "xz_tokio", + # xz is an alias to lzma "xz", diff --git a/pixi.toml b/pixi.toml index ed7d01f..a6fa76a 100644 --- a/pixi.toml +++ b/pixi.toml @@ -1,6 +1,6 @@ [project] name = "niffler" -version = "2.7.0" +version = "3.0.0" description = "Simple and transparent support for compressed files." authors = ["Pierre Marijon ", "Luiz Irber "] channels = ["conda-forge"] @@ -31,6 +31,9 @@ rust = "~=1.84.0" cargo-nextest = ">=0.9.78,<0.10" cargo-llvm-cov = ">=0.6.15,<0.7" +[feature.dev.tasks] +install_tools = "cargo install -f cargo-binstall && cargo binstall -y --force cargo-feature-combinations && cargo binstall -y --force cargo-semver-checks" + [feature.build.dependencies] compilers = ">=1.7.0,<1.8" cmake = ">=3.29.5,<3.30" diff --git a/src/send/compression.rs b/src/send/compression.rs index ec86567..b73d773 100644 --- a/src/send/compression.rs +++ b/src/send/compression.rs @@ -78,7 +78,7 @@ cfg_if! { inp: Box, ) -> Result<(Box, Format), Error> { Ok(( - Box::new(bzip2::read::BzDecoder::new(inp)), + Box::new(bzip2::read::MultiBzDecoder::new(inp)), Format::Bzip, )) } diff --git a/src/send/mod.rs b/src/send/mod.rs index 69bcfe2..1dd0f33 100644 --- a/src/send/mod.rs +++ b/src/send/mod.rs @@ -77,7 +77,6 @@ pub fn to_path<'a, P: AsRef>( #[cfg(test)] mod test { - use super::*; use tempfile::NamedTempFile; From 96b0ad4c59f3e1d67ceac9fe7b1dae047f58676b Mon Sep 17 00:00:00 2001 From: Luiz Irber Date: Thu, 6 Feb 2025 13:38:33 -0800 Subject: [PATCH 3/8] reuse readme as crate doc --- Cargo.toml | 1 - README.md | 79 +++++++++++++++++++++++++++++++++++++++++++----------- src/lib.rs | 69 +---------------------------------------------- 3 files changed, 65 insertions(+), 84 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4243e70..31b60f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,6 @@ wasm = ["zstd", "lzma", "gz", "bgz"] [dependencies] cfg-if = "1.0" thiserror = "2.0" -#bzip2 = { version = "0.4.4", optional = true, default-features = false } bzip2 = { version = "0.5.0", optional = true, default-features = false } flate2 = { version = "1.0", optional = true, default-features = false } liblzma = { version = "0.3", optional = true, default-features = false } diff --git a/README.md b/README.md index b1714a9..da11bc1 100644 --- a/README.md +++ b/README.md @@ -19,22 +19,71 @@ bioinformatics workflows. [build-status]: https://github.com/luizirber/niffler/workflows/CI/badge.svg [github-actions]: https://github.com/luizirber/niffler/actions?query=workflow%3ACI + +# Example + +```rust +use niffler::{Error, compression}; +# fn main() -> Result<(), Error> { +# #[cfg(feature = "gz")] { +let mut buffer = Vec::new(); + +{ + let mut writer = niffler::get_writer(Box::new(&mut buffer), compression::Format::Gzip, niffler::Level::Nine)?; + writer.write_all(b"hello")?; +} + +# assert_eq!(&buffer, &[0x1f, 0x8b, 8, 0, 0, 0, 0, 0, 2, 255, 203, 72, 205, 201, 201, 7, 0, 134, 166, 16, 54, 5, 0, 0, 0]); + +let (mut reader, compression) = niffler::get_reader(Box::new(&buffer[..]))?; + +let mut contents = String::new(); +reader.read_to_string(&mut contents)?; + +assert_eq!(compression, niffler::compression::Format::Gzip); +assert_eq!(contents, "hello"); +# } +# Ok(()) +# } +``` + ## Selecting compression formats -By default all supported compression formats are enabled. -If you're working on systems that don't support them you can disable default -features and select the ones you want. +By default all supported compression formats are enabled, +using their default features or with an optimized subset of features. + +The crates used for decompression provide a number of features that can have +a significant impact on performance. +For advanced uses, +like selecting specific features for any of the compression crates, +or if you are working on systems that do not support some of the compression formats, +you can disable default features and select the compression formats you want in niffler, +and then you must select the appropriate features for the specific compression crate +implementing that format. For example, -currently only `gz` is supported in Webassembly environments -(because `niffler` depends on crates that have system dependencies for `bz2` and `lzma` compression), -so you can use this in your `Cargo.toml` to select only the `gz` support: -``` -niffler = { version = "2.2.0", default-features = false, features = ["gz"] } +you can use this in your `Cargo.toml` to select only the `gz` support, +and choose your preferred gzip implementation: +```toml +niffler = { version = "3.0.0", default-features = false, features = ["gz"] } +flate2 = { version = "1.0.35", default-features = false, features = ["zlib-ng"] } ``` +These are the niffler features, and the compression crate used. +Check [Cargo.toml](Cargo.toml) for specific versions when adding to your project. +| niffler feature | Crate | Crate features | +| --- | --- | --- | +| `bgz` | [bgzip](https://lib.rs/crates/bgzip) | [Check on docs.rs](https://docs.rs/crate/bgzip/latest/features) | +| `bz2` | [bzip2](https://lib.rs/crates/bzip2) | [Check on docs.rs](https://docs.rs/crate/bzip2/latest/features) | +| `gz` | [flate2](https://lib.rs/crates/flate2) | [Check on docs.rs](https://docs.rs/crate/flate2/latest/features) | +| `lzma` | [liblzma](https://lib.rs/crates/liblzma) | [Check on docs.rs](https://docs.rs/crate/liblzma/latest/features) | +| `zstd` | [zstd](https://lib.rs/crates/zstd) | [Check on docs.rs](https://docs.rs/crate/zstd/latest/features) | + +This is especially useful if you need to link with an external C/C++ project that +has specific requirements, +or if you want to harmonize features with other crates you have in your projects. You can still use `niffler::sniff()` to find what is the compression format, even if any feature is disabled. -But if you try to use `niffler::get_reader` for a disabled feature, +But if you try to use `niffler::get_reader` or `niffler::get_writer` for a feature that was not enabled, it will throw a runtime error. ## Minimum supported Rust version @@ -56,24 +105,24 @@ niffler development is open, and [pull requests](https://github.com/luizirber/ni Before creating your pull request, please try to write a test and benchmark (if possible). Some commands we suggest running to help with these tasks: -``` +```bash cargo fmt cargo test cargo clippy ``` To run tests use: -``` +```bash cargo test --all-features ``` To test benchmark run: -``` +```bash cargo test --benches --all-features ``` To run all benchmark use: -``` +```bash cargo bench --all-features ``` @@ -84,8 +133,8 @@ which will execute all these commands. Licensed under either of these: - * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0) - * MIT License ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT) + * Apache License, Version 2.0 ([LICENSE-APACHE](./LICENSE-APACHE) or ) + * MIT License ([LICENSE-MIT](./LICENSE-MIT) or ) ### Contributing diff --git a/src/lib.rs b/src/lib.rs index 9659d3c..b54ccd6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,71 +1,4 @@ -//! # niffler -//! Simple and transparent support for compressed files. -//! -//! This library provides two main features: -//! - sniffs out compression formats from input files and return a -//! `Read` trait object ready for consumption. -//! - Create a Writer initialized with compression ready for writing. -//! -//! The goal is to lower the barrier to open and use a file, especially in -//! bioinformatics workflows. -//! -//! # Example -//! -//! ```rust -//! use niffler::{Error, compression}; -//! # fn main() -> Result<(), Error> { -//! # #[cfg(feature = "gz")] { -//! let mut buffer = Vec::new(); -//! -//! { -//! let mut writer = niffler::get_writer(Box::new(&mut buffer), compression::Format::Gzip, niffler::Level::Nine)?; -//! writer.write_all(b"hello")?; -//! } -//! -//! # assert_eq!(&buffer, &[0x1f, 0x8b, 8, 0, 0, 0, 0, 0, 2, 255, 203, 72, 205, 201, 201, 7, 0, 134, 166, 16, 54, 5, 0, 0, 0]); -//! -//! let (mut reader, compression) = niffler::get_reader(Box::new(&buffer[..]))?; -//! -//! let mut contents = String::new(); -//! reader.read_to_string(&mut contents)?; -//! -//! assert_eq!(compression, niffler::compression::Format::Gzip); -//! assert_eq!(contents, "hello"); -//! # } -//! # Ok(()) -//! # } -//! ``` -//! -//! ## Selecting compression formats -//! -//! By default all supported compression formats are enabled. -//! If you're working on systems that don't support them you can disable default -//! features and select the ones you want. -//! For example, -//! currently only `gz` is supported in Webassembly environments -//! (because `niffler` depends on crates that have system dependencies for `bz2` and `lzma` compression), -//! so you can use this in your `Cargo.toml` to select only the `gz` support: -//! ```toml -//! niffler = { version = "2.2.0", default-features = false, features = ["gz"] } -//! ``` -//! -//! You can still use `niffler::sniff()` to find what is the compression format, -//! even if any feature is disabled. -//! But if you try to use `niffler::get_reader` for a disabled feature, -//! it will throw a runtime error. -//! -//! ## Backends features -//! -//! The libraries that are used for decompression provide a number of features that can have a significant impact on performance. -//! Here is the list of features available with corresponding backend crates and features name in backend crates: -//! - bz2_tokio -> bzip2 tokio -//! - bz2_static -> bzip2 static -//! - lzma_tokio -> lzma tokio -//! - gz_zlib -> flate2 zlib -//! - gz_zlib-ng-compat -> flate2 zlib-ng-compat -//! - gz_cloudflare_zlib -> flate2 cloudflare_zlib -//! - gz_rust_backend -> flate2 rust_backend -//! - xz_tokio -> xz2 tokio +#![doc = include_str!("../README.md")] /* declare mod */ pub mod basic; From 4e04ff967ed5591509cb29ae8fe1d6fcf2cca985 Mon Sep 17 00:00:00 2001 From: Luiz Irber Date: Thu, 6 Feb 2025 13:51:39 -0800 Subject: [PATCH 4/8] Add instructions to figure out what features are enabled with cargo-tree --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index da11bc1..c6637cb 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,21 @@ Check [Cargo.toml](Cargo.toml) for specific versions when adding to your project | `lzma` | [liblzma](https://lib.rs/crates/liblzma) | [Check on docs.rs](https://docs.rs/crate/liblzma/latest/features) | | `zstd` | [zstd](https://lib.rs/crates/zstd) | [Check on docs.rs](https://docs.rs/crate/zstd/latest/features) | -This is especially useful if you need to link with an external C/C++ project that +You can also run `cargo tree` to verify what features are enabled by default, +and better guide you when choosing the features you want. +```bash +❯ cargo tree -f '{p} {f}' -e no-dev --depth 1 +niffler v3.0.0 bgz,bz2,default,gz,lzma,zstd +├── bgzip v0.3.1 default,flate2,log,rayon,rust_backend +├── bzip2 v0.5.0 default +├── cfg-if v1.0.0 +├── flate2 v1.0.35 any_impl,default,miniz_oxide,rust_backend +├── liblzma v0.3.5 bindgen,default +├── thiserror v2.0.11 default,std +└── zstd v0.13.2 arrays,default,legacy,zdict_builder +``` + +This level of control is especially useful if you need to link with an external C/C++ project that has specific requirements, or if you want to harmonize features with other crates you have in your projects. From 849f77ca72a64343e132d590d7dd0e6c5f28f622 Mon Sep 17 00:00:00 2001 From: Luiz Irber Date: Thu, 6 Feb 2025 14:48:34 -0800 Subject: [PATCH 5/8] remove redundant xz feature; fix wasm feature with working defaults --- Cargo.lock | 7 +++++++ Cargo.toml | 45 +++++++++++++-------------------------------- src/basic/mod.rs | 47 ----------------------------------------------- src/send/mod.rs | 47 ----------------------------------------------- 4 files changed, 20 insertions(+), 126 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa8e97e..56ed988 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,6 +66,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bafdbf26611df8c14810e268ddceda071c297570a5fb360ceddf617fe417ef58" dependencies = [ "bzip2-sys", + "libbz2-rs-sys", "libc", ] @@ -373,6 +374,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "libbz2-rs-sys" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55bbb91f13e5136d00496b884cdb605fb983d6f964c8735bc5837d1c98550fd5" + [[package]] name = "libc" version = "0.2.169" diff --git a/Cargo.toml b/Cargo.toml index 31b60f7..229ebd6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,18 +14,24 @@ rust-version = "1.74" [features] default = [ "bgz", "bgzip/default", - "bz2", "bzip2/default", #for 0.5.0 + "bz2", "bzip2/default", "gz", "flate2/default", - "lzma", "xz", "liblzma/default", + "lzma", "liblzma/default", "zstd", "zstd/default" ] bz2 = ["dep:bzip2"] lzma = ["dep:liblzma"] gz = ["dep:flate2"] bgz = ["dep:bgzip"] -xz = ["lzma"] zstd = ["dep:zstd"] -wasm = ["zstd", "lzma", "gz", "bgz"] + +wasm = [ + "zstd", + "lzma", "liblzma/default", + "gz", "flate2/rust_backend", + "bgz", "bgzip/rust_backend", + "bz2", "bzip2/libbz2-rs-sys", +] [dependencies] cfg-if = "1.0" @@ -57,36 +63,11 @@ required-features = ["bz2"] [[bench]] name = "lzma" harness = false -required-features = ["xz"] +required-features = ["lzma"] [package.metadata.cargo-feature-combinations] denylist = [ - # bzip2 feature transitivity - "bz2_libbz2-rs-sys", - "bz2_static", - - # lzma feature transitivity - "lzma_tokio", - - # flate2 feature transitivity - "gz_zlib", - "gz_zlib-ng", - "gz_zlib-ng-compat", - "gz_cloudflare_zlib", - "gz_rust_backend", - - # xz feature transitivity - "xz_tokio", - - # xz is an alias to lzma - "xz", - - # optional dependencies - "bzip2", - "flate2", - "liblzma", - "bgzip", - - # skip default + # skip default and wasm "default", + "wasm", ] diff --git a/src/basic/mod.rs b/src/basic/mod.rs index 6362392..cc80d73 100644 --- a/src/basic/mod.rs +++ b/src/basic/mod.rs @@ -383,47 +383,6 @@ mod test { assert_eq!(LOREM_IPSUM, buffer.as_slice()); } - #[test] - #[cfg(all(not(feature = "xz"), not(feature = "lzma")))] - fn no_xz_feature() { - assert!( - get_writer(Box::new(vec![]), compression::Format::Xz, Level::Six).is_err(), - "xz disabled, this assertion should fail" - ); - - assert!( - get_reader(Box::new(&LZMA_FILE[..])).is_err(), - "xz disabled, this assertion should fail" - ); - } - - #[cfg(feature = "xz")] - #[test] - fn xz() { - let ofile = NamedTempFile::new().expect("Can't create tmpfile"); - - { - let wfile = ofile.reopen().expect("Can't create tmpfile"); - let mut writer = - get_writer(Box::new(wfile), compression::Format::Xz, Level::Six).unwrap(); - writer - .write_all(LOREM_IPSUM) - .expect("Error during write of data"); - } - - let rfile = ofile.reopen().expect("Can't create tmpfile"); - let (mut reader, compression) = - get_reader(Box::new(rfile)).expect("Error reading from tmpfile"); - - assert_eq!(compression, compression::Format::Xz); - - let mut buffer = Vec::new(); - reader - .read_to_end(&mut buffer) - .expect("Error during reading"); - assert_eq!(LOREM_IPSUM, buffer.as_slice()); - } - #[test] #[cfg(not(feature = "zstd"))] fn no_zstd_feature() { @@ -487,12 +446,6 @@ mod test { assert_eq!(compression, compression::Format::Lzma); } - #[test] - fn xz() { - let (_, compression) = sniff(Box::new(LZMA_FILE)).expect("Error in read file"); - assert_eq!(compression, compression::Format::Xz); - } - #[test] fn zstd() { let (_, compression) = sniff(Box::new(ZSTD_FILE)).expect("Error in read file"); diff --git a/src/send/mod.rs b/src/send/mod.rs index 1dd0f33..c8cde8d 100644 --- a/src/send/mod.rs +++ b/src/send/mod.rs @@ -225,47 +225,6 @@ mod test { assert_eq!(LOREM_IPSUM, buffer.as_slice()); } - #[test] - #[cfg(all(not(feature = "xz"), not(feature = "lzma")))] - fn no_xz_feature() { - assert!( - get_writer(Box::new(vec![]), compression::Format::Xz, Level::Six).is_err(), - "xz disabled, this assertion should fail" - ); - - assert!( - get_reader(Box::new(&LZMA_FILE[..])).is_err(), - "lzma disabled, this assertion should fail" - ); - } - - #[cfg(feature = "xz")] - #[test] - fn xz() { - let ofile = NamedTempFile::new().expect("Can't create tmpfile"); - - { - let wfile = ofile.reopen().expect("Can't create tmpfile"); - let mut writer = - get_writer(Box::new(wfile), compression::Format::Xz, Level::Six).unwrap(); - writer - .write_all(LOREM_IPSUM) - .expect("Error during write of data"); - } - - let rfile = ofile.reopen().expect("Can't create tmpfile"); - let (mut reader, compression) = - get_reader(Box::new(rfile)).expect("Error reading from tmpfile"); - - assert_eq!(compression, compression::Format::Xz); - - let mut buffer = Vec::new(); - reader - .read_to_end(&mut buffer) - .expect("Error during reading"); - assert_eq!(LOREM_IPSUM, buffer.as_slice()); - } - #[test] #[cfg(not(feature = "zstd"))] fn no_zstd_feature() { @@ -329,12 +288,6 @@ mod test { assert_eq!(compression, compression::Format::Lzma); } - #[test] - fn xz() { - let (_, compression) = sniff(Box::new(LZMA_FILE)).expect("Error in read file"); - assert_eq!(compression, compression::Format::Xz); - } - #[test] fn zstd() { let (_, compression) = sniff(Box::new(ZSTD_FILE)).expect("Error in read file"); From f8282e388908cfd619ab91b83beb7a9c6f515051 Mon Sep 17 00:00:00 2001 From: Luiz Irber Date: Thu, 6 Feb 2025 14:49:09 -0800 Subject: [PATCH 6/8] Cargo update --- Cargo.lock | 57 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 56ed988..a3ab043 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -55,9 +55,9 @@ checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "bzip2" @@ -89,9 +89,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.10" +version = "1.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" +checksum = "755717a7de9ec452bf7f3f1a3099085deabd7f2962b861dae91ecd7a365903d2" dependencies = [ "jobserver", "libc", @@ -133,9 +133,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.27" +version = "4.5.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "769b0145982b4b48713e01ec42d61614425f27b7058bda7180a3a41f30104796" +checksum = "3e77c3243bd94243c03672cb5154667347c457ca271254724f9f393aee1c05ff" dependencies = [ "clap_builder", ] @@ -298,13 +298,14 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.15" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" dependencies = [ "cfg-if", "libc", "wasi", + "windows-targets", ] [[package]] @@ -459,9 +460,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.2" +version = "1.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" [[package]] name = "oorandom" @@ -591,9 +592,9 @@ checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" [[package]] name = "same-file" @@ -626,9 +627,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.137" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "930cfb6e6abf99298aaad7d29abbef7a9999a9a8806a40088f55f0dcec03146b" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" dependencies = [ "itoa", "memchr", @@ -644,9 +645,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "syn" -version = "2.0.96" +version = "2.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" dependencies = [ "proc-macro2", "quote", @@ -655,9 +656,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.15.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" +checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" dependencies = [ "cfg-if", "fastrand", @@ -719,9 +720,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11cd88e12b17c6494200a9c1b683a04fcac9573ed74cd1b62aeb2727c5592243" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" [[package]] name = "walkdir" @@ -735,9 +736,12 @@ dependencies = [ [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.13.3+wasi-0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] [[package]] name = "wasm-bindgen" @@ -889,6 +893,15 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags", +] + [[package]] name = "zstd" version = "0.13.2" From 285cc067f59a2f714f3ff8ba124018b5d3bada83 Mon Sep 17 00:00:00 2001 From: Luiz Irber Date: Thu, 6 Feb 2025 14:55:05 -0800 Subject: [PATCH 7/8] fix clippy issue --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c6637cb..5111d17 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Simple and transparent support for compressed files. This library provides two main features: - sniffs out compression formats from input files and returns a -Read trait object ready for consumption. + Read trait object ready for consumption. - Create a Writer initialized with compression ready for writing. The goal is to lower the barrier to open and use a file, especially in From d22cb5a383c04b22794ee323baabb899a7a8d70f Mon Sep 17 00:00:00 2001 From: Luiz Irber Date: Thu, 6 Feb 2025 15:18:52 -0800 Subject: [PATCH 8/8] temporarily use git until new bzip2 version is released --- Cargo.lock | 7 ++----- Cargo.toml | 4 +++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3ab043..d0a3df8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,19 +62,16 @@ checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "bzip2" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bafdbf26611df8c14810e268ddceda071c297570a5fb360ceddf617fe417ef58" +source = "git+https://github.com/trifectatechfoundation/bzip2-rs#09a87db73c0517a9715ab3fd96fbe4961d545aee" dependencies = [ "bzip2-sys", "libbz2-rs-sys", - "libc", ] [[package]] name = "bzip2-sys" version = "0.1.11+1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +source = "git+https://github.com/trifectatechfoundation/bzip2-rs#09a87db73c0517a9715ab3fd96fbe4961d545aee" dependencies = [ "cc", "libc", diff --git a/Cargo.toml b/Cargo.toml index 229ebd6..6964c36 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,9 @@ wasm = [ [dependencies] cfg-if = "1.0" thiserror = "2.0" -bzip2 = { version = "0.5.0", optional = true, default-features = false } +#bzip2 = { version = "0.5.0", optional = true, default-features = false } +## Need a 0.5.1 release to be able to use bzip2, because of auto finish and libc dep removal +bzip2 = { version = "0.5.0", git = "https://github.com/trifectatechfoundation/bzip2-rs", optional = true, default-features = false } flate2 = { version = "1.0", optional = true, default-features = false } liblzma = { version = "0.3", optional = true, default-features = false } bgzip = { version = "0.3", optional = true, default-features = false }