[−][src]Struct read_token::ReadToken
Stores the state of parsing.
Fields
src: &'a str
Source.
offset: usize
Byte offset.
Methods
impl<'a> ReadToken<'a>
[src]
pub fn new(src: &'a str, offset: usize) -> ReadToken<'a>
[src]
Creates a new ReadToken
.
The offset is in bytes.
pub fn consume(self, n: usize) -> ReadToken<'a>
[src]
Consumes n bytes.
pub fn raw_string(&self, n: usize) -> String
[src]
Reads a raw string.
pub fn lines<F>(&self, f: F) -> Result<Range, Range> where
F: FnMut(&ReadToken) -> Option<Range>,
[src]
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.
pub fn subtract(&self, rhs: &Self) -> Range
[src]
Returns the difference in offset.
pub fn start(&self) -> Range
[src]
Returns an empty range at current offset.
pub fn peek(&self, n: usize) -> Range
[src]
Peek a number of bytes ahead.
pub fn tag(&self, tag: &str) -> Option<Range>
[src]
Reads an expected tag, returns character range and new state. Returns old state when fail to match tag.
pub fn until_any_or_whitespace(&self, any: &str) -> (Range, Option<usize>)
[src]
Reads a token until any character in string or whitespace.
Returns (range, None)
if stopping at whitespace or end of text.
Returns (range, Some(x))
if stopping at a character.
pub fn until_any(&self, any: &str) -> (Range, Option<usize>)
[src]
Reads token until any character in string.
Returns (new_state, range, None)
if stopping at end of text.
Returns (new_state, range, Some(x))
if stopping at a character.
pub fn whitespace(&self) -> Range
[src]
Reads whitespace.
pub fn string(&self) -> Option<Range>
[src]
Reads string with character escapes.
pub fn number(&self, settings: &NumberSettings) -> Option<Range>
[src]
Reads number.
pub fn parse_string(&self, n: usize) -> Result<String, Range<ParseStringError>>
[src]
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 bytes to read and must be at least 2,
because the string is surrounded by quotes.
pub fn parse_number(
&self,
settings: &NumberSettings,
n: usize
) -> Result<f64, ParseNumberError>
[src]
&self,
settings: &NumberSettings,
n: usize
) -> Result<f64, ParseNumberError>
Parses number from n bytes.
Trait Implementations
impl<'a> Clone for ReadToken<'a>
[src]
fn clone(&self) -> ReadToken<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a> Copy for ReadToken<'a>
[src]
impl<'a> Debug for ReadToken<'a>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,