mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-18 18:02:08 +08:00
refactor: replace smartstring with tristr for backend strings (#8673)
* refactor(config): adopt tristr for config strings Wire the tristr git dependency (pinned rev) and switch the config and enhance modules from smartstring::alias::String to tristr::alias::String. Drop the smartstring-era per-field specta overrides except the three webdav fields required by serialize_with and the ipc::JsonValue bridge: tristr maps to Primitive::str natively and the generated bindings stay byte-identical (gen-contract --check passes). Call sites in not-yet-migrated modules (cmd/core/feat/utils) are bridged with explicit tristr::alias::String paths and as_str().into() conversions; each bridge is absorbed when its module migrates. * refactor(cmd): adopt tristr for command strings Switch the cmd module from smartstring::alias::String to tristr::alias::String and drop its smartstring-era per-field specta overrides (ProfileSelection/ProfileCreate/ProfilePatch, RuntimeLogs); bindings stay byte-identical. Calls into not-yet-migrated feat/core functions keep smartstring-typed locals via full paths until those modules migrate. * refactor(core): adopt tristr for core strings Switch the core module (validate, timer, sysopt, backup, hotkey, tray, manager, notify) from smartstring::alias::String to tristr::alias::String and drop the smartstring-era specta overrides on ValidationOutcome and the notify payload structs; bindings stay byte-identical. WebDAV calls from the not-yet-migrated feat module are bridged with as_str().into(). * refactor(feat): adopt tristr for feature strings Switch the feat module (backup, icon, dns, profile, clash) from smartstring::alias::String to tristr::alias::String, drop its smartstring-era specta overrides (IconInfo, backup listings, DnsOverrideOutcome), and absorb the temporary smartstring-typed bridge locals the cmd module used to call into feat. * refactor(utils): adopt tristr for utility strings Switch utils/network.rs and utils/resolve/scheme.rs from smartstring::alias::String to tristr::alias::String and absorb the temporary user_agent and profile-name bridge conversions. * refactor(deps): drop smartstring in favor of tristr Remove the smartstring workspace and member dependencies and its Cargo.lock entry; tristr is the only string representation left. * build(deps): bump tristr to fuzz-harness fix rev Pin 3738d8c renames the stale vstr path dependency in the upstream fuzz manifest so its seven targets build again; library code is unchanged from 3756ed1a.
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
@@ -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<FailureTable> = LazyLock::new(FailureTable::de
|
||||
#[derive(Debug, Default, Clone, serde::Serialize, specta::Type)]
|
||||
pub struct SidecarFailureSnapshot {
|
||||
pub revision: u64,
|
||||
#[specta(type = Option<std::string::String>)]
|
||||
pub detail: Option<String>,
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<String, TaskSchedule>),
|
||||
@@ -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<AtomicBool>,
|
||||
|
||||
@@ -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")]
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user