Skip to main content

spire_ai/filecache/
types.rs

1//! Types for the file cache module.
2
3use serde::{Deserialize, Serialize};
4
5/// Result of reading a file through the cache.
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub enum ReadResult {
8    /// First time reading this file — full content returned.
9    Fresh {
10        content: String,
11        lines: usize,
12        tokens_estimated: usize,
13    },
14    /// File has not changed since last read.
15    Unchanged {
16        path: String,
17        lines: usize,
18        tokens_saved: usize,
19    },
20    /// File changed — unified diff returned instead of full content.
21    Modified {
22        diff: String,
23        lines_changed: usize,
24        tokens_saved: usize,
25    },
26}
27
28/// Statistics about cache usage.
29#[derive(Debug, Clone, Serialize, Deserialize)]
30pub struct CacheStats {
31    pub files_tracked: usize,
32    pub tokens_saved: usize,
33}