| Crates.io | entidb_storage |
| lib.rs | entidb_storage |
| version | 2.0.0-alpha.3 |
| created_at | 2025-12-25 14:42:45.264698+00 |
| updated_at | 2026-01-03 03:09:16.260792+00 |
| description | Storage backend trait and implementations for EntiDB |
| homepage | |
| repository | https://github.com/Tembocs/entidb |
| max_upload_size | |
| id | 2004614 |
| size | 86,077 |
Storage backend trait and implementations for EntiDB.
This crate provides the lowest-level storage abstraction for EntiDB. Storage backends are opaque byte stores - they do not interpret the data they store.
Send + Sync for concurrent access| Backend | Use Case |
|---|---|
InMemoryBackend |
Testing, ephemeral storage |
FileBackend |
Persistent storage using OS file APIs |
use entidb_storage::{StorageBackend, InMemoryBackend, FileBackend};
use std::path::Path;
// In-memory for tests
let mut memory = InMemoryBackend::new();
let offset = memory.append(b"hello").unwrap();
let data = memory.read_at(offset, 5).unwrap();
// File for persistence
let mut file = FileBackend::open(Path::new("data.bin")).unwrap();
file.append(b"persistent data").unwrap();
file.sync().unwrap(); // Ensure durability
pub trait StorageBackend: Send + Sync {
fn read_at(&self, offset: u64, len: usize) -> Result<Vec<u8>>;
fn append(&mut self, data: &[u8]) -> Result<u64>;
fn flush(&mut self) -> Result<()>;
fn size(&self) -> Result<u64>;
fn sync(&mut self) -> Result<()>;
}
MIT OR Apache-2.0