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

Function compress

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

Source from the content-addressed store, hash-verified

11}
12
13pub fn compress(data: &[u8]) -> Vec<u8> {
14 let mut out = Vec::new();
15 COMPRESSOR.with(|c| {
16 if let Ok(mut c) = c.try_borrow_mut() {
17 match &mut *c {
18 Ok(c) => match c.compress(data) {
19 Ok(res) => out = res,
20 Err(err) => {
21 crate::log::debug!("Failed to compress: {}", err);
22 }
23 },
24 Err(err) => {
25 crate::log::debug!("Failed to get compressor: {}", err);
26 }
27 }
28 }
29 });
30 out
31}
32
33pub fn decompress(data: &[u8]) -> Vec<u8> {
34 let mut out = Vec::new();

Callers 2

storeMethod · 0.85
readMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected