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:: ops:: { Deref , DerefMut } ;
@@ -71,7 +71,7 @@ use threaded::PoolReference;
71
71
72
72
/// Carries the implementation specific data for complete file transfers into the executor.
73
73
#[ derive( Debug ) ]
74
- pub enum FileBuffer {
74
+ pub ( crate ) enum FileBuffer {
75
75
Immediate ( Vec < u8 > ) ,
76
76
// A reference to the object in the pool, and a handle to write to it
77
77
Threaded ( PoolReference ) ,
@@ -131,7 +131,7 @@ pub(crate) const IO_CHUNK_SIZE: usize = 16_777_216;
131
131
132
132
/// Carries the implementation specific channel data into the executor.
133
133
#[ derive( Debug ) ]
134
- pub enum IncrementalFile {
134
+ pub ( crate ) enum IncrementalFile {
135
135
ImmediateReceiver ,
136
136
ThreadedReceiver ( Receiver < FileBuffer > ) ,
137
137
}
@@ -176,41 +176,41 @@ pub enum IncrementalFile {
176
176
177
177
/// What kind of IO operation to perform
178
178
#[ derive( Debug ) ]
179
- pub enum Kind {
179
+ pub ( crate ) enum Kind {
180
180
Directory ,
181
181
File ( FileBuffer ) ,
182
182
IncrementalFile ( IncrementalFile ) ,
183
183
}
184
184
185
185
/// The details of the IO operation
186
186
#[ derive( Debug ) ]
187
- pub struct Item {
187
+ pub ( crate ) struct Item {
188
188
/// The path to operate on
189
- pub full_path : PathBuf ,
189
+ pub ( crate ) full_path : PathBuf ,
190
190
/// The operation to perform
191
- pub kind : Kind ,
191
+ pub ( crate ) kind : Kind ,
192
192
/// When the operation started
193
- pub start : Option < Instant > ,
193
+ start : Option < Instant > ,
194
194
/// Amount of time the operation took to finish
195
- pub finish : Option < Duration > ,
195
+ finish : Option < Duration > ,
196
196
/// The length of the file, for files (for stats)
197
- pub size : Option < usize > ,
197
+ size : Option < usize > ,
198
198
/// The result of the operation (could now be factored into CompletedIO...)
199
- pub result : io:: Result < ( ) > ,
199
+ pub ( crate ) result : io:: Result < ( ) > ,
200
200
/// The mode to apply
201
- pub mode : u32 ,
201
+ mode : u32 ,
202
202
}
203
203
204
204
#[ derive( Debug ) ]
205
- pub enum CompletedIo {
205
+ pub ( crate ) enum CompletedIo {
206
206
/// A submitted Item has completed
207
207
Item ( Item ) ,
208
208
/// An IncrementalFile has completed a single chunk
209
209
Chunk ( usize ) ,
210
210
}
211
211
212
212
impl Item {
213
- pub fn make_dir ( full_path : PathBuf , mode : u32 ) -> Self {
213
+ pub ( crate ) fn make_dir ( full_path : PathBuf , mode : u32 ) -> Self {
214
214
Self {
215
215
full_path,
216
216
kind : Kind :: Directory ,
@@ -222,7 +222,7 @@ impl Item {
222
222
}
223
223
}
224
224
225
- pub fn write_file ( full_path : PathBuf , mode : u32 , content : FileBuffer ) -> Self {
225
+ pub ( crate ) fn write_file ( full_path : PathBuf , mode : u32 , content : FileBuffer ) -> Self {
226
226
let len = content. len ( ) ;
227
227
Self {
228
228
full_path,
@@ -235,7 +235,7 @@ impl Item {
235
235
}
236
236
}
237
237
238
- pub fn write_file_segmented < ' a > (
238
+ pub ( crate ) fn write_file_segmented < ' a > (
239
239
full_path : PathBuf ,
240
240
mode : u32 ,
241
241
state : IncrementalFileState ,
@@ -261,7 +261,7 @@ impl Item {
261
261
/// just allows the immediate codepath to get access to the Arc referenced state
262
262
/// without holding a lifetime reference to the executor, as the threaded code
263
263
/// path is all message passing.
264
- pub enum IncrementalFileState {
264
+ pub ( crate ) enum IncrementalFileState {
265
265
Threaded ,
266
266
Immediate ( immediate:: IncrementalFileState ) ,
267
267
}
@@ -294,7 +294,7 @@ impl IncrementalFileState {
294
294
/// Trait object for performing IO. At this point the overhead
295
295
/// of trait invocation is not a bottleneck, but if it becomes
296
296
/// one we could consider an enum variant based approach instead.
297
- pub trait Executor {
297
+ pub ( crate ) trait Executor {
298
298
/// Perform a single operation.
299
299
/// During overload situations previously queued items may
300
300
/// need to be completed before the item is accepted:
@@ -332,7 +332,7 @@ pub trait Executor {
332
332
333
333
/// Trivial single threaded IO to be used from executors.
334
334
/// (Crazy sophisticated ones can obviously ignore this)
335
- pub fn perform < F : Fn ( usize ) > ( item : & mut Item , chunk_complete_callback : F ) {
335
+ pub ( crate ) fn perform < F : Fn ( usize ) > ( item : & mut Item , chunk_complete_callback : F ) {
336
336
// directories: make them, TODO: register with the dir existence cache.
337
337
// Files, write them.
338
338
item. result = match & mut item. kind {
@@ -361,7 +361,7 @@ pub fn perform<F: Fn(usize)>(item: &mut Item, chunk_complete_callback: F) {
361
361
}
362
362
363
363
#[ allow( unused_variables) ]
364
- pub fn write_file < P : AsRef < Path > , C : AsRef < [ u8 ] > > (
364
+ pub ( crate ) fn write_file < P : AsRef < Path > , C : AsRef < [ u8 ] > > (
365
365
path : P ,
366
366
contents : C ,
367
367
mode : u32 ,
@@ -392,7 +392,7 @@ pub fn write_file<P: AsRef<Path>, C: AsRef<[u8]>>(
392
392
}
393
393
394
394
#[ allow( unused_variables) ]
395
- pub fn write_file_incremental < P : AsRef < Path > , F : Fn ( usize ) > (
395
+ pub ( crate ) fn write_file_incremental < P : AsRef < Path > , F : Fn ( usize ) > (
396
396
path : P ,
397
397
content_callback : & mut IncrementalFile ,
398
398
mode : u32 ,
@@ -437,15 +437,15 @@ pub fn write_file_incremental<P: AsRef<Path>, F: Fn(usize)>(
437
437
Ok ( ( ) )
438
438
}
439
439
440
- pub fn create_dir < P : AsRef < Path > > ( path : P ) -> io:: Result < ( ) > {
440
+ pub ( crate ) fn create_dir < P : AsRef < Path > > ( path : P ) -> io:: Result < ( ) > {
441
441
let path = path. as_ref ( ) ;
442
442
let path_display = format ! ( "{}" , path. display( ) ) ;
443
443
trace_scoped ! ( "create_dir" , "name" : path_display) ;
444
444
std:: fs:: create_dir ( path)
445
445
}
446
446
447
447
/// Get the executor for disk IO.
448
- pub fn get_executor < ' a > (
448
+ pub ( crate ) fn get_executor < ' a > (
449
449
notify_handler : Option < & ' a dyn Fn ( Notification < ' _ > ) > ,
450
450
ram_budget : usize ,
451
451
) -> Result < Box < dyn Executor + ' a > > {
0 commit comments