Skip to content

Commit

Permalink
Added supertraits
Browse files Browse the repository at this point in the history
  • Loading branch information
labra committed Jul 15, 2023
1 parent 296c358 commit 17b9190
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions srdf/src/srdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,38 @@ use std::{collections::HashSet, fmt::Display};
pub use bag::Bag;
use std::hash::Hash;

pub trait SRDF {
pub trait SRDFComparisons {
type Subject: Display ;
type IRI: Display + Hash + Eq ;
type BNode: Display ;
type Literal: Display ;
type Term: Display ;
type Err: Display;

fn get_predicates_subject(
fn subject2iri(&self, subject: &Self::Subject) -> Option<Self::IRI>;
fn subject2bnode(&self, subject: &Self::Subject) -> Option<Self::BNode>;
fn subject_is_iri(&self, subject: &Self::Subject) -> bool;
fn subject_is_bnode(&self, subject: &Self::Subject) -> bool;

fn object2iri(&self, object: &Self::Term) -> Option<Self::IRI>;
fn object2bnode(&self, object: &Self::Term) -> Option<Self::BNode>;
fn object2literal(&self, object: &Self::Term) -> Option<Self::Literal>;
fn object_is_iri(&self, object: &Self::Term) -> bool;
fn object_is_bnode(&self, object: &Self::Term) -> bool;
fn object_is_literal(&self, object: &Self::Term) -> bool;

fn term_as_subject(&self, object: &Self::Term) -> Option<Self::Subject>;

fn lexical_form(&self, literal: &Self::Literal) -> String;
fn lang(&self, literal: &Self::Literal) -> Option<String>;
fn datatype(&self, literal: &Self::Literal) -> Self::IRI;

fn iri_from_str(&self, str: String) -> Self::IRI;
}

pub trait SRDF : SRDFComparisons {

fn get_predicates_for_subject(
&self,
subject: &Self::Subject,
) -> Result<Bag<Self::IRI>, Self::Err>;
Expand Down

0 comments on commit 17b9190

Please sign in to comment.