Struct hdt::hdt_graph::HdtGraph

source ·
pub struct HdtGraph {
    pub hdt: Hdt,
}
Expand description

Adapter to use HDT as a Sophia graph.

Fields§

§hdt: Hdt

Wrapped HDT instance

Implementations§

source§

impl HdtGraph

source

pub const fn new(hdt: Hdt) -> Self

Wrapper around Hdt.

source

pub fn size_in_bytes(&self) -> usize

Size in bytes on the heap.

Trait Implementations§

source§

impl Graph for HdtGraph

source§

fn triples(&self) -> GTripleSource<'_, Self>

§Example
use hdt::sophia::api::graph::Graph;
fn print_first_triple(graph: hdt::HdtGraph) {
    println!("{:?}", graph.triples().next().expect("no triple in the graph"));
}
source§

fn triples_matching<'s, S, P, O>( &'s self, sm: S, pm: P, om: O ) -> GTripleSource<'s, Self>
where S: TermMatcher + 's, P: TermMatcher + 's, O: TermMatcher + 's,

Only supports constant and “any” matchers. Non-constant matchers are supposed to be “any” matchers.

§Example

Who was born in Leipzig?

use hdt::{Hdt,HdtGraph};
use hdt::sophia::api::graph::Graph;
use hdt::sophia::api::term::{IriRef, SimpleTerm, matcher::Any};

fn query(dbpedia: hdt::HdtGraph) {
    let birth_place = SimpleTerm::Iri(IriRef::new_unchecked("http://www.snik.eu/ontology/birthPlace".into()));
    let leipzig = SimpleTerm::Iri(IriRef::new_unchecked("http://www.snik.eu/resource/Leipzig".into()));
    let persons = dbpedia.triples_matching(Any, Some(birth_place), Some(leipzig));
}
§

type Triple<'a> = [HdtTerm; 3]

Determine the type of Triples that the methods of this graph will yield.
§

type Error = Infallible

The error type that this graph may raise.
source§

fn contains<TS, TP, TO>(&self, s: TS, p: TP, o: TO) -> Result<bool, Self::Error>
where TS: Term, TP: Term, TO: Term,

Return true if this graph contains the given triple.
source§

fn subjects( &self ) -> Box<dyn Iterator<Item = Result<<Self::Triple<'_> as Triple>::Term, Self::Error>> + '_>

Build a fallible iterator of all the terms used as subject in this Graph. Read more
source§

fn predicates( &self ) -> Box<dyn Iterator<Item = Result<<Self::Triple<'_> as Triple>::Term, Self::Error>> + '_>

Build a fallible iterator of all the terms used as predicate in this Graph. Read more
source§

fn objects( &self ) -> Box<dyn Iterator<Item = Result<<Self::Triple<'_> as Triple>::Term, Self::Error>> + '_>

Build a fallible iterator of all the terms used as object in this Graph. Read more
source§

fn iris( &self ) -> Box<dyn Iterator<Item = Result<<Self::Triple<'_> as Triple>::Term, Self::Error>> + '_>

Build a fallible iterator of all the IRIs used in this Graph (including those used inside quoted triples, if any). Read more
source§

fn blank_nodes( &self ) -> Box<dyn Iterator<Item = Result<<Self::Triple<'_> as Triple>::Term, Self::Error>> + '_>

Build a fallible iterator of all the blank nodes used in this Graph (including those used inside quoted triples, if any). Read more
source§

fn literals( &self ) -> Box<dyn Iterator<Item = Result<<Self::Triple<'_> as Triple>::Term, Self::Error>> + '_>

Build a fallible iterator of all the literals used in this Graph (including those used inside quoted triples, if any). Read more
source§

fn quoted_triples<'s>( &'s self ) -> Box<dyn Iterator<Item = Result<<Self::Triple<'s> as Triple>::Term, Self::Error>> + 's>
where <Self::Triple<'s> as Triple>::Term: Clone,

Build a fallible iterator of all the quoted triples used in this Graph (including those used inside quoted triples, if any). Read more
source§

fn variables( &self ) -> Box<dyn Iterator<Item = Result<<Self::Triple<'_> as Triple>::Term, Self::Error>> + '_>

Build a fallible iterator of all the variables used in this Graph (including those used inside quoted triples, if any). Read more
source§

fn as_dataset(&self) -> GraphAsDataset<&Self>

Dataset adapter borrowing this graph
source§

fn as_dataset_mut(&mut self) -> GraphAsDataset<&mut Self>

Dataset adapter borrowing this graph mutably
source§

fn into_dataset(self) -> GraphAsDataset<Self>
where Self: Sized,

Dataset adapter taking ownership of this graph

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.