#[non_exhaustive]pub enum Value {
}Expand description
Dynamic value type for properties, parameters, and results.
Preserves the distinction between integers and floats, and includes graph-specific variants for nodes, edges, paths, and vectors.
Note: PartialEq, Eq, and Hash are implemented manually to support
using Value as a HashMap key. The Value::Float arm uses a normalized
total ordering rather than raw IEEE-754: 0.0 equals -0.0, and NaN
equals NaN (so Eq’s reflexivity holds). Hash is consistent with this:
all zeros hash alike and all NaNs hash alike. All other floats compare and
hash by their (canonical) bit representation. This affects only internal
bucketing — Cypher =/IN/DISTINCT route through cypher_eq, not here.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Null
JSON/Cypher null.
Bool(bool)
Boolean value.
Int(i64)
64-bit signed integer.
Float(f64)
64-bit floating-point number.
String(String)
UTF-8 string.
Bytes(Vec<u8>)
Raw byte buffer.
List(Vec<Value>)
Ordered list of values.
Map(HashMap<String, Value>)
String-keyed map of values.
Node(Node)
Graph node with VID, label, and properties.
Edge(Edge)
Graph edge with EID, type, endpoints, and properties.
Path(Path)
Graph path (alternating nodes and edges).
Vector(Vec<f32>)
Dense float vector for similarity search.
Temporal(TemporalValue)
Typed temporal value (date, time, datetime, duration).
Implementations§
Source§impl Value
impl Value
Sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
Returns the integer as u64 if this is a non-negative Int, otherwise None.
Sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
Returns a float, coercing Int to f64 if needed.
Returns None for non-numeric variants.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns the string slice if this is String, otherwise None.
Sourcepub fn as_array(&self) -> Option<&Vec<Value>>
pub fn as_array(&self) -> Option<&Vec<Value>>
Returns the list if this is List, otherwise None.
Sourcepub fn as_object(&self) -> Option<&HashMap<String, Value>>
pub fn as_object(&self) -> Option<&HashMap<String, Value>>
Returns the map if this is Map, otherwise None.
Sourcepub fn get(&self, key: &str) -> Option<&Value>
pub fn get(&self, key: &str) -> Option<&Value>
Gets a value by key if this is a Map.
Returns None if not a map or key doesn’t exist.
Sourcepub fn is_temporal(&self) -> bool
pub fn is_temporal(&self) -> bool
Returns true if this is a Temporal value.
Sourcepub fn as_temporal(&self) -> Option<&TemporalValue>
pub fn as_temporal(&self) -> Option<&TemporalValue>
Returns the temporal value reference if this is Temporal, otherwise None.
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>,
impl Eq for Value
Source§impl PartialEq for Value
impl PartialEq for Value
Source§fn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
Structural equality, with the Value::Float arm normalized so that
0.0 == -0.0 and NaN == NaN (see float_eq_normalized).
All non-float arms match the behavior of the former #[derive(PartialEq)]
exactly. Container variants (List, Map, Node, Edge, Path)
recurse through this same impl, so nested floats normalize too.
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more