pub trait FileConcatRead: ConcatRead {
// Required method
fn file_path(&self) -> Option<&Path>;
}
Expand description
FileConcatRead
is a kind of ConcatRead
which can provide information about the file currently read.
§Example
use std::io;
use std::io::prelude::*;
use std::path::Path;
use crate::concat_reader::*;
fn main() -> io::Result<()> {
let files = vec!["/path/to/file_1", "/path/to/file_2", "/path/to/file_3"];
let mut f = concat_path(files);
assert!(f.file_path().is_none());
let mut buffer = [0; 10];
f.read(&mut buffer)?;
assert_eq!(f.file_path(), Some(Path::new("/path/to/file_1")));
Ok(())
}
Required Methods§
Sourcefn file_path(&self) -> Option<&Path>
fn file_path(&self) -> Option<&Path>
Returns the path to the current File
being read from.
use std::io;
use std::io::prelude::*;
use crate::concat_reader::*;
fn main() -> io::Result<()> {
let files = vec!["/path/to/file_1", "/path/to/file_2", "/path/to/file_3"];
let mut f = concat_path(files);
let mut buffer = [0; 1];
//read 1 bytes from the reader
f.read_exact(&mut buffer);
println!("read from {}", f.file_path().unwrap().display());
//skip to next file in reader
f.skip();
/// //read 1 bytes from the reader
f.read_exact(&mut buffer);
println!("read from {}", f.file_path().unwrap().display());
Ok(())
}