A WebAssembly library that provides raw C bindings for the Oxigraph RDF store, designed for use in sandboxed WASM environments that don't support JavaScript.
- Store Management: Create, destroy, and clear RDF stores
- Triple Operations: Add, check existence, and count triples
- SPARQL Queries: Execute SPARQL queries with string results
- RDF Serialization: Load and serialize Turtle format
- WASM Optimized: Built for
wasm32-unknown-unknowntarget - Custom Random: Deterministic random number generation for WASM
- FFI Safe: All functions use C-compatible types
oxigraph_create_store()- Create a new storeoxigraph_destroy_store(store)- Destroy a storeoxigraph_clear_store(store)- Clear all triplesoxigraph_count_triples(store)- Get triple count
oxigraph_add_triple(store, subject, predicate, object)- Add a tripleoxigraph_contains_triple(store, subject, predicate, object)- Check if triple exists
oxigraph_query_sparql(store, query, result, result_len)- Execute SPARQL query
oxigraph_load_turtle(store, turtle_data, base_iri)- Load Turtle dataoxigraph_serialize_turtle(store, result, result_len)- Export as Turtle
# Install WASM target
rustup target add wasm32-unknown-unknown
# Build release version
cargo build --release --target wasm32-unknown-unknown
# Or use the build script
./build.shtarget/wasm32-unknown-unknown/release/oxigraph_wasm.wasm- WASM moduletarget/wasm32-unknown-unknown/release/liboxigraph_wasm.a- Static libraryoxigraph_wasm.h- C header file
Include the header file in your C/C++ code:
#include "oxigraph_wasm.h"
// Create store
Store* store = oxigraph_create_store();
// Add a triple
int result = oxigraph_add_triple(store,
"http://example.org/subject",
"http://example.org/predicate",
"example value");
// Query
char buffer[1024];
int len = oxigraph_query_sparql(store,
"SELECT ?s ?p ?o WHERE { ?s ?p ?o }",
buffer, sizeof(buffer));
// Cleanup
oxigraph_destroy_store(store);- Oxigraph (Deepthought-Solutions fork with WASM support)
- getrandom 0.3 (with custom backend for WASM)
All functions return negative values on error:
-1: NULL pointer or invalid arguments-2: Invalid UTF-8 encoding-3: RDF/SPARQL parse error-4: Store operation error-5: Serialization error-6: Buffer too small
This crate is specifically designed for sandboxed WASM environments and includes:
- Custom deterministic random number generation
- Fixed time functions
- No JavaScript dependencies
- Optimized build configuration