Skip to main content

codefold_core/
result.rs

1/// A parsed code symbol (function, class, method, etc.).
2#[derive(Debug, Clone, PartialEq, Eq)]
3pub struct Symbol {
4    pub name: String,
5    pub kind: SymbolKind,
6    pub byte_start: usize,
7    pub byte_end: usize,
8    pub line_start: usize,
9    pub line_end: usize,
10}
11
12#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub enum SymbolKind {
14    Function,
15    Method,
16    Class,
17    Import,
18}
19
20/// Output of `read()`.
21#[derive(Debug, Clone, PartialEq, Eq)]
22pub struct FoldResult {
23    /// The rendered view the caller should hand to the model.
24    pub content: String,
25    /// Symbols extracted from the file, with original positions.
26    pub symbols: Vec<Symbol>,
27    /// Byte ranges in the original source that were elided.
28    pub hidden_ranges: Vec<(usize, usize)>,
29    /// Detected language (`"python"`, `"typescript"`, ...).
30    pub language: String,
31    /// Estimated token count for `content`. Uses cl100k_base (GPT-4 tokenizer)
32    /// as a proxy for Anthropic/OpenAI models — accurate to within ~15%.
33    pub tokens_est: usize,
34}