summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-04-23 08:07:10 +0300
committerLars Wirzenius <liw@liw.fi>2021-04-23 08:07:10 +0300
commit486f5f69b6e2d10eafa44c28b93caa8454e48911 (patch)
tree483dbe07960555d48b4dc7392be94077abf70f0a
parentc494f88db3d86a13134a6e86ee7e0246ab9d3943 (diff)
downloadsummain-rs-486f5f69b6e2d10eafa44c28b93caa8454e48911.tar.gz
first steps for async
-rw-r--r--src/bin/summain.rs9
-rw-r--r--src/lib.rs2
2 files changed, 7 insertions, 4 deletions
diff --git a/src/bin/summain.rs b/src/bin/summain.rs
index 76982b9..8526759 100644
--- a/src/bin/summain.rs
+++ b/src/bin/summain.rs
@@ -1,4 +1,5 @@
use anyhow::Context;
+use futures::executor::block_on;
use std::path::{Path, PathBuf};
use structopt::StructOpt;
use summain::ManifestEntry;
@@ -8,7 +9,7 @@ fn main() -> anyhow::Result<()> {
opt.pathnames[..].sort();
for filename in opt.pathnames.iter() {
- let m = manifest(&filename)?;
+ let m = block_on(manifest(&filename))?;
print!("{}", serde_yaml::to_string(&m)?);
}
@@ -21,6 +22,8 @@ struct Opt {
pathnames: Vec<PathBuf>,
}
-fn manifest(path: &Path) -> anyhow::Result<ManifestEntry> {
- ManifestEntry::new(path).with_context(|| format!("{}", path.display()))
+async fn manifest(path: &Path) -> anyhow::Result<ManifestEntry> {
+ ManifestEntry::new(path)
+ .await
+ .with_context(|| format!("{}", path.display()))
}
diff --git a/src/lib.rs b/src/lib.rs
index 3c90156..00c64cf 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -60,7 +60,7 @@ impl ManifestEntry {
/// caller. This function doesn't query the system for it.
///
/// The structure can be serialized using serde.
- pub fn new(path: &Path) -> std::io::Result<Self> {
+ pub async fn new(path: &Path) -> std::io::Result<Self> {
let m = symlink_metadata(path)?;
let hash = if m.is_file() {
Some(file_checksum(path)?)