I have custom types that serve as a wrapper of other types than can be safely used in Diesel:
use uuid::Uuid;
pub schema Post {
id: PostId,
title: String,
body: String
}
pub schema PostId {value: Uuid}
I can't use these custom wrappers with Diesel. The error message I get is the following:
#[derive(Insertable)]
the trait `diesel::Expression` is not implemented for `models::PostId`
I've tried to look for examples on converting custom types and so far the two approaches I've seen are to either implement the AsExpression trait or the FromSql and ToSql traits, but the examples I've seen so far are for enum types and I can't infer what's the difference between the two approaches other than the former seems to be an older way of doing it, nor what the expected implementation of those traits are.