1个稳定版本
1.0.0 | 2018年12月30日 |
---|
#25 在 #ram
112 每月下载量
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