mirror of
https://github.com/lanyeeee/bilibili-video-downloader.git
synced 2026-09-08 17:16:52 +08:00
feat: 添加一些实用的扩展方法
This commit is contained in:
Generated
+1
@@ -267,6 +267,7 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
|||||||
name = "bilibili-video-downloader"
|
name = "bilibili-video-downloader"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"specta",
|
"specta",
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ specta = { version = "=2.0.0-rc.20", features = ["serde_json"] }
|
|||||||
tauri-specta = { version = "=2.0.0-rc.20", features = ["derive", "typescript"] }
|
tauri-specta = { version = "=2.0.0-rc.20", features = ["derive", "typescript"] }
|
||||||
specta-typescript = { version = "=0.0.7" }
|
specta-typescript = { version = "=0.0.7" }
|
||||||
|
|
||||||
|
anyhow = { version = "1.0.98" }
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
strip = true
|
strip = true
|
||||||
lto = true
|
lto = true
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
pub trait AnyhowErrorToStringChain {
|
||||||
|
/// 将 `anyhow::Error` 转换为chain格式
|
||||||
|
/// # Example
|
||||||
|
/// 0: error message\
|
||||||
|
/// 1: error message\
|
||||||
|
/// 2: error message
|
||||||
|
fn to_string_chain(&self) -> String;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AnyhowErrorToStringChain for anyhow::Error {
|
||||||
|
fn to_string_chain(&self) -> String {
|
||||||
|
use std::fmt::Write;
|
||||||
|
self.chain()
|
||||||
|
.enumerate()
|
||||||
|
.fold(String::new(), |mut output, (i, e)| {
|
||||||
|
let _ = writeln!(output, "{i}: {e}");
|
||||||
|
output
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
mod commands;
|
mod commands;
|
||||||
|
mod extensions;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
use tauri::Wry;
|
use tauri::Wry;
|
||||||
|
|||||||
Reference in New Issue
Block a user