pchampin / sophia_rs

Sophia: a Rust toolkit for RDF and Linked Data
Other
210 stars 23 forks source link

Convert between sophia::term::iri::Iri and sophia::iri:Iri? #118

Closed KonradHoeffner closed 1 year ago

KonradHoeffner commented 1 year ago

I am confused by the different Iri structs in Sophia: sophia::iri::Iri and sophia::iri::IriBox vs sophia::term::iri::Iri and hope someone an explain to me:

  1. Why are there two different types with the same name (Iri) in the same library?
  2. Why is there a sophia::iri::IriBox but no sophia::term::iri::IriBox?
  3. Is it possible to convert between the three without going through Strings?

My use case is that I query a graph for triples using triples_with_s and then want to save the properties of triple.p() into a Map<IriBox,String> but iri.boxed() fails with method not found in &sophia::term::iri::Iri<Arc<str>>.

pchampin commented 1 year ago

The current state of IRIs in Sophia is a bit of a mess, as I already described here -- and I can never apologize enough for it. :confused:

If you know for sure that your predicates are absolute IRIs (which is the case if you parse standard RDF, as opposed to the [generalized RDF] supported by Sophia), then you can build your IriBox like this:

IriRefBox::new_unchecked(triple.p().value().into())
KonradHoeffner commented 1 year ago

Thanks, that is very helpful! I converted my usage of sophia::term::iri::Iri to sophia::iri::Iri.