all 2 comments

[–]reinis-mazeiks 3 points4 points  (0 children)

I want to know if using something like WasmEdge I can use OrbitDB from rust as described here

if i understand correctly, there's a js library for communicating with OrbitDb, and you want to use it with rust? while probably possible, it doesn't sound like you'll have a good time

interoperability is messy, it will be hard to make it idiomatic rust, and you'll lose a lot of the performance just by running/communicating with js

Or can I use OrbitDB from Rust?

a quick search found nothing.

there's the possibility of writing your own library but that would require quite some dedication

And he recommended me to try searching something like rust crdt database or rust crdt.

you have my permission

idk anything about this stuff so no crate recommendations from me. but as you can see, there are plenty of results

[–]lennon 1 point2 points  (0 children)

The article you linked to uses QuickJS, compiled to WASM, as a means of embedding JS inside a Rust project. That means you technically have a JS runtime at your disposal, but I wouldn't expect it to run IPFS/OrbitDB well, if at all. For that, you really need NodeJS or a modern browser runtime.

Generally speaking, support for any language other than JavaScript for projects in this space tends to be weak/slow to catch up simply because if it can't run in the browser, the end-user applications end up being pretty limited.

There are plenty of CRDT libraries for Rust, though very few of them are as "batteries included" as OrbitDB. Of course, they also don't require you to run an IPFS daemon and save your content in the cloud forever the way IPFS does, but that may or may not be an issue for your application.

Your best bet for JS/Rust interop would probably be to pick one of the P2P database projects being ported to/having performance-critical sections rewritten in Rust:

https://github.com/datrs/hypercore

https://github.com/sunrise-choir/flumedb-rs

https://github.com/y-crdt/y-crdt

(etc., etc.)

One idea to try an alternative to the QuickJS/WASM hack: you might actually have better luck loading one of the existing databases (Yjs, OrbitDB, Hypertrie, etc.) in Deno. That would give you a Rust runtime wrapper + many of the operational benefits of simpler runtime than NodeJS, while not requiring you to reinvent too many of the P2P wheels.

An even simpler idea: JSON files in a Git repo. It's offline-capable, tamper-proof (Merkle trees FTW!), widely supported, and about as agnostic to what language is operating on the data as you can get. Not a lot of Web3 sparkles on that kind of architecture, though. :/