block_db/
delete.rs

1// Authors: Robert Lopez
2
3use super::{error::Error, util::fs::delete_directory, BlockDB, ConfirmDestructiveAction};
4
5impl BlockDB {
6    /// ⚠️ **DELETES the `BlockDB` and _all_ of its data. This action is irreversible.**
7    ///
8    /// Requires explicitly passing `ConfirmDestructiveAction::IKnowWhatImDoing`
9    /// to confirm intent.
10    ///
11    /// Use with extreme caution. This will remove all `DataFile`s, metadata,
12    /// WALs, and configuration associated with the database.
13    ///
14    /// ---
15    /// - **Atomic**
16    /// - **Non-corruptible**
17    ///
18    /// ---
19    /// Example
20    /// ```
21    /// let block_db = BlockDB::open("./data", None).await?;
22    ///
23    /// block_db.delete(ConfirmDestructiveAction::IKnowWhatImDoing).await?;
24    /// ```
25    pub async fn delete(self, _: ConfirmDestructiveAction) -> Result<(), Error> {
26        delete_directory(&self.path).await?;
27
28        Ok(())
29    }
30}