pub struct FromTokioAsyncReadJsonReader<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::{FromTokioAsyncReadJsonReader, JsonEvent};
let mut reader = FromTokioAsyncReadJsonReader::new(b"{\"foo\": 1}".as_slice());
assert_eq!(reader.read_next_event().await?, JsonEvent::StartObject);
assert_eq!(reader.read_next_event().await?, JsonEvent::ObjectKey("foo".into()));
assert_eq!(reader.read_next_event().await?, JsonEvent::Number("1".into()));
assert_eq!(reader.read_next_event().await?, JsonEvent::EndObject);
assert_eq!(reader.read_next_event().await?, JsonEvent::Eof);
Implementations§
Source§impl<R: AsyncRead + Unpin> FromTokioAsyncReadJsonReader<R>
impl<R: AsyncRead + Unpin> FromTokioAsyncReadJsonReader<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 read_next_event(&mut self) -> Result<JsonEvent<'_>, ParseError>
Auto Trait Implementations§
impl<R> Freeze for FromTokioAsyncReadJsonReader<R>where
R: Freeze,
impl<R> RefUnwindSafe for FromTokioAsyncReadJsonReader<R>where
R: RefUnwindSafe,
impl<R> Send for FromTokioAsyncReadJsonReader<R>where
R: Send,
impl<R> Sync for FromTokioAsyncReadJsonReader<R>where
R: Sync,
impl<R> Unpin for FromTokioAsyncReadJsonReader<R>
impl<R> UnwindSafe for FromTokioAsyncReadJsonReader<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