edgedb / edgedb-rust

The official Rust binding for EdgeDB
https://edgedb.com
Apache License 2.0
214 stars 26 forks source link

Deserializing edgedb types to simple std types #315

Closed MrFoxPro closed 5 months ago

MrFoxPro commented 5 months ago

Seems like related to this: https://github.com/edgedb/edgedb-rust/issues/22

Right now seems like it's impossible to deserialize

type Entity {
}

to

[derive(Queryable)]
struct Entity {
  id: String
}

because driver wants edgedb_protocol::model::Uuid for id. Seems like it's related to https://github.com/edgedb/edgedb-rust/issues/22, but I'm thinking that maybe it would be easier to implement some kind of serde interopability? Because, for exampe, serde_json::Value has pretty much complete functionality for representing and accessing JSON objects. Right now to avoid manual convertation and coupling with internal edgedb types I'm using _json methods and casting it to string, and then to desired type. Could this be semplified, like

let entity /* Option<Entity> */ = client.query_single_serde::<Entity, _>(..);

?

MrFoxPro commented 5 months ago

Uhh, there was hidden item image