use ggen_utils::error::Result;
use std::future::Future;
use std::path::Path;
use std::pin::Pin;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Triple {
pub subject: String,
pub predicate: String,
pub object: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Class {
pub uri: String,
pub label: Option<String>,
pub comment: Option<String>,
pub properties: Vec<Property>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Property {
pub uri: String,
pub label: Option<String>,
pub domain: Option<String>,
pub range: Option<String>,
}
#[derive(Debug, Clone, Default)]
pub struct ParseStats {
pub triples_parsed: usize,
pub classes_extracted: usize,
pub properties_extracted: usize,
pub parse_duration_ms: u128,
}
pub trait OntologyParser: Send + Sync {
fn parse_file(
&self,
path: &Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<Triple>>> + Send + '_>>;
fn parse_str(
&self,
content: &str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Triple>>> + Send + '_>>;
fn extract_classes(
&self,
path: &Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<Class>>> + Send + '_>>;
fn stats(&self) -> ParseStats;
}