Use a type alias for read file results.

This commit is contained in:
Tom Alexander 2024-10-19 17:03:52 -04:00
parent 379850fe3d
commit 7ddc4011b3
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -263,9 +263,11 @@ fn build_name_contents_pairs<'a>(
Ok((name, contents))
}
type ReadFileResult = std::io::Result<(PathBuf, Vec<u8>)>;
fn get_all_files<P: AsRef<Path>>(
root_dir: P,
) -> Result<impl Iterator<Item = JoinHandle<std::io::Result<(PathBuf, Vec<u8>)>>>, walkdir::Error> {
) -> Result<impl Iterator<Item = JoinHandle<ReadFileResult>>, walkdir::Error> {
let files = WalkDir::new(root_dir)
.into_iter()
.filter(|e| match e {
@ -280,7 +282,7 @@ fn get_all_files<P: AsRef<Path>>(
Ok(org_files)
}
async fn read_file(path: PathBuf) -> std::io::Result<(PathBuf, Vec<u8>)> {
async fn read_file(path: PathBuf) -> ReadFileResult {
let contents = tokio::fs::read(&path).await?;
Ok((path, contents))
}