pub enum Value {
U32(u32),
U64(u64),
I32(i32),
I64(i64),
F64(f64),
Bool(bool),
String(String),
Uuid(Uuid),
Timestamp(Timestamp),
}Expand description
A generic value type that can hold any ForgeDB primitive type
This enum represents all primitive types supported by ForgeDB schemas, providing a type-safe way to work with heterogeneous data.
§Examples
use forgedb_types::{Value, Uuid};
let int_val = Value::I32(42);
let uint_val = Value::U64(1_000_000_000_u64);
let str_val = Value::String("hello".to_string());
let uuid_val = Value::Uuid(Uuid::new_v4());
// Serialize to JSON
let json = serde_json::to_string(&int_val).unwrap();Variants§
U32(u32)
32-bit unsigned integer
U64(u64)
64-bit unsigned integer — stored losslessly; u64 values above i64::MAX
cannot be represented by the signed I64 variant without truncation
I32(i32)
32-bit signed integer
I64(i64)
64-bit signed integer
F64(f64)
64-bit floating point number
Bool(bool)
Boolean value
String(String)
UTF-8 encoded string
Uuid(Uuid)
Universally unique identifier
Timestamp(Timestamp)
Unix timestamp (seconds since epoch)
Implementations§
Source§impl Value
impl Value
Sourcepub fn type_name(&self) -> &'static str
pub fn type_name(&self) -> &'static str
Returns the type name of this value
§Examples
use forgedb_types::Value;
let val = Value::I32(42);
assert_eq!(val.type_name(), "i32");
let val = Value::U64(u64::MAX);
assert_eq!(val.type_name(), "u64");Sourcepub fn is_numeric(&self) -> bool
pub fn is_numeric(&self) -> bool
Returns true if this value is a numeric type (u32, u64, i32, i64, or f64)
§Examples
use forgedb_types::Value;
assert!(Value::U32(10).is_numeric());
assert!(Value::U64(u64::MAX).is_numeric());
assert!(Value::I32(42).is_numeric());
assert!(Value::F64(3.14).is_numeric());
assert!(!Value::String("hello".to_string()).is_numeric());Trait Implementations§
Source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnsafeUnpin for Value
impl UnwindSafe for Value
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more