Zebo
Zebo is a simple library that help you to write data on FS effectively. It groups your data in files according to the limitations you imposed.
Usage
To use this crate, add the following to your Cargo.toml:
[]
= "*"
use Zebo;
Design choice
You may wonder why there's no "insert_document" method. Instead, we have "reserve_space_for" method that reserves space for multiple documents at once. This is because reserving space for multiple documents at once allows Zebo to optimize file usage and minimize fragmentation.
But, there's another important reason.
Consider you have RwLock<Zebo> and you want to insert a lot of documents.
Based on the current design, you can do:
use Zebo;
use RwLock;
let zebo = try_new.unwrap;
let zebo = new;
let mut lock = zebo.write.unwrap;
let space = lock.reserve_space_for.unwrap;
drop; // Release the lock ASAP
space.write_all.unwrap; // Write the content outside the lock
So you can write documents without holding the lock.
This because space points to a specific location in a specific file, and writing to that location does not require access to the Zebo instance itself.