use async_std::fs

This commit is contained in:
mirsal 2021-03-29 00:32:55 +00:00
parent 2c6aaf5265
commit 9f2dac0d35
1 changed files with 3 additions and 2 deletions

View File

@ -4,6 +4,7 @@ use json::{object, JsonValue};
use rand::rngs::OsRng;
use regex::Regex;
use async_std::fs;
use async_std::path::PathBuf;
use async_trait::async_trait;
@ -56,7 +57,7 @@ impl SSBKeypair for Keypair {
async fn read_or_generate(path: PathBuf) -> Self {
if path.exists().await {
let secret = async_std::fs::read_to_string(path).await.unwrap();
let secret = fs::read_to_string(path).await.unwrap();
let re = Regex::new(r"\s*#[^\n]*").unwrap();
let secret = re.replace_all(secret.as_str(), "");
SSBKeypair::from_json(json::parse(&secret).unwrap())
@ -64,7 +65,7 @@ impl SSBKeypair for Keypair {
let mut csprng = OsRng {};
let keypair = Keypair::generate(&mut csprng);
let keypair_json = keypair.to_json();
async_std::fs::write(
fs::write(
path,
format!(
include_str!("warning.txt"),