pub struct BufferedTokenQueue<T: TokenTrait, TData> { /* private fields */ }
Expand description

A queue which can be used as a sender and reader. Use this for buffering all the tokens before reading

Implementations§

source§

impl<T: TokenTrait, TData> BufferedTokenQueue<T, TData>

source

pub fn new() -> Self

Constructs a new BufferedTokenQueue

Trait Implementations§

source§

impl<T: TokenTrait, TData> Default for BufferedTokenQueue<T, TData>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T: TokenTrait, TData> TokenReader<T, TData> for BufferedTokenQueue<T, TData>

source§

fn peek(&mut self) -> Option<&Token<T, TData>>

Returns a reference to next token but does not advance current position
source§

fn peek_n(&mut self, n: usize) -> Option<&Token<T, TData>>

Returns a reference to nth (zero based) upcoming token without advancing
source§

fn peek_mut(&mut self) -> Option<&mut Token<T, TData>>

Use with caution
source§

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

Returns the next token and advances
source§

fn scan( &mut self, cb: impl FnMut(&T, &TData) -> bool ) -> Option<&Token<T, TData>>

Runs the closure (cb) over upcoming tokens. Passes the value behind the Token to the closure. Will stop and return a reference to the next Token from when the closure returns true. Returns None if scanning finishes before closure returns true. Does not advance the reader. Read more
source§

fn conditional_next( &mut self, cb: impl FnOnce(&T) -> bool ) -> Option<Token<T, TData>>

Returns next if cb returns true for the upcoming token (the token from TokenReader::peek)
source§

fn expect_next( &mut self, expected_type: T ) -> Result<TData, Option<(T, Token<T, TData>)>>

Tests that next token matches an expected type. Will return error if does not match. The Ok value contains the data of the valid token. Else it will return the Err with the expected token type and the token that did not match Read more
source§

impl<T: TokenTrait, TData> TokenSender<T, TData> for BufferedTokenQueue<T, TData>

source§

fn push(&mut self, token: Token<T, TData>) -> bool

Appends a new Token Will return false if could not push token

Auto Trait Implementations§

§

impl<T, TData> RefUnwindSafe for BufferedTokenQueue<T, TData>where T: RefUnwindSafe, TData: RefUnwindSafe,

§

impl<T, TData> Send for BufferedTokenQueue<T, TData>where T: Send, TData: Send,

§

impl<T, TData> Sync for BufferedTokenQueue<T, TData>where T: Sync, TData: Sync,

§

impl<T, TData> Unpin for BufferedTokenQueue<T, TData>where T: Unpin, TData: Unpin,

§

impl<T, TData> UnwindSafe for BufferedTokenQueue<T, TData>where T: UnwindSafe, TData: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.