使用旧的 Rust 2015
0.1.0 |
|
---|
#22 in #snappy
1MB
2.5K SLoC
susy-snappy
Rust 对 snappy 压缩库的绑定。
目前此库使用 snappy v1.1.7。snappy 的源代码包含在 susy-snappy-sys
包中,因此无需预先安装 snappy,库将被静态链接。
示例
use susy_snappy as snappy;
let input: Vec<u8> = ...;
let compressed = snappy::compress(&input);
let decompressed = snappy::decompress(&compressed);
assert_eq!(decompressed == input);
use susy_snappy as snappy;
let input: Vec<u8> = ...;
let mut compressed = Vec::with_capacity(snappy::max_compressed_len(input.len()));
let mut decompressed = Vec::with_capacity(input.len());
let len = snappy::compress_into(&input, &mut compressed);
let _ = snappy::decompress_into(&compressed[..len], &mut decompressed);
assert_eq!(decompressed == input);