pub struct TokioAsyncReaderJsonParser<R: AsyncRead + Unpin> { /* private fields */ }
Available on crate feature
async-tokio
only.Expand description
Parses a JSON file from an AsyncRead
implementation.
use json_event_parser::{JsonEvent, TokioAsyncReaderJsonParser};
let mut reader = TokioAsyncReaderJsonParser::new(b"{\"foo\": 1}".as_slice());
assert_eq!(reader.parse_next().await?, JsonEvent::StartObject);
assert_eq!(
reader.parse_next().await?,
JsonEvent::ObjectKey("foo".into())
);
assert_eq!(reader.parse_next().await?, JsonEvent::Number("1".into()));
assert_eq!(reader.parse_next().await?, JsonEvent::EndObject);
assert_eq!(reader.parse_next().await?, JsonEvent::Eof);
Implementations§
Source§impl<R: AsyncRead + Unpin> TokioAsyncReaderJsonParser<R>
impl<R: AsyncRead + Unpin> TokioAsyncReaderJsonParser<R>
pub const fn new(read: R) -> Self
Sourcepub fn with_max_buffer_size(self, size: usize) -> Self
pub fn with_max_buffer_size(self, size: usize) -> Self
Sets the max size of the internal buffer in bytes
pub async fn parse_next(&mut self) -> Result<JsonEvent<'_>, JsonParseError>
pub async fn read_next_event(&mut self) -> Result<JsonEvent<'_>, JsonParseError>
👎Deprecated: Use parse_next() instead
Auto Trait Implementations§
impl<R> Freeze for TokioAsyncReaderJsonParser<R>where
R: Freeze,
impl<R> RefUnwindSafe for TokioAsyncReaderJsonParser<R>where
R: RefUnwindSafe,
impl<R> Send for TokioAsyncReaderJsonParser<R>where
R: Send,
impl<R> Sync for TokioAsyncReaderJsonParser<R>where
R: Sync,
impl<R> Unpin for TokioAsyncReaderJsonParser<R>
impl<R> UnwindSafe for TokioAsyncReaderJsonParser<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more