pub struct ForwardText { /* private fields */ }Expand description
The text of one file, read from the front.
With map, an uncompressed file of 64 KiB or more stays mapped, and
Self::release_before advises MADV_DONTNEED for the pages before the
read position. On Linux that drops the file pages, so resident memory
stays near [RELEASE_STEP] instead of the file size. macOS gets the same
call, but its MADV_DONTNEED does not discard pages. Outside Unix the
release is a no-op. On those systems the whole file can become resident.
A mapped file is not a snapshot and must not change while it is read; a
truncation can end the process with SIGBUS.
Implementations§
Source§impl ForwardText
impl ForwardText
Sourcepub fn open(path: &Path, map: bool) -> Result<Self, Box<dyn Error>>
pub fn open(path: &Path, map: bool) -> Result<Self, Box<dyn Error>>
The text of path. Without map it is read_file_text.
pub fn as_str(&self) -> &str
Sourcepub fn release_before(&mut self, pos: usize) -> Result<()>
pub fn release_before(&mut self, pos: usize) -> Result<()>
Release the mapped pages before byte pos once [RELEASE_STEP]
bytes have been read since the last release. A later read of them
maps them in again. A pos past the end counts as the end.