diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-04-23 08:18:26 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-04-23 08:18:26 +0300 |
commit | b245389cfeed2a3a222ab512feb6449f610c2d9c (patch) | |
tree | d4f883c0c9ba3a6525a428fb88a86744a8b58ee1 | |
parent | 075172eccb3f66c0b5791c6125c0685b22315d53 (diff) | |
download | summain-rs-b245389cfeed2a3a222ab512feb6449f610c2d9c.tar.gz |
use tokio io
-rw-r--r-- | src/lib.rs | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -31,11 +31,12 @@ use serde::Serialize; use sha2::{Digest, Sha256}; -use std::fs::File; use std::fs::{read_link, symlink_metadata}; -use std::io::{BufReader, Read}; use std::os::linux::fs::MetadataExt; use std::path::{Path, PathBuf}; +use tokio::fs::File; +use tokio::io::AsyncReadExt; +use tokio::io::BufReader; const BUF_SIZE: usize = 1024 * 1024; @@ -88,11 +89,11 @@ impl ManifestEntry { async fn file_checksum(path: &Path) -> std::io::Result<String> { let mut hasher = Sha256::new(); - let file = File::open(path)?; + let file = File::open(path).await?; let mut reader = BufReader::new(file); let mut buf = vec![0; BUF_SIZE]; loop { - let n = reader.read(&mut buf)?; + let n = reader.read(&mut buf).await?; if n == 0 { break; } |