Skip to content

Commit 182bf97

Browse files
author
cht
committed
cargo fmt
1 parent 89d76e8 commit 182bf97

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/utils.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ use serde_json::Value;
33
use std::{
44
env,
55
fs::{self, File},
6-
io::prelude::*,
7-
io::Error,
6+
io::{prelude::*, Result},
87
path::Path,
9-
result::Result,
108
};
119
#[allow(dead_code)]
12-
pub enum Save{
10+
pub enum Save {
1311
Storage,
1412
Running,
1513
V2ray,
@@ -18,20 +16,20 @@ fn create_storage_before() {
1816
let home = env::var("HOME").unwrap();
1917
fs::create_dir_all(home + "/.config/tv2ray").unwrap();
2018
}
21-
pub fn create_json_file(save:Save,input: String) -> Result<(), Error> {
19+
pub fn create_json_file(save: Save, input: String) -> Result<()> {
2220
let home = env::var("HOME").unwrap();
2321
let location = match save {
2422
Save::Storage => format!("{}/.config/tv2ray/storage.json", home),
25-
Save::Running => format!("{}/.config/tv2ray/running.json",home),
26-
Save::V2ray => format!("{}/.config/tv2ray/v2core.json",home),
23+
Save::Running => format!("{}/.config/tv2ray/running.json", home),
24+
Save::V2ray => format!("{}/.config/tv2ray/v2core.json", home),
2725
};
2826
let path = Path::new(location.as_str());
2927
let mut file = File::create(&path)?;
3028
//let storge: String = input;
3129
file.write_all(input.as_bytes())?;
3230
Ok(())
3331
}
34-
fn get_json() -> Result<String, Error> {
32+
fn get_json() -> Result<String> {
3533
let home = env::var("HOME").unwrap();
3634
let location = format!("{}/.config/tv2ray/storage.json", home);
3735
let mut file = File::open(location)?;
@@ -44,7 +42,7 @@ pub fn start() -> Vec<Information> {
4442
let messages = match get_json() {
4543
Ok(output) => output,
4644
Err(_) => {
47-
if let Err(err) = create_json_file(Save::Storage,"[]".to_string()) {
45+
if let Err(err) = create_json_file(Save::Storage, "[]".to_string()) {
4846
panic!("{}", err);
4947
};
5048
"[]".to_string()

0 commit comments

Comments
 (0)