oxirs_core/lib.rs
1//! # OxiRS Core - RDF and SPARQL Foundation
2//!
3//! [](https://github.com/cool-japan/oxirs/releases)
4//! [](https://docs.rs/oxirs-core)
5//!
6//! **Status**: Alpha Release (v0.1.0-alpha.2)
7//! ⚠️ APIs may change. Not recommended for production use.
8//!
9//! Zero-dependency, Rust-native RDF data model and SPARQL foundation for the OxiRS semantic web platform.
10//! This crate provides the core types, traits, and operations that all other OxiRS crates build upon.
11//!
12//! ## Features
13//!
14//! - **RDF 1.2 Support** - Complete RDF data model implementation
15//! - **SPARQL Foundation** - Core types for SPARQL query processing
16//! - **Zero Dependencies** - Minimal external dependencies for maximum portability
17//! - **Memory Efficiency** - Optimized data structures for large knowledge graphs
18//! - **Concurrent Operations** - Thread-safe operations for multi-threaded environments
19//! - **Storage Backends** - Pluggable storage with memory and disk options
20//!
21//! ## Quick Start Examples
22//!
23//! ### Basic Store Operations
24//!
25//! ```rust,no_run
26//! use oxirs_core::store::ConcreteStore;
27//! use oxirs_core::model::{NamedNode, Triple};
28//!
29//! # fn example() -> Result<(), Box<dyn std::error::Error>> {
30//! // Create a new RDF store
31//! let store = ConcreteStore::new();
32//!
33//! // Add RDF data
34//! let subject = NamedNode::new("http://example.org/alice")?;
35//! let predicate = NamedNode::new("http://example.org/knows")?;
36//! let object = NamedNode::new("http://example.org/bob")?;
37//! let triple = Triple::new(subject, predicate, object);
38//!
39//! store.insert_triple(triple)?;
40//! println!("Triple added successfully");
41//! # Ok(())
42//! # }
43//! ```
44//!
45//! ### Consciousness-Inspired Processing
46//!
47//! ```rust,no_run
48//! use oxirs_core::consciousness::{ConsciousnessCoordinator, ConsciousnessLevel};
49//!
50//! # async fn consciousness_example() -> Result<(), Box<dyn std::error::Error>> {
51//! let mut coordinator = ConsciousnessCoordinator::new();
52//!
53//! // Configure consciousness-inspired optimization
54//! coordinator.set_consciousness_level(ConsciousnessLevel::SelfAware);
55//! coordinator.enable_dream_processing(true);
56//! coordinator.enable_emotional_learning(true);
57//!
58//! println!("Consciousness coordinator initialized");
59//! # Ok(())
60//! # }
61//! ```
62
63pub mod ai;
64pub mod concurrent;
65pub mod consciousness; // Consciousness-inspired computing for intuitive query optimization
66pub mod distributed;
67pub mod federation; // SPARQL federation support for distributed query execution
68pub mod format; // Phase 3: Complete RDF format support with zero dependencies
69pub mod graph;
70pub mod indexing;
71pub mod interning;
72pub mod io;
73pub mod model;
74pub mod molecular; // Molecular-level memory management inspired by biological systems
75pub mod optimization;
76pub mod parser;
77pub mod quantum; // Quantum-inspired computing for next-generation RDF processing
78pub mod query;
79pub mod rdf_store;
80pub mod serializer;
81pub mod sparql; // SPARQL query processing modules
82pub mod storage;
83pub mod store;
84pub mod transaction;
85pub mod vocab;
86// pub mod config;
87pub mod jsonld; // Re-enabled after fixing StringInterner method calls
88pub mod oxigraph_compat;
89pub mod rdfxml; // Oxigraph compatibility layer
90
91// Core abstractions for OxiRS ecosystem
92pub mod error;
93#[cfg(feature = "parallel")]
94pub mod parallel;
95pub mod platform;
96#[cfg(feature = "simd")]
97pub mod simd;
98
99// Re-export core types for convenience
100pub use model::*;
101pub use rdf_store::{ConcreteStore, RdfStore, Store};
102pub use transaction::Transaction;
103
104/// Core error type for OxiRS operations
105#[derive(Debug, Clone, thiserror::Error)]
106pub enum OxirsError {
107 #[error("Store error: {0}")]
108 Store(String),
109 #[error("Query error: {0}")]
110 Query(String),
111 #[error("Parse error: {0}")]
112 Parse(String),
113 #[error("Serialization error: {0}")]
114 Serialize(String),
115 #[error("IO error: {0}")]
116 Io(String),
117 #[error("Concurrency error: {0}")]
118 ConcurrencyError(String),
119 #[error("Quantum computing error: {0}")]
120 QuantumError(String),
121 #[error("Molecular optimization error: {0}")]
122 MolecularError(String),
123 #[error("Neural-symbolic fusion error: {0}")]
124 NeuralSymbolicError(String),
125 #[error("Operation not supported: {0}")]
126 NotSupported(String),
127 #[error("Update error: {0}")]
128 Update(String),
129 #[error("Federation error: {0}")]
130 Federation(String),
131}
132
133impl From<std::io::Error> for OxirsError {
134 fn from(err: std::io::Error) -> Self {
135 OxirsError::Io(err.to_string())
136 }
137}
138
139// Additional error conversions
140impl From<bincode::Error> for OxirsError {
141 fn from(err: bincode::Error) -> Self {
142 OxirsError::Serialize(err.to_string())
143 }
144}
145
146impl From<serde_json::Error> for OxirsError {
147 fn from(err: serde_json::Error) -> Self {
148 OxirsError::Serialize(err.to_string())
149 }
150}
151
152#[cfg(feature = "rocksdb")]
153impl From<rocksdb::Error> for OxirsError {
154 fn from(err: rocksdb::Error) -> Self {
155 OxirsError::Store(err.to_string())
156 }
157}
158
159// Note: DataFusion, Arrow, and Parquet error conversions removed
160// Add these features to Cargo.toml if these integrations are needed
161
162impl From<std::time::SystemTimeError> for OxirsError {
163 fn from(err: std::time::SystemTimeError) -> Self {
164 OxirsError::Io(format!("System time error: {err}"))
165 }
166}
167
168/// Result type alias for OxiRS operations
169pub type Result<T> = std::result::Result<T, OxirsError>;
170
171/// Version information for OxiRS Core
172pub const VERSION: &str = env!("CARGO_PKG_VERSION");
173
174/// Initialize OxiRS Core with default configuration
175pub fn init() -> Result<()> {
176 tracing::info!("Initializing OxiRS Core v{}", VERSION);
177 Ok(())
178}