[−][src]Struct grep_searcher::BinaryDetection
The behavior of binary detection while searching.
Binary detection is the process of heuristically identifying whether a given chunk of data is binary or not, and then taking an action based on the result of that heuristic. The motivation behind detecting binary data is that binary data often indicates data that is undesirable to search using textual patterns. Of course, there are many cases in which this isn't true, which is why binary detection is disabled by default.
Unfortunately, binary detection works differently depending on the type of search being executed:
- When performing a search using a fixed size buffer, binary detection is applied to the buffer's contents as it is filled. Binary detection must be applied to the buffer directly because binary files may not contain line terminators, which could result in exorbitant memory usage.
- When performing a search using memory maps or by reading data off the
heap, then binary detection is only guaranteed to be applied to the
parts corresponding to a match. When
Quit
is enabled, then the first few KB of the data are searched for binary data.
Methods
impl BinaryDetection
[src]
pub fn none() -> BinaryDetection
[src]
No binary detection is performed. Data reported by the searcher may contain arbitrary bytes.
This is the default.
pub fn quit(binary_byte: u8) -> BinaryDetection
[src]
Binary detection is performed by looking for the given byte.
When searching is performed using a fixed size buffer, then the contents of that buffer are always searched for the presence of this byte. If it is found, then the underlying data is considered binary and the search stops as if it reached EOF.
When searching is performed with the entire contents mapped into memory, then binary detection is more conservative. Namely, only a fixed sized region at the beginning of the contents are detected for binary data. As a compromise, any subsequent matching (or context) lines are also searched for binary data. If binary data is detected at any point, then the search stops as if it reached EOF.
Trait Implementations
impl Clone for BinaryDetection
[src]
fn clone(&self) -> BinaryDetection
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for BinaryDetection
[src]
fn default() -> BinaryDetection
[src]
impl Debug for BinaryDetection
[src]
Auto Trait Implementations
impl Send for BinaryDetection
impl Sync for BinaryDetection
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,