diff --git a/Cargo.lock b/Cargo.lock index b35ce67a3..c70e4abff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1127,7 +1127,6 @@ dependencies = [ "serde_json", "serde_yaml_ng", "sha2 0.11.1", - "smartstring", "socket2", "specta", "specta-typescript", @@ -1155,6 +1154,7 @@ dependencies = [ "tokio-rustls", "tokio-util", "tracing", + "tristr", "warp", "webpki-roots", "windows 0.62.2", @@ -6801,18 +6801,6 @@ dependencies = [ "thiserror 2.0.20", ] -[[package]] -name = "smartstring" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a155190f9c039a1e9b6e92efbfa50ae68daad98a0fd6d5521a5a09ef782383e8" -dependencies = [ - "autocfg", - "serde", - "static_assertions", - "version_check", -] - [[package]] name = "socket2" version = "0.6.5" @@ -8577,6 +8565,15 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "tristr" +version = "0.1.0" +source = "git+https://github.com/Tunglies/tristr?rev=3738d8c5785d609674c5f4f05def26b94724200c#3738d8c5785d609674c5f4f05def26b94724200c" +dependencies = [ + "serde", + "specta", +] + [[package]] name = "try-lock" version = "0.2.5" diff --git a/Cargo.toml b/Cargo.toml index 576c9beb0..978649bf2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,9 +84,8 @@ reqwest = { version = "0.13.5", features = [ ] } rust_iso3166 = "0.2.0" -smartstring = { version = "2.0.0" } - serde = { version = "1.0.229" } +tristr = { git = "https://github.com/Tunglies/tristr", rev = "3738d8c5785d609674c5f4f05def26b94724200c", default-features = false, features = ["serde", "specta"] } serde_json = { version = "1.0.154" } serde_yaml_ng = { version = "0.10.0" } socket2 = "0.6.5" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 25b5996cb..ef93aec61 100755 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -54,7 +54,7 @@ log = { workspace = true } serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true } serde_yaml_ng = { workspace = true } -smartstring = { workspace = true, features = ["serde"] } +tristr = { workspace = true } socket2 = { workspace = true } warp = { version = "0.4.4", features = ["server"] } open = "5.4.5" diff --git a/src-tauri/src/cmd/app.rs b/src-tauri/src/cmd/app.rs index 3e6597f3b..f4f34b593 100644 --- a/src-tauri/src/cmd/app.rs +++ b/src-tauri/src/cmd/app.rs @@ -8,8 +8,8 @@ use crate::{ feat, utils::dirs, }; -use smartstring::alias::String; use tauri::{AppHandle, Manager as _, ipc::Channel}; +use tristr::alias::String; #[tauri::command] #[specta::specta] diff --git a/src-tauri/src/cmd/backup.rs b/src-tauri/src/cmd/backup.rs index 349c869b5..b4891680a 100644 --- a/src-tauri/src/cmd/backup.rs +++ b/src-tauri/src/cmd/backup.rs @@ -1,7 +1,7 @@ use super::CmdResult; use crate::{cmd::StringifyErr as _, feat}; use feat::LocalBackupFile; -use smartstring::alias::String; +use tristr::alias::String; #[tauri::command] #[specta::specta] diff --git a/src-tauri/src/cmd/clash.rs b/src-tauri/src/cmd/clash.rs index bd0ba09aa..8c6468955 100644 --- a/src-tauri/src/cmd/clash.rs +++ b/src-tauri/src/cmd/clash.rs @@ -12,8 +12,8 @@ use crate::{ }, }; use clash_verge_logging::{Type, logging, logging_error}; -use smartstring::alias::String; use tokio::fs; +use tristr::alias::String; #[tauri::command] #[specta::specta] diff --git a/src-tauri/src/cmd/mod.rs b/src-tauri/src/cmd/mod.rs index 1bb2d3041..940b0c216 100644 --- a/src-tauri/src/cmd/mod.rs +++ b/src-tauri/src/cmd/mod.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use smartstring::alias::String; +use tristr::alias::String; pub type CmdResult = Result; diff --git a/src-tauri/src/cmd/profile.rs b/src-tauri/src/cmd/profile.rs index b6d592090..5c43c1508 100644 --- a/src-tauri/src/cmd/profile.rs +++ b/src-tauri/src/cmd/profile.rs @@ -18,11 +18,11 @@ use crate::{ }; use clash_verge_draft::{Draft, SharedDraft}; use clash_verge_logging::{Type, logging, logging_error}; -use smartstring::alias::String; use std::{ mem::DropGuard, sync::atomic::{AtomicBool, Ordering}, }; +use tristr::alias::String; static CURRENT_SWITCHING_PROFILE: AtomicBool = AtomicBool::new(false); @@ -322,7 +322,6 @@ async fn perform_config_update( #[derive(Default, serde::Deserialize, specta::Type)] #[serde(default)] pub struct ProfileSelection { - #[specta(type = Option)] pub current: Option, } @@ -330,13 +329,9 @@ pub struct ProfileSelection { #[serde(default)] pub struct ProfileCreate { #[serde(rename = "type")] - #[specta(type = Option)] pub itype: Option, - #[specta(type = Option)] pub name: Option, - #[specta(type = Option)] pub desc: Option, - #[specta(type = Option)] pub url: Option, pub option: Option, } @@ -358,15 +353,10 @@ impl From for PrfItem { #[serde(default)] pub struct ProfilePatch { #[serde(rename = "type")] - #[specta(type = Option)] pub itype: Option, - #[specta(type = Option)] pub name: Option, - #[specta(type = Option)] pub desc: Option, - #[specta(type = Option)] pub file: Option, - #[specta(type = Option)] pub url: Option, pub selected: Option>, pub extra: Option, diff --git a/src-tauri/src/cmd/runtime.rs b/src-tauri/src/cmd/runtime.rs index c3a53a667..fa2972b4a 100644 --- a/src-tauri/src/cmd/runtime.rs +++ b/src-tauri/src/cmd/runtime.rs @@ -1,8 +1,8 @@ use super::CmdResult; use crate::{cmd::StringifyErr as _, config::Config, core::CoreManager, utils::yaml_emitter}; use anyhow::{Context as _, anyhow}; -use smartstring::alias::String; use std::collections::HashMap; +use tristr::alias::String; #[tauri::command] #[specta::specta] @@ -36,10 +36,7 @@ pub async fn get_runtime_logs() -> CmdResult { #[derive(serde::Serialize, specta::Type)] #[serde(transparent)] -pub struct RuntimeLogs( - #[specta(type = HashMap>)] - HashMap>, -); +pub struct RuntimeLogs(HashMap>); #[tauri::command] #[specta::specta] diff --git a/src-tauri/src/cmd/save_profile.rs b/src-tauri/src/cmd/save_profile.rs index 196060218..2679635a1 100644 --- a/src-tauri/src/cmd/save_profile.rs +++ b/src-tauri/src/cmd/save_profile.rs @@ -11,8 +11,8 @@ use crate::{ utils::dirs, }; use clash_verge_logging::{Type, logging}; -use smartstring::alias::String; use tokio::fs; +use tristr::alias::String; /// 保存profiles的配置 #[tauri::command] diff --git a/src-tauri/src/cmd/webdav.rs b/src-tauri/src/cmd/webdav.rs index dad1de657..b40c943a0 100644 --- a/src-tauri/src/cmd/webdav.rs +++ b/src-tauri/src/cmd/webdav.rs @@ -4,7 +4,7 @@ use crate::{ config::{Config, IVerge}, core, feat, }; -use smartstring::alias::String; +use tristr::alias::String; #[tauri::command] #[specta::specta] diff --git a/src-tauri/src/config/config.rs b/src-tauri/src/config/config.rs index cd9386317..8a7c25a85 100644 --- a/src-tauri/src/config/config.rs +++ b/src-tauri/src/config/config.rs @@ -20,10 +20,10 @@ use backon::{ExponentialBuilder, Retryable as _}; use clash_verge_draft::Draft; use clash_verge_logging::{Type, logging, logging_error}; use serde_yaml_ng::{Mapping, Value}; -use smartstring::alias::String; use std::{collections::HashSet, path::PathBuf}; use tokio::sync::{Mutex, MutexGuard, OnceCell}; use tokio::time::sleep; +use tristr::alias::String; pub(crate) struct Config { clash_config: Draft, diff --git a/src-tauri/src/config/dns.rs b/src-tauri/src/config/dns.rs index 6240e19b7..fd86bfcc8 100644 --- a/src-tauri/src/config/dns.rs +++ b/src-tauri/src/config/dns.rs @@ -5,8 +5,8 @@ use clash_verge_draft::DraftTransaction; use serde::{Deserialize, Serialize}; use serde_yaml_ng::{Mapping, Value}; use sha2::{Digest as _, Sha256}; -use smartstring::alias::String; use std::sync::atomic::{AtomicBool, Ordering}; +use tristr::alias::String; use super::{Config, IVerge}; use crate::core::handle::Handle; @@ -109,7 +109,6 @@ impl DnsOverrideState { pub struct ProfileDnsSettings { pub enabled: bool, #[serde(default, skip_serializing_if = "Option::is_none")] - #[specta(type = Option)] pub confirmation: Option, } diff --git a/src-tauri/src/config/prfitem.rs b/src-tauri/src/config/prfitem.rs index cd9d00224..94a3c0252 100644 --- a/src-tauri/src/config/prfitem.rs +++ b/src-tauri/src/config/prfitem.rs @@ -11,9 +11,9 @@ use crate::{ use anyhow::{Context as _, Result, bail}; use serde::{Deserialize, Serialize}; use serde_yaml_ng::Mapping; -use smartstring::alias::String; use std::time::Duration; use tokio::fs; +use tristr::alias::String; // TODO, use other re-export use reqwest_dav::re_exports::url::form_urlencoded; use tauri::Url; @@ -32,24 +32,18 @@ pub(super) fn normalize_profile_home_url(raw: &str) -> Option { #[derive(Debug, Clone, Deserialize, Serialize, Default, specta::Type)] #[serde(default)] pub struct PrfItem { - #[specta(type = Option)] pub uid: Option, /// enum value: remote | local | script | merge #[serde(rename = "type")] - #[specta(type = Option)] pub itype: Option, - #[specta(type = Option)] pub name: Option, - #[specta(type = Option)] pub file: Option, #[serde(skip_serializing_if = "Option::is_none")] - #[specta(type = Option)] pub desc: Option, #[serde(skip_serializing_if = "Option::is_none")] - #[specta(type = Option)] pub url: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -64,20 +58,16 @@ pub struct PrfItem { pub option: Option, #[serde(skip_serializing_if = "Option::is_none")] - #[specta(type = Option)] pub home: Option, #[serde(skip)] - #[specta(type = Option)] pub file_data: Option, } #[derive(Default, Debug, Clone, Deserialize, Serialize, PartialEq, Eq, specta::Type)] #[serde(default)] pub struct PrfSelected { - #[specta(type = Option)] pub name: Option, - #[specta(type = Option)] pub now: Option, } @@ -93,7 +83,6 @@ pub struct PrfExtra { #[serde(default)] pub struct PrfOption { #[serde(skip_serializing_if = "Option::is_none")] - #[specta(type = Option)] pub user_agent: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -116,15 +105,10 @@ pub struct PrfOption { #[serde(skip_serializing_if = "Option::is_none")] pub allow_auto_update: Option, - #[specta(type = Option)] pub merge: Option, - #[specta(type = Option)] pub script: Option, - #[specta(type = Option)] pub rules: Option, - #[specta(type = Option)] pub proxies: Option, - #[specta(type = Option)] pub groups: Option, } diff --git a/src-tauri/src/config/profiles.rs b/src-tauri/src/config/profiles.rs index 989e8f51b..e6ab22168 100644 --- a/src-tauri/src/config/profiles.rs +++ b/src-tauri/src/config/profiles.rs @@ -17,7 +17,6 @@ use clash_verge_logging::{Type, logging}; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use serde_yaml_ng::Mapping; -use smartstring::alias::String; use std::num::NonZeroUsize; use std::{ collections::{HashMap, HashSet}, @@ -30,6 +29,7 @@ use std::{ }; use tauri_plugin_mihomo::models::{Proxies, ProxyType}; use tokio::{fs, task::JoinHandle}; +use tristr::alias::String; pub(crate) static PROFILE_WRITE_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(()); @@ -51,7 +51,6 @@ const SELECTED_NODES_FIRST_PASS_BUDGET: Duration = Duration::from_secs(3); #[derive(Default, Debug, Clone, Deserialize, Serialize, specta::Type)] #[serde(default)] pub struct IProfiles { - #[specta(type = Option)] pub current: Option, pub items: Option>, diff --git a/src-tauri/src/config/runtime.rs b/src-tauri/src/config/runtime.rs index 105dc8b46..0fbcb9811 100644 --- a/src-tauri/src/config/runtime.rs +++ b/src-tauri/src/config/runtime.rs @@ -1,6 +1,6 @@ use serde_yaml_ng::{Mapping, Value}; -use smartstring::alias::String; use std::collections::{HashMap, HashSet}; +use tristr::alias::String; use crate::enhance::field::use_keys; diff --git a/src-tauri/src/config/verge.rs b/src-tauri/src/config/verge.rs index d3b58dcf0..88eebd4dd 100644 --- a/src-tauri/src/config/verge.rs +++ b/src-tauri/src/config/verge.rs @@ -8,33 +8,26 @@ use anyhow::Result; use clash_verge_logging::{Type, logging}; use log::LevelFilter; use serde::{Deserialize, Serialize}; -use smartstring::alias::String; +use tristr::alias::String; /// ### `verge.yaml` schema #[derive(Default, Debug, Clone, Deserialize, Serialize, specta::Type)] #[serde(default)] pub struct IVerge { /// silent | error | warn | info | debug | trace - #[specta(type = Option)] pub app_log_level: Option, /// Maximum app log size in KiB. pub app_log_max_size: Option, pub app_log_max_count: Option, - #[specta(type = Option)] pub language: Option, /// `light` or `dark` or `system` - #[specta(type = Option)] pub theme_mode: Option, - #[specta(type = Option)] pub tray_event: Option, - #[specta(type = Option)] pub env_type: Option, - #[specta(type = Option)] pub start_page: Option, - #[specta(type = Option)] pub startup_script: Option, pub traffic_graph: Option, @@ -52,23 +45,18 @@ pub struct IVerge { #[cfg(target_os = "macos")] #[serde(skip_serializing_if = "Option::is_none")] - #[specta(type = Option)] pub tray_icon: Option, #[serde(skip_serializing_if = "Option::is_none")] - #[specta(type = Option)] pub menu_icon: Option, #[serde(skip_serializing_if = "Option::is_none")] - #[specta(type = Option>)] pub menu_order: Option>, #[serde(skip_serializing_if = "Option::is_none")] - #[specta(type = Option)] pub proxy_group_tools_position: Option, #[serde(skip_serializing_if = "Option::is_none")] - #[specta(type = Option)] pub notice_position: Option, pub collapse_navbar: Option, @@ -93,32 +81,25 @@ pub struct IVerge { pub enable_dns_settings: Option, #[serde(default, skip_serializing_if = "std::collections::BTreeMap::is_empty")] - #[specta(type = std::collections::BTreeMap)] pub profile_dns_settings: std::collections::BTreeMap, pub use_default_bypass: Option, - #[specta(type = Option)] pub system_proxy_bypass: Option, pub proxy_guard_duration: Option, pub proxy_auto_config: Option, - #[specta(type = Option)] pub pac_file_content: Option, - #[specta(type = Option)] pub proxy_host: Option, pub theme_setting: Option, - #[specta(type = Option>)] pub web_ui_list: Option>, #[serde(skip_serializing_if = "Option::is_none")] - #[specta(type = Option)] pub clash_core: Option, /// format: {func},{key} #[serde(skip_serializing_if = "Option::is_none")] - #[specta(type = Option>)] pub hotkeys: Option>, pub enable_global_hotkey: Option, @@ -129,7 +110,6 @@ pub struct IVerge { pub auto_close_connection: Option, pub auto_check_update: Option, - #[specta(type = Option)] pub default_latency_test: Option, pub default_latency_timeout: Option, @@ -209,7 +189,6 @@ pub struct IVerge { pub enable_tray_speed: Option, #[serde(skip_serializing_if = "Option::is_none")] - #[specta(type = Option)] pub tray_proxy_groups_display_mode: Option, pub tray_inline_outbound_modes: Option, @@ -229,38 +208,24 @@ pub struct IVerge { #[derive(Default, Debug, Clone, Deserialize, Serialize, specta::Type)] #[serde(default)] pub struct IVergeTestItem { - #[specta(type = Option)] pub uid: Option, - #[specta(type = Option)] pub name: Option, - #[specta(type = Option)] pub icon: Option, - #[specta(type = Option)] pub url: Option, } #[derive(Default, Debug, Clone, Deserialize, Serialize, specta::Type)] #[serde(default)] pub struct IVergeTheme { - #[specta(type = Option)] pub primary_color: Option, - #[specta(type = Option)] pub secondary_color: Option, - #[specta(type = Option)] pub primary_text: Option, - #[specta(type = Option)] pub secondary_text: Option, - #[specta(type = Option)] pub info_color: Option, - #[specta(type = Option)] pub error_color: Option, - #[specta(type = Option)] pub warning_color: Option, - #[specta(type = Option)] pub success_color: Option, - #[specta(type = Option)] pub font_family: Option, - #[specta(type = Option)] pub css_injection: Option, } diff --git a/src-tauri/src/core/backup.rs b/src-tauri/src/core/backup.rs index 481fdcb83..d0d40ca67 100644 --- a/src-tauri/src/core/backup.rs +++ b/src-tauri/src/core/backup.rs @@ -5,7 +5,6 @@ use arc_swap::{ArcSwap, ArcSwapOption}; use backon::{ConstantBuilder, Retryable as _}; use clash_verge_logging::{Type, logging}; use reqwest_dav::list_cmd::{ListEntity, ListFile, ListMultiStatus}; -use smartstring::alias::String; use std::{ collections::HashMap, env::{consts::OS, temp_dir}, @@ -15,6 +14,7 @@ use std::{ time::Duration, }; use tokio::{fs, time::timeout}; +use tristr::alias::String; use zip::write::SimpleFileOptions; const APP_VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/src-tauri/src/core/hotkey.rs b/src-tauri/src/core/hotkey.rs index d23ae2a57..5ecff74dc 100755 --- a/src-tauri/src/core/hotkey.rs +++ b/src-tauri/src/core/hotkey.rs @@ -7,7 +7,6 @@ use crate::{config::Config, core::handle, core::lightweight::entry_lightweight_m use anyhow::{Result, bail}; use arc_swap::ArcSwap; use clash_verge_logging::{Type, logging}; -use smartstring::alias::String; use std::{ collections::HashMap, fmt, @@ -18,6 +17,7 @@ use std::{ }, }; use tauri_plugin_global_shortcut::{Code, GlobalShortcutExt as _, ShortcutState}; +use tristr::alias::String; /// Enum representing all available hotkey functions #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] diff --git a/src-tauri/src/core/manager/config.rs b/src-tauri/src/core/manager/config.rs index f42f34ee2..c97ba5df4 100644 --- a/src-tauri/src/core/manager/config.rs +++ b/src-tauri/src/core/manager/config.rs @@ -14,7 +14,6 @@ use anyhow::{Result, anyhow}; use clash_verge_draft::DraftTransaction; use clash_verge_logging::{Type, logging}; use clash_verge_service_ipc::StageRuntimeOutcome; -use smartstring::alias::String; use std::{ collections::HashSet, mem::DropGuard, @@ -23,6 +22,7 @@ use std::{ time::{Duration, Instant}, }; use tauri_plugin_mihomo::Error as MihomoError; +use tristr::alias::String; /// A staging result separated from the policy that acts on it. #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/src-tauri/src/core/manager/lifecycle.rs b/src-tauri/src/core/manager/lifecycle.rs index 8e6074d51..373133e56 100644 --- a/src-tauri/src/core/manager/lifecycle.rs +++ b/src-tauri/src/core/manager/lifecycle.rs @@ -6,10 +6,10 @@ use crate::core::proxy_control::{self, SysproxyFailure}; use crate::core::service::{SERVICE_MANAGER, ServiceStatus}; use anyhow::Result; use clash_verge_logging::{Type, logging}; -use smartstring::alias::String; use std::{mem::DropGuard, path::Path}; #[cfg(target_os = "windows")] use tauri_plugin_clash_verge_sysinfo::is_current_app_handle_admin; +use tristr::alias::String; #[cfg(any(target_os = "windows", test))] const fn should_wait_for_service(tun_enabled: bool, service_ready: bool, is_admin: bool) -> bool { diff --git a/src-tauri/src/core/notify/handle.rs b/src-tauri/src/core/notify/handle.rs index af1241bed..9ad5ff700 100644 --- a/src-tauri/src/core/notify/handle.rs +++ b/src-tauri/src/core/notify/handle.rs @@ -1,13 +1,13 @@ use super::NoticeStatus; use crate::{APP_HANDLE, singleton}; -#[cfg(target_os = "macos")] -use smartstring::alias::String; use std::sync::{ Arc, atomic::{AtomicBool, Ordering}, }; use tauri::AppHandle; use tauri_plugin_mihomo::{Mihomo, MihomoExt as _}; +#[cfg(target_os = "macos")] +use tristr::alias::String; use super::notification::{FrontendEvent, NotificationSystem}; diff --git a/src-tauri/src/core/notify/notification.rs b/src-tauri/src/core/notify/notification.rs index d3e0eace7..7ee40b090 100644 --- a/src-tauri/src/core/notify/notification.rs +++ b/src-tauri/src/core/notify/notification.rs @@ -3,11 +3,11 @@ use clash_verge_logging::{Type, logging}; use parking_lot::Mutex; #[cfg(test)] use serde_json::json; -use smartstring::alias::String; use std::sync::Arc; use std::sync::LazyLock; use std::{collections::HashMap, future::Future}; use tauri::{AppHandle, Emitter as _, Manager as _, WebviewWindow}; +use tristr::alias::String; #[derive(Debug, Clone)] pub enum FrontendEvent<'a> { @@ -77,10 +77,8 @@ impl FailedOperation { #[serde(rename_all = "camelCase")] pub struct PendingFailure { /// Stable code used as the table key. - #[specta(type = std::string::String)] pub code: String, /// Full diagnostic context chain. - #[specta(type = std::string::String)] pub detail: String, pub operation: FailedOperation, /// Monotonic identity for repeated failures under the same code. @@ -247,7 +245,6 @@ static PENDING_FAILURES: LazyLock = LazyLock::new(FailureTable::de #[derive(Debug, Default, Clone, serde::Serialize, specta::Type)] pub struct SidecarFailureSnapshot { pub revision: u64, - #[specta(type = Option)] pub detail: Option, } diff --git a/src-tauri/src/core/sysopt.rs b/src-tauri/src/core/sysopt.rs index 5809d38a1..a4c7edabf 100644 --- a/src-tauri/src/core/sysopt.rs +++ b/src-tauri/src/core/sysopt.rs @@ -7,7 +7,6 @@ use crate::{ use anyhow::Result; use clash_verge_logging::{Type, logging}; use parking_lot::RwLock; -use smartstring::alias::String; use std::{ mem::DropGuard, sync::{ @@ -18,6 +17,7 @@ use std::{ }; use sysproxy::{Autoproxy, GuardMonitor, GuardType, Sysproxy}; use tokio::sync::Mutex as TokioMutex; +use tristr::alias::String; #[derive(Clone, Copy, Debug, PartialEq, Eq)] enum ProxyApplyStep { diff --git a/src-tauri/src/core/timer.rs b/src-tauri/src/core/timer.rs index 4aae074e5..703e883c8 100644 --- a/src-tauri/src/core/timer.rs +++ b/src-tauri/src/core/timer.rs @@ -9,7 +9,6 @@ use anyhow::Result; use clash_verge_logging::{Type, logging, logging_error}; use futures::StreamExt as _; use parking_lot::{Mutex, RwLock}; -use smartstring::alias::String; use std::{ collections::HashMap, sync::{ @@ -23,6 +22,7 @@ use tokio::{ time::{sleep, timeout}, }; use tokio_util::time::{DelayQueue, delay_queue::Key}; +use tristr::alias::String; enum TimerCommand { Apply(HashMap), @@ -503,7 +503,6 @@ mod tests { use crate::config::{PrfItem, PrfOption}; use futures::StreamExt as _; use parking_lot::Mutex; - use smartstring::alias::String; use std::collections::HashMap; use std::{ sync::{ @@ -515,6 +514,7 @@ mod tests { }; use tokio::sync::Barrier; use tokio_util::time::DelayQueue; + use tristr::alias::String; struct CancellationProbe { cancelled: Arc, diff --git a/src-tauri/src/core/tray/mod.rs b/src-tauri/src/core/tray/mod.rs index cebb66097..4f474a782 100644 --- a/src-tauri/src/core/tray/mod.rs +++ b/src-tauri/src/core/tray/mod.rs @@ -19,7 +19,6 @@ use tokio::fs; use super::handle; use anyhow::Result; -use smartstring::alias::String; use std::borrow::Cow; use std::collections::HashMap; use std::time::Duration; @@ -27,6 +26,7 @@ use tauri::{ AppHandle, Wry, menu::{CheckMenuItem, IsMenuItem, MenuEvent, MenuItem, PredefinedMenuItem, Submenu}, }; +use tristr::alias::String; mod menu_def; #[cfg(target_os = "macos")] diff --git a/src-tauri/src/core/validate.rs b/src-tauri/src/core/validate.rs index 74ce7f349..4871c238d 100644 --- a/src-tauri/src/core/validate.rs +++ b/src-tauri/src/core/validate.rs @@ -1,6 +1,5 @@ use anyhow::Result; use serde::Serialize; -use smartstring::alias::String; use std::{ fmt, hash::{DefaultHasher, Hash as _, Hasher as _}, @@ -10,6 +9,7 @@ use std::{ }; use tauri_plugin_shell::ShellExt as _; use tokio::fs; +use tristr::alias::String; use crate::config::Config; use crate::core::handle; @@ -114,14 +114,8 @@ impl fmt::Display for ValidationSkipReason { #[serde(tag = "status", rename_all = "camelCase")] pub enum ValidationOutcome { Valid, - Invalid { - kind: ValidationErrorKind, - #[specta(type = std::string::String)] - message: String, - }, - Skipped { - reason: ValidationSkipReason, - }, + Invalid { kind: ValidationErrorKind, message: String }, + Skipped { reason: ValidationSkipReason }, Busy, } diff --git a/src-tauri/src/enhance/chain.rs b/src-tauri/src/enhance/chain.rs index df25c712f..0899373b3 100644 --- a/src-tauri/src/enhance/chain.rs +++ b/src-tauri/src/enhance/chain.rs @@ -4,8 +4,8 @@ use crate::{ utils::{dirs, help}, }; use serde_yaml_ng::Mapping; -use smartstring::alias::String; use tokio::fs; +use tristr::alias::String; #[derive(Debug, Clone)] pub struct ChainItem { diff --git a/src-tauri/src/enhance/field.rs b/src-tauri/src/enhance/field.rs index 1b1567fed..e37c49700 100644 --- a/src-tauri/src/enhance/field.rs +++ b/src-tauri/src/enhance/field.rs @@ -1,5 +1,5 @@ use serde_yaml_ng::{Mapping, Value}; -use smartstring::alias::String; +use tristr::alias::String; pub const HANDLE_FIELDS: [&str; 12] = [ "mode", diff --git a/src-tauri/src/enhance/mod.rs b/src-tauri/src/enhance/mod.rs index 6d61fb55d..d5e82bf56 100644 --- a/src-tauri/src/enhance/mod.rs +++ b/src-tauri/src/enhance/mod.rs @@ -26,10 +26,10 @@ use anyhow::{Context as _, Result}; use clash_verge_logging::{Type, logging}; use parking_lot::Mutex; use serde_yaml_ng::{Mapping, Value}; -use smartstring::alias::String; use std::collections::{HashMap, HashSet}; use std::hash::{Hash as _, Hasher as _}; use tokio::fs; +use tristr::alias::String; type ResultLog = Vec<(String, String)>; #[derive(Debug)] diff --git a/src-tauri/src/enhance/script.rs b/src-tauri/src/enhance/script.rs index da22bf415..4cc366491 100644 --- a/src-tauri/src/enhance/script.rs +++ b/src-tauri/src/enhance/script.rs @@ -6,8 +6,8 @@ use boa_engine::{Context, JsString, JsValue, Source, js_string, native_function: use clash_verge_logging::{Type, logging}; use parking_lot::Mutex; use serde_yaml_ng::Mapping; -use smartstring::alias::String; use std::sync::Arc; +use tristr::alias::String; const MAX_OUTPUTS: usize = 1000; const MAX_OUTPUT_SIZE: usize = 1024 * 1024; // 1MB diff --git a/src-tauri/src/feat/backup.rs b/src-tauri/src/feat/backup.rs index aeccf37d2..4bbd42083 100644 --- a/src-tauri/src/feat/backup.rs +++ b/src-tauri/src/feat/backup.rs @@ -12,17 +12,14 @@ use chrono::Utc; use clash_verge_logging::{Type, logging}; use reqwest_dav::list_cmd::ListFile; use serde::Serialize; -use smartstring::alias::String; use std::path::PathBuf; use tokio::fs; +use tristr::alias::String; #[derive(Debug, Serialize, specta::Type)] pub struct LocalBackupFile { - #[specta(type = std::string::String)] pub filename: String, - #[specta(type = std::string::String)] pub path: String, - #[specta(type = std::string::String)] pub last_modified: String, pub content_length: u64, } diff --git a/src-tauri/src/feat/clash.rs b/src-tauri/src/feat/clash.rs index 7b6d4aa21..96cd6ecf4 100644 --- a/src-tauri/src/feat/clash.rs +++ b/src-tauri/src/feat/clash.rs @@ -10,8 +10,8 @@ use crate::{ use bytes::BytesMut; use clash_verge_logging::{Type, logging}; use serde_yaml_ng::{Mapping, Value}; -use smartstring::alias::String; use std::sync::{Arc, LazyLock}; +use tristr::alias::String; #[allow(clippy::expect_used)] static TLS_CONFIG: LazyLock> = diff --git a/src-tauri/src/feat/dns.rs b/src-tauri/src/feat/dns.rs index a897b1b59..0bb2dd624 100644 --- a/src-tauri/src/feat/dns.rs +++ b/src-tauri/src/feat/dns.rs @@ -2,7 +2,7 @@ use crate::core::notify::{Refresh, announce}; use anyhow::{Result, ensure}; use clash_verge_draft::DraftTransaction; use serde::Serialize; -use smartstring::alias::String; +use tristr::alias::String; use crate::{ config::{ @@ -19,10 +19,7 @@ use crate::{ #[serde(tag = "status", rename_all = "snake_case")] pub enum DnsOverrideOutcome { Applied, - ConfirmationRequired { - #[specta(type = std::string::String)] - source: String, - }, + ConfirmationRequired { source: String }, } pub async fn set_dns_override( diff --git a/src-tauri/src/feat/icon.rs b/src-tauri/src/feat/icon.rs index 0f8bb2da3..40dd264eb 100644 --- a/src-tauri/src/feat/icon.rs +++ b/src-tauri/src/feat/icon.rs @@ -3,18 +3,15 @@ use crate::{ utils::dirs::{self, PathBufExec as _}, }; use clash_verge_logging::{Type, logging}; -use smartstring::alias::String; use std::path::{Component, Path, PathBuf}; use tokio::fs; use tokio::io::AsyncWriteExt as _; +use tristr::alias::String; #[derive(Debug, serde::Serialize, serde::Deserialize, specta::Type)] pub struct IconInfo { - #[specta(type = std::string::String)] name: String, - #[specta(type = std::string::String)] previous_t: String, - #[specta(type = std::string::String)] current_t: String, } diff --git a/src-tauri/src/feat/profile.rs b/src-tauri/src/feat/profile.rs index b2e7a2f85..e8a0c00b7 100644 --- a/src-tauri/src/feat/profile.rs +++ b/src-tauri/src/feat/profile.rs @@ -9,7 +9,7 @@ use crate::{ }; use anyhow::{Result, bail}; use clash_verge_logging::{Type, logging}; -use smartstring::alias::String; +use tristr::alias::String; /// Toggle proxy profile pub async fn toggle_proxy_profile(profile_index: String) { diff --git a/src-tauri/src/utils/network.rs b/src-tauri/src/utils/network.rs index 1eba283ed..a6c70850c 100644 --- a/src-tauri/src/utils/network.rs +++ b/src-tauri/src/utils/network.rs @@ -5,10 +5,10 @@ use reqwest::{ Client, Proxy, StatusCode, header::{HeaderMap, HeaderValue, USER_AGENT}, }; -use smartstring::alias::String; use std::{sync::Arc, time::Duration}; use sysproxy::Sysproxy; use tauri::Url; +use tristr::alias::String; #[derive(Debug)] pub struct HttpResponse { diff --git a/src-tauri/src/utils/resolve/scheme.rs b/src-tauri/src/utils/resolve/scheme.rs index c80fa829f..86aa598fd 100644 --- a/src-tauri/src/utils/resolve/scheme.rs +++ b/src-tauri/src/utils/resolve/scheme.rs @@ -1,8 +1,8 @@ use crate::core::notify::NoticeStatus; use anyhow::Result; use percent_encoding::percent_decode_str; -use smartstring::alias::String; use tauri::Url; +use tristr::alias::String; use crate::{ config::{Config, PrfItem, profiles},