I'm trying to implement a serializer for my struct:
#[derive(Queryable, Debug, Clone, Serialize, Deserialize)]
struct One {
two_id: i32,
}
#[derive(Queryable, Debug, Clone, Serialize, Deserialize)]
struct Two {
id: i32,
}
I'd like to get struct One from the database with diesel and print it with serde. I found the serialize_with attribute which can be applied to two_id. How would I implement such a method with the given interface: fn<'de, D>(D) -> Result<T, D::Error> where D: Deserializer<'de> to invoke json!(get_two_from_db()) on my queried object?
I'd like to be able to call json!(one) and automatically get the joined objects.