1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Authors: Robert Lopez
use super::{error::Error, BlockDB, ConfirmDestructiveAction};
use crate::util::map_data_file::{map_data_file, map_data_files};
impl BlockDB {
/// ⚠️ **CLEARS a `DataFile` of _all_ of its data. This action is irreversible.**
///
/// Requires explicitly passing `ConfirmDestructiveAction::IKnowWhatImDoing`
/// to confirm intent.
///
/// Use with extreme caution.
///
/// ---
/// - **Atomic**
/// - **Corruptible**
///
/// ---
/// Example
/// ```
/// let block_db = BlockDB::open("./data", None).await?;
///
/// block_db.clear_data_file("3f-6hf", ConfirmDestructiveAction::IKnowWhatImDoing).await?;
/// ```
pub async fn clear_data_file<S: AsRef<str>>(
&self,
data_file_id: S,
_: ConfirmDestructiveAction,
) -> Result<(), Error> {
map_data_file!(self, data_file_id.as_ref(), clear);
Ok(())
}
/// ⚠️ **CLEARS _all_ `DataFile`s and _all_ of their data. This action is irreversible.**
///
/// Requires explicitly passing `ConfirmDestructiveAction::IKnowWhatImDoing`
/// to confirm intent.
///
/// Use with extreme caution.
///
/// ---
/// - **Atomic**
/// - **Corruptible**
///
/// ---
/// Example
/// ```
/// let block_db = BlockDB::open("./data", None).await?;
///
/// block_db.clear_data_files(ConfirmDestructiveAction::IKnowWhatImDoing).await?;
/// ```
pub async fn clear_data_files(&self, _: ConfirmDestructiveAction) -> Result<(), Error> {
map_data_files!(self, clear);
Ok(())
}
}