qubit-budget 0.5.0

Dependency-light resource limit and budget accounting primitives for Qubit Rust crates
Documentation
// =============================================================================
//    Copyright (c) 2025 - 2026 Haixing Hu.
//
//    SPDX-License-Identifier: Apache-2.0
//
//    Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Defines resource identities for JSON processing limits.

/// A JSON quantity constrained while processing one JSON input.
///
/// # Examples
///
/// ```
/// use qubit_budget::json::JsonResource;
/// use qubit_budget::ResourceLimit;
///
/// let limit = ResourceLimit::new(JsonResource::InputBytes, 128_usize);
/// assert_eq!(limit.maximum(), 128);
/// ```
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum JsonResource {
    /// The total byte length of one complete JSON input.
    InputBytes,
    /// The byte length of normalized input processed after lenient cleanup.
    NormalizedInputBytes,
    /// The total byte length of one complete JSON output.
    OutputBytes,
    /// The root-inclusive nesting depth of the current JSON value.
    Depth,
    /// The cumulative number of JSON nodes processed in one session.
    Nodes,
    /// The number of items in one JSON array.
    SequenceItems,
    /// The number of entries in one JSON object.
    MapEntries,
    /// The byte length of one JSON object key.
    KeyBytes,
    /// The byte length of one JSON string value.
    StringBytes,
    /// The byte length of one JSON number representation.
    NumberBytes,
    /// The cumulative bytes of JSON object keys, strings and numbers.
    PayloadBytes,
}