farena 0.1.0

A file-backed arena allocator using pread for RSS-conscious byte storage
Documentation
//! File-backed arena allocator using `pread(2)` for RSS-conscious byte storage.
//!
//! # Usage
//!
//! ```rust
//! use farena::{FileArena, FileArenaWriter, Location};
//!
//! // Write phase
//! let mut writer = FileArenaWriter::new()?;
//! let (offset1, len1) = writer.push("hello")?;
//! let (offset2, len2) = writer.push(" world")?;
//! let file = writer.finish()?.unwrap();
//!
//! // Read phase
//! let arena = FileArena::new(vec![file])?;
//! let loc1 = Location::new(0, offset1, len1);
//! let loc2 = Location::new(0, offset2, len2);
//!
//! assert_eq!(arena.get(loc1)?, b"hello");
//! assert_eq!(arena.get(loc2)?, b" world");
//! # Ok::<_, std::io::Error>(())
//! ```
//!
//! # Multiple files
//!
//! Each file gets an index in the arena:
//!
//! ```rust
//! # use farena::{FileArena, FileArenaWriter, Location};
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let mut w1 = FileArenaWriter::new()?;
//! let (o1, l1) = w1.push("data1")?;
//! let f1 = w1.finish()?.unwrap();
//!
//! let mut w2 = FileArenaWriter::new()?;
//! let (o2, l2) = w2.push("data2")?;
//! let f2 = w2.finish()?.unwrap();
//!
//! let arena = FileArena::new(vec![f1, f2])?;
//! let loc1 = Location::new(0, o1, l1);  // file index 0
//! let loc2 = Location::new(1, o2, l2);  // file index 1
//! # Ok(())
//! # }
//! ```

mod arena;
mod location;
mod writer;

pub use arena::FileArena;
pub use location::Location;
pub use writer::FileArenaWriter;