1
- #![ cfg( test) ]
2
1
use crate :: { digesters:: ImmutableFile , entities:: ImmutableFileNumber } ;
3
2
use std:: {
4
3
fs:: File ,
5
4
io:: prelude:: Write ,
6
5
path:: { Path , PathBuf } ,
7
6
} ;
8
7
8
+ /// A [DummyImmutableDb] builder.
9
9
pub struct DummyImmutablesDbBuilder {
10
10
dir : PathBuf ,
11
11
immutables_to_write : Vec < ImmutableFileNumber > ,
@@ -14,9 +14,13 @@ pub struct DummyImmutablesDbBuilder {
14
14
file_size : Option < u64 > ,
15
15
}
16
16
17
+ /// A dummy cardano immutable db.
17
18
pub struct DummyImmutableDb {
19
+ /// The dummy cardano db directory path.
18
20
pub dir : PathBuf ,
21
+ /// The [immutables files][ImmutableFile] in the dummy cardano db.
19
22
pub immutables_files : Vec < ImmutableFile > ,
23
+ /// Files that doesn't follow the immutable file name scheme in the dummy cardano db.
20
24
pub non_immutables_files : Vec < PathBuf > ,
21
25
}
22
26
@@ -33,11 +37,14 @@ impl DummyImmutablesDbBuilder {
33
37
}
34
38
}
35
39
40
+ /// Set the immutables file number that will be used to generate the immutable files, for each
41
+ /// number three files will be generated (a 'chunk', a 'primary' and a 'secondary' file).
36
42
pub fn with_immutables ( & mut self , immutables : & [ ImmutableFileNumber ] ) -> & mut Self {
37
43
self . immutables_to_write = immutables. to_vec ( ) ;
38
44
self
39
45
}
40
46
47
+ /// Set filenames to write to the db that doesn't follow the immutable file name scheme.
41
48
pub fn with_non_immutables ( & mut self , non_immutables : & [ & str ] ) -> & mut Self {
42
49
self . non_immutables_to_write = non_immutables. iter ( ) . map ( |f| f. to_string ( ) ) . collect ( ) ;
43
50
self
@@ -59,6 +66,7 @@ impl DummyImmutablesDbBuilder {
59
66
self
60
67
}
61
68
69
+ /// Build a [DummyImmutableDb].
62
70
pub fn build ( & self ) -> DummyImmutableDb {
63
71
let mut non_immutables_files = vec ! [ ] ;
64
72
let mut immutable_numbers = self . immutables_to_write . clone ( ) ;
0 commit comments