SFA (simple file 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 or (offset, len) tuples.
Sponsors
Basic usage
use ;
use ;
let file = create?;
let mut file = new;
let mut writer = from_writer;
writer.start?;
writer.write_all?;
writer.finish?;
file.get_mut.sync_all?;
drop;
// If on Unix, you probably want to fsync the directory here
let reader = new?;
let toc = reader.toc;
assert_eq!;
assert_eq!;
assert_eq!;
let reader = toc.buf_reader.unwrap;
assert_eq!;
Stable disk format
The disk format will be stable as of 1.0.0.
Future breaking changes will result in a major version bump.
??? (header content)
[section1]
??? (section1 content)
[section2]
??? (section2 content)
[toc]
[magic, 4 bytes]
[len, 4 bytes]
<section pos, 8 bytes>
<section len, 8 bytes>
<section name, len = N, 2 bytes>
<section name, N bytes>
...
[trailer]
[magic, 4 bytes]
[version, 1 byte, 0x1]
[checksum type, 1 byte, always 0x0]
[toc checksum, 16 bytes]
[toc pos, 8 bytes]
[toc len, 8 bytes]
All integers are little-endian encoded.
License
All source code is licensed under MIT OR Apache-2.0.
All contributions are to be licensed as MIT OR Apache-2.0.