json_event_parser/
lib.rs

1#![doc = include_str!("../README.md")]
2#![cfg_attr(docsrs, feature(doc_auto_cfg))]
3#![deny(
4    future_incompatible,
5    nonstandard_style,
6    rust_2018_idioms,
7    missing_copy_implementations,
8    trivial_casts,
9    trivial_numeric_casts,
10    unsafe_code,
11    unused_qualifications
12)]
13
14mod read;
15mod write;
16
17#[cfg(feature = "async-tokio")]
18pub use crate::read::TokioAsyncReaderJsonParser;
19pub use crate::read::{
20    JsonParseError, JsonSyntaxError, LowLevelJsonParser, LowLevelJsonParserResult,
21    ReaderJsonParser, SliceJsonParser, TextPosition,
22};
23#[cfg(feature = "async-tokio")]
24pub use crate::write::TokioAsyncWriterJsonSerializer;
25pub use crate::write::{LowLevelJsonSerializer, WriterJsonSerializer};
26use std::borrow::Cow;
27
28/// Possible events during JSON parsing.
29#[derive(Eq, PartialEq, Debug, Clone, Hash)]
30pub enum JsonEvent<'a> {
31    String(Cow<'a, str>),
32    Number(Cow<'a, str>),
33    Boolean(bool),
34    Null,
35    StartArray,
36    EndArray,
37    StartObject,
38    EndObject,
39    ObjectKey(Cow<'a, str>),
40    Eof,
41}
42
43#[cfg(feature = "async-tokio")]
44#[deprecated(note = "Use TokioAsyncReaderJsonParser")]
45pub type FromTokioAsyncReadJsonReader<R> = TokioAsyncReaderJsonParser<R>;
46#[deprecated(note = "Use SliceJsonParser")]
47pub type FromBufferJsonReader<'a> = SliceJsonParser<'a>;
48#[deprecated(note = "Use ReaderJsonParser")]
49pub type FromReadJsonReader<R> = ReaderJsonParser<R>;
50#[deprecated(note = "Use LowLevelJsonParser")]
51pub type LowLevelJsonReader = LowLevelJsonParser;
52#[deprecated(note = "Use LowLevelJsonParserResult")]
53pub type LowLevelJsonReaderResult<'a> = LowLevelJsonParserResult<'a>;
54#[deprecated(note = "Use JsonParseError")]
55pub type ParseError = JsonParseError;
56#[deprecated(note = "Use JsonSyntaxError")]
57pub type SyntaxError = JsonSyntaxError;
58#[cfg(feature = "async-tokio")]
59#[deprecated(note = "Use TokioAsyncWriterJsonSerializer")]
60pub type ToTokioAsyncWriteJsonWriter<W> = TokioAsyncWriterJsonSerializer<W>;
61#[deprecated(note = "Use WriterJsonSerializer")]
62pub type ToWriteJsonWriter<W> = WriterJsonSerializer<W>;
63#[deprecated(note = "Use LowLevelJsonSerializer")]
64pub type LowLevelJsonWriter = LowLevelJsonSerializer;