Skip to main content

ForwardText

Struct ForwardText 

Source
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

Source

pub fn open(path: &Path, map: bool) -> Result<Self, Box<dyn Error>>

The text of path. Without map it is read_file_text.

Source

pub fn as_str(&self) -> &str

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.