### Running gremlin-rs Tutorial Examples (Shell) Source: https://github.com/wolf4ood/gremlin-rs/blob/master/gremlin-tutorial/README.md Provides the necessary shell commands to navigate to the tutorial directory, start the required Docker services (like a Gremlin server), and execute the Rust example code using Cargo. ```Shell cd gremlin-tutorial cd docker-compose docker-compose up -d cd .. cargo run ``` -------------------------------- ### Install gremlin-client Crate (Basic) - TOML Source: https://github.com/wolf4ood/gremlin-rs/blob/master/gremlin-client/README.md Adds the `gremlin-client` crate as a dependency to your Rust project's `Cargo.toml` file. This provides the basic synchronous client functionality. ```TOML [dependencies] gremlin-client = "0.8" ``` -------------------------------- ### Installing gremlin-cli (Shell) Source: https://github.com/wolf4ood/gremlin-rs/blob/master/README.md Provides the simple `cargo install` command to install the `gremlin-cli` tool from crates.io. ```Shell cargo install gremlin-cli ``` -------------------------------- ### Install gremlin-cli using Cargo Source: https://github.com/wolf4ood/gremlin-rs/blob/master/gremlin-cli/README.md Installs the gremlin-cli command-line tool using the Cargo package manager for Rust. This command fetches the latest version from crates.io and compiles/installs it. ```Shell cargo install gremlin-cli ``` -------------------------------- ### Running gremlin-rs Tests (Shell) Source: https://github.com/wolf4ood/gremlin-rs/blob/master/README.md Shows how to set up and run integration tests for `gremlin-rs` using Docker Compose. It includes navigating to the docker directory, setting the `GREMLIN_SERVER` environment variable, starting the Gremlin server container, returning to the project root, and running tests with all features enabled. Requires Docker and Docker Compose. ```Shell cd docker-compose export GREMLIN_SERVER=3.4.4 docker-compose up -d cd .. cargo test --all-features ``` -------------------------------- ### Install gremlin-client Crate (async-std Feature) - TOML Source: https://github.com/wolf4ood/gremlin-rs/blob/master/gremlin-client/README.md Adds the `gremlin-client` crate with the `async_std` feature enabled to your `Cargo.toml`. This is required for using the asynchronous client with the async-std runtime. ```TOML [dependencies] gremlin-client = { version = "0.8", features = ["async_std"] } ``` -------------------------------- ### Execute Basic Gremlin Query (Async, tokio) - Rust Source: https://github.com/wolf4ood/gremlin-rs/blob/master/gremlin-client/README.md Demonstrates asynchronous connection and query execution using the `tokio` runtime. It collects the results asynchronously. Requires the `tokio-runtime` feature and runtime activation. ```Rust use gremlin_client::{aio::GremlinClient, Vertex}; use tokio_stream::StreamExt; #[tokio::main] async fn main() -> Result<(), Box> { let client = GremlinClient::connect("localhost").await?; let results = client.execute("g.V(param)", &[("param", &1)]).await? .filter_map(Result::ok) .map(|f| f.take::()) .collect::, _>>().await?; println!("{:?}", results); Ok(()) } ``` -------------------------------- ### Execute Basic Gremlin Query (Async, async-std) - Rust Source: https://github.com/wolf4ood/gremlin-rs/blob/master/gremlin-client/README.md Shows how to connect asynchronously and execute a simple Gremlin query using the `async_std` runtime. It collects the results asynchronously. Requires the `async_std` feature and runtime activation. ```Rust use gremlin_client::{aio::GremlinClient, Vertex}; use async_std::prelude::*; #[async_std::main] async fn main() -> Result<(), Box> { let client = GremlinClient::connect("localhost").await?; let results = client.execute("g.V(param)", &[("param", &1)]).await? .filter_map(Result::ok) .map(|f| f.take::()) .collect::, _>>().await?; println!("{:?}", results); Ok(()) } ``` -------------------------------- ### Execute Basic Gremlin Query (Synchronous) - Rust Source: https://github.com/wolf4ood/gremlin-rs/blob/master/gremlin-client/README.md Demonstrates connecting to a Gremlin server and executing a simple synchronous query (`g.V(param)`) with a bound parameter. It collects the results as a vector of `Vertex` objects. Requires the basic `gremlin-client` dependency. ```Rust use gremlin_client::{GremlinClient, Vertex}; fn main() -> Result<(), Box> { let client = GremlinClient::connect("localhost")?; let results = client .execute("g.V(param)", &[("param", &1)])? .filter_map(Result::ok) .map(|f| f.take::()) .collect::, _>>()?; println!("{:?}", results); Ok(()) } ``` -------------------------------- ### Execute Basic Query Asynchronously Tokio Rust Source: https://github.com/wolf4ood/gremlin-rs/blob/master/README.md Demonstrates connecting and executing a simple parameterized query asynchronously using `gremlin_client::aio::GremlinClient` with the `tokio` runtime. It collects the results asynchronously. Requires the `tokio-runtime` feature. ```Rust use gremlin_client::{aio::GremlinClient, Vertex}; use tokio_stream::StreamExt; #[tokio::main] async fn main() -> Result<(), Box> { let client = GremlinClient::connect("localhost").await?; let results = client.execute("g.V(param)", &[("param", &1)]).await? .filter_map(Result::ok) .map(|f| f.take::()) .collect::, _>>().await?; println!("{:?}", results); Ok(()) } ``` -------------------------------- ### Execute Basic Query Synchronously Rust Source: https://github.com/wolf4ood/gremlin-rs/blob/master/README.md Demonstrates how to connect to a Gremlin server and execute a simple parameterized query synchronously using the `gremlin_client::GremlinClient`. It retrieves and collects results as `Vertex` objects. ```Rust use gremlin_client::{GremlinClient, Vertex}; fn main() -> Result<(), Box> { let client = GremlinClient::connect("localhost")?; let results = client .execute("g.V(param)", &[("param", &1)])? .filter_map(Result::ok) .map(|f| f.take::()) .collect::, _>>()?; println!("{:?}", results); Ok(()) } ``` -------------------------------- ### Compiling gremlin-rs (Shell) Source: https://github.com/wolf4ood/gremlin-rs/blob/master/README.md Provides the shell commands necessary to clone the `gremlin-rs` repository, navigate into the directory, and build the project using `cargo build`. ```Shell git clone https://github.com/wolf4ood/gremlin-rs.git cd gremlin-rs cargo build ``` -------------------------------- ### Execute Gremlin Traversal (Async GLV, tokio) - Rust Source: https://github.com/wolf4ood/gremlin-rs/blob/master/gremlin-client/README.md Shows how to build and execute an asynchronous Gremlin traversal using the Rust GLV with the `tokio` runtime. It connects asynchronously and uses `with_remote_async`. Requires the `tokio-runtime` feature and runtime activation. ```Rust use gremlin_client::{aio::GremlinClient, Vertex, process::traversal::traversal}; use tokio_stream::StreamExt; #[tokio::main] async fn main() -> Result<(), Box> { let client = GremlinClient::connect("localhost").await?; let g = traversal().with_remote_async(client); let results = g.v(()).has_label("person").has(("name","Jon")).to_list().await?; println!("{:?}", results); Ok(()) } ``` -------------------------------- ### Execute Gremlin Traversal (Async GLV, async-std) - Rust Source: https://github.com/wolf4ood/gremlin-rs/blob/master/gremlin-client/README.md Demonstrates building and executing an asynchronous Gremlin traversal using the Rust GLV with the `async_std` runtime. It connects asynchronously and uses `with_remote_async`. Requires the `async_std` feature and runtime activation. ```Rust use gremlin_client::{aio::GremlinClient, Vertex, process::traversal::traversal}; use async_std::prelude::*; #[async_std::main] async fn main() -> Result<(), Box> { let client = GremlinClient::connect("localhost").await?; let g = traversal().with_remote_async(client); let results = g.v(()).has_label("person").has(("name","Jon")).to_list().await?; println!("{:?}", results); Ok(()) } ``` -------------------------------- ### Execute Basic Query Asynchronously Async-std Rust Source: https://github.com/wolf4ood/gremlin-rs/blob/master/README.md Shows how to connect and execute a simple parameterized query asynchronously using `gremlin_client::aio::GremlinClient` with the `async-std` runtime. It collects the results asynchronously. Requires the `async-std-runtime` feature. ```Rust use gremlin_client::{aio::GremlinClient, Vertex}; use async_std::prelude::*; #[async_std::main] async fn main() -> Result<(), Box> { let client = GremlinClient::connect("localhost").await?; let results = client.execute("g.V(param)", &[("param", &1)]).await? .filter_map(Result::ok) .map(|f| f.take::()) .collect::, _>>().await?; println!("{:?}", results); Ok(()) } ``` -------------------------------- ### Execute Gremlin Traversal (Synchronous GLV) - Rust Source: https://github.com/wolf4ood/gremlin-rs/blob/master/gremlin-client/README.md Shows how to use the Rust Gremlin Language Variant (GLV) to build and execute a synchronous traversal (`g.V().hasLabel("person").has("name", "Jon")`). It connects to the server and uses `with_remote` to bind the traversal to the client. ```Rust use gremlin_client::{GremlinClient, Vertex, process::traversal::traversal}; fn main() -> Result<(), Box> { let client = GremlinClient::connect("localhost")?; let g = traversal().with_remote(client); let results = g.v(()).has_label("person").has(("name","Jon")).to_list()?; println!("{:?}", results); Ok(()) } ``` -------------------------------- ### Using FromGMap Derive with Traversal (Rust) Source: https://github.com/wolf4ood/gremlin-rs/blob/master/README.md Illustrates using the `FromGMap` derive macro with the Gremlin traversal API (`g.v(1).value_map()`) to map results into a Rust struct (`Person`). It shows connecting to the server, building a traversal, executing it, and converting the results. ```Rust use gremlin_client::derive::FromGMap; use gremlin_client::process::traversal::traversal; use gremlin_client::GremlinClient; use std::convert::TryFrom; fn main() -> Result<(), Box> { let client = GremlinClient::connect("localhost")?; #[derive(Debug, PartialEq, FromGMap)] struct Person { name: String, } let g = traversal().with_remote(client); let results = g .v(1) .value_map(()) .iter()?; .filter_map(Result::ok) .map(Person::try_from) .collect::, _>>()?; println!("Person {:?}", results[0]); Ok(()) } ``` -------------------------------- ### Perform Traversal Asynchronously Tokio Rust GLV Source: https://github.com/wolf4ood/gremlin-rs/blob/master/README.md Demonstrates using the Rust GLV to build and execute an asynchronous traversal with the `tokio` runtime. It connects asynchronously, creates an asynchronous remote traversal source, and executes a traversal. Requires the `tokio-runtime` feature. ```Rust use gremlin_client::{aio::GremlinClient, Vertex, process::traversal::traversal}; use tokio_stream::StreamExt; #[tokio::main] async fn main() -> Result<(), Box> { let client = GremlinClient::connect("localhost").await?; let g = traversal().with_remote_async(client); let results = g.v(()).has_label("person").has(("name","Jon")).to_list().await?; println!("{:?}", results); Ok(()) } ``` -------------------------------- ### Perform Traversal Asynchronously Async-std Rust GLV Source: https://github.com/wolf4ood/gremlin-rs/blob/master/README.md Shows how to use the Rust GLV to build and execute an asynchronous traversal with the `async-std` runtime. It connects asynchronously, creates an asynchronous remote traversal source, and executes a traversal. Requires the `async-std-runtime` feature. ```Rust use gremlin_client::{aio::GremlinClient, Vertex, process::traversal::traversal}; use async_std::prelude::*; #[async_std::main] async fn main() -> Result<(), Box> { let client = GremlinClient::connect("localhost").await?; let g = traversal().with_remote_async(client); let results = g.v(()).has_label("person").has(("name","Jon")).to_list().await?; println!("{:?}", results); Ok(()) } ``` -------------------------------- ### Adding gremlin-client derive Feature (Cargo.toml) Source: https://github.com/wolf4ood/gremlin-rs/blob/master/README.md Shows how to add the `gremlin-client` crate with the `derive` feature enabled to your `Cargo.toml` file, which is required to use the `FromGMap` and `FromGValue` derive macros. ```Toml [dependencies] gremlin-client = { version = "*", features = ["derive"] } ``` -------------------------------- ### Enable Gremlin-rs Derive Feature Source: https://github.com/wolf4ood/gremlin-rs/blob/master/gremlin-client/README.md Add the `derive` feature flag to the `gremlin_client` dependency in your Cargo.toml file to enable the `FromGMap` and `FromGValue` derive macros for automatic struct mapping. ```TOML [dependencies] gremlin_client = { version = "*", features = ["derive"] } ``` -------------------------------- ### Using FromGValue and FromGMap Derives (Rust) Source: https://github.com/wolf4ood/gremlin-rs/blob/master/README.md Demonstrates how to use the `FromGValue` and `FromGMap` derive macros to automatically convert `GValue` (specifically Map) and `GMap` results from Gremlin queries into a custom Rust struct (`Person`). It shows connecting to the server, executing a query, and mapping the results. ```Rust use gremlin_client::derive::{FromGMap, FromGValue}; use gremlin_client::process::traversal::traversal; use gremlin_client::GremlinClient; use std::convert::TryFrom; fn main() -> Result<(), Box> { let client = GremlinClient::connect("localhost")?; #[derive(Debug, PartialEq, FromGValue, FromGMap)] struct Person { name: String, } let results = client .execute("g.V(param).valueMap()", &[("param", &1)])? .filter_map(Result::ok) .map(|f| Person::try_from(f)) .collect::, _>>()?; println!("Person {:?}", results[0]); Ok(()) } ``` -------------------------------- ### Add Gremlin-client Dependency TOML Source: https://github.com/wolf4ood/gremlin-rs/blob/master/README.md Adds the basic `gremlin-client` crate as a dependency in the `Cargo.toml` file. This is the standard way to include the library in a Rust project. ```TOML [dependencies] gremlin-client = "0.8" ``` -------------------------------- ### Add Gremlin-client Tokio Dependency TOML Source: https://github.com/wolf4ood/gremlin-rs/blob/master/README.md Adds the `gremlin-client` crate with the `tokio-runtime` feature enabled in `Cargo.toml`. This is required to use the asynchronous client with the `tokio` runtime. ```TOML [dependencies] gremlin-client = { version = "0.4.0", features = ["tokio-runtime"] } ``` -------------------------------- ### Add Gremlin-client Async-std Dependency TOML Source: https://github.com/wolf4ood/gremlin-rs/blob/master/README.md Adds the `gremlin-client` crate with the `async-std-runtime` feature enabled in `Cargo.toml`. This is required to use the asynchronous client with the `async-std` runtime. ```TOML [dependencies] gremlin-client = { version = "0.8", features = ["async-std-runtime"] } ``` -------------------------------- ### Perform Traversal Synchronously Rust GLV Source: https://github.com/wolf4ood/gremlin-rs/blob/master/README.md Illustrates using the Rust Gremlin Language Variant (GLV) to build and execute a traversal synchronously. It connects to the server, creates a remote traversal source, and executes a traversal to find a vertex by label and property. ```Rust use gremlin_client::{GremlinClient, Vertex, process::traversal::traversal}; fn main() -> Result<(), Box> { let client = GremlinClient::connect("localhost")?; let g = traversal().with_remote(client); let results = g.v(()).has_label("person").has(("name","Jon")).to_list()?; println!("{:?}", results); Ok(()) } ``` -------------------------------- ### Derive Struct from GValue using FromGValue Source: https://github.com/wolf4ood/gremlin-rs/blob/master/gremlin-client/README.md Demonstrates how to use the `FromGValue` and `FromGMap` derive macros to map a `GValue` (specifically a Map) returned by `client.execute` into a Rust struct. This requires the `derive` feature enabled in Cargo.toml. ```Rust use gremlin_client::derive::{FromGMap, FromGValue}; use gremlin_client::process::traversal::traversal; use gremlin_client::GremlinClient; use std::convert::TryFrom; fn main() -> Result<(), Box> { let client = GremlinClient::connect("localhost")?; #[derive(Debug, PartialEq, FromGValue, FromGMap)] struct Person { name: String, } let results = client .execute("g.V(param).valueMap()", &[("param", &1)])? .filter_map(Result::ok) .map(|f| Person::try_from(f)) .collect::, _>>()?; println!("Person {:?}", results[0); Ok(()) } ``` -------------------------------- ### Derive Struct from GMap using FromGMap Source: https://github.com/wolf4ood/gremlin-rs/blob/master/gremlin-client/README.md Demonstrates how to use the `FromGMap` derive macro to map a `GMap` returned by a traversal (`g.v(1).value_map(())`) into a Rust struct. This requires the `derive` feature and a remote traversal source. ```Rust use gremlin_client::derive::FromGMap; use gremlin_client::process::traversal::traversal; use gremlin_client::GremlinClient; use std::convert::TryFrom; fn main() -> Result<(), Box> { let client = GremlinClient::connect("localhost")?; #[derive(Debug, PartialEq, FromGMap)] struct Person { name: String, } let g = traversal().with_remote(client); let results = g .v(1) .value_map(()) .iter()?; .filter_map(Result::ok) .map(Person::try_from) .collect::, _>>()?; println!("Person {:?}", results[0); Ok(()) } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.