subx_cli/core/matcher/
cache.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
5pub struct SnapshotItem {
6 pub name: String,
7 pub size: u64,
8 pub mtime: u64,
9 pub file_type: String,
10}
11
12#[derive(Debug, Serialize, Deserialize, Clone)]
14pub struct OpItem {
15 pub video_file: String,
16 pub subtitle_file: String,
17 pub new_subtitle_name: String,
18 pub confidence: f32,
19 pub reasoning: Vec<String>,
20}
21
22#[derive(Debug, Serialize, Deserialize, Clone)]
24pub struct CacheData {
25 pub cache_version: String,
26 pub directory: String,
27 pub file_snapshot: Vec<SnapshotItem>,
28 pub match_operations: Vec<OpItem>,
29 pub created_at: u64,
30 pub ai_model_used: String,
31 pub config_hash: String,
32}
33
34impl CacheData {
35 pub fn load(path: &std::path::Path) -> Result<Self, anyhow::Error> {
37 let content = std::fs::read_to_string(path)?;
38 let data = serde_json::from_str(&content)?;
39 Ok(data)
40 }
41}