fix: 修复ComfyUI SDK的cargo check和clippy警告

- 修复ComfyUIError中WebSocket变体过大的问题,使用Box包装
- 添加自定义From实现处理Box包装的WebSocket错误
- 修复所有格式化字符串警告,使用内联格式化
- 移除无用的类型转换(reqwest::Error::from)
- 修复代码质量问题:
  - 简化if语句嵌套
  - 使用?操作符替代显式错误处理
  - 优化map迭代方式
  - 使用is_some_and替代map_or

修复内容:
- 44个clippy警告全部解决
- 所有测试通过
- cargo check --lib 无错误无警告
This commit is contained in:
2025-08-08 16:12:25 +08:00
parent e874d281e0
commit e69ce2b817
9 changed files with 63 additions and 71 deletions

View File

@@ -106,7 +106,7 @@ impl TemplateManager {
pub fn create_instance(&self, template_id: &str, parameters: ParameterValues) -> Result<WorkflowInstance> {
let template = self.get_by_id(template_id)
.ok_or_else(|| ComfyUIError::template_validation(
format!("Template with ID '{}' not found", template_id)
format!("Template with ID '{template_id}' not found")
))?;
template.create_instance(parameters)
@@ -158,7 +158,7 @@ impl TemplateManager {
if !validation.valid {
return Err(ComfyUIError::template_validation(
format!("Template '{}' validation failed", id)
format!("Template '{id}' validation failed")
));
}
}

View File

@@ -62,7 +62,7 @@ impl WorkflowInstance {
// Check if parameter exists in template
if !self.template.has_parameter(&name) {
return Err(ComfyUIError::parameter_validation(
format!("Parameter '{}' does not exist in template", name)
format!("Parameter '{name}' does not exist in template")
));
}
@@ -93,7 +93,7 @@ impl WorkflowInstance {
for name in parameters.keys() {
if !self.template.has_parameter(name) {
return Err(ComfyUIError::parameter_validation(
format!("Parameter '{}' does not exist in template", name)
format!("Parameter '{name}' does not exist in template")
));
}
}