pub struct FileReader { /* private fields */ }Expand description
File reader with support for memory mapping.
Automatically chooses the best reading strategy based on file size:
- Small files (< 1MB): Read directly into memory
- Large files (>= 1MB): Use memory mapping
§Examples
use rlm_rs::io::FileReader;
let reader = FileReader::open("large_file.txt").unwrap();
let content = reader.read_to_string().unwrap();Implementations§
Source§impl FileReader
impl FileReader
Sourcepub fn read_to_string(&self) -> Result<String>
pub fn read_to_string(&self) -> Result<String>
Reads the file content as a string.
Uses memory mapping for large files.
§Errors
Returns an error if reading fails or content is not valid UTF-8.
Sourcepub fn read_to_bytes(&self) -> Result<Vec<u8>>
pub fn read_to_bytes(&self) -> Result<Vec<u8>>
Auto Trait Implementations§
impl Freeze for FileReader
impl RefUnwindSafe for FileReader
impl Send for FileReader
impl Sync for FileReader
impl Unpin for FileReader
impl UnsafeUnpin for FileReader
impl UnwindSafe for FileReader
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