disk_based_bfs/
provider.rs

1//! Defines the `BfsSettingsProvider` trait and related types.
2
3/// Defines the behavior of update files and update bit arrays at the end of each iteration.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum UpdateFilesBehavior {
6    /// Don't merge update files into a bit array at the end of the iteration.
7    DontMerge,
8
9    /// Merge update files into a bit array at the end of the iteration, and delete them after they
10    /// have been used.
11    MergeAndDelete,
12
13    /// Merge update files into a bit array at the end of the iteration, and move them to a backup
14    /// directory after they have been used.
15    MergeAndKeep,
16}
17
18impl UpdateFilesBehavior {
19    pub(crate) fn should_merge(self) -> bool {
20        matches!(self, Self::MergeAndDelete | Self::MergeAndKeep)
21    }
22}
23
24/// Defines the behavior of chunk files at the end of each iteration.
25#[derive(Debug, Clone, Copy, PartialEq, Eq)]
26pub enum ChunkFilesBehavior {
27    /// Delete chunk files at the end of the iteration.
28    Delete,
29
30    /// Move chunk files to a backup directory at the end of the iteration.
31    Keep,
32}
33
34/// Provider for some additional settings for the BFS.
35pub trait BfsSettingsProvider {
36    /// Returns an index into [`BfsBuilder::root_directories`] that defines which hard drive the
37    /// given chunk should be stored on.
38    ///
39    /// [`BfsBuilder::root_directories`]: ../builder/struct.BfsBuilder.html
40    fn chunk_root_idx(&self, chunk_idx: usize) -> usize;
41
42    /// Returns the behavior of update files at the end of the depth `depth` iteration.
43    fn update_files_behavior(&self, depth: usize) -> UpdateFilesBehavior;
44
45    /// Returns the behavior of chunk files at the end of the depth `depth` iteration.
46    fn chunk_files_behavior(&self, depth: usize) -> ChunkFilesBehavior;
47}