1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! **jzon** — purpose-built, zero-copy JSON serialization for specific structs.
//!
//! # Design
//!
//! Use `#[derive(ToJson, FromJson)]` to generate a **monomorphised** JSON
//! (de)serializer for each of your types at compile time. No generic visitor
//! indirection, no intermediate `Value` allocation, no format-string overhead.
//!
//! ## Cargo features
//!
//! | Feature | Effect |
//! |---------|--------|
//! | *(none)* | SWAR u64 scanning (8 B/iter, safe, zero deps) |
//! | `simd` | Adds u128 SWAR (16 B/iter) on all platforms |
//! | `simd + unstable` | Uses `std::simd` portable SIMD (32–64 B/iter) on nightly Rust |
//! | `stats` | Attaches a `ScannerStats` to every `Scanner` to track allocations and cache hits |
//!
//! ## Zero-copy deserialization
//!
//! Fields typed `&'de str` borrow **directly** from the input — no `String` is
//! allocated unless the JSON string contains escape sequences (in which case
//! `Error::EscapedString` is returned so the user can switch to `String`).
//!
//! ## Field-hint cache
//!
//! The generated `FromJson` impl maintains a one-word *field-hint* variable
//! that predicts which field key to expect next. For JSON payloads whose
//! field order matches the struct definition — the common case — almost every
//! key dispatch is O(1) without hashing.
//!
//! ## Safe Rust only
//!
//! There are **no `unsafe` blocks** anywhere in this crate. All SIMD scanning
//! is done through `std::simd` (nightly) or pure u64/u128 arithmetic (SWAR).
//!
//! # Quick start
//!
//! ```rust,ignore
//! use jzon::{ToJson, FromJson};
//!
//! #[derive(ToJson, FromJson, Debug, PartialEq)]
//! #[serde(rename_all = "camelCase")]
//! struct User<'a> {
//! user_id: u64,
//! name: &'a str, // zero-copy borrow
//! #[serde(skip_serializing_if = "Option::is_none")]
//! email: Option<String>,
//! #[serde(default)]
//! score: f64,
//! }
//!
//! let input = r#"{"userId":1,"name":"alice","score":9.5}"#;
//! let user: User = User::from_json_str(input).unwrap();
//! let out = user.to_json_string();
//! ```
// Enable `std::simd` portable SIMD on nightly when `unstable` feature is set.
pub use Error;
pub use ;
pub use ToJson;
pub use FromJson;
pub use ;
// Re-export the derive macros under the same names as the traits.
// In Rust, traits live in the type namespace and derive macros live in the
// macro namespace — they can share the same identifier without conflict.
pub use ;