pub fn get_mmap_if_suitable<P: AsRef<Path>>(
    hay_path: P,
    max_size: usize
) -> Result<Option<Mmap>>
Expand description

return the memmap to the file except if it was determined that the file is binary (from its extension, size, or first bytes) or is too big

Examples found in repository?
src/content_search/mod.rs (line 53)
52
53
54
pub fn is_path_suitable<P: AsRef<Path>>(path: P, max_size: usize) -> bool {
    matches!(get_mmap_if_suitable(path, max_size), Ok(Some(_)))
}
More examples
Hide additional examples
src/content_search/needle.rs (line 202)
201
202
203
204
205
206
207
    pub fn search<P: AsRef<Path>>(&self, hay_path: P) -> io::Result<ContentSearchResult> {
        super::get_mmap_if_suitable(hay_path, self.max_file_size)
            .map(|om| om.map_or(
                ContentSearchResult::NotSuitable,
                |hay| self.search_mmap(&hay),
            ))
    }