#snappy #bindings

已删除 susy-dev-snappy

Rust 对 snappy 压缩库的绑定

使用旧的 Rust 2015

0.1.0 2019年3月22日

#21#snappy

GPL-3.0 许可证

1MB
2.5K SLoC

C++ 2.5K SLoC // 0.2% comments Rust 179 SLoC // 0.1% comments

susy-dev-snappy

Build Status Build status

Rust 对 snappy 压缩库的绑定。

目前此库使用 snappy v1.1.7。snappy 的源代码包含在 susy-dev-snappy-sys 包中,因此无需预先安装 snappy,库将被静态链接。

示例

use susy_dev_snappy as snappy;

let input: Vec<u8> = ...;
let compressed = snappy::compress(&input);
let decompressed = snappy::decompress(&compressed);

assert_eq!(decompressed == input);
use susy_dev_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);

依赖项