pub struct ReaderJsonParser<R: Read> { /* private fields */ }
Expand description
Parses a JSON file from a Read
implementation.
use json_event_parser::{JsonEvent, ReaderJsonParser};
let mut reader = ReaderJsonParser::new(b"{\"foo\": 1}".as_slice());
assert_eq!(reader.parse_next()?, JsonEvent::StartObject);
assert_eq!(reader.parse_next()?, JsonEvent::ObjectKey("foo".into()));
assert_eq!(reader.parse_next()?, JsonEvent::Number("1".into()));
assert_eq!(reader.parse_next()?, JsonEvent::EndObject);
assert_eq!(reader.parse_next()?, JsonEvent::Eof);
Implementations§
Source§impl<R: Read> ReaderJsonParser<R>
impl<R: Read> ReaderJsonParser<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 fn parse_next(&mut self) -> Result<JsonEvent<'_>, JsonParseError>
pub fn read_next_event(&mut self) -> Result<JsonEvent<'_>, JsonParseError>
👎Deprecated: Use parse_next() instead
Auto Trait Implementations§
impl<R> Freeze for ReaderJsonParser<R>where
R: Freeze,
impl<R> RefUnwindSafe for ReaderJsonParser<R>where
R: RefUnwindSafe,
impl<R> Send for ReaderJsonParser<R>where
R: Send,
impl<R> Sync for ReaderJsonParser<R>where
R: Sync,
impl<R> Unpin for ReaderJsonParser<R>where
R: Unpin,
impl<R> UnwindSafe for ReaderJsonParser<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