← 返回
内容创作 中文

surrealism

SurrealDB Surrealism WASM extension development. Write Rust functions, compile to WASM, deploy as database modules. Part of the surreal-skills collection.
SurrealDB Surrealism WASM 扩展开发:编写 Rust 函数,编译为 WASM,部署为数据库模块。属于 surreal-skills 系列。
24601
内容创作 clawhub v1.2.1 3 版本 99894.5 Key: 无需
★ 2
Stars
📥 907
下载
💾 17
安装
3
版本
#latest#surrealdb

概述

Surrealism -- WASM Extensions for SurrealDB

New in SurrealDB 3. Write custom functions in Rust, compile them to WebAssembly

(WASM), and deploy them as native database modules callable from SurrealQL.

Prerequisites

  • Rust toolchain (stable) with wasm32-unknown-unknown target
  • SurrealDB CLI v3.0.0+ (surreal binary with surreal module subcommand)
  • Familiarity with SurrealQL DEFINE MODULE and DEFINE BUCKET

Development Workflow

1. Annotate   -- surrealism.toml + #[surrealism] on Rust functions
2. Compile    -- surreal module compile  (produces .wasm binary)
3. Register   -- DEFINE BUCKET + DEFINE MODULE in SurrealQL

Quick Start

# Create a new Surrealism project
cargo new --lib my_extension
cd my_extension

# Add the WASM target
rustup target add wasm32-unknown-unknown

# Create surrealism.toml (required manifest)
cat > surrealism.toml << 'TOML'
[package]
name = "my_extension"
version = "0.1.0"
TOML

# Write your extension (annotate with #[surrealism])
cat > src/lib.rs << 'RUST'
use surrealism::surrealism;

#[surrealism]
fn greet(name: String) -> String {
    format!("Hello, {}!", name)
}
RUST

# Compile to WASM using SurrealDB CLI
surreal module compile

# Register in SurrealDB
surreal sql --endpoint http://localhost:8000 --user root --pass root --ns test --db test
-- Grant access to the WASM file
DEFINE BUCKET my_bucket;

-- Register the module functions
DEFINE MODULE my_extension FROM 'my_bucket:my_extension.wasm';

-- Use the function in queries
SELECT my_extension::greet('World');

Use Cases

  • Custom scalar functions callable from SurrealQL
  • Fake/mock data generation for testing
  • Domain-specific logic (language processing, quantitative finance, custom encoding)
  • Access to niche Rust crate functionality too specific for core SurrealDB
  • Custom analyzers for full-text search

Status

Surrealism is actively in development and not yet stable. The API may change

between SurrealDB 3.x releases. File feedback via GitHub issues/PRs on the

surrealdb/surrealdb repository.

Full Documentation

See the main skill's rule file for complete guidance:

版本历史

共 3 个版本

  • v1.2.1 当前
    2026-03-31 15:07 安全 安全
  • v1.2.0
    2026-03-26 21:29
  • v1.1.1
    2026-03-07 01:53

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

content-creation

AdMapix

fly0pants
广告情报与应用数据分析助手,支持搜索广告素材、分析应用排名、下载量、收入及市场洞察,用于广告素材和竞品分析。
★ 295 📥 136,530
content-creation

Baidu Wenku AIPPT

ide-rea
使用百度文库 AI 智能生成 PPT,自动根据内容选择模板。
★ 66 📥 46,232
developer-tools

Deep Research (Gemini)

24601
通过 Gemini Interactions API 进行异步深度研究(无需 Gemini CLI 依赖)。在本地文件上进行 RAG 基础查询 (--context),预览成本 (--dry-run),结构化...
★ 3 📥 3,864