block-db 0.2.0

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

use super::{
    error::Error,
    util::map_data_file::{map_data_file, map_data_files},
    BlockDB,
};

impl BlockDB {
    /// Recovers a specific `DataFile` to a known good state.
    ///
    /// During recovery, the `DataFile` will replay its WAL,
    /// truncate the binary file to the correct length,
    /// and update in-memory state accordingly.
    ///
    /// ---
    /// - **Atomic**
    /// - **Non-corruptible**
    ///
    /// ---
    /// Example
    /// ``` let block_db = BlockDB::open("./data", None).await?;
    ///
    /// block_db.recover_data_file("3f-6hf").await?;
    /// ```
    /// ---
    pub async fn recover_data_file<S: AsRef<str>>(&self, data_file_id: S) -> Result<(), Error> {
        map_data_file!(self, data_file_id.as_ref(), recover);

        Ok(())
    }

    /// Recovers all `DataFile`s to a known good state.
    ///
    /// During recovery, each `DataFile` will replay its WAL and truncate the
    /// binary file to the correct length. This process restores the in-memory
    /// state to match the persistent state on disk.
    ///
    /// ---
    /// - **Atomic**
    /// - **Non-corruptible**
    ///
    /// ---
    /// Example
    /// ``` let block_db = BlockDB::open("./data", None).await?;
    ///
    /// block_db.recover_data_files().await?;
    /// ```
    /// ---
    pub async fn recover_data_files(&self) -> Result<(), Error> {
        map_data_files!(self, recover);

        Ok(())
    }
}