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