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:
@@ -66,11 +66,11 @@ impl ComfyUIClient {
|
||||
pub async fn connect(&mut self) -> Result<()> {
|
||||
// Test HTTP connection first
|
||||
self.http_client.get_queue().await
|
||||
.map_err(|e| ComfyUIError::connection(format!("HTTP connection failed: {}", e)))?;
|
||||
.map_err(|e| ComfyUIError::connection(format!("HTTP connection failed: {e}")))?;
|
||||
|
||||
// Connect WebSocket
|
||||
self.ws_client.connect().await
|
||||
.map_err(|e| ComfyUIError::connection(format!("WebSocket connection failed: {}", e)))?;
|
||||
.map_err(|e| ComfyUIError::connection(format!("WebSocket connection failed: {e}")))?;
|
||||
|
||||
log::info!("Successfully connected to ComfyUI server");
|
||||
Ok(())
|
||||
@@ -107,7 +107,7 @@ impl ComfyUIClient {
|
||||
let prompt_response = self.http_client.queue_prompt(&prompt_request).await?;
|
||||
let prompt_id = prompt_response.prompt_id.clone();
|
||||
|
||||
log::info!("Submitted prompt with ID: {}", prompt_id);
|
||||
log::info!("Submitted prompt with ID: {prompt_id}");
|
||||
|
||||
// Wait for completion if WebSocket is connected
|
||||
if self.ws_client.is_connected().await {
|
||||
@@ -186,8 +186,7 @@ impl ComfyUIClient {
|
||||
// Check timeout
|
||||
if start_time.elapsed() > timeout_duration {
|
||||
return Err(ComfyUIError::timeout(format!(
|
||||
"Execution timed out after {:?}",
|
||||
timeout_duration
|
||||
"Execution timed out after {timeout_duration:?}"
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -210,7 +209,7 @@ impl ComfyUIClient {
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("Error checking history: {}", e);
|
||||
log::warn!("Error checking history: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user