qubit_json/json_decode_stage.rs
1/*******************************************************************************
2 *
3 * Copyright (c) 2026.
4 * Haixing Hu, Qubit Co. Ltd.
5 *
6 * All rights reserved.
7 *
8 ******************************************************************************/
9//! Defines the [`JsonDecodeStage`] type used by the public decoder API.
10//!
11//! Author: Haixing Hu
12
13use std::fmt;
14
15/// Identifies the decoding stage where an error was produced.
16#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
17pub enum JsonDecodeStage {
18 /// The error happened while normalizing raw input text.
19 Normalize,
20 /// The error happened while parsing normalized text as JSON syntax.
21 Parse,
22 /// The error happened while enforcing a top-level kind contract.
23 TopLevelCheck,
24 /// The error happened while deserializing a parsed JSON value.
25 Deserialize,
26}
27
28impl fmt::Display for JsonDecodeStage {
29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
30 match self {
31 Self::Normalize => f.write_str("normalize"),
32 Self::Parse => f.write_str("parse"),
33 Self::TopLevelCheck => f.write_str("top_level_check"),
34 Self::Deserialize => f.write_str("deserialize"),
35 }
36 }
37}