51
51
// loss or errors in this model.
52
52
// f) data gathering: record (name, bytes, start, duration)
53
53
// write to disk afterwards as a csv file?
54
- pub mod immediate;
54
+ pub ( crate ) mod immediate;
55
55
#[ cfg( test) ]
56
56
mod test;
57
- pub mod threaded;
57
+ pub ( crate ) mod threaded;
58
58
59
59
use std:: io:: { self , Write } ;
60
60
use std:: path:: { Path , PathBuf } ;
@@ -69,7 +69,7 @@ use crate::utils::notifications::Notification;
69
69
70
70
/// Carries the implementation specific channel data into the executor.
71
71
#[ derive( Debug ) ]
72
- pub enum IncrementalFile {
72
+ pub ( crate ) enum IncrementalFile {
73
73
ImmediateReceiver ,
74
74
ThreadedReceiver ( Receiver < Vec < u8 > > ) ,
75
75
}
@@ -114,41 +114,41 @@ pub enum IncrementalFile {
114
114
115
115
/// What kind of IO operation to perform
116
116
#[ derive( Debug ) ]
117
- pub enum Kind {
117
+ pub ( crate ) enum Kind {
118
118
Directory ,
119
119
File ( Vec < u8 > ) ,
120
120
IncrementalFile ( IncrementalFile ) ,
121
121
}
122
122
123
123
/// The details of the IO operation
124
124
#[ derive( Debug ) ]
125
- pub struct Item {
125
+ pub ( crate ) struct Item {
126
126
/// The path to operate on
127
- pub full_path : PathBuf ,
127
+ pub ( crate ) full_path : PathBuf ,
128
128
/// The operation to perform
129
- pub kind : Kind ,
129
+ pub ( crate ) kind : Kind ,
130
130
/// When the operation started
131
- pub start : Option < Instant > ,
131
+ start : Option < Instant > ,
132
132
/// Amount of time the operation took to finish
133
- pub finish : Option < Duration > ,
133
+ finish : Option < Duration > ,
134
134
/// The length of the file, for files (for stats)
135
- pub size : Option < usize > ,
135
+ size : Option < usize > ,
136
136
/// The result of the operation (could now be factored into CompletedIO...)
137
- pub result : io:: Result < ( ) > ,
137
+ pub ( crate ) result : io:: Result < ( ) > ,
138
138
/// The mode to apply
139
- pub mode : u32 ,
139
+ mode : u32 ,
140
140
}
141
141
142
142
#[ derive( Debug ) ]
143
- pub enum CompletedIo {
143
+ pub ( crate ) enum CompletedIo {
144
144
/// A submitted Item has completed
145
145
Item ( Item ) ,
146
146
/// An IncrementalFile has completed a single chunk
147
147
Chunk ( usize ) ,
148
148
}
149
149
150
150
impl Item {
151
- pub fn make_dir ( full_path : PathBuf , mode : u32 ) -> Self {
151
+ pub ( crate ) fn make_dir ( full_path : PathBuf , mode : u32 ) -> Self {
152
152
Self {
153
153
full_path,
154
154
kind : Kind :: Directory ,
@@ -160,7 +160,7 @@ impl Item {
160
160
}
161
161
}
162
162
163
- pub fn write_file ( full_path : PathBuf , content : Vec < u8 > , mode : u32 ) -> Self {
163
+ pub ( crate ) fn write_file ( full_path : PathBuf , content : Vec < u8 > , mode : u32 ) -> Self {
164
164
let len = content. len ( ) ;
165
165
Self {
166
166
full_path,
@@ -173,7 +173,7 @@ impl Item {
173
173
}
174
174
}
175
175
176
- pub fn write_file_segmented < ' a > (
176
+ pub ( crate ) fn write_file_segmented < ' a > (
177
177
full_path : PathBuf ,
178
178
mode : u32 ,
179
179
state : IncrementalFileState ,
@@ -199,7 +199,7 @@ impl Item {
199
199
/// just allows the immediate codepath to get access to the Arc referenced state
200
200
/// without holding a lifetime reference to the executor, as the threaded code
201
201
/// path is all message passing.
202
- pub enum IncrementalFileState {
202
+ pub ( crate ) enum IncrementalFileState {
203
203
Threaded ,
204
204
Immediate ( immediate:: IncrementalFileState ) ,
205
205
}
@@ -232,7 +232,7 @@ impl IncrementalFileState {
232
232
/// Trait object for performing IO. At this point the overhead
233
233
/// of trait invocation is not a bottleneck, but if it becomes
234
234
/// one we could consider an enum variant based approach instead.
235
- pub trait Executor {
235
+ pub ( crate ) trait Executor {
236
236
/// Perform a single operation.
237
237
/// During overload situations previously queued items may
238
238
/// need to be completed before the item is accepted:
@@ -262,7 +262,7 @@ pub trait Executor {
262
262
263
263
/// Trivial single threaded IO to be used from executors.
264
264
/// (Crazy sophisticated ones can obviously ignore this)
265
- pub fn perform < F : Fn ( usize ) > ( item : & mut Item , chunk_complete_callback : F ) {
265
+ pub ( crate ) fn perform < F : Fn ( usize ) > ( item : & mut Item , chunk_complete_callback : F ) {
266
266
// directories: make them, TODO: register with the dir existence cache.
267
267
// Files, write them.
268
268
item. result = match & mut item. kind {
@@ -281,7 +281,7 @@ pub fn perform<F: Fn(usize)>(item: &mut Item, chunk_complete_callback: F) {
281
281
}
282
282
283
283
#[ allow( unused_variables) ]
284
- pub fn write_file < P : AsRef < Path > , C : AsRef < [ u8 ] > > (
284
+ pub ( crate ) fn write_file < P : AsRef < Path > , C : AsRef < [ u8 ] > > (
285
285
path : P ,
286
286
contents : C ,
287
287
mode : u32 ,
@@ -312,7 +312,7 @@ pub fn write_file<P: AsRef<Path>, C: AsRef<[u8]>>(
312
312
}
313
313
314
314
#[ allow( unused_variables) ]
315
- pub fn write_file_incremental < P : AsRef < Path > , F : Fn ( usize ) > (
315
+ pub ( crate ) fn write_file_incremental < P : AsRef < Path > , F : Fn ( usize ) > (
316
316
path : P ,
317
317
content_callback : & mut IncrementalFile ,
318
318
mode : u32 ,
@@ -357,15 +357,15 @@ pub fn write_file_incremental<P: AsRef<Path>, F: Fn(usize)>(
357
357
Ok ( ( ) )
358
358
}
359
359
360
- pub fn create_dir < P : AsRef < Path > > ( path : P ) -> io:: Result < ( ) > {
360
+ pub ( crate ) fn create_dir < P : AsRef < Path > > ( path : P ) -> io:: Result < ( ) > {
361
361
let path = path. as_ref ( ) ;
362
362
let path_display = format ! ( "{}" , path. display( ) ) ;
363
363
trace_scoped ! ( "create_dir" , "name" : path_display) ;
364
364
std:: fs:: create_dir ( path)
365
365
}
366
366
367
367
/// Get the executor for disk IO.
368
- pub fn get_executor < ' a > (
368
+ pub ( crate ) fn get_executor < ' a > (
369
369
notify_handler : Option < & ' a dyn Fn ( Notification < ' _ > ) > ,
370
370
) -> Result < Box < dyn Executor + ' a > > {
371
371
// If this gets lots of use, consider exposing via the config file.
0 commit comments