From 701a9d2e43d2e9e2845a6716b238d79d48a702c7 Mon Sep 17 00:00:00 2001 From: matea16 Date: Thu, 17 Jul 2025 12:02:13 +0200 Subject: [PATCH] add rust overview page --- pages/custom-query-modules/rust.mdx | 62 +++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 pages/custom-query-modules/rust.mdx diff --git a/pages/custom-query-modules/rust.mdx b/pages/custom-query-modules/rust.mdx new file mode 100644 index 000000000..7057b2341 --- /dev/null +++ b/pages/custom-query-modules/rust.mdx @@ -0,0 +1,62 @@ +--- +title: How to create a query module in Rust +description: Enhance your graph data analysis by integrating the Rust programming language with Memgraph. +--- + +import { Callout } from 'nextra/components' +import {CommunityLinks} from '/components/social-card/CommunityLinks' + +# How to create a query module in Rust + +To create a query module in Rust for Memgraph, you need to compile your code +into a shared library (`.so` file) that Memgraph can load dynamically at +runtime. + +## Development environment options + +You have two main ways to set up your Rust +development environment: + +1. **Using your own environment**
+You can compile Rust query modules on your local machine or server, but you’ll +need to manually install Rust tooling and any necessary dependencies (like +`cargo` and system libraries). + +2. **Using the MAGE environment**
+The Memgraph MAGE development Docker image (with the `-dev` tag) contains all +required dependencies and provides an isolated environment ideal for +development. + +See the [quickstart to custom query +module](/custom-query-modules/rust/rust-example) in Rust for a full guide. + +## How the Rust API works + +The Rust API is a wrapper around Memgraph’s C API, providing a more ergonomic +and memory-safe interface while maintaining high performance. Query modules +written in Rust are compiled to shared libraries and loaded by Memgraph at +startup. + +- The API includes wrappers for working with graph data, procedures, results, +errors, and more. +- You can define custom procedures using macros like `init_module!`, +`define_procedure!`, and `close_module!`. +- Exception handling in Rust (with `Result` types) ensures better stability, but +unhandled `panic!` calls can still crash Memgraph. + +Full reference: [Rust API documentation](/custom-query-modules/rust/rust-api). + +## Quickstart summary + +To get started quickly: +1. Run Memgraph using the MAGE development Docker image. +2. Install `cargo` inside the container. +3. Copy the query module boilerplate and adjust `Cargo.toml` and `lib.rs`. +4. Build your module using `python3 setup build -p + /usr/lib/memgraph/query_modules/`. +5. Load the module in Memgraph with `CALL mg.load_all();`. + +Follow the [quickstart guide](/custom-query-modules/rust/rust-example) for +detailed instructions. + + \ No newline at end of file