block-db 0.2.0

Local, multi-threaded, durable byte DB.
Documentation
// Authors: Robert Lopez

#![allow(unused_parens)]
use crate::options::BlockDBOptions;
use nanoid::nanoid;
use serde::{Deserialize, Serialize};
use std::collections::VecDeque;

#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct DataBlock {
    pub padding: usize,
    pub chunk_offsets: VecDeque<usize>,
}

impl DataBlock {
    pub fn size(&self, options: &BlockDBOptions) -> usize {
        self.chunk_offsets.len() * options.chunk_size()
    }

    pub fn generate_id() -> String {
        nanoid!(15)
    }
}