校验文案的版本标签改为从契约枚举推导
- validate_generation_options 的错误文案改用 wire_str_lossy 取 serde 线上值 - v3.x 家族的模型标签收敛到 v3_model_labels 助手 - 契约改名后诊断文案随之更新,不再手写重复的版本字符串
This commit is contained in:
@@ -5,6 +5,7 @@ use shared_contracts::model3d::common::{
|
||||
use shared_contracts::model3d::image_to_model::Model3dImageToModelParams;
|
||||
use shared_contracts::model3d::multiview_to_model::Model3dMultiviewToModelRequest;
|
||||
use shared_contracts::model3d::text_to_model::Model3dTextToModelParams;
|
||||
use shared_contracts::model3d::wire_str_lossy;
|
||||
|
||||
use super::{TripoError, TripoField, TripoTaskHandle, TripoValidationReason};
|
||||
|
||||
@@ -65,6 +66,18 @@ tripo_generation_options_from! {
|
||||
compress,
|
||||
}
|
||||
|
||||
/// v3.x 家族的模型标签,供「只支持 v3.x」类错误文案复用。
|
||||
///
|
||||
/// 标签取自契约枚举的 serde 取值([`wire_str_lossy`]),契约改名后文案跟着变,
|
||||
/// 这里不再手写第二份版本字符串。
|
||||
fn v3_model_labels() -> String {
|
||||
format!(
|
||||
"{} and {}",
|
||||
wire_str_lossy(&Model3dModelVersion::H31),
|
||||
wire_str_lossy(&Model3dModelVersion::H30)
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn validate_generation_options(
|
||||
options: &TripoGenerationOptions,
|
||||
) -> Result<(), TripoError> {
|
||||
@@ -74,7 +87,10 @@ pub(crate) fn validate_generation_options(
|
||||
return Err(invalid(
|
||||
Some(TripoField::TextureQuality),
|
||||
TripoValidationReason::InvalidCombination,
|
||||
"texture_quality is not supported by v2.5-20250123",
|
||||
&format!(
|
||||
"texture_quality is not supported by {}",
|
||||
wire_str_lossy(&Model3dModelVersion::H25)
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -85,7 +101,10 @@ pub(crate) fn validate_generation_options(
|
||||
return Err(invalid(
|
||||
Some(TripoField::TextureQuality),
|
||||
TripoValidationReason::InvalidCombination,
|
||||
"texture_quality=fast requires texture_version=v3.5-20260815",
|
||||
&format!(
|
||||
"texture_quality=fast requires texture_version={}",
|
||||
wire_str_lossy(&Model3dTextureVersion::V35)
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -94,7 +113,10 @@ pub(crate) fn validate_generation_options(
|
||||
return Err(invalid(
|
||||
Some(TripoField::GeometryQuality),
|
||||
TripoValidationReason::InvalidCombination,
|
||||
"geometry_quality is only supported by v3.1-20260211 and v3.0-20250812",
|
||||
&format!(
|
||||
"geometry_quality is only supported by {}",
|
||||
v3_model_labels()
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -102,7 +124,7 @@ pub(crate) fn validate_generation_options(
|
||||
return Err(invalid(
|
||||
Some(TripoField::Compress),
|
||||
TripoValidationReason::InvalidCombination,
|
||||
"compress is only supported by v3.1-20260211 and v3.0-20250812",
|
||||
&format!("compress is only supported by {}", v3_model_labels()),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -110,7 +132,10 @@ pub(crate) fn validate_generation_options(
|
||||
return Err(invalid(
|
||||
Some(TripoField::AutoSize),
|
||||
TripoValidationReason::InvalidCombination,
|
||||
"auto_size is not supported by v2.5-20250123",
|
||||
&format!(
|
||||
"auto_size is not supported by {}",
|
||||
wire_str_lossy(&Model3dModelVersion::H25)
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -121,7 +146,7 @@ pub(crate) fn validate_generation_options(
|
||||
return Err(invalid(
|
||||
Some(TripoField::SmartLowPoly),
|
||||
TripoValidationReason::InvalidCombination,
|
||||
"smart_low_poly is only supported by v3.1-20260211 and v3.0-20250812",
|
||||
&format!("smart_low_poly is only supported by {}", v3_model_labels()),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -132,7 +157,7 @@ pub(crate) fn validate_generation_options(
|
||||
return Err(invalid(
|
||||
Some(TripoField::GenerateParts),
|
||||
TripoValidationReason::InvalidCombination,
|
||||
"generate_parts is only supported by v3.1-20260211 and v3.0-20250812",
|
||||
&format!("generate_parts is only supported by {}", v3_model_labels()),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -145,7 +170,10 @@ pub(crate) fn validate_generation_options(
|
||||
return Err(invalid(
|
||||
Some(TripoField::Quad),
|
||||
TripoValidationReason::InvalidCombination,
|
||||
"quad=true is only supported by v3.x models and P2-20260801",
|
||||
&format!(
|
||||
"quad=true is only supported by v3.x models and {}",
|
||||
wire_str_lossy(&Model3dModelVersion::P2)
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user