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
| Method | Returns | Terminal Output |
|---|---|---|
v() | TypedTraversal<Vertex> | GraphVertex |
e() | TypedTraversal<Edge> | GraphEdge |
inject() | TypedTraversal<Scalar> | Value |
Implementations§
Source§impl<'g> TypedTraversalSource<'g>
impl<'g> TypedTraversalSource<'g>
Sourcepub fn new<S: SnapshotLike + ?Sized>(snapshot: &'g S, graph: Arc<Graph>) -> Self
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 internergraph- AnArc<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());Sourcepub fn v(&self) -> TypedTraversal<'g, Vertex>
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());Sourcepub fn e(&self) -> TypedTraversal<'g, Edge>
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());Sourcepub fn inject<T, I>(&self, values: I) -> TypedTraversal<'g, Scalar>
pub fn inject<T, I>(&self, values: I) -> TypedTraversal<'g, Scalar>
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);Auto Trait Implementations§
impl<'g> Freeze for TypedTraversalSource<'g>
impl<'g> !RefUnwindSafe for TypedTraversalSource<'g>
impl<'g> Send for TypedTraversalSource<'g>
impl<'g> Sync for TypedTraversalSource<'g>
impl<'g> Unpin for TypedTraversalSource<'g>
impl<'g> UnsafeUnpin for TypedTraversalSource<'g>
impl<'g> !UnwindSafe for TypedTraversalSource<'g>
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