block_db/
recover_data_file.rs

1// Authors: Robert Lopez
2
3use super::{
4    error::Error,
5    util::map_data_file::{map_data_file, map_data_files},
6    BlockDB,
7};
8
9impl BlockDB {
10    /// Recovers a specific `DataFile` to a known good state.
11    ///
12    /// During recovery, the `DataFile` will replay its WAL,
13    /// truncate the binary file to the correct length,
14    /// and update in-memory state accordingly.
15    ///
16    /// ---
17    /// - **Atomic**
18    /// - **Non-corruptible**
19    ///
20    /// ---
21    /// Example
22    /// ``` let block_db = BlockDB::open("./data", None).await?;
23    ///
24    /// block_db.recover_data_file("3f-6hf").await?;
25    /// ```
26    /// ---
27    pub async fn recover_data_file<S: AsRef<str>>(&self, data_file_id: S) -> Result<(), Error> {
28        map_data_file!(self, data_file_id.as_ref(), recover);
29
30        Ok(())
31    }
32
33    /// Recovers all `DataFile`s to a known good state.
34    ///
35    /// During recovery, each `DataFile` will replay its WAL and truncate the
36    /// binary file to the correct length. This process restores the in-memory
37    /// state to match the persistent state on disk.
38    ///
39    /// ---
40    /// - **Atomic**
41    /// - **Non-corruptible**
42    ///
43    /// ---
44    /// Example
45    /// ``` let block_db = BlockDB::open("./data", None).await?;
46    ///
47    /// block_db.recover_data_files().await?;
48    /// ```
49    /// ---
50    pub async fn recover_data_files(&self) -> Result<(), Error> {
51        map_data_files!(self, recover);
52
53        Ok(())
54    }
55}