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>
impl<R: AsyncRead + Unpin> AsyncJsonStreamReader<R>
Sourcepub fn new(reader: R) -> Self
pub fn new(reader: R) -> Self
Create a new stream reader with the default internal buffer size.
Sourcepub async fn next_token(
&mut self,
) -> Result<Option<JsonToken>, AsyncJsonStreamReaderError>
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.
Sourcepub async fn next_object_entry(
&mut self,
) -> Result<Option<String>, AsyncJsonStreamReaderError>
pub async fn next_object_entry( &mut self, ) -> Result<Option<String>, AsyncJsonStreamReaderError>
Read the next object key and position the reader on its value.
Sourcepub async fn skip_to_key(
&mut self,
target_key: &str,
) -> Result<(), AsyncJsonStreamReaderError>
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.
Sourcepub async fn skip_object(&mut self) -> Result<(), AsyncJsonStreamReaderError>
pub async fn skip_object(&mut self) -> Result<(), AsyncJsonStreamReaderError>
Skip the next object value entirely.
Sourcepub async fn start_array_item(
&mut self,
) -> Result<bool, AsyncJsonStreamReaderError>
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.
Sourcepub async fn start_object(&mut self) -> Result<(), AsyncJsonStreamReaderError>
pub async fn start_object(&mut self) -> Result<(), AsyncJsonStreamReaderError>
Start reading an object.
Sourcepub async fn read_string(
&mut self,
) -> Result<String, AsyncJsonStreamReaderError>
pub async fn read_string( &mut self, ) -> Result<String, AsyncJsonStreamReaderError>
Read a string value.
Sourcepub async fn read_nullable_string(
&mut self,
) -> Result<Option<String>, AsyncJsonStreamReaderError>
pub async fn read_nullable_string( &mut self, ) -> Result<Option<String>, AsyncJsonStreamReaderError>
Read a nullable string value.
Sourcepub async fn read_number<T>(&mut self) -> Result<T, AsyncJsonStreamReaderError>
pub async fn read_number<T>(&mut self) -> Result<T, AsyncJsonStreamReaderError>
Read a number value.
Sourcepub async fn read_boolean(&mut self) -> Result<bool, AsyncJsonStreamReaderError>
pub async fn read_boolean(&mut self) -> Result<bool, AsyncJsonStreamReaderError>
Read a boolean value.
Sourcepub async fn read_key(
&mut self,
) -> Result<Option<String>, AsyncJsonStreamReaderError>
pub async fn read_key( &mut self, ) -> Result<Option<String>, AsyncJsonStreamReaderError>
Read the next key in an object.
Sourcepub async fn deserialize_object(
&mut self,
) -> Result<Map<String, Value>, AsyncJsonStreamReaderError>
pub async fn deserialize_object( &mut self, ) -> Result<Map<String, Value>, AsyncJsonStreamReaderError>
Read an object and deserialize it into a JSON map.