Struct read_token::ReadToken [] [src]

pub struct ReadToken<'a> {
    // some fields omitted
}

Stores the state of parsing.

Methods

impl<'a> ReadToken<'a>
[src]

fn new(chars: &'a [char], offset: usize) -> ReadToken<'a>

Creates a new state.

fn consume(self, n: usize) -> ReadToken<'a>

Consumes n characters.

fn raw_string(&self, n: usize) -> String

Reads a raw string.

fn lines<F>(&self, f: F) -> Result<Range, Range> where F: FnMut(&ReadToken) -> Option<Range>

Read lines until closure returns None. Returns Ok(range) of the successful read lines. Returns Err(range) when expected new line.

fn subtract(&self, rhs: &Self) -> Range

Returns the difference in offset.

fn start(&self) -> Range

Returns an empty range at current offset.

fn peek(&self, n: usize) -> Range

Peek a number of characters ahead.

fn tag(&self, tag: &str) -> Option<Range>

Reads an expected tag, returns character range and new state. Returns old state when fail to match tag.

fn until_any_or_whitespace(&self, any: &str) -> (Range, Option<usize>)

Reads a token until any character in string or whitespace. Returns (range, None) if stopping at whitespace or end of characters. Returns (range, Some(x)) if stopping at a character.

fn until_any(&self, any: &str) -> (Range, Option<usize>)

Reads token until any character in string. Returns (new_state, range, None) if stopping at end of characters. Returns (new_state, range, Some(x)) if stopping at a character.

fn whitespace(&self) -> Range

Reads whitespace.

fn string(&self) -> Option<Range>

Reads string with character escapes.

fn number(&self, settings: &NumberSettings) -> Option<Range>

Reads number.

fn parse_string(&self, n: usize) -> Result<String, Range<ParseStringError>>

Parses string into a real string according to the JSON standard.

Assumes the string starts and ends with double-quotes. n is the number of characters to read and must be at least 2, because the string is surrounded by quotes.

fn parse_number(&self, settings: &NumberSettings, n: usize) -> Result<f64ParseNumberError>

Parses number from n characters.

Trait Implementations

impl<'a> Debug for ReadToken<'a>
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<'a> Clone for ReadToken<'a>
[src]

fn clone(&self) -> ReadToken<'a>

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl<'a> Copy for ReadToken<'a>
[src]