Skip to main content

CypherValue

Enum CypherValue 

Source
pub enum CypherValue {
Show 18 variants Null, Bool(bool), Int(i64), Float(f64), Str(String), List(Vec<CypherValue>), Map(IndexMap<String, CypherValue>), Node { id: i64, labels: Vec<String>, properties: IndexMap<String, CypherValue>, }, Relationship { id: i64, start_id: i64, end_id: i64, rel_type: String, properties: IndexMap<String, CypherValue>, }, Path { nodes: Vec<CypherValue>, relationships: Vec<CypherValue>, }, Date(NaiveDate), Time(NaiveTime, Option<FixedOffset>), DateTime(DateTime<FixedOffset>, Option<String>), LocalDateTime(NaiveDateTime), Duration(IsoDuration), Point(PointValue), Geometry(GeometryValue), Vector { coord: VectorCoordKind, dim: usize, values: Vec<CypherValue>, },
}
Expand description

The core value type for Relate.

Every value flowing through the query engine is represented as a CypherValue. This replaces Go’s interface{} with a proper algebraic type.

Variants§

§

Null

§

Bool(bool)

§

Int(i64)

§

Float(f64)

§

Str(String)

§

List(Vec<CypherValue>)

§

Map(IndexMap<String, CypherValue>)

§

Node

Fields

§id: i64
§labels: Vec<String>
§

Relationship

Fields

§id: i64
§start_id: i64
§end_id: i64
§rel_type: String
§

Path

Fields

§relationships: Vec<CypherValue>
§

Date(NaiveDate)

§

Time(NaiveTime, Option<FixedOffset>)

§

DateTime(DateTime<FixedOffset>, Option<String>)

DateTime with fixed offset and optional IANA timezone name (e.g., “Europe/Stockholm”).

§

LocalDateTime(NaiveDateTime)

§

Duration(IsoDuration)

§

Point(PointValue)

§

Geometry(GeometryValue)

§

Vector

CIP-200 VECTOR runtime value: a fixed-length, homogeneously-typed numeric vector distinct from List. values elements are always CypherValue::Int when coord.is_integer(), CypherValue::Float otherwise (never Null or any other variant – enforced by the vector() constructor, the only way to produce one). dim is always values.len().

Fields

§dim: usize

Implementations§

Source§

impl CypherValue

Source

pub fn is_null(&self) -> bool

Returns true if this value is Null.

Source

pub fn is_temporal(&self) -> bool

True for the five temporal variants (Date, Time, DateTime, LocalDateTime, Duration) — the one enumeration of the set, beside Self::is_null and type_name; the renderers that classify temporals (TOON’s scalars-bare token policy) consult this instead of re-listing the variants, and a new variant is a compile error here.

Source

pub fn type_name(&self) -> &'static str

Returns the type name as a string (for the type() function).

Source

pub fn as_bool(&self) -> Option<bool>

Attempts to extract a boolean value.

Source

pub fn as_int(&self) -> Option<i64>

Attempts to extract an integer value.

Source

pub fn as_float(&self) -> Option<f64>

Attempts to extract a float value, including int-to-float promotion.

Source

pub fn as_str(&self) -> Option<&str>

Attempts to extract a string reference.

Source

pub fn as_list(&self) -> Option<&[CypherValue]>

Attempts to extract a list reference.

Source

pub fn as_map(&self) -> Option<&IndexMap<String, CypherValue>>

Attempts to extract a map reference.

Source

pub fn to_bool_3vl(&self) -> Option<bool>

Returns true if this value is truthy in Cypher’s three-valued logic. Null returns None (unknown), true/false return Some(bool).

Source

pub fn as_numeric(&self) -> Option<(f64, bool)>

Coerce to a numeric type for arithmetic. Returns (value_as_f64, is_integer).

Trait Implementations§

Source§

impl Clone for CypherValue

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CypherValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for CypherValue

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for CypherValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&str> for CypherValue

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<CypherValue>> From<Option<T>> for CypherValue

Source§

fn from(o: Option<T>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for CypherValue

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<CypherValue>> From<Vec<T>> for CypherValue

Source§

fn from(v: Vec<T>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for CypherValue

Source§

fn from(b: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for CypherValue

Source§

fn from(f: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for CypherValue

Source§

fn from(i: i64) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for CypherValue

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for CypherValue

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for CypherValue

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.