GraphTraversalSource

Struct GraphTraversalSource 

Source
pub struct GraphTraversalSource<A: Terminator<GValue>> { /* private fields */ }

Implementations§

Source§

impl<A: Terminator<GValue>> GraphTraversalSource<A>

Source

pub fn new(terminator: A) -> GraphTraversalSource<A>

Source

pub fn empty() -> GraphTraversalSource<MockTerminator>

Source

pub fn with_remote( &self, client: GremlinClient, ) -> GraphTraversalSource<SyncTerminator>

Source

pub fn v<T>(&self, ids: T) -> GraphTraversal<Vertex, Vertex, A>
where T: Into<GIDs>, A: Terminator<Vertex>,

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
Hide additional 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}
Source

pub fn add_v<T>(&self, label: T) -> GraphTraversal<Vertex, Vertex, A>
where T: Into<Labels>, A: Terminator<Vertex>,

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}
Source

pub fn add_e<T>(&self, label: T) -> GraphTraversal<Edge, Edge, A>
where T: Into<Labels>, A: Terminator<Edge>,

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}
Source

pub fn e<T>(&self, ids: T) -> GraphTraversal<Edge, Edge, A>
where T: Into<GIDs>, A: Terminator<Edge>,

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}
Source

pub fn with_side_effect<T>( &self, step: (&'static str, T), ) -> GraphTraversal<GValue, GValue, A>
where T: Into<GValue> + FromGValue, A: Terminator<T>,

Trait Implementations§

Source§

impl<A: Clone + Terminator<GValue>> Clone for GraphTraversalSource<A>

Source§

fn clone(&self) -> GraphTraversalSource<A>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

Auto 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> 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> 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> 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, 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