Skip to content

Plugins

Surrealism plugins

Surrealism extensions are written in Rust, compiled into .surli archives, and loaded into a running SurrealDB instance. This gives you access to the Rust ecosystem while keeping extensions sandboxed within the database.

Surrealism was built in order to allow users to extend SurrealDB in ways that benefit them, without needing to make any changes to the code of SurrealDB itself. Some potential use cases are:

Surrealism works by using the following steps:

  • Use the surreal ext init command to begin a new project. This command works in a similar manner to cargo new in scaffolding a new project with its own toml file (package.toml).

  • Annotate functions to export with #[surrealism].

  • Use the surreal ext build command to build the extension, and optionally surreal ext sign to sign it.

  • In SurrealDB, allow access to the archive and define the extension to access the functions.

A flowchart showing the steps involved to turn regular Rust code into a compiled WASM binary that can be accessed from a running SurrealDB instance.A flowchart showing the steps involved to turn regular Rust code into a compiled WASM binary that can be accessed from a running SurrealDB instance.

Current Surrealism releases include:

  • function-level metadata such as comment via #[surrealism(...)], and read-only or read-write database access through a Transaction parameter;

  • one-time initialisation with #[surrealism(init)], run when the extension is built;

  • namespaced exports with #[surrealism] mod ...;

  • optional read-only attached filesystem data packaged into the archive;

  • signed archives, and capabilities granted per extension when it is defined;

  • server-side resource controls for execution time, memory, and the number of calls that run at once.

The next pages walk through the workflow and APIs:

Was this page helpful?