Skip to main content

TypedTraversalSource

Struct TypedTraversalSource 

Source
pub struct TypedTraversalSource<'g> { /* private fields */ }
Expand description

Entry point for typed traversals with compile-time output tracking.

TypedTraversalSource produces TypedTraversals that know their output type at compile time, enabling type-safe terminal methods.

§Creating a Source

use interstellar::prelude::*;
use interstellar::traversal::typed::TypedTraversalSource;
use std::sync::Arc;

let graph = Arc::new(Graph::new());
let snapshot = graph.snapshot();
let g = TypedTraversalSource::new(&snapshot, graph.clone());

§Source Methods

MethodReturnsTerminal Output
v()TypedTraversal<Vertex>GraphVertex
e()TypedTraversal<Edge>GraphEdge
inject()TypedTraversal<Scalar>Value

Implementations§

Source§

impl<'g> TypedTraversalSource<'g>

Source

pub fn new<S: SnapshotLike + ?Sized>(snapshot: &'g S, graph: Arc<Graph>) -> Self

Create a new typed traversal source.

§Arguments
  • snapshot - A graph snapshot providing storage and interner
  • graph - An Arc<Graph> for creating rich element types
§Example
use interstellar::prelude::*;
use interstellar::traversal::typed::TypedTraversalSource;
use std::sync::Arc;

let graph = Arc::new(Graph::new());
let snapshot = graph.snapshot();
let g = TypedTraversalSource::new(&snapshot, graph.clone());
Source

pub fn v(&self) -> TypedTraversal<'g, Vertex>

Start traversal from all vertices.

Returns a TypedTraversal<Vertex> where terminal methods return GraphVertex objects.

§Example
use interstellar::prelude::*;
use interstellar::traversal::typed::TypedTraversalSource;
use std::sync::Arc;
use std::collections::HashMap;

let graph = Arc::new(Graph::new());
let _ = graph.add_vertex("person", HashMap::new());

let snapshot = graph.snapshot();
let g = TypedTraversalSource::new(&snapshot, graph.clone());

// next() returns Option<GraphVertex>
let v = g.v().next();
assert!(v.is_some());
Source

pub fn e(&self) -> TypedTraversal<'g, Edge>

Start traversal from all edges.

Returns a TypedTraversal<Edge> where terminal methods return GraphEdge objects.

§Example
use interstellar::prelude::*;
use interstellar::traversal::typed::TypedTraversalSource;
use std::sync::Arc;
use std::collections::HashMap;

let graph = Arc::new(Graph::new());
let a = graph.add_vertex("person", HashMap::new());
let b = graph.add_vertex("person", HashMap::new());
graph.add_edge(a, b, "knows", HashMap::new()).unwrap();

let snapshot = graph.snapshot();
let g = TypedTraversalSource::new(&snapshot, graph.clone());

// next() returns Option<GraphEdge>
let e = g.e().next();
assert!(e.is_some());
Source

pub fn inject<T, I>(&self, values: I) -> TypedTraversal<'g, Scalar>
where I: IntoIterator<Item = T>, T: Into<Value>,

Inject arbitrary values into the traversal.

Returns a TypedTraversal<Scalar> where terminal methods return raw Value objects.

§Example
use interstellar::prelude::*;
use interstellar::traversal::typed::TypedTraversalSource;
use std::sync::Arc;

let graph = Arc::new(Graph::new());
let snapshot = graph.snapshot();
let g = TypedTraversalSource::new(&snapshot, graph.clone());

let values = g.inject([1i64, 2, 3]).to_list();
assert_eq!(values.len(), 3);
Source

pub fn graph(&self) -> &Arc<Graph>

Get the graph reference.

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V