{"id":13438724,"url":"https://github.com/rust-lang/flate2-rs","last_synced_at":"2025-12-12T12:40:39.879Z","repository":{"id":18742178,"uuid":"21954009","full_name":"rust-lang/flate2-rs","owner":"rust-lang","description":"DEFLATE, gzip, and zlib bindings for Rust","archived":false,"fork":false,"pushed_at":"2025-05-05T17:12:07.000Z","size":1188,"stargazers_count":1004,"open_issues_count":24,"forks_count":177,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-05-08T00:13:34.490Z","etag":null,"topics":["deflate","gzip","zlib","zlib-ng"],"latest_commit_sha":null,"homepage":"https://docs.rs/flate2","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rust-lang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-07-17T19:03:20.000Z","updated_at":"2025-05-07T20:03:29.000Z","dependencies_parsed_at":"2024-03-14T19:02:24.753Z","dependency_job_id":"5a41d020-e699-4150-a21c-32a7dfdd93ee","html_url":"https://github.com/rust-lang/flate2-rs","commit_stats":{"total_commits":540,"total_committers":100,"mean_commits":5.4,"dds":"0.49629629629629635","last_synced_commit":"1a28821dc116dac14178858be056e4a58ef8f501"},"previous_names":["alexcrichton/flate2-rs"],"tags_count":71,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang%2Fflate2-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang%2Fflate2-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang%2Fflate2-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang%2Fflate2-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rust-lang","download_url":"https://codeload.github.com/rust-lang/flate2-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253342299,"owners_count":21893558,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deflate","gzip","zlib","zlib-ng"],"created_at":"2024-07-31T03:01:07.886Z","updated_at":"2025-12-12T12:40:39.810Z","avatar_url":"https://github.com/rust-lang.png","language":"Rust","funding_links":[],"categories":["Libraries","Rust","库 Libraries","others"],"sub_categories":["Compression","压缩 Compression"],"readme":"# flate2\n\n[![Crates.io](https://img.shields.io/crates/v/flate2.svg?maxAge=2592000)](https://crates.io/crates/flate2)\n[![Documentation](https://docs.rs/flate2/badge.svg)](https://docs.rs/flate2)\n\nA streaming compression/decompression library DEFLATE-based streams in Rust.\n\nThis crate by default uses the `miniz_oxide` crate, a port of `miniz.c` to pure\nRust. This crate also supports other [backends](#backends), such as the widely\navailable zlib library or the high-performance zlib-ng library.\n\nSupported formats:\n\n* deflate\n* zlib\n* gzip\n\n```toml\n# Cargo.toml\n[dependencies]\nflate2 = \"1.0\"\n```\n\n## MSRV (Minimum Supported Rust Version) Policy\n\nThis crate supports the current and previous stable versions of the Rust compiler.\nFor example, if the current stable is 1.80, this crate supports 1.80 and 1.79.\n\nOther compiler versions may work, but failures may not be treated as a `flate2` bug.\n\nThe `Cargo.toml` file specifies a `rust-version` for which builds of the current version\npassed at some point. This value is indicative only, and may change at any time.\n\nThe `rust-version` is a best-effort measured value and is different to the MSRV. The\n`rust-version` can be incremented by a PR in order to pass tests, as long as the MSRV\ncontinues to hold. When the `rust-version` increases, the next release should be a minor\nversion, to allow any affected users to pin to a previous minor version.\n\n## Compression\n\n```rust\nuse std::io::prelude::*;\nuse flate2::Compression;\nuse flate2::write::ZlibEncoder;\n\nfn main() {\n    let mut e = ZlibEncoder::new(Vec::new(), Compression::default());\n    e.write_all(b\"foo\");\n    e.write_all(b\"bar\");\n    let compressed_bytes = e.finish();\n}\n```\n\n## Decompression\n\n```rust,no_run\nuse std::io::prelude::*;\nuse flate2::read::GzDecoder;\n\nfn main() {\n    let mut d = GzDecoder::new(\"...\".as_bytes());\n    let mut s = String::new();\n    d.read_to_string(\u0026mut s).unwrap();\n    println!(\"{}\", s);\n}\n```\n\n## Backends\n\nThe default `miniz_oxide` backend has the advantage of only using safe Rust.\n\nIf you want maximum performance while still benefiting from a Rust\nimplementation at the cost of some `unsafe`, you can use `zlib-rs`:\n\n```toml\n[dependencies]\nflate2 = { version = \"1.0.17\", features = [\"zlib-rs\"], default-features = false }\n```\n\n### C backends\n\nWhile zlib-rs is [the fastest overall](https://trifectatech.org/blog/zlib-rs-is-faster-than-c/),\nthe zlib-ng C library can be slightly faster in certain cases:\n\n```toml\n[dependencies]\nflate2 = { version = \"1.0.17\", features = [\"zlib-ng\"], default-features = false }\n```\n\nNote that the `\"zlib-ng\"` feature works even if some other part of your crate\ngraph depends on zlib.\n\nHowever, if you're already using another C or Rust library that depends on\nzlib, and you want to avoid including both zlib and zlib-ng, you can use that\nfor Rust code as well:\n\n```toml\n[dependencies]\nflate2 = { version = \"1.0.17\", features = [\"zlib\"], default-features = false }\n```\n\nOr, if you have C or Rust code that depends on zlib and you want to use zlib-ng\nvia libz-sys in zlib-compat mode, use:\n\n```toml\n[dependencies]\nflate2 = { version = \"1.0.17\", features = [\"zlib-ng-compat\"], default-features = false }\n```\n\nNote that when using the `\"zlib-ng-compat\"` feature, if any crate in your\ndependency graph explicitly requests stock zlib, or uses libz-sys directly\nwithout `default-features = false`, you'll get stock zlib rather than zlib-ng.\nSee [the libz-sys\nREADME](https://github.com/rust-lang/libz-sys/blob/main/README.md) for details.\nTo avoid that, use the `\"zlib-ng\"` feature instead.\n\nFor compatibility with previous versions of `flate2`, the Cloudflare optimized\nversion of zlib is available, via the `cloudflare_zlib` feature. It's not as\nfast as zlib-ng, but it's faster than stock zlib. It requires an x86-64 CPU with\nSSE 4.2 or ARM64 with NEON \u0026 CRC. It does not support 32-bit CPUs at all and is\nincompatible with mingw. For more information check the [crate\ndocumentation](https://crates.io/crates/cloudflare-zlib-sys). Note that\n`cloudflare_zlib` will cause breakage if any other crate in your crate graph\nuses another version of zlib/libz.\n\n# License\n\nThis project is licensed under either of\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or\n   https://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or\n   https://opensource.org/licenses/MIT)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this project by you, as defined in the Apache-2.0 license,\nshall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-lang%2Fflate2-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frust-lang%2Fflate2-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-lang%2Fflate2-rs/lists"}