Struct grep_searcher::MmapChoice
source · pub struct MmapChoice(/* private fields */);
Expand description
Controls the strategy used for determining when to use memory maps.
If a searcher is called in circumstances where it is possible to use memory maps, and memory maps are enabled, then it will attempt to do so if it believes it will make the search faster.
By default, memory maps are disabled.
Implementations§
source§impl MmapChoice
impl MmapChoice
sourcepub unsafe fn auto() -> MmapChoice
pub unsafe fn auto() -> MmapChoice
Use memory maps when they are believed to be advantageous.
The heuristics used to determine whether to use a memory map or not may depend on many things, including but not limited to, file size and platform.
If memory maps are unavailable or cannot be used for a specific input, then normal OS read calls are used instead.
§Safety
This constructor is not safe because there is no obvious way to encapsulate the safety of file backed memory maps on all platforms without simultaneously negating some or all of their benefits.
The specific contract the caller is required to uphold isn’t precise,
but it basically amounts to something like, “the caller guarantees that
the underlying file won’t be mutated.” This, of course, isn’t feasible
in many environments. However, command line tools may still decide to
take the risk of, say, a SIGBUS
occurring while attempting to read a
memory map.
sourcepub fn never() -> MmapChoice
pub fn never() -> MmapChoice
Never use memory maps, no matter what. This is the default.
Trait Implementations§
source§impl Clone for MmapChoice
impl Clone for MmapChoice
source§fn clone(&self) -> MmapChoice
fn clone(&self) -> MmapChoice
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MmapChoice
impl Debug for MmapChoice
source§impl Default for MmapChoice
impl Default for MmapChoice
source§fn default() -> MmapChoice
fn default() -> MmapChoice
Auto Trait Implementations§
impl Freeze for MmapChoice
impl RefUnwindSafe for MmapChoice
impl Send for MmapChoice
impl Sync for MmapChoice
impl Unpin for MmapChoice
impl UnwindSafe for MmapChoice
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)