Update zstd-safe to 7.1.0 and zstd to 0.13.1 in pingora-header-serde

Includes-commit: 0026a572a7
Replicated-from: https://github.com/cloudflare/pingora/pull/197
This commit is contained in:
Johan Planchon 2024-04-10 22:06:14 +00:00 committed by Kevin Guthrie
parent e19d8c817d
commit 218dbdfd5d
3 changed files with 6 additions and 5 deletions

2
.bleep
View file

@ -1 +1 @@
996a452a8ef2543944390046e383351d79c8e803
ffd2f7edb1d520d04fe3ec61dab949b10ff6e0f1

View file

@ -22,8 +22,8 @@ name = "trainer"
path = "src/trainer.rs"
[dependencies]
zstd = "0.9.0"
zstd-safe = "4.1.1"
zstd = "0.13.1"
zstd-safe = { version = "7.1.0", features = ["std"] }
http = { workspace = true }
bytes = { workspace = true }
httparse = { workspace = true }

View file

@ -14,6 +14,7 @@
use std::cell::RefCell;
use thread_local::ThreadLocal;
use zstd_safe::{CCtx, DCtx};
/// Each thread will own its compression and decompression CTXes, and they share a single dict
/// https://facebook.github.io/zstd/zstd_manual.html recommends to reuse ctx per thread
@ -50,7 +51,7 @@ impl Compression {
level: i32,
) -> Result<usize, &'static str> {
self.com_context
.get_or(|| RefCell::new(zstd_safe::create_cctx()))
.get_or(|| RefCell::new(CCtx::create()))
.borrow_mut()
.compress_using_dict(destination, source, &self.dict[..], level)
.map_err(zstd_safe::get_error_name)
@ -71,7 +72,7 @@ impl Compression {
destination: &mut C,
) -> Result<usize, &'static str> {
self.de_context
.get_or(|| RefCell::new(zstd_safe::create_dctx()))
.get_or(|| RefCell::new(DCtx::create()))
.borrow_mut()
.decompress_using_dict(destination, source, &self.dict)
.map_err(zstd_safe::get_error_name)