codec_jcs/lib.rs
1// SPDX-FileCopyrightText: 2026 ReallyMe Technologies Limited
2//
3// SPDX-License-Identifier: MIT OR Apache-2.0
4
5//! JSON Canonicalization Scheme helpers.
6//!
7//! Object member ordering and finite floating-point formatting follow RFC
8//! 8785. The raw-text API rejects duplicate object member names and malformed
9//! JSON. Integer tokens that `serde_json` retains exactly as `i64` or `u64`
10//! are additionally rejected outside `[-(2^53)+1, (2^53)-1]`; integer-valued
11//! binary64 numbers are subject to the same local policy. Non-integer binary64
12//! numbers follow RFC 8785's ECMAScript rounding semantics.
13//! If dependency feature unification enables `serde_json/arbitrary_precision`,
14//! the raw-text entry point fails closed with
15//! [`JcsError::UnsupportedNumberRepresentation`]. The feature changes the
16//! dependency's number visitor contract. That feature combination remains
17//! unsupported; use a separately compiled JCS lane.
18//! The raw-text parser decodes strings into wiping owners and parses numbers
19//! without a heap scratch buffer. Returned canonical text belongs to the caller.
20
21mod canonicalize;
22mod error;
23mod parse_json;
24mod read_json_string;
25mod sensitive_json_value;
26
27pub use canonicalize::{canonicalize_json_text, canonicalize_trusted_json_value};
28pub use error::JcsError;
29
30mod limits;
31pub use limits::MAX_NESTING_DEPTH;