Skip to main content

qubit_json/decode/
json_decode_context.rs

1// =============================================================================
2//    Copyright (c) 2026 Haixing Hu.
3//
4//    SPDX-License-Identifier: Apache-2.0
5//
6//    Licensed under the Apache License, Version 2.0.
7// =============================================================================
8//! Contexts for immediate validated decode failures.
9
10/// Grammar location where a validated decode failure occurred.
11///
12/// # Examples
13///
14/// ```
15/// use qubit_json::decode::JsonDecodeContext;
16///
17/// let context = JsonDecodeContext::ObjectKey;
18/// assert_eq!(context, JsonDecodeContext::ObjectKey);
19/// ```
20#[non_exhaustive]
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
22pub enum JsonDecodeContext {
23    /// A JSON value token was expected.
24    Value,
25    /// An object key token was expected.
26    ObjectKey,
27    /// A string token was being scanned.
28    String,
29    /// A number token was being scanned or projected.
30    Number,
31    /// An object colon was expected.
32    Colon,
33    /// An array separator or closing bracket was expected.
34    ArraySeparator,
35    /// An object separator or closing brace was expected.
36    ObjectSeparator,
37    /// The document had trailing input after its root value.
38    TrailingInput,
39}