Struct StreamParser

Source
pub struct StreamParser<'b, R: Reader, C: BitStackConfig = DefaultConfig> { /* private fields */ }
Expand description

A pull parser that parses JSON from a stream.

Generic over BitStackConfig for configurable nesting depth. It is designed to be used with the Reader trait, which is used to read data from a stream.

Implementations§

Source§

impl<'b, R: Reader> StreamParser<'b, R, DefaultConfig>

Methods for StreamParser using DefaultConfig

Source

pub fn new(reader: R, buffer: &'b mut [u8]) -> Self

Create a new StreamParser with default configuration

Uses the default BitStack configuration (u32 bucket, u8 counter) for most common use cases.

Source§

impl<'b, R: Reader, C: BitStackConfig> StreamParser<'b, R, C>

Methods for StreamParser with custom BitStackConfig

Source

pub fn with_config(reader: R, buffer: &'b mut [u8]) -> Self

Create a new StreamParser with custom configuration

Use this when you need custom BitStack storage types for specific memory or nesting depth requirements.

§Example
use picojson::{StreamParser, BitStackStruct, ArrayBitStack};

let reader = JsonReader::new(json);
let mut buffer = [0u8; 256];

// Custom configuration: u64 bucket + u16 counter for deeper nesting
let mut parser = StreamParser::<_, BitStackStruct<u64, u16>>::with_config(reader, &mut buffer);

Trait Implementations§

Source§

impl<'b, R: Reader, C: BitStackConfig> PullParser for StreamParser<'b, R, C>

Source§

fn next_event(&mut self) -> Result<Event<'_, '_>, ParseError>

Returns the next JSON event or an error if parsing fails. Parsing continues until EndDocument is returned or an error occurs.
Source§

fn next(&mut self) -> Option<Result<Event<'_, '_>, ParseError>>

Iterator-like method that returns None when parsing is complete. This method returns None when EndDocument is reached, Some(Ok(event)) for successful events, and Some(Err(error)) for parsing errors.

Auto Trait Implementations§

§

impl<'b, R, C> Freeze for StreamParser<'b, R, C>

§

impl<'b, R, C> RefUnwindSafe for StreamParser<'b, R, C>

§

impl<'b, R, C> Send for StreamParser<'b, R, C>
where R: Send, <C as BitStackConfig>::Counter: Send, <C as BitStackConfig>::Bucket: Send,

§

impl<'b, R, C> Sync for StreamParser<'b, R, C>
where R: Sync, <C as BitStackConfig>::Counter: Sync, <C as BitStackConfig>::Bucket: Sync,

§

impl<'b, R, C> Unpin for StreamParser<'b, R, C>

§

impl<'b, R, C = DefaultConfig> !UnwindSafe for StreamParser<'b, R, C>

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.