脱敏 TripoUrl 的 Debug 输出

为 TripoUrl 手写 Debug 实现,改用隐藏 query 与 fragment 的脱敏形式

新增 TripoUrl::redacted 提供日志用脱敏 URL,完整 URL 仍由 as_str 显式读取

TripoTaskSnapshot、TripoTaskOutput、TripoDownloadedModel 的调试输出随之不再暴露带签名的下载地址
This commit is contained in:
2026-09-19 13:05:40 +08:00
parent 950209f038
commit 771ff88440
@@ -22,7 +22,7 @@ pub enum TripoTaskType {
MultiviewToModel,
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Eq, PartialEq)]
pub struct TripoUrl(Url);
impl TripoUrl {
@@ -40,9 +40,25 @@ impl TripoUrl {
Ok(Self(url))
}
/// 完整 URL 只通过该显式访问器读取。
pub fn as_str(&self) -> &str {
self.0.as_str()
}
/// 日志与调试用脱敏形式:隐藏可能携带签名参数的 query 与 fragment。
pub fn redacted(&self) -> String {
let full = self.0.as_str();
match full.find(['?', '#']) {
Some(index) => format!("{}?<redacted>", &full[..index]),
None => full.to_owned(),
}
}
}
impl fmt::Debug for TripoUrl {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("TripoUrl").field(&self.redacted()).finish()
}
}
impl fmt::Display for TripoUrl {