pchampin / sophia_rs

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

Make sophia ready to support external serializers #34

Closed MattesWhite closed 4 years ago

MattesWhite commented 4 years ago

For now sophia only provides serializers for N-Triples and N-Quads. In order to support further serializers, we must develop an API for them, i.e. traits and some utilities. This contributes to #23.

When ever triples and graphs are mentioned those can be replaced by quad and dataset respectively. If not mentioned otherwise.

Steps towards an improved serializer API

All points are open to discussion.

MattesWhite commented 4 years ago

I started writting my Turtle serializer: https://github.com/MattesWhite/metis-rs

For now it is pretty basic and far from usable but the stream serializer already works (kind of). What stops me from advancing at the moment is the abbreviation of IRI, i.e. how to match against a namespace. Maybe something like

impl IriData {
    fn match_ns(&'a self, ns: impl AsRef<str>) -> Option<impl Iterator<Item = &'a Char>>;
}

where in case of a match the Iterator holds the left chars so it matches all (non-)suffixed IRIs...

I can implement this if you want but as said I wait for the serializer API to be merged before continuing my work.

pchampin commented 4 years ago

I started writting my Turtle serializer: https://github.com/MattesWhite/metis-rs

Awesome :)

I'm on my way to improve the stream API (#38), which will open the way to a cleaner Serializer API (#37). Once this is done, I'd like to release a new version. It's been a long time since the last one, and your crate could depend on a stable version rather than a github link...

Regarding match_ns, that's a good idea, with the following changes:

pchampin commented 4 years ago

@MattesWhite could you please have a loop at the latest commit 9a97dae ? It introduces a new Serializer API which I think will please you better than my former attempt #37.

MattesWhite commented 4 years ago

[...] I think will please you better than my former attempt [...]

Your right :smile:, nice work. I created a PR, fixing some minor issues.

The only thing left on the initial agenda is now separating the 'kinds of term' into own modules. We already talked about this in #35 . Should I take care about this or do you want to do this on your own?

pchampin commented 4 years ago

Should I take care about this or do you want to do this on your own?

I don't mind if you do ;-)