Skip to main content

AsyncJsonStreamReader

Struct AsyncJsonStreamReader 

Source
pub struct AsyncJsonStreamReader<R> { /* private fields */ }
Expand description

The main async JSON stream reader for selective parsing.

Implementations§

Source§

impl<R: AsyncRead + Unpin> AsyncJsonStreamReader<R>

Source

pub fn new(reader: R) -> Self

Create a new stream reader with the default internal buffer size.

Source

pub async fn next_token( &mut self, ) -> Result<Option<JsonToken>, AsyncJsonStreamReaderError>

Read the next JSON token from the stream.

This is a low-level API; avoid mixing it with next_object_entry-based helpers.

Source

pub async fn next_object_entry( &mut self, ) -> Result<Option<String>, AsyncJsonStreamReaderError>

Read the next object key and position the reader on its value.

Source

pub async fn skip_to_key( &mut self, target_key: &str, ) -> Result<(), AsyncJsonStreamReaderError>

Skip to a specific key in the current object without descending into nested objects.

After this returns Ok(()), the reader is positioned on the value for target_key. Use read_* methods to consume that value before calling next_object_entry.

Source

pub async fn skip_object(&mut self) -> Result<(), AsyncJsonStreamReaderError>

Skip the next object value entirely.

Source

pub async fn start_array_item( &mut self, ) -> Result<bool, AsyncJsonStreamReaderError>

Read the next item in an array.

Returns true if an item was read, false if the array ended.

Source

pub async fn start_object(&mut self) -> Result<(), AsyncJsonStreamReaderError>

Start reading an object.

Source

pub async fn read_string( &mut self, ) -> Result<String, AsyncJsonStreamReaderError>

Read a string value.

Source

pub async fn read_nullable_string( &mut self, ) -> Result<Option<String>, AsyncJsonStreamReaderError>

Read a nullable string value.

Source

pub async fn read_number<T>(&mut self) -> Result<T, AsyncJsonStreamReaderError>
where T: FromStr, <T as FromStr>::Err: Debug,

Read a number value.

Source

pub async fn read_boolean(&mut self) -> Result<bool, AsyncJsonStreamReaderError>

Read a boolean value.

Source

pub async fn read_key( &mut self, ) -> Result<Option<String>, AsyncJsonStreamReaderError>

Read the next key in an object.

Source

pub async fn deserialize_object( &mut self, ) -> Result<Map<String, Value>, AsyncJsonStreamReaderError>

Read an object and deserialize it into a JSON map.

Auto Trait Implementations§

§

impl<R> Freeze for AsyncJsonStreamReader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for AsyncJsonStreamReader<R>
where R: RefUnwindSafe,

§

impl<R> Send for AsyncJsonStreamReader<R>
where R: Send,

§

impl<R> Sync for AsyncJsonStreamReader<R>
where R: Sync,

§

impl<R> Unpin for AsyncJsonStreamReader<R>
where R: Unpin,

§

impl<R> UnwindSafe for AsyncJsonStreamReader<R>
where R: UnwindSafe,

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.