Struct grep_searcher::SinkMatch
source · pub struct SinkMatch<'b> { /* private fields */ }
Expand description
A type that describes a match reported by a searcher.
Implementations§
source§impl<'b> SinkMatch<'b>
impl<'b> SinkMatch<'b>
sourcepub fn bytes(&self) -> &'b [u8] ⓘ
pub fn bytes(&self) -> &'b [u8] ⓘ
Returns the bytes for all matching lines, including the line terminators, if they exist.
sourcepub fn lines(&self) -> LineIter<'b> ⓘ
pub fn lines(&self) -> LineIter<'b> ⓘ
Return an iterator over the lines in this match.
If multi line search is enabled, then this may yield more than one line (but always at least one line). If multi line search is disabled, then this always reports exactly one line (but may consist of just the line terminator).
Lines yielded by this iterator include their terminators.
sourcepub fn absolute_byte_offset(&self) -> u64
pub fn absolute_byte_offset(&self) -> u64
Returns the absolute byte offset of the start of this match. This offset is absolute in that it is relative to the very beginning of the input in a search, and can never be relied upon to be a valid index into an in-memory slice.
sourcepub fn line_number(&self) -> Option<u64>
pub fn line_number(&self) -> Option<u64>
Returns the line number of the first line in this match, if available.
Line numbers are only available when the search builder is instructed to compute them.
sourcepub fn buffer(&self) -> &'b [u8] ⓘ
pub fn buffer(&self) -> &'b [u8] ⓘ
Exposes as much of the underlying buffer that was search as possible.
sourcepub fn bytes_range_in_buffer(&self) -> Range<usize>
pub fn bytes_range_in_buffer(&self) -> Range<usize>
Returns a range that corresponds to where SinkMatch::bytes
appears
in SinkMatch::buffer
.