This PR aims to rework the elements of sophia related to the TermFactory.
Like pointed out in #82 the current TermFactory trait does no longer fit into sophia with the TTerm trait.
Following the previous discussion and inspired by Code Smell: Concrete Abstraction this PR removes the TermFactory trait completely. In turn, the existing implementations for WeakHashSet is turned into a concrete TermCache that fulfils the same task. Furthermore, the traits FromData and IntoData have been added for proper conversion between TermData types. This will hopefully lead to an easier TermData handling. As you can see the implementations of FromData and IntoData allow to pass in either owned or reference types when the function signature is something like:
fn foo(td: IntoData<Arc<str>>) {}
fn main() {
// all works
foo("foo");
foo("bar".to_string());
let rc: Rc<str> = "baz".into();
foo(&rc);
}
ToDo:
[ ] Introduce TermCache to IndexMap
While doing so #64 could be done.
[ ] Adapt the APIs of Term, Iri and similar to the new FromData and IntoData traits.
This PR aims to rework the elements of
sophia
related to theTermFactory
.Like pointed out in #82 the current
TermFactory
trait does no longer fit intosophia
with theTTerm
trait.Following the previous discussion and inspired by Code Smell: Concrete Abstraction this PR removes the
TermFactory
trait completely. In turn, the existing implementations forWeakHashSet
is turned into a concreteTermCache
that fulfils the same task. Furthermore, the traitsFromData
andIntoData
have been added for proper conversion betweenTermData
types. This will hopefully lead to an easierTermData
handling. As you can see the implementations ofFromData
andIntoData
allow to pass in either owned or reference types when the function signature is something like:ToDo:
TermCache
toIndexMap
Term
,Iri
and similar to the newFromData
andIntoData
traits.