pub struct FileContentInjector { /* private fields */ }Expand description
Handles @ mention file content injection with structured XML tags.
Implementations§
Source§impl FileContentInjector
impl FileContentInjector
Sourcepub fn process_text_file(path: &Path, ref_str: &str) -> Result<String, String>
pub fn process_text_file(path: &Path, ref_str: &str) -> Result<String, String>
Process a text file: read content, optionally truncate.
Sourcepub fn process_large_file(
path: &Path,
ref_str: &str,
_content: &str,
lines: &[&str],
) -> String
pub fn process_large_file( path: &Path, ref_str: &str, _content: &str, lines: &[&str], ) -> String
Process a large file with head/tail truncation.
Sourcepub fn process_directory(&self, path: &Path, ref_str: &str) -> String
pub fn process_directory(&self, path: &Path, ref_str: &str) -> String
Process a directory: recursive tree listing.
Sourcepub fn process_pdf(path: &Path, ref_str: &str) -> String
pub fn process_pdf(path: &Path, ref_str: &str) -> String
Process a PDF file (placeholder – real extraction needs an external crate).
Sourcepub fn process_image(path: &Path, ref_str: &str) -> (String, Option<ImageBlock>)
pub fn process_image(path: &Path, ref_str: &str) -> (String, Option<ImageBlock>)
Process an image: base64 encode and emit an XML tag plus an ImageBlock.
Source§impl FileContentInjector
impl FileContentInjector
Sourcepub fn inject_content(&self, query: &str) -> InjectionResult
pub fn inject_content(&self, query: &str) -> InjectionResult
Extract @ references from query and inject file contents.
Sourcepub fn extract_refs(&self, query: &str) -> Vec<(String, PathBuf)>
pub fn extract_refs(&self, query: &str) -> Vec<(String, PathBuf)>
Extract file references from a query string.
Supports:
- Quoted paths:
@"path with spaces/file.py" - Unquoted paths:
@main.py,@src/utils.py
Excludes email addresses like user@example.com.
Sourcepub fn resolve_path(&self, ref_str: &str) -> PathBuf
pub fn resolve_path(&self, ref_str: &str) -> PathBuf
Resolve a reference string to an absolute path.
Sourcepub fn is_text_file(path: &Path) -> bool
pub fn is_text_file(path: &Path) -> bool
Check whether a path is a text file suitable for injection.
Sourcepub fn detect_text_file(path: &Path) -> bool
pub fn detect_text_file(path: &Path) -> bool
Heuristic text-file detection: read 8 KB sample, reject null bytes, accept valid UTF-8, fallback to printability ratio.
Sourcepub fn get_language(path: &Path) -> &'static str
pub fn get_language(path: &Path) -> &'static str
Get the syntax-highlighting language for a path.
Sourcepub fn format_size(size: u64) -> String
pub fn format_size(size: u64) -> String
Format a byte size as a human-readable string.