Skip to main content

Module value

Module value 

Source
Expand description

Value types and element identifiers for graph data.

This module provides the core data types used throughout Interstellar:

  • VertexId / EdgeId - Unique identifiers for graph elements
  • ElementId - Union type for either vertex or edge IDs
  • Value - Dynamic property value type (similar to JSON)
  • ComparableValue - An ordered version of Value for sorting/dedup

§Value System

Interstellar uses a dynamic type system for property values, similar to JSON but extended with graph-specific types for vertices and edges. The Value enum can hold:

  • Primitives: Null, Bool, Int (i64), Float (f64), String
  • Collections: List, Map
  • Graph references: Vertex, Edge

§Type Conversions

Value implements From for common Rust types, making it easy to construct values:

use interstellar::prelude::*;

let int_val: Value = 42i64.into();
let str_val: Value = "hello".into();
let bool_val: Value = true.into();
let float_val: Value = 3.14f64.into();

§Serialization

Values can be serialized to and from a compact binary format using Value::serialize and Value::deserialize, useful for persistence.

§Example

use interstellar::prelude::*;
use std::collections::HashMap;

// Create values from Rust types
let name: Value = "Alice".into();
let age: Value = 30i64.into();

// Check types
assert!(name.as_str().is_some());
assert!(age.as_i64().is_some());

// Work with vertex IDs
let vid = VertexId(42);
let vertex_val: Value = vid.into();
assert!(vertex_val.is_vertex());
assert_eq!(vertex_val.as_vertex_id(), Some(VertexId(42)));

Structs§

EdgeId
A unique identifier for an edge in the graph.
OrderedFloat
A floating-point wrapper that provides total ordering.
VertexId
A unique identifier for a vertex in the graph.

Enums§

ComparableValue
A comparable version of Value that implements Ord.
ElementId
A union type representing either a vertex or edge identifier.
Value
A dynamic value type for graph properties and traversal results.

Traits§

IntoValueMap
Helper trait for ergonomic conversion of map-like collections into a ValueMap for use with Value::Map.
IntoVertexId
Trait for types that can be converted to a VertexId.

Type Aliases§

ValueMap
An order-preserving map type used for Value::Map payloads.