Closed brycefisher closed 3 years ago
In the scope of Rust, I would say sophia
is your best choice currently.
As far as I understood, Hydra it's basically a vocabulary for describing Web APIs. For building up an RDF-graph sophia
is totally suited and has many convenient things to do so, e.g. namespace!()
to declare your vocabulary inside Rust code.
As far as JSON-LD support goes, you might have seen the sophia_jsonld
crate. It might not be very mature as it can only serialize expanded JSON-LD at the moment but it is a good point to start. In the end, the only missing thing for from the RDF-side of your project is to implement a proper JSON-LD compaction algorithm to have a nice serialization.
There are other crates about JSON-LD (https://crates.io/search?q=json-ld, https://lib.rs/search?q=json-ld), however, none of them is as well maintained as sophia
and most are only concerned with JSON-LD directly and do not cover the RDF part.
@brycefisher nice project, I'm looking forward to trying that!
@MattesWhite summed it up pretty well. You can either construct an RDF graph using the implementations provided by Sophia, or maybe have your own types implement the Graph trait to avoid duplicating information.
Then indeed, you can generate expanded JSON-LD with the serializer provided in sophia_jsonld
. Compacting it to a more idiomatic form is the job of JSON-LD's compaction algorithm, which has no implementation in Rust for the moment, AFAIK.
However, I have been in contact with @timothee-haudebourg, who is working on an implementation of JSON-LD. Hopefully I'll find some time to contribute to this one during the summer, but I guess Timothée can use any help he can find :wink:.
This is great info and great news! Thanks so much. I think I still need to get up to speed on JSON-LD syntax and semantics, but it sounds like this is the crate for me. Many thanks!!
Help is indeed welcome :smiley: I'm working on the compaction algorithm on a dedicated branch. I had to take a break from JSON-LD but I should resume development relatively soon.
In the scope of the Rust ecosystem, is Sophia a good choice for serializing Hydra into JSON-LD?
My end goal is to create a wrapper around an existing Rust web framework (maybe Warp?) that makes it easy to generate Hydra JSON-LD documentation automatically from Rust source code with minimal effort. I know that there are many projects for serializing to JSON, but getting the JSON-LD semantics correct would be extremely helpful.
From the documentation I've looked at so far, I'm not quite sure if this project is a good choice to build on top of or not. Do you recommend looking for a different crate? Are there any hydra crates I've overlooked?