pub struct SmartFileReader { /* private fields */ }Expand description
Smart file reader that chooses optimal reading strategy based on file size.
For files smaller than the threshold, uses std::fs::read_to_string for simplicity.
For larger files, uses memory-mapped files to avoid loading entire content into heap.
Implementations§
Source§impl SmartFileReader
impl SmartFileReader
Sourcepub const fn with_threshold(threshold: u64) -> Self
pub const fn with_threshold(threshold: u64) -> Self
Creates a new SmartFileReader with a custom threshold
Sourcepub fn read(&self, path: &Path) -> Result<FileContent, ProcessingError>
pub fn read(&self, path: &Path) -> Result<FileContent, ProcessingError>
Reads file content using the optimal strategy based on file size.
Returns FileContent and automatically chooses between:
read_to_stringfor files < thresholdmmapfor files >= threshold
Falls back to read_to_string if mmap fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SmartFileReader
impl RefUnwindSafe for SmartFileReader
impl Send for SmartFileReader
impl Sync for SmartFileReader
impl Unpin for SmartFileReader
impl UnwindSafe for SmartFileReader
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> 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