Trait tantivy::tokenizer::TokenStream

source ·
pub trait TokenStream {
    // Required methods
    fn advance(&mut self) -> bool;
    fn token(&self) -> &Token;
    fn token_mut(&mut self) -> &mut Token;

    // Provided methods
    fn next(&mut self) -> Option<&Token> { ... }
    fn process(&mut self, sink: &mut dyn FnMut(&Token)) { ... }
}
Expand description

TokenStream is the result of the tokenization.

It consists consumable stream of Tokens.

Required Methods§

source

fn advance(&mut self) -> bool

Advance to the next token

Returns false if there are no other tokens.

source

fn token(&self) -> &Token

Returns a reference to the current token.

source

fn token_mut(&mut self) -> &mut Token

Returns a mutable reference to the current token.

Provided Methods§

source

fn next(&mut self) -> Option<&Token>

Helper to iterate over tokens. It simply combines a call to .advance() and .token().

source

fn process(&mut self, sink: &mut dyn FnMut(&Token))

Helper function to consume the entire TokenStream and push the tokens to a sink function.

Trait Implementations§

source§

impl<'a> TokenStream for Box<dyn TokenStream + 'a>

source§

fn advance(&mut self) -> bool

Advance to the next token Read more
source§

fn token<'b>(&'b self) -> &'b Token

Returns a reference to the current token.
source§

fn token_mut<'b>(&'b mut self) -> &'b mut Token

Returns a mutable reference to the current token.
source§

fn next(&mut self) -> Option<&Token>

Helper to iterate over tokens. It simply combines a call to .advance() and .token().
source§

fn process(&mut self, sink: &mut dyn FnMut(&Token))

Helper function to consume the entire TokenStream and push the tokens to a sink function.

Implementations on Foreign Types§

source§

impl<'a> TokenStream for Box<dyn TokenStream + 'a>

source§

fn advance(&mut self) -> bool

source§

fn token<'b>(&'b self) -> &'b Token

source§

fn token_mut<'b>(&'b mut self) -> &'b mut Token

Implementors§