qubit_value/value/value_ref.rs
1// =============================================================================
2// Copyright (c) 2025 - 2026 Haixing Hu.
3//
4// SPDX-License-Identifier: Apache-2.0
5//
6// Licensed under the Apache License, Version 2.0.
7// =============================================================================
8
9//! Borrowed semantic views for [`crate::Value`].
10
11use qubit_datatype::DataType;
12
13/// Borrowed semantic view of a [`crate::Value`].
14#[must_use]
15#[non_exhaustive]
16#[derive(Debug, Clone, Copy)]
17pub enum ValueRef<'a> {
18 /// An unset value retaining its declared type.
19 Unset(DataType),
20 /// A boolean value.
21 Bool(bool),
22 /// A character value.
23 Char(char),
24 /// A signed integer value.
25 Int8(i8),
26 /// A signed integer value.
27 Int16(i16),
28 /// A signed integer value.
29 Int32(i32),
30 /// A signed integer value.
31 Int64(i64),
32 /// A signed integer value.
33 Int128(i128),
34 /// An unsigned integer value.
35 UInt8(u8),
36 /// An unsigned integer value.
37 UInt16(u16),
38 /// An unsigned integer value.
39 UInt32(u32),
40 /// An unsigned integer value.
41 UInt64(u64),
42 /// An unsigned integer value.
43 UInt128(u128),
44 /// A 32-bit floating-point value.
45 Float32(f32),
46 /// A 64-bit floating-point value.
47 Float64(f64),
48 /// An arbitrary-precision integer.
49 #[cfg(feature = "big-integer")]
50 BigInteger(&'a num_bigint::BigInt),
51 /// An arbitrary-precision decimal.
52 #[cfg(feature = "big-decimal")]
53 BigDecimal(&'a bigdecimal::BigDecimal),
54 /// A string value.
55 String(&'a str),
56 /// A calendar date.
57 #[cfg(feature = "chrono")]
58 Date(&'a chrono::NaiveDate),
59 /// A time-of-day value.
60 #[cfg(feature = "chrono")]
61 Time(&'a chrono::NaiveTime),
62 /// A date-and-time value.
63 #[cfg(feature = "chrono")]
64 DateTime(&'a chrono::NaiveDateTime),
65 /// A UTC instant.
66 #[cfg(feature = "chrono")]
67 Instant(&'a chrono::DateTime<chrono::Utc>),
68 /// A duration value.
69 Duration(&'a std::time::Duration),
70 /// A URL value.
71 #[cfg(feature = "url")]
72 Url(&'a url::Url),
73 /// A map with string keys and values.
74 StringMap(&'a std::collections::HashMap<String, String>),
75 /// A JSON value.
76 #[cfg(feature = "json")]
77 Json(&'a serde_json::Value),
78}