pub trait AnyWalker: Sized {
// Required method
fn visit_file_entry(
&mut self,
entry: &mut FileEntry<impl Read>,
) -> Result<()>;
// Provided methods
fn begin_visit_archive(
&mut self,
details: &EntryDetails,
format: FormatKind,
) -> Result<bool> { ... }
fn end_visit_archive(
&mut self,
details: EntryDetails,
format: FormatKind,
) -> Result<()> { ... }
fn walk(&mut self, entry: FileEntry<impl Read>) -> Result<()> { ... }
}
Required Methods§
Provided Methods§
fn begin_visit_archive( &mut self, details: &EntryDetails, format: FormatKind, ) -> Result<bool>
fn end_visit_archive( &mut self, details: EntryDetails, format: FormatKind, ) -> Result<()>
Sourcefn walk(&mut self, entry: FileEntry<impl Read>) -> Result<()>
fn walk(&mut self, entry: FileEntry<impl Read>) -> Result<()>
Examples found in repository?
More examples
examples/count_files.rs (line 63)
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
fn main() -> std::io::Result<()> {
let path = PathBuf::from(args().nth(1).unwrap());
println!("{path:?}");
let mut elapsed = Duration::from_secs(0);
let mut visitor = Visitor::default();
for item in std::fs::read_dir(&path)? {
let item = item?;
let path = item.path();
if path.is_dir() {
continue;
}
let start = Instant::now();
let entry = FileEntry::from_path(path.clone())?;
visitor.walk(entry)?;
elapsed += start.elapsed();
}
println!("Total files: {}", visitor.count);
println!("Total size: {}", visitor.size);
let elapsed = elapsed.as_secs_f64();
println!("Elapsed: {:.3}s", elapsed);
println!("Throughput: {:.3} files/s", visitor.count as f64 / elapsed);
println!(
"Throughput: {:.3} MB/s",
visitor.size as f64 / elapsed / 1024.0 / 1024.0
);
let mut counts: Vec<_> = visitor.format_counts.into_iter().collect();
counts.sort_by_key(|(_, count)| *count);
for (format, count) in counts {
println!("{:?}: {}", format, count);
}
Ok(())
}
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.