Struct json_event_parser::JsonReader[][src]

pub struct JsonReader<R: BufRead> { /* fields omitted */ }
Expand description

A simple JSON streaming parser.

Does not allocate except a stack to check if array and object opening and closing are properly nested. This stack size might be limited using the method max_stack_size.

Example:

use json_event_parser::{JsonReader, JsonEvent};
use std::io::Cursor;

let json = b"{\"foo\": 1}";
let mut reader = JsonReader::from_reader(Cursor::new(json));

let mut buffer = Vec::new();
assert_eq!(JsonEvent::StartObject, reader.read_event(&mut buffer)?);
assert_eq!(JsonEvent::ObjectKey("foo"), reader.read_event(&mut buffer)?);
assert_eq!(JsonEvent::Number("1"), reader.read_event(&mut buffer)?);
assert_eq!(JsonEvent::EndObject, reader.read_event(&mut buffer)?);
assert_eq!(JsonEvent::Eof, reader.read_event(&mut buffer)?);

Implementations

impl<R: BufRead> JsonReader<R>[src]

pub fn from_reader(reader: R) -> Self[src]

pub fn max_stack_size(&mut self, size: usize) -> &mut Self[src]

Maximal allowed number of nested object and array openings. Infinite by default.

pub fn read_event<'a>(
    &mut self,
    buffer: &'a mut Vec<u8>
) -> Result<JsonEvent<'a>>
[src]

Auto Trait Implementations

impl<R> RefUnwindSafe for JsonReader<R> where
    R: RefUnwindSafe

impl<R> Send for JsonReader<R> where
    R: Send

impl<R> Sync for JsonReader<R> where
    R: Sync

impl<R> Unpin for JsonReader<R> where
    R: Unpin

impl<R> UnwindSafe for JsonReader<R> where
    R: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.