Skip to main content

cached_context/
types.rs

1//! Types module
2
3use serde::{Deserialize, Serialize};
4use std::path::PathBuf;
5
6/// Configuration for cached-context
7#[derive(Debug, Clone)]
8pub struct CacheConfig {
9    pub db_path: PathBuf,
10    pub session_id: String,
11    pub workdir: PathBuf,
12}
13
14impl Default for CacheConfig {
15    fn default() -> Self {
16        Self {
17            db_path: PathBuf::from(".cached-context/cache.db"),
18            session_id: uuid::Uuid::new_v4().to_string(),
19            workdir: std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")),
20        }
21    }
22}
23
24/// Result of a file read operation
25#[derive(Debug, Serialize, Deserialize)]
26pub struct FileReadResult {
27    pub cached: bool,
28    pub content: String,
29    pub hash: String,
30    pub total_lines: usize,
31    pub lines_changed: Option<usize>,
32    pub diff: Option<String>,
33}
34
35/// Cache statistics
36#[derive(Debug, Serialize, Deserialize)]
37pub struct CacheStats {
38    pub files_tracked: usize,
39    pub tokens_saved: u64,
40    pub session_tokens_saved: u64,
41}