qubit-json 0.13.0

Resource-aware infrastructure for lenient and strict JSON processing
Documentation
// =============================================================================
//    Copyright (c) 2026 Haixing Hu.
//
//    SPDX-License-Identifier: Apache-2.0
//
//    Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Structured reasons for failures while materializing unique-key or bounded
//! last-wins JSON values.

/// Describes why an admitted document could not be materialized as a
/// duplicate-rejecting unique-key value or a bounded last-wins value.
///
/// The reason is available independently of diagnostic source retention and
/// never contains input-derived text.
///
/// # Examples
///
/// ```
/// use qubit_json::decode::JsonMaterializationErrorReason;
///
/// let reason = JsonMaterializationErrorReason::DuplicateKey;
/// assert_eq!(reason, JsonMaterializationErrorReason::DuplicateKey);
/// ```
#[non_exhaustive]
#[must_use]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum JsonMaterializationErrorReason {
    /// A decoded object key appeared more than once.
    DuplicateKey,
    /// Historical compatibility reason; the shared builder no longer produces
    /// it. Current root-inclusive `max_depth` rejection is reported as a
    /// budget error during lexical admission.
    DepthLimit {
        /// Historical maximum number of nested containers accepted during
        /// construction.
        limit: usize,
    },
    /// The bounded last-wins builder encountered more simultaneously open
    /// containers than configured. The associated decode error points to the
    /// opening byte of the first over-limit container, unless a later syntax
    /// or budget failure takes precedence.
    ContainerLimit {
        /// Maximum number of simultaneously open containers accepted.
        limit: usize,
    },
    /// An admitted number could not be represented by the intermediate tree.
    InvalidNumber,
}