概要
- Zeekstd はRust製のZstandard Seekable Format実装ライブラリ
- 圧縮データを 独立したフレーム 単位で管理し、部分展開が容易
- CLIツール も同梱し、通常のzstdツールと類似の使用感
- C実装の制約を解消し、 高度なAPI を活用
- BSD 2-Clauseライセンスで オープンソース公開
Zeekstd: RustによるZstandard Seekable Format実装
- Zeekstd は、Rustで書かれた Zstandard Seekable Format の実装ライブラリ
- Seekable Formatは、圧縮データを 独立した複数フレーム に分割管理
- アーカイブ中間部の展開時、 必要最小限のフレームのみ展開 可能
- 通常のzstd圧縮ファイルは 単一フレーム、全体展開が必要
- 初期仕様との互換性 を維持しつつ、アップデートされた仕様を実装
- 圧縮時、デフォルトで 2MiBごとに新フレーム自動生成
圧縮処理例(Rustコード)
- ファイルを seekable.zst として圧縮保存
- 圧縮終了時に シークテーブル を末尾へ書き込み
use std::{fs::File, io};
use zeekstd::Encoder;
fn main() -> zeekstd::Result<()> {
let mut input = File::open("data")?;
let output = File::create("seekable.zst")?;
let mut encoder = Encoder::new(output)?;
io::copy(&mut input, &mut encoder)?;
encoder.finish()?; // 圧縮終了とシークテーブル書き込み
Ok(())
}
展開処理例(Rustコード)
- デフォルトで 全フレーム展開
- 特定フレームのみ展開 する設定も可能
use std::{fs::File, io};
use zeekstd::Decoder;
fn main() -> zeekstd::Result<()> {
let input = File::open("seekable.zst")?;
let mut output = File::create("decompressed")?;
let mut decoder = Decoder::new(input)?;
io::copy(&mut decoder, &mut output)?; // 全体展開
let mut partial = File::create("partial")?;
decoder.set_lower_frame(2);
decoder.set_upper_frame(5);
io::copy(&mut decoder, &mut partial)?; // フレーム2〜5のみ展開
Ok(())
}
CLIツール
- コマンドラインツール を同梱
- ライブラリ同様の seekable圧縮・展開 処理が可能
ライセンス
- zstd Cライブラリ はBSD/GPLv2のデュアルライセンス
- Zeekstd はBSD 2-Clauseライセンス
開発背景と経緯
- 通常のzstd圧縮ファイルは 単一フレーム構造
- 大容量ファイルのダウンロード再開や部分展開 要件から、seekable formatに着目
- C実装(upstream/contrib/seekable_format)を バインディング利用 も、機能制限・API非推奨・メンテナンス性に課題
- Rustによる完全な再実装 を決意
- zstd 1.4.0以降 の高度な圧縮APIを活用
- 単一依存のライブラリクレート と、 CLIクレート を公開
参考リンク
フィードバックのお願い
- 利用者からのフィードバック を歓迎
- 不具合報告や要望 の受付
主な特徴まとめ
- 部分展開に最適なZstandard圧縮 のRust実装
- 高い互換性 と 柔軟なフレーム制御
- CLIツール同梱 で即利用可能
- BSD 2-Clauseライセンス によるオープンソース提供