Streamer

Struct Streamer 

Source
pub struct Streamer { /* private fields */ }
Expand description

Reads parts of UTF-8 json input and emits paths e.g. reading of

{
    "People": [
        {"Height": 180, "Age": 33},
        {"Height": 175, "Age": 24}
    ]
}

should emit (index and path)

Start( 0, ParsedKind::Obj) // Streamer.path == ""
Start( 1, ParsedKind::Arr) // Streamer.path == "{\"People\"}"
Start( 3, ParsedKind::Obj) // Streamer.path == "{\"People\"}[0]"
Start( 4, ParsedKind::Num) // Streamer.path == "{\"People\"}[0]{\"Height\"}"
End(   5, ParsedKind::Num)
Start( 6, ParsedKind::Num) // Streamer.path == "{\"People\"}[0]{\"Age\"}"
End(   7, ParsedKind::Num)
End(   8, ParsedKind::Obj)
Start( 9, ParsedKind::Obj) // Streamer.path == "{\"People\"}[1]"
Start(10, ParsedKind::Num) // Streamer.path == "{\"People\"}[1]{\"Height\"}"
End(  11, ParsedKind::Num)
Start(12, ParsedKind::Num) // Streamer.path == "{\"People\"}[1]{\"Age\"}"
End(  13, ParsedKind::Num)
End(  14, ParsedKind::Obj)
End(  15, ParsedKind::Arr)
End(  16, ParsedKind::Obj)

Implementations§

Source§

impl Streamer

Source

pub fn new() -> Self

Creates a new instance of streamer

Source

pub fn current_path(&mut self) -> &mut Path

Returns current path

Source

pub fn feed(&mut self, input: &[u8])

Feed streamer with data

Source

pub fn read(&mut self) -> Result<Token, General>

Reads data from streamer and emits Token struct

§Errors

If invalid JSON is passed and error may be emitted. Note that validity of input JSON is not checked.

Trait Implementations§

Source§

impl Debug for Streamer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Streamer

Source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.