MCPcopy Create free account
hub / github.com/Recordscript/recordscript / decompress

Function decompress

libs/hbb_common/src/compress.rs:33–57  ·  view source on GitHub ↗
(data: &[u8])

Source from the content-addressed store, hash-verified

31}
32
33pub fn decompress(data: &[u8]) -> Vec<u8> {
34 let mut out = Vec::new();
35 DECOMPRESSOR.with(|d| {
36 if let Ok(mut d) = d.try_borrow_mut() {
37 match &mut *d {
38 Ok(d) => {
39 const MAX: usize = 1024 * 1024 * 64;
40 const MIN: usize = 1024 * 1024;
41 let mut n = 30 * data.len();
42 n = n.clamp(MIN, MAX);
43 match d.decompress(data, n) {
44 Ok(res) => out = res,
45 Err(err) => {
46 crate::log::debug!("Failed to decompress: {}", err);
47 }
48 }
49 }
50 Err(err) => {
51 crate::log::debug!("Failed to get decompressor: {}", err);
52 }
53 }
54 }
55 });
56 out
57}

Callers 2

loadMethod · 0.85
writeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected