pub struct GraphTraversalSource<A: Terminator<GValue>> { /* private fields */ }Implementations§
Source§impl<A: Terminator<GValue>> GraphTraversalSource<A>
impl<A: Terminator<GValue>> GraphTraversalSource<A>
pub fn new(terminator: A) -> GraphTraversalSource<A>
pub fn empty() -> GraphTraversalSource<MockTerminator>
pub fn with_remote( &self, client: GremlinClient, ) -> GraphTraversalSource<SyncTerminator>
Sourcepub fn v<T>(&self, ids: T) -> GraphTraversal<Vertex, Vertex, A>
pub fn v<T>(&self, ids: T) -> GraphTraversal<Vertex, Vertex, A>
Examples found in repository?
examples/traversal.rs (line 9)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4 let client = GremlinClient::connect("localhost")?;
5
6 let g = traversal().with_remote(client);
7
8 let vertices = g
9 .v(())
10 .has_label("person")
11 .has(("name", "marko"))
12 .to_list()?;
13
14 println!("{:?}", vertices);
15
16 let friends = g
17 .v(())
18 .has_label("person")
19 .has(("name", "marko"))
20 .out("knows")
21 .to_list()?;
22
23 println!("{:?}", friends);
24
25 Ok(())
26}More examples
examples/traversal_complex.rs (line 15)
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8 let client = GremlinClient::connect("localhost")?;
9
10 let g = traversal().with_remote(client);
11
12 create_graph(&g)?;
13
14 let result = g
15 .v(())
16 .has_label("complex_vertex")
17 .has(("name", "test1"))
18 .out("complex_label")
19 .out("complex_label")
20 .value_map(())
21 .next()?
22 .expect("no vertices found");
23
24 println!(
25 "Found vertex with name {:?}",
26 result["name"].get::<List>().unwrap()[0]
27 );
28
29 let results = g
30 .v(())
31 .has_label("complex_vertex")
32 .has(("number", P::gt(3)))
33 .to_list()?;
34
35 println!(
36 "Found {} vertices with number greater than 3",
37 results.len()
38 );
39
40 let results = g
41 .v(())
42 .has_label("complex_vertex")
43 .has(("number", P::within((3, 6))))
44 .to_list()?;
45
46 println!("Found {} vertices with number 3 or 6", results.len());
47
48 let results = g
49 .v(())
50 .has_label("complex_vertex")
51 .where_(__.out("complex_label").count().is(P::gte(1)))
52 .to_list()?;
53
54 println!(
55 "Found {} vertices with 1 or more connected edges with label complex_label",
56 results.len()
57 );
58
59 Ok(())
60}
61
62fn create_graph(
63 g: &GraphTraversalSource<SyncTerminator>,
64) -> Result<(), Box<dyn std::error::Error>> {
65 g.v(()).has_label("complex_vertex").drop().next()?;
66 g.e(()).has_label("complex_label").drop().next()?;
67
68 let mut current_next: Option<Vertex> = None;
69 (0..10).for_each(|e| {
70 let next = g
71 .add_v("complex_vertex")
72 .property("name", format!("test{}", e))
73 .property("number", e)
74 .next()
75 .expect("failed to create vertex");
76
77 current_next.iter().zip(next.iter()).for_each(|(a, b)| {
78 g.add_e("complex_label")
79 .from(a)
80 .to(b)
81 .next()
82 .expect("failed to create edge");
83 });
84
85 current_next = next;
86 });
87
88 Ok(())
89}Sourcepub fn add_v<T>(&self, label: T) -> GraphTraversal<Vertex, Vertex, A>
pub fn add_v<T>(&self, label: T) -> GraphTraversal<Vertex, Vertex, A>
Examples found in repository?
examples/traversal_complex.rs (line 71)
62fn create_graph(
63 g: &GraphTraversalSource<SyncTerminator>,
64) -> Result<(), Box<dyn std::error::Error>> {
65 g.v(()).has_label("complex_vertex").drop().next()?;
66 g.e(()).has_label("complex_label").drop().next()?;
67
68 let mut current_next: Option<Vertex> = None;
69 (0..10).for_each(|e| {
70 let next = g
71 .add_v("complex_vertex")
72 .property("name", format!("test{}", e))
73 .property("number", e)
74 .next()
75 .expect("failed to create vertex");
76
77 current_next.iter().zip(next.iter()).for_each(|(a, b)| {
78 g.add_e("complex_label")
79 .from(a)
80 .to(b)
81 .next()
82 .expect("failed to create edge");
83 });
84
85 current_next = next;
86 });
87
88 Ok(())
89}Sourcepub fn add_e<T>(&self, label: T) -> GraphTraversal<Edge, Edge, A>
pub fn add_e<T>(&self, label: T) -> GraphTraversal<Edge, Edge, A>
Examples found in repository?
examples/traversal_complex.rs (line 78)
62fn create_graph(
63 g: &GraphTraversalSource<SyncTerminator>,
64) -> Result<(), Box<dyn std::error::Error>> {
65 g.v(()).has_label("complex_vertex").drop().next()?;
66 g.e(()).has_label("complex_label").drop().next()?;
67
68 let mut current_next: Option<Vertex> = None;
69 (0..10).for_each(|e| {
70 let next = g
71 .add_v("complex_vertex")
72 .property("name", format!("test{}", e))
73 .property("number", e)
74 .next()
75 .expect("failed to create vertex");
76
77 current_next.iter().zip(next.iter()).for_each(|(a, b)| {
78 g.add_e("complex_label")
79 .from(a)
80 .to(b)
81 .next()
82 .expect("failed to create edge");
83 });
84
85 current_next = next;
86 });
87
88 Ok(())
89}Sourcepub fn e<T>(&self, ids: T) -> GraphTraversal<Edge, Edge, A>
pub fn e<T>(&self, ids: T) -> GraphTraversal<Edge, Edge, A>
Examples found in repository?
examples/traversal_complex.rs (line 66)
62fn create_graph(
63 g: &GraphTraversalSource<SyncTerminator>,
64) -> Result<(), Box<dyn std::error::Error>> {
65 g.v(()).has_label("complex_vertex").drop().next()?;
66 g.e(()).has_label("complex_label").drop().next()?;
67
68 let mut current_next: Option<Vertex> = None;
69 (0..10).for_each(|e| {
70 let next = g
71 .add_v("complex_vertex")
72 .property("name", format!("test{}", e))
73 .property("number", e)
74 .next()
75 .expect("failed to create vertex");
76
77 current_next.iter().zip(next.iter()).for_each(|(a, b)| {
78 g.add_e("complex_label")
79 .from(a)
80 .to(b)
81 .next()
82 .expect("failed to create edge");
83 });
84
85 current_next = next;
86 });
87
88 Ok(())
89}pub fn with_side_effect<T>( &self, step: (&'static str, T), ) -> GraphTraversal<GValue, GValue, A>
Trait Implementations§
Source§impl<A: Clone + Terminator<GValue>> Clone for GraphTraversalSource<A>
impl<A: Clone + Terminator<GValue>> Clone for GraphTraversalSource<A>
Source§fn clone(&self) -> GraphTraversalSource<A>
fn clone(&self) -> GraphTraversalSource<A>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<A> Freeze for GraphTraversalSource<A>where
A: Freeze,
impl<A> RefUnwindSafe for GraphTraversalSource<A>where
A: RefUnwindSafe,
impl<A> Send for GraphTraversalSource<A>where
A: Send,
impl<A> Sync for GraphTraversalSource<A>where
A: Sync,
impl<A> Unpin for GraphTraversalSource<A>where
A: Unpin,
impl<A> UnwindSafe for GraphTraversalSource<A>where
A: UnwindSafe,
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