清理后端编译警告

删除后端未使用的历史 helper、mapper、handler 和 re-export

将仅测试使用的导入、常量和辅助函数收口到 cfg(test)

补齐 Jump Hop 测试构造体字段并对齐 Match3D 当前素材表测试契约

验证后端 workspace cargo check 与 Match3D、Puzzle 相关测试
This commit is contained in:
2026-06-07 22:20:58 +08:00
parent cc84656a1f
commit decded991e
35 changed files with 109 additions and 1146 deletions

View File

@@ -45,7 +45,6 @@ pub(crate) struct PuzzleResolvedReferenceImage {
pub(crate) mime_type: String,
pub(crate) bytes_len: usize,
pub(crate) bytes: Vec<u8>,
pub(crate) signed_read_url: Option<String>,
}
pub(crate) struct GeneratedPuzzleImageCandidate {
@@ -318,10 +317,10 @@ pub(crate) fn build_puzzle_downloaded_image_reference(
mime_type: image.mime_type.clone(),
bytes_len: image.bytes.len(),
bytes: image.bytes.clone(),
signed_read_url: None,
}
}
#[cfg(test)]
pub(crate) fn build_puzzle_vector_engine_image_request_body(
image_model: PuzzleImageModel,
prompt: &str,
@@ -330,7 +329,7 @@ pub(crate) fn build_puzzle_vector_engine_image_request_body(
candidate_count: u32,
reference_image: Option<&PuzzleResolvedReferenceImage>,
) -> Value {
let body = Map::from_iter([
let body = serde_json::Map::from_iter([
(
"model".to_string(),
Value::String(image_model.request_model_name().to_string()),
@@ -415,32 +414,6 @@ pub(crate) fn collect_puzzle_reference_image_sources(
sources
}
pub(crate) fn collect_legacy_puzzle_reference_image_sources(
legacy_reference_image_src: Option<&str>,
reference_image_srcs: &[String],
) -> Vec<String> {
let mut sources = Vec::new();
for source in legacy_reference_image_src
.into_iter()
.chain(reference_image_srcs.iter().map(String::as_str))
{
let normalized = source.trim();
if normalized.is_empty() {
continue;
}
if !sources
.iter()
.any(|existing: &String| existing == normalized)
{
sources.push(normalized.to_string());
}
if sources.len() >= PUZZLE_REFERENCE_IMAGE_SOURCE_LIMIT {
break;
}
}
sources
}
pub(crate) fn has_puzzle_reference_images(
legacy_reference_image_src: Option<&str>,
reference_image_srcs: &[String],
@@ -463,6 +436,7 @@ pub(crate) fn should_use_puzzle_reference_image_generation(
use_reference_image_generation && has_puzzle_reference_image(reference_image_src)
}
#[cfg(test)]
pub(crate) fn build_puzzle_vector_engine_prompt(prompt: &str, negative_prompt: &str) -> String {
let prompt = prompt.trim();
let negative_prompt = negative_prompt.trim();
@@ -525,7 +499,6 @@ pub(crate) async fn resolve_puzzle_reference_image(
mime_type: parsed.mime_type,
bytes_len,
bytes: parsed.bytes,
signed_read_url: None,
});
}
@@ -758,7 +731,6 @@ async fn download_signed_puzzle_reference_image(
mime_type,
bytes_len,
bytes: body.to_vec(),
signed_read_url: Some(signed_read_url),
})
}
@@ -1075,47 +1047,6 @@ pub(crate) fn decode_puzzle_base64(value: &str) -> Option<Vec<u8>> {
Some(output)
}
pub(crate) fn find_first_puzzle_string_by_key(payload: &Value, target_key: &str) -> Option<String> {
let mut results = Vec::new();
collect_puzzle_strings_by_key(payload, target_key, &mut results);
results.into_iter().next()
}
pub(crate) fn collect_puzzle_strings_by_key(
payload: &Value,
target_key: &str,
results: &mut Vec<String>,
) {
match payload {
Value::Array(entries) => {
for entry in entries {
collect_puzzle_strings_by_key(entry, target_key, results);
}
}
Value::Object(object) => {
for (key, value) in object {
if key == target_key {
collect_puzzle_string_values(value, results);
}
collect_puzzle_strings_by_key(value, target_key, results);
}
}
_ => {}
}
}
pub(crate) fn collect_puzzle_string_values(payload: &Value, results: &mut Vec<String>) {
match payload {
Value::String(text) => results.push(text.to_string()),
Value::Array(items) => {
for item in items {
collect_puzzle_string_values(item, results);
}
}
_ => {}
}
}
pub(crate) fn normalize_puzzle_downloaded_image_mime_type(content_type: &str) -> String {
let mime_type = content_type
.split(';')