pub mod api;
pub mod error;
pub mod inference;
pub mod named_graph;
pub mod parser;
pub mod query;
pub mod store;
pub mod update;
pub mod results_csv;
pub mod geojson_support;
pub mod sparql_formatter;
pub mod prefix_manager;
pub mod streaming_parser;
pub mod wasm_bridge;
pub mod query_validator;
pub mod graph_visualizer;
pub mod triple_store;
pub mod sparql_executor;
pub mod storage_adapter;
pub mod event_dispatcher;
pub mod namespace_manager;
use wasm_bindgen::prelude::*;
pub use api::WasmSparqlStore;
pub use error::WasmError;
pub use store::OxiRSStore;
#[wasm_bindgen(start)]
pub fn init() {
console_error_panic_hook::set_once();
}
#[wasm_bindgen]
#[derive(Debug, Clone)]
pub struct Triple {
subject: String,
predicate: String,
object: String,
}
#[wasm_bindgen]
impl Triple {
#[wasm_bindgen(constructor)]
pub fn new(subject: &str, predicate: &str, object: &str) -> Self {
Self {
subject: subject.to_string(),
predicate: predicate.to_string(),
object: object.to_string(),
}
}
#[wasm_bindgen(getter)]
pub fn subject(&self) -> String {
self.subject.clone()
}
#[wasm_bindgen(getter)]
pub fn predicate(&self) -> String {
self.predicate.clone()
}
#[wasm_bindgen(getter)]
pub fn object(&self) -> String {
self.object.clone()
}
}
#[wasm_bindgen]
pub struct QueryResult {
bindings: Vec<JsValue>,
}
#[wasm_bindgen]
impl QueryResult {
#[wasm_bindgen(getter)]
pub fn bindings(&self) -> Vec<JsValue> {
self.bindings.clone()
}
#[wasm_bindgen(getter)]
pub fn length(&self) -> usize {
self.bindings.len()
}
}
#[wasm_bindgen]
pub fn version() -> String {
env!("CARGO_PKG_VERSION").to_string()
}
#[wasm_bindgen]
pub fn log(message: &str) {
web_sys::console::log_1(&message.into());
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_triple() {
let triple = Triple::new("http://a", "http://b", "http://c");
assert_eq!(triple.subject(), "http://a");
assert_eq!(triple.predicate(), "http://b");
assert_eq!(triple.object(), "http://c");
}
}