Crate sfa

Crate sfa 

Source
Expand description

SFA (simple file-based archive) is a minimal, flat file archive encoding/decoding library for Rust.

The file can be segmented into multiple sections (similar to a zip file), and individual sections accessed as a std::io::Read.

use sfa::{Writer, Reader};
use std::io::{Read, Write};

let mut writer = Writer::new_at_path(&path)?;
writer.start("Section 1")?;
writer.write_all(b"Hello world!\n")?;
writer.finish()?;
// If on Unix, you probably want to fsync the directory here

let reader = Reader::new(&path)?;
let toc = reader.toc();
assert_eq!(toc.len(), 1);
assert_eq!(toc[0].name(), b"Section 1");
assert_eq!(toc[0].len(), 13);

let reader = toc[0].buf_reader(&path).unwrap();
assert_eq!(b"Hello world!\n", &*reader.bytes().collect::<Result<Vec<_>, _>>()?);

Structs§

Checksum
An 128-bit checksum
Reader
Archive reader
Toc
Table of contents
TocEntry
Entry in the table of contents (a section in the archive)
Writer
Archive writer

Enums§

Error
Error type