pchampin / sophia_rs

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

Refactor error handling in mods graph and dataset #31

Closed MattesWhite closed 4 years ago

MattesWhite commented 4 years ago

Continuation of #8 .

Removes unnecessary error variants from sophia::error::Error and adds a new error for the Graph to Dataset wrapper.

Future work

At investigating GraphAsDataset<G, H> I recognized that the second parameter H is used nowhere actually. I could remove this within this PR if you like or did I missed something?

@pchampin It seems to me that the mods parser and serializer are currently adapted to the rio crates. Is this work finished and I can continue refactoring the error handling or should I wait?

pchampin commented 4 years ago

At investigating GraphAsDataset<G, H> I recognized that the second parameter H is used nowhere

Actually, it is used. GraphAsDataset does not wrap a G(raph) but a Borrow (which is the trait bound on H). So you can decide to wrap either an owned graph or a simple reference to a graph.

It seems to me that the mods parser and serializer are currently adapted to the rio crates.

Not sure what makes you think that... I tried to keep rio-specific code in rio_common.rs and all the parsers that are now based on rio (nt, nq, turtle, trig, ntrig), but parser.rs and serializer.rs are meant to be agnostic. If they are not, this is a bug.

Is this work finished and I can continue refactoring the error handling or should I wait?

I won't be able to work on it in the next week or two, so you are free to go. That being said, may be it would make sense to wait until theses modules are refactored to expose proper traits (as you suggested in #25)...

pchampin commented 4 years ago

Apart from all that, I like what's in this PR. Do you want me to merge it now, or do you plan to include the symetrical work in dataset before? (I'm asking because the title of this PR is hinting at it, not to force you into more work... :sweat_smile:)

MattesWhite commented 4 years ago

Actually the work for dataset is done. Every existing implemtation of Dataset uses Infallible as error (except GraphAsDataset 😉) so far. Therefore, there is nothing to be done.

pchampin commented 4 years ago

Ok cool, merging at once.

After all, I am working now on the parser module, so you might want to wait a little bit before touching it...