Hello! I think the Rust [sparrowdb] crate is a superb choice for modern graph dbs; I’m hoping to package this up in an elixir pkg.
[sparrowdb]: crates.io: Rust Package Registry
Here’s the sample code from their README:
let db = GraphDb::open(std::path::Path::new("social.db"))?;
db.execute("CREATE (alice:Person {name: 'Alice', age: 30})")?;
db.execute("CREATE (bob:Person {name: 'Bob', age: 25})")?;
db.execute("MATCH (a:Person {name:'Alice'}), (b:Person {name:'Bob'}) CREATE (a)-[:KNOWS]->(b)")?;
// Who does Alice know? Who do *they* know?
let fof = db.execute("MATCH (a:Person {name:'Alice'})-[:KNOWS*1..2]->(f) RETURN DISTINCT f.name")?;
// -> [["Bob"], ["Carol"]] (Carol is a friend-of-friend)
let _ = fof;
Ok(())
I can think of some simple changes to make this more approachable as an elixir module. Primarily, loading the db variable should be done in one function call, and each call to execute should be another function call.
I’ve come across this in another rust db package; how does one keep a reference to a rust object, such as db, loaded from a rustler function call? How do future rustler-bound functions refer to the same rust object (db) without leaking or cleaning up the memory address?
I’m new to Rust so I probably need to learn some lifetime attribute concepts. If there are common themes from other rustler packages that I can learn from, I’d be thrilled to find something that I can repurpose across the language boundary.






















