diff --git a/src/cluster.rs b/src/cluster.rs index 9d6623f..45d587d 100644 --- a/src/cluster.rs +++ b/src/cluster.rs @@ -2,9 +2,9 @@ use crate::config::Config; use crate::utils::avro_data_to_file_list; use crate::PROTOCOL_VERSION; -use tracing::{info, warn}; use reqwest::{Client, StatusCode}; use serde::Deserialize; +use tracing::{info, warn}; use zstd::stream::decode_all; #[derive(Deserialize, Debug, Clone)] @@ -26,6 +26,7 @@ impl Cluster { Self { config, ua } } + /// ```typescript /// this.ua = `openbmclapi-cluster/${version}` /// this.got = got.extend({ /// prefixUrl: this.prefixUrl, @@ -58,6 +59,7 @@ impl Cluster { /// files: FileListSchema.fromBuffer(Buffer.from(decompressed)), /// } /// } + /// ``` pub async fn get_file_list(&self) -> Option> { // server: https://openbmclapi.bangbang93.com // path: /openbmclapi/files @@ -126,7 +128,7 @@ mod tests { test_conf.cluster_secret, None, None, - None + None, ) } diff --git a/src/config.rs b/src/config.rs index 8acbf7c..378cfcb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,11 +1,11 @@ use { crate::fatal, - tracing::{info, warn}, serde::{Deserialize, Serialize}, std::{ env, fs, path::{Path, PathBuf}, }, + tracing::{info, warn}, }; const CONFIG_PATH: &str = "config.toml"; @@ -137,8 +137,8 @@ impl Config { /// 从文件加载 pub fn update_from_file(&mut self, path: &str) { - let raw_data: Config = toml::from_str(&fs::read_to_string(path).unwrap()) - .unwrap_or_else(|err| { + let raw_data: Config = + toml::from_str(&fs::read_to_string(path).unwrap()).unwrap_or_else(|err| { fatal!(("Failed to load config: {}", err), ("{}", err)); }); self.center_url = raw_data.center_url; @@ -168,7 +168,7 @@ fn test_save_and_load_config() { "123456789".to_string(), Some(true), Some(PathBuf::from("cache")), - Some(true) + Some(true), ); let mut test_config: Config = Config::new( None, @@ -178,7 +178,7 @@ fn test_save_and_load_config() { "222".to_string(), None, None, - None + None, ); config.save_to_file(tmp_file.to_str().unwrap()); test_config.update_from_file(tmp_file.to_str().unwrap()); diff --git a/src/log.rs b/src/log.rs index d6e189a..b65c398 100644 --- a/src/log.rs +++ b/src/log.rs @@ -4,6 +4,6 @@ pub fn init_log_with_cli() { // --debug // --trace // 从低级开始判断 - + tracing_subscriber::fmt::init(); } diff --git a/src/utils.rs b/src/utils.rs index e771d4e..cbf9b4f 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -3,10 +3,10 @@ use crate::cluster::SyncFile; use std::io::Cursor; use apache_avro::{from_avro_datum, from_value, types::Value}; -use tracing::{info, warn}; use md5::{Digest, Md5}; use sha1::Sha1; use std::path::PathBuf; +use tracing::{info, warn}; /// import {join} from 'path' ///