#string #deflate #ram #gzip

compressed_string

使用DEFLATE算法存储在内存中的压缩字符串

1个稳定版本

1.0.0 2018年12月30日

#25#ram

Download history 1/week @ 2024-03-26 14/week @ 2024-04-02

112 每月下载量

CC0 许可

6KB
79

内存中压缩的 String

如果你的应用程序在RAM中保存许多长字符串,你可以通过压缩字符串来减少其内存使用。

可选地,如果启用了 with_serde 功能,它也可以用于在已压缩的形式中序列化和反序列化字符串的二进制格式。

use compressed_string::ComprString;

let raw = "It uses the deflate algorithm, which has a small header overhead, \
so it's suitable even for short-ish strings";

let compr = ComprString::new(raw);

assert_eq!(109, raw.len());
assert_eq!(84, compr.compressed_len());

println!("{}", compr);
let string = compr.to_string();

lib.rs:

use compressed_string::ComprString;

let raw = "It uses the deflate algorithm, which has a small header overhead, \
so it's suitable even for short-ish strings";

let compr = ComprString::new(raw);

assert_eq!(109, raw.len());
assert_eq!(84, compr.compressed_len());

println!("{}", compr);
let string = compr.to_string();

依赖项

~260–490KB