pub struct FileCache { /* private fields */ }Expand description
LRU cache for file contents
Caches file contents as line vectors for fast line access. Uses a simple eviction strategy when memory limit is reached.
Implementations§
Source§impl FileCache
impl FileCache
Sourcepub fn new(project_root: impl AsRef<Path>) -> Self
pub fn new(project_root: impl AsRef<Path>) -> Self
Create a new file cache with default 16MB limit
Sourcepub fn with_capacity(project_root: impl AsRef<Path>, max_bytes: usize) -> Self
pub fn with_capacity(project_root: impl AsRef<Path>, max_bytes: usize) -> Self
Create with custom memory limit
Sourcepub fn get_line(&mut self, path: &Path, line: u32) -> Option<String>
pub fn get_line(&mut self, path: &Path, line: u32) -> Option<String>
Get a single line from a file (1-indexed)
Sourcepub fn get_range(
&mut self,
path: &Path,
start: u32,
end: u32,
) -> Option<Vec<String>>
pub fn get_range( &mut self, path: &Path, start: u32, end: u32, ) -> Option<Vec<String>>
Get multiple lines as a range (1-indexed, inclusive)
Sourcepub fn get_context(
&mut self,
path: &Path,
line: u32,
before: u32,
after: u32,
) -> Option<CodeContext>
pub fn get_context( &mut self, path: &Path, line: u32, before: u32, after: u32, ) -> Option<CodeContext>
Get code context around a line
Sourcepub fn get_context_with_column(
&mut self,
path: &Path,
line: u32,
column: Option<u16>,
before: u32,
after: u32,
) -> Option<CodeContext>
pub fn get_context_with_column( &mut self, path: &Path, line: u32, column: Option<u16>, before: u32, after: u32, ) -> Option<CodeContext>
Get code context with column highlighting
Sourcepub fn get_enclosing_block(
&mut self,
path: &Path,
line: u32,
max_lines: u32,
) -> Option<Vec<String>>
pub fn get_enclosing_block( &mut self, path: &Path, line: u32, max_lines: u32, ) -> Option<Vec<String>>
Get the full function/block containing a line
Sourcepub fn file_exists(&self, path: &Path) -> bool
pub fn file_exists(&self, path: &Path) -> bool
Check if a file exists and is readable
Sourcepub fn line_count(&mut self, path: &Path) -> Option<usize>
pub fn line_count(&mut self, path: &Path) -> Option<usize>
Get total lines in a file
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Auto Trait Implementations§
impl Freeze for FileCache
impl RefUnwindSafe for FileCache
impl Send for FileCache
impl Sync for FileCache
impl Unpin for FileCache
impl UnwindSafe for FileCache
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
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
Converts
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>
Converts
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