memvec/lib.rs
1//! # MemVec - Memory-Mapped Vectors
2//!
3//! A high-performance library that provides `Vec`-like interface over memory-mapped storage.
4//! MemVec bridges the gap between standard Rust vectors and persistent or high-performance
5//! memory backends through a clean, pluggable architecture.
6//!
7//! ## Core Architecture
8//!
9//! MemVec is built around three key concepts:
10//!
11//! ### 1. Frontend: MemVec
12//! [`MemVec<T, A>`] is the main interface that provides all the familiar `Vec<T>` methods
13//! you know and love - `push()`, `pop()`, `insert()`, `remove()`, indexing, iteration, etc.
14//! It acts as a frontend that wraps any memory backend.
15//!
16//! ### 2. Backend: Memory Trait
17//! Any type implementing the [`Memory`] trait can serve as a backend for `MemVec`.
18//! This pluggable design allows you to choose the right storage strategy for your needs
19//! or implement custom backends.
20//!
21//! ### 3. Built-in Backends
22//! The library provides several ready-to-use backends:
23//!
24//! - **[`VecFile`]** - File-backed storage with automatic persistence
25//! - **[`MmapAnon`]** - Anonymous memory mapping for high-performance temporary storage
26//! - **[`MmapFile`]** - Low-level file mapping for advanced use cases
27//!
28//! ## Performance Benefits
29//!
30//! - **Zero-copy operations** - Direct memory access without serialization
31//! - **Memory-mapped I/O** - Let the OS handle efficient data loading
32//! - **Familiar API** - No learning curve if you know `Vec<T>`
33
34mod mem_vec;
35mod memory;
36mod mmap;
37
38#[cfg(test)]
39mod tests;
40
41pub use mem_vec::MemVec;
42pub use memory::{Memory, MemoryLayoutError};
43pub use mmap::{MmapAnon, MmapFile, VecFile};