Skip to main content

qubit_json/encode/
json_map_key_kind.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//! Defines unsupported Serde shapes used as JSON object keys.
9
10/// Serde value shape that cannot be represented as a JSON object key.
11///
12/// # Examples
13///
14/// ```
15/// use qubit_json::encode::JsonMapKeyKind;
16/// use qubit_json::encode::JsonSerializationError;
17/// use qubit_json::encode::JsonSerializationErrorKind;
18///
19/// let error = JsonSerializationError::new(JsonSerializationErrorKind::UnsupportedMapKey {
20///     kind: JsonMapKeyKind::Map,
21/// });
22/// assert_eq!(error.map_key_kind(), Some(JsonMapKeyKind::Map));
23/// ```
24#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
25pub enum JsonMapKeyKind {
26    /// A byte sequence.
27    Bytes,
28    /// An absent optional value.
29    None,
30    /// A unit value.
31    Unit,
32    /// A unit struct.
33    UnitStruct,
34    /// A newtype variant.
35    NewtypeVariant,
36    /// A sequence.
37    Sequence,
38    /// A tuple.
39    Tuple,
40    /// A tuple struct.
41    TupleStruct,
42    /// A tuple variant.
43    TupleVariant,
44    /// A map.
45    Map,
46    /// A struct.
47    Struct,
48    /// A struct variant.
49    StructVariant,
50}