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§

source

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.

source

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

source

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

source

fn total_bytes(&self) -> Option<usize>

Returns the total length of the data. This does not take the current cursor position into account and should not change with calls to advance and backtrack.

source

fn offset(&self) -> usize

The offset of the current chunk from the start of the haystack in bytes

Provided Methods§

source

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.

Implementations on Foreign Types§

source§

impl Cursor for &str

source§

fn chunk(&self) -> &[u8]

source§

fn utf8_aware(&self) -> bool

source§

fn advance(&mut self) -> bool

source§

fn backtrack(&mut self) -> bool

source§

fn total_bytes(&self) -> Option<usize>

source§

fn offset(&self) -> usize

source§

impl Cursor for &[u8]

source§

fn chunk(&self) -> &[u8]

source§

fn utf8_aware(&self) -> bool

source§

fn advance(&mut self) -> bool

source§

fn backtrack(&mut self) -> bool

source§

fn total_bytes(&self) -> Option<usize>

source§

fn offset(&self) -> usize

source§

impl<C: Cursor> Cursor for &mut C

source§

fn chunk(&self) -> &[u8]

source§

fn utf8_aware(&self) -> bool

source§

fn advance(&mut self) -> bool

source§

fn backtrack(&mut self) -> bool

source§

fn total_bytes(&self) -> Option<usize>

source§

fn offset(&self) -> usize

Implementors§