summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-04-23 08:18:26 +0300
committerLars Wirzenius <liw@liw.fi>2021-04-23 08:18:26 +0300
commitb245389cfeed2a3a222ab512feb6449f610c2d9c (patch)
treed4f883c0c9ba3a6525a428fb88a86744a8b58ee1
parent075172eccb3f66c0b5791c6125c0685b22315d53 (diff)
downloadsummain-rs-b245389cfeed2a3a222ab512feb6449f610c2d9c.tar.gz
use tokio io
-rw-r--r--src/lib.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 9ce3b58..668b533 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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;
}