farena-0.1.0 has been yanked.
farena
File-backed arena allocator using pread(2) for RSS-conscious byte storage.
Usage
use ;
// Write phase
let mut writer = new?;
let = writer.push?;
let = writer.push?;
let file = writer.finish?.unwrap;
// Read phase
let arena = new?;
let loc1 = new;
let loc2 = new;
assert_eq!;
assert_eq!;
Multiple files
let mut w1 = new?;
let = w1.push?;
let f1 = w1.finish?.unwrap;
let mut w2 = new?;
let = w2.push?;
let f2 = w2.finish?.unwrap;
let arena = new?;
let loc1 = new; // file index 0
let loc2 = new; // file index 1
Buffer reuse
let mut buf = Vecnew;
arena.get_into?; // appends to buf
API
| Method | Description |
|---|---|
FileArenaWriter::new() |
Create writer backed by temp file |
writer.push(data) |
Append data, returns (offset, len) |
writer.finish() |
Flush and return file handle |
FileArena::new(files) |
Create arena from file handles |
arena.get(loc) |
Read bytes at location |
arena.get_into(loc, buf) |
Read bytes into buffer |