Trait regex_cursor::Cursor
source · pub trait Cursor {
// Required methods
fn chunk(&self) -> &[u8] ⓘ;
fn advance(&mut self) -> bool;
fn backtrack(&mut self) -> bool;
fn total_bytes(&self) -> Option<usize>;
fn offset(&self) -> usize;
// Provided method
fn utf8_aware(&self) -> bool { ... }
}
Expand description
A cursor that allows traversing a discontiguous string like a rope.
Required Methods§
sourcefn chunk(&self) -> &[u8] ⓘ
fn chunk(&self) -> &[u8] ⓘ
Returns the current chunk. If utf8_aware
returns true then this function
must never return a chunk that splits a unicode codepoint.
See utf8_aware
for details.
Must never return an empty byteslice unless the underlying collection is empty.
sourcefn advance(&mut self) -> bool
fn advance(&mut self) -> bool
Advances the cursor to the next chunk if possible. In that case true
must be returned. If the end of data is reached this function should
return false
and not change the chunk
sourcefn backtrack(&mut self) -> bool
fn backtrack(&mut self) -> bool
Moves the cursor to the previous chunk if possible. In that case true
must be returned If the start of data is reached this function should
return false
and not change the chunk
sourcefn total_bytes(&self) -> Option<usize>
fn total_bytes(&self) -> Option<usize>
Provided Methods§
sourcefn utf8_aware(&self) -> bool
fn utf8_aware(&self) -> bool
Whether this cursor is aware of utf-8 codepoint boundaries.
true
means that his cursor must never split a unicode codepoint at a
chunk boundary. In that case all regex features are supported.
false
means that his cursor can not be used for utf-8 mode
matching (only affects empty strings) and can not be used to match
unicode word boundaries.