pub struct File(/* private fields */);
Expand description
A wrapper around std::fs::File
which implements ReadByLine
and holds an index of the
lines.
Implementations§
Source§impl File
impl File
Sourcepub fn open<P: AsRef<Path>>(path: P) -> Result<File>
pub fn open<P: AsRef<Path>>(path: P) -> Result<File>
Open a new indexed file.
Returns an error if the index is malformed, missing or an io error occurs
Sourcepub fn open_raw<P: AsRef<Path>>(path: P) -> Result<File>
pub fn open_raw<P: AsRef<Path>>(path: P) -> Result<File>
Open a non indexed file and generates the index.
Sourcepub fn open_custom<P: AsRef<Path>>(path: P, index: Arc<Index>) -> Result<File>
pub fn open_custom<P: AsRef<Path>>(path: P, index: Arc<Index>) -> Result<File>
Open a non indexed file and uses a custom index index
.
Expects the index to be properly built.
Trait Implementations§
Source§impl IndexableFile for File
impl IndexableFile for File
Source§fn read_current_line(&mut self, buf: &mut Vec<u8>, line: usize) -> Result<usize>
fn read_current_line(&mut self, buf: &mut Vec<u8>, line: usize) -> Result<usize>
Should read from the current position until the end of the line, omitting the \n
Source§fn seek_line(&mut self, line: usize) -> Result<()>
fn seek_line(&mut self, line: usize) -> Result<()>
Should seek the file to the given line
line
Source§impl ReadByLine for File
impl ReadByLine for File
Source§fn read_line_raw(&mut self, line: usize, buf: &mut Vec<u8>) -> Result<usize>
fn read_line_raw(&mut self, line: usize, buf: &mut Vec<u8>) -> Result<usize>
Reads the given line and stores into
buf
Source§fn binary_search(&mut self, x: &str) -> Result<usize>
fn binary_search(&mut self, x: &str) -> Result<usize>
Do a binary search on
ReadByLine
implementing Types, since it provides everything required
for binary search. Only works with sorted filesSource§fn binary_search_by<F>(&mut self, f: F) -> Result<usize>
fn binary_search_by<F>(&mut self, f: F) -> Result<usize>
Do a binary search by on
ReadByLine
implementing Types, since it provides everything required
for binary search. Only works with sorted filesAuto Trait Implementations§
impl Freeze for File
impl RefUnwindSafe for File
impl Send for File
impl Sync for File
impl Unpin for File
impl UnwindSafe for File
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