mirror of
https://github.com/lanyeeee/bilibili-video-downloader.git
synced 2026-09-05 23:57:23 +08:00
feat: 添加一些实用的扩展方法
This commit is contained in:
Generated
+1
@@ -267,6 +267,7 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||
name = "bilibili-video-downloader"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"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"] }
|
||||
specta-typescript = { version = "=0.0.7" }
|
||||
|
||||
anyhow = { version = "1.0.98" }
|
||||
|
||||
[profile.release]
|
||||
strip = 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 extensions;
|
||||
mod utils;
|
||||
|
||||
use tauri::Wry;
|
||||
|
||||
Reference in New Issue
Block a user