cargo fmt?(

This commit is contained in:
shenjack-5600u 2024-01-30 23:13:57 +08:00
parent ff89797f98
commit 73fdc1d696
Signed by: shenjack
GPG Key ID: FDF9864E11C7E79F
4 changed files with 11 additions and 9 deletions

View File

@ -2,9 +2,9 @@ use crate::config::Config;
use crate::utils::avro_data_to_file_list; use crate::utils::avro_data_to_file_list;
use crate::PROTOCOL_VERSION; use crate::PROTOCOL_VERSION;
use tracing::{info, warn};
use reqwest::{Client, StatusCode}; use reqwest::{Client, StatusCode};
use serde::Deserialize; use serde::Deserialize;
use tracing::{info, warn};
use zstd::stream::decode_all; use zstd::stream::decode_all;
#[derive(Deserialize, Debug, Clone)] #[derive(Deserialize, Debug, Clone)]
@ -26,6 +26,7 @@ impl Cluster {
Self { config, ua } Self { config, ua }
} }
/// ```typescript
/// this.ua = `openbmclapi-cluster/${version}` /// this.ua = `openbmclapi-cluster/${version}`
/// this.got = got.extend({ /// this.got = got.extend({
/// prefixUrl: this.prefixUrl, /// prefixUrl: this.prefixUrl,
@ -58,6 +59,7 @@ impl Cluster {
/// files: FileListSchema.fromBuffer(Buffer.from(decompressed)), /// files: FileListSchema.fromBuffer(Buffer.from(decompressed)),
/// } /// }
/// } /// }
/// ```
pub async fn get_file_list(&self) -> Option<Vec<SyncFile>> { pub async fn get_file_list(&self) -> Option<Vec<SyncFile>> {
// server: https://openbmclapi.bangbang93.com // server: https://openbmclapi.bangbang93.com
// path: /openbmclapi/files // path: /openbmclapi/files
@ -126,7 +128,7 @@ mod tests {
test_conf.cluster_secret, test_conf.cluster_secret,
None, None,
None, None,
None None,
) )
} }

View File

@ -1,11 +1,11 @@
use { use {
crate::fatal, crate::fatal,
tracing::{info, warn},
serde::{Deserialize, Serialize}, serde::{Deserialize, Serialize},
std::{ std::{
env, fs, env, fs,
path::{Path, PathBuf}, path::{Path, PathBuf},
}, },
tracing::{info, warn},
}; };
const CONFIG_PATH: &str = "config.toml"; const CONFIG_PATH: &str = "config.toml";
@ -137,8 +137,8 @@ impl Config {
/// 从文件加载 /// 从文件加载
pub fn update_from_file(&mut self, path: &str) { pub fn update_from_file(&mut self, path: &str) {
let raw_data: Config = toml::from_str(&fs::read_to_string(path).unwrap()) let raw_data: Config =
.unwrap_or_else(|err| { toml::from_str(&fs::read_to_string(path).unwrap()).unwrap_or_else(|err| {
fatal!(("Failed to load config: {}", err), ("{}", err)); fatal!(("Failed to load config: {}", err), ("{}", err));
}); });
self.center_url = raw_data.center_url; self.center_url = raw_data.center_url;
@ -168,7 +168,7 @@ fn test_save_and_load_config() {
"123456789".to_string(), "123456789".to_string(),
Some(true), Some(true),
Some(PathBuf::from("cache")), Some(PathBuf::from("cache")),
Some(true) Some(true),
); );
let mut test_config: Config = Config::new( let mut test_config: Config = Config::new(
None, None,
@ -178,7 +178,7 @@ fn test_save_and_load_config() {
"222".to_string(), "222".to_string(),
None, None,
None, None,
None None,
); );
config.save_to_file(tmp_file.to_str().unwrap()); config.save_to_file(tmp_file.to_str().unwrap());
test_config.update_from_file(tmp_file.to_str().unwrap()); test_config.update_from_file(tmp_file.to_str().unwrap());

View File

@ -3,10 +3,10 @@ use crate::cluster::SyncFile;
use std::io::Cursor; use std::io::Cursor;
use apache_avro::{from_avro_datum, from_value, types::Value}; use apache_avro::{from_avro_datum, from_value, types::Value};
use tracing::{info, warn};
use md5::{Digest, Md5}; use md5::{Digest, Md5};
use sha1::Sha1; use sha1::Sha1;
use std::path::PathBuf; use std::path::PathBuf;
use tracing::{info, warn};
/// import {join} from 'path' /// import {join} from 'path'
/// ///