Expand description
§tzip - TorrentZip Library for Rust
Create, update, and validate TorrentZip-formatted ZIP files.
§What is TorrentZip?
TorrentZip is a standardized ZIP format designed for reproducible, deterministic archives. It ensures that identical input always produces byte-identical output, making it ideal for:
- ROM preservation and distribution
- BitTorrent sharing (identical hashes across sources)
- Content-addressable storage
§TorrentZip Requirements
- All files sorted by lowercase filename
- Fixed timestamp: December 24, 1996, 23:32:00
- DEFLATE compression at maximum level (9)
- Archive comment:
TORRENTZIPPED-{CRC32}where CRC32 is of the central directory
§Example: Creating a TorrentZip
use tzip::TorrentZipWriter;
use std::io::Cursor;
let mut buffer = Cursor::new(Vec::new());
let mut tz = TorrentZipWriter::new(&mut buffer);
tz.add_file("game.bin", &[0x00, 0x01, 0x02, 0x03]).unwrap();
tz.add_file("readme.txt", b"This is a readme").unwrap();
tz.finish().unwrap();
// buffer now contains a valid TorrentZip archive
println!("TorrentZip CRC32: {:08X}", tz.torrentzip_crc32().unwrap());Modules§
- spec
- ZIP format constants and structures for TorrentZip compliance.
Structs§
- Torrent
ZipValidator - TorrentZip validator
- Torrent
ZipWriter - TorrentZip-compliant ZIP file writer.
- Validation
Result - Result of TorrentZip validation
Enums§
- Error
- Main error type for tzip operations.
- Validation
Error - Validation error for TorrentZip compliance checking.
Functions§
- compute_
central_ directory_ crc32 - Compute CRC32 of the central directory headers only.
- create_
torrentzip - Convenience function to create a TorrentZip from file pairs.
Type Aliases§
- Result
- Result type alias for tzip operations.