Environment:0xranx OpenContext Rust Toolchain
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Build_Toolchain |
| Last Updated | 2026-10-24 10:00 GMT |
Overview
Rust stable toolchain with Cargo for building the `opencontext-core` library with the `search` feature for native chunking, embedding, and vector store operations.
Description
This environment provides the Rust/Cargo toolchain required to build the `opencontext-core` crate and its NAPI-RS bindings (`opencontext-node`). The core library uses `edition = "2021"` and requires the `search` feature flag to enable LanceDB, Arrow, reqwest, pulldown-cmark, tokio, and other search-related dependencies. CI also requires `protobuf-compiler` for building native modules.
Usage
Use this environment when building native modules from source or running Rust tests. It is the prerequisite for `Chunker`, `EmbeddingClient`, `VectorStore`, and `IndexSyncService` implementations that are compiled from Rust.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux, macOS, Windows | Cross-compilation supported via CI |
| Hardware | Any modern CPU | Build may require 2GB+ RAM |
| Disk | 1GB+ for Cargo build cache | `target/` directory |
Dependencies
System Packages
- Rust stable toolchain (via `rustup` or `dtolnay/rust-toolchain`)
- `protobuf-compiler` (required for native module builds)
- `cargo` (included with Rust)
Rust Crates (opencontext-core)
- `rusqlite` = 0.31 (bundled SQLite)
- `serde` = 1, `serde_json` = 1
- `chrono` = 0.4.38
- `parking_lot` = 0.12
- `dirs` = 5
- `thiserror` = 1
Search Feature Dependencies
- `lancedb` = 0.17
- `arrow-array` = 53, `arrow-schema` = 53
- `reqwest` = 0.12 (with `json` feature)
- `pulldown-cmark` = 0.12
- `tokio` = 1 (rt-multi-thread, macros, sync)
- `futures` = 0.3
- `toml` = 0.8
- `uuid` = 1 (v4)
- `log` = 0.4
- `regex` = 1
- `urlencoding` = 2.1
NAPI Build
- `@napi-rs/cli` >= 2.18.0
- `napi build --platform --release`
Credentials
No credentials required for building. API keys are only needed at runtime.
Quick Install
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install protobuf (Ubuntu/Debian)
sudo apt-get install -y protobuf-compiler
# Install protobuf (macOS)
brew install protobuf
# Build core library with search feature
cd crates/opencontext-core
cargo build --release --features search
# Build NAPI native bindings
cd crates/opencontext-node
npm ci
npm run build
Code Evidence
Cargo edition and features from `crates/opencontext-core/Cargo.toml:1-21`:
[package]
name = "opencontext-core"
version = "0.1.0"
edition = "2021"
[features]
default = []
search = [
"dep:lancedb", "dep:arrow-array", "dep:arrow-schema",
"dep:reqwest", "dep:pulldown-cmark", "dep:toml",
"dep:tokio", "dep:futures", "dep:uuid", "dep:log",
"dep:regex", "dep:urlencoding",
]
CI test command from `.github/workflows/ci.yml:69-72`:
- name: Run Rust tests
run: |
cd crates/opencontext-core
cargo test --release --features search
NAPI build command from `crates/opencontext-node/package.json:23-25`:
"build": "napi build --platform --release",
"build:debug": "napi build --platform",
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `error: protoc not found` | protobuf-compiler not installed | `sudo apt-get install protobuf-compiler` or `brew install protobuf` |
| `error: feature search is required` | Built without `--features search` | Add `--features search` to cargo command |
| `napi: command not found` | `@napi-rs/cli` not installed | `cd crates/opencontext-node && npm ci` |
Compatibility Notes
- Rust edition 2021: Required; older editions will not compile.
- Bundled SQLite: `rusqlite` uses the `bundled` feature, so no system SQLite is needed.
- Cross-compilation: CI builds for `x86_64-apple-darwin`, `aarch64-apple-darwin`, `x86_64-pc-windows-msvc`, and `x86_64-unknown-linux-gnu`.
- macOS deployment target: Set to 10.13 for native module builds.