summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-07-22 21:17:14 +0300
committerLars Wirzenius <liw@liw.fi>2021-07-23 19:23:12 +0300
commit45601862fb983f8fc35ab1c65ad27d0a09285c61 (patch)
tree2b314e4572b3c64ff4d182834bf4ca57eb68eb20 /src
parent34a039ee8b882e577faa3aa8298c1ad08fefa14f (diff)
downloadobnam2-45601862fb983f8fc35ab1c65ad27d0a09285c61.tar.gz
refactor: async for "obnam show-generation"
Sponsored-by: author
Diffstat (limited to 'src')
-rw-r--r--src/cmd/show_gen.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/cmd/show_gen.rs b/src/cmd/show_gen.rs
index df8a030..8df26c2 100644
--- a/src/cmd/show_gen.rs
+++ b/src/cmd/show_gen.rs
@@ -1,10 +1,11 @@
-use crate::client::BackupClient;
+use crate::client::AsyncBackupClient;
use crate::config::ClientConfig;
use crate::error::ObnamError;
use crate::fsentry::FilesystemKind;
use indicatif::HumanBytes;
use structopt::StructOpt;
use tempfile::NamedTempFile;
+use tokio::runtime::Runtime;
#[derive(Debug, StructOpt)]
pub struct ShowGeneration {
@@ -14,13 +15,17 @@ pub struct ShowGeneration {
impl ShowGeneration {
pub fn run(&self, config: &ClientConfig) -> Result<(), ObnamError> {
- let temp = NamedTempFile::new()?;
+ let rt = Runtime::new()?;
+ rt.block_on(self.run_async(config))
+ }
- let client = BackupClient::new(config)?;
+ async fn run_async(&self, config: &ClientConfig) -> Result<(), ObnamError> {
+ let temp = NamedTempFile::new()?;
+ let client = AsyncBackupClient::new(config)?;
- let genlist = client.list_generations()?;
+ let genlist = client.list_generations().await?;
let gen_id: String = genlist.resolve(&self.gen_id)?;
- let gen = client.fetch_generation(&gen_id, temp.path())?;
+ let gen = client.fetch_generation(&gen_id, temp.path()).await?;
let mut files = gen.files()?;
let mut files = files.iter()?;