gremlin_client/lib.rs
1//! Experimental Rust client for Apache Tinkerpop Gremlin Server.
2//! The driver supports the execution of raw Gremlin queries and GLV traversal
3//!
4//!
5//! You can use gremlin-client this lines in your `Cargo.toml`
6//!
7//! ```toml
8//! [dependencies]
9//! gremlin-client = "*"
10//! ```
11//!
12//! For async support via [async-std](https://async.rs/)
13//! ```toml
14//! [dependencies]
15//! gremlin-client = { version = "*", features = ["async_std"] }
16//! ```
17//!
18//!
19//! Here it is an usage example:
20//!
21//! **Synchronous**
22//!
23//! ```rust,no_run
24//!
25//! use gremlin_client::{GremlinClient, Vertex};
26//!
27//! fn main() -> Result<(), Box<std::error::Error>> {
28//! let client = GremlinClient::connect("localhost")?;
29//!
30//! let results = client
31//! .execute("g.V(param)", &[("param", &1)])?
32//! .filter_map(Result::ok)
33//! .map(|f| f.take::<Vertex>())
34//! .collect::<Result<Vec<Vertex>, _>>()?;
35//!
36//! println!("{:?}", results);
37//!
38//! Ok(())
39//!}
40//!
41//!
42//! ```
43//!
44//! **Asynchronous**
45//!
46//! ```rust,no_run,ignore
47//!
48//! use gremlin_client::{aio::GremlinClient, Vertex};
49//! use async_std::task;
50//! use async_std::prelude::*;
51//!
52//! fn main() -> Result<(), Box<std::error::Error>> {
53//!
54//! task::block_on(async {
55//! let client = GremlinClient::connect("localhost").await?;
56//! let results = client
57//! .execute("g.V(param)", &[("param", &1)]).await?
58//! .filter_map(Result::ok)
59//! .map(|f| f.take::<Vertex>())
60//! .collect::<Result<Vec<Vertex>, _>>().await?;
61//! println!("{:?}", results);
62//! Ok(())
63//! })
64//!
65//!}
66//!
67//!
68//! ```
69//!
70//! Here it is an example with traversal:
71//!
72//! **Synchronous**
73//!
74//! ```rust,no_run
75//!
76//! use gremlin_client::{GremlinClient, Vertex, process::traversal::traversal};
77//!
78//! fn main() -> Result<(), Box<std::error::Error>> {
79//! let client = GremlinClient::connect("localhost")?;
80//!
81//! let g = traversal().with_remote(client);
82//!
83//! let results = g.v(()).has_label("person").has(("name","Jon")).to_list()?;
84//!
85//! println!("{:?}", results);
86//! Ok(())
87//!}
88//!
89//! ```
90//! **Aynchronous**
91//!
92//! ```rust,no_run,ignore
93//!
94//! use gremlin_client::{aio::GremlinClient, Vertex, process::traversal::traversal};
95//! use async_std::task;
96//! use async_std::prelude::*;
97//!
98//! fn main() -> Result<(), Box<std::error::Error>> {
99//!
100//! task::block_on(async {
101//!
102//! let client = GremlinClient::connect("localhost").await?;
103//!
104//! let g = traversal().with_remote_async(client);
105//!
106//! let results = g.v(()).has_label("person").has(("name","Jon")).to_list().await?;
107//!
108//! println!("{:?}", results);
109//! Ok(())
110//! })
111//!}
112//!
113#[macro_use]
114extern crate lazy_static;
115
116mod client;
117mod connection;
118mod conversion;
119mod error;
120mod io;
121mod message;
122mod pool;
123
124pub use client::GremlinClient;
125pub use connection::{
126 ConnectionOptions, ConnectionOptionsBuilder, TlsOptions, WebSocketOptions,
127 WebSocketOptionsBuilder,
128};
129pub use conversion::{BorrowFromGValue, FromGValue, ToGValue};
130pub use error::GremlinError;
131pub use io::GraphSON;
132pub use message::Message;
133
134pub type GremlinResult<T> = Result<T, error::GremlinError>;
135
136pub use structure::{
137 Cardinality, Edge, GKey, GResultSet, GValue, IntermediateRepr, List, Map, Metric, Path,
138 Property, Token, TraversalExplanation, TraversalMetrics, Vertex, VertexProperty, GID,
139};
140
141#[cfg(feature = "async_gremlin")]
142pub mod aio;
143
144pub mod process;
145pub mod structure;
146pub mod utils;
147
148#[cfg(feature = "derive")]
149pub mod derive {
150 pub use gremlin_derive::FromGMap;
151 pub use gremlin_derive::FromGValue;
152}