pub struct FileInfo {Show 14 fields
pub path: PathBuf,
pub relative_path: String,
pub size: u64,
pub modified: Option<SystemTime>,
pub decision: RenderDecision,
pub file_type: FileType,
pub language: Language,
pub content: Option<String>,
pub token_estimate: Option<usize>,
pub line_count: Option<usize>,
pub char_count: Option<usize>,
pub is_binary: bool,
pub git_status: Option<GitStatus>,
pub centrality_score: Option<f64>,
}Expand description
Comprehensive file metadata structure
Fields§
§path: PathBufAbsolute path to the file on disk
relative_path: StringPath relative to repository root (forward slash separated)
size: u64File size in bytes
modified: Option<SystemTime>File modification time
decision: RenderDecisionAnalysis decision (include/exclude)
file_type: FileTypeDetected file type
language: LanguageDetected programming language
content: Option<String>File content (loaded on demand)
token_estimate: Option<usize>Estimated token count for LLM processing
line_count: Option<usize>Line count (if text file)
char_count: Option<usize>Character count (if text file)
is_binary: boolWhether the file is likely binary
git_status: Option<GitStatus>Git status information (if available)
centrality_score: Option<f64>PageRank centrality score (0.0-1.0, higher means more important)
Implementations§
Source§impl FileInfo
impl FileInfo
Sourcepub fn new<P>(
path: P,
relative_path: String,
decision: RenderDecision,
) -> Result<FileInfo, ScribeError>
pub fn new<P>( path: P, relative_path: String, decision: RenderDecision, ) -> Result<FileInfo, ScribeError>
Create a new FileInfo from a path
Sourcepub fn load_content(&mut self) -> Result<(), ScribeError>
pub fn load_content(&mut self) -> Result<(), ScribeError>
Load file content and compute statistics
Sourcepub fn estimate_tokens(content: &str) -> usize
pub fn estimate_tokens(content: &str) -> usize
Estimate token count for LLM processing using tiktoken
This method uses the shared global TokenCounter instance for optimal performance. If tiktoken fails, it falls back to the legacy character-based estimation.
Sourcepub fn estimate_tokens_with_path(content: &str, file_path: &Path) -> usize
pub fn estimate_tokens_with_path(content: &str, file_path: &Path) -> usize
Estimate token count for LLM processing with file context
This method uses the file path to apply language-specific multipliers for more accurate token estimation.
Sourcepub fn detect_binary(path: &Path) -> bool
pub fn detect_binary(path: &Path) -> bool
Detect whether a file is binary using libmagic-compatible signatures with sensible fallbacks for small or unknown files.
Sourcepub fn detect_binary_with_hint(path: &Path, extension: &str) -> bool
pub fn detect_binary_with_hint(path: &Path, extension: &str) -> bool
Detect whether a file is binary, allowing the caller to provide an extension hint for fallback heuristics.
Sourcepub fn detect_binary_from_bytes(bytes: &[u8], extension: Option<&str>) -> bool
pub fn detect_binary_from_bytes(bytes: &[u8], extension: Option<&str>) -> bool
Detect whether in-memory content represents a binary file.
Sourcepub fn detect_binary_by_extension(extension: &str) -> bool
pub fn detect_binary_by_extension(extension: &str) -> bool
Check if file extension indicates binary content (fallback heuristic).
Sourcepub fn classify_file_type(
path: &str,
language: &Language,
extension: &str,
) -> FileType
pub fn classify_file_type( path: &str, language: &Language, extension: &str, ) -> FileType
Classify file type based on path and language
Sourcepub fn classify_file_type_with_binary(
path: &str,
language: &Language,
extension: &str,
is_binary: bool,
) -> FileType
pub fn classify_file_type_with_binary( path: &str, language: &Language, extension: &str, is_binary: bool, ) -> FileType
Classify file type when the binary state is already known.
Sourcepub fn human_size(&self) -> String
pub fn human_size(&self) -> String
Get human-readable size
Sourcepub fn should_include(&self) -> bool
pub fn should_include(&self) -> bool
Check if file should be included in analysis
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FileInfo
impl<'de> Deserialize<'de> for FileInfo
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<FileInfo, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<FileInfo, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for FileInfo
impl Serialize for FileInfo
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for FileInfo
impl RefUnwindSafe for FileInfo
impl Send for FileInfo
impl Sync for FileInfo
impl Unpin for FileInfo
impl UnsafeUnpin for FileInfo
impl UnwindSafe for FileInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more