mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-08 07:12:49 +00:00
update cli
to use async
crypto
This commit is contained in:
parent
ecc6ac9a53
commit
d8b6789cb7
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -841,6 +841,7 @@ dependencies = [
|
|||
"hex",
|
||||
"indoc",
|
||||
"sd-crypto",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -11,3 +11,4 @@ clap = { version = "4.0.32", features = ["derive"] }
|
|||
anyhow = "1.0.68"
|
||||
hex = "0.4.3"
|
||||
sd-crypto = { path = "../../crates/crypto" }
|
||||
tokio = { version = "1.21.2", features = ["io-util", "rt-multi-thread"] }
|
||||
|
|
|
@ -2,7 +2,8 @@ use anyhow::{Context, Result};
|
|||
use clap::Parser;
|
||||
use indoc::printdoc;
|
||||
use sd_crypto::header::file::FileHeader;
|
||||
use std::{fs::File, path::PathBuf};
|
||||
use std::path::PathBuf;
|
||||
use tokio::fs::File;
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
|
@ -10,17 +11,18 @@ struct Args {
|
|||
path: PathBuf,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let args = Args::parse();
|
||||
|
||||
let mut reader = File::open(args.path).context("unable to open file")?;
|
||||
let (header, aad) = FileHeader::from_reader(&mut reader)?;
|
||||
print_details(&header, &aad);
|
||||
let mut reader = File::open(args.path).await.context("unable to open file")?;
|
||||
let (header, aad) = FileHeader::from_reader(&mut reader).await?;
|
||||
print_crypto_details(&header, &aad);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn print_details(header: &FileHeader, aad: &[u8]) {
|
||||
fn print_crypto_details(header: &FileHeader, aad: &[u8]) {
|
||||
printdoc! {"
|
||||
Header version: {version}
|
||||
Encryption algorithm: {algorithm}
|
||||
|
|
Loading…
Reference in a new issue