【发布时间】:2021-10-22 04:21:14
【问题描述】:
我正在尝试使用 UUID 作为我在 Postgres 中的主键。
我得到特征 FromSql<'_> 没有在 tokio-postgres 中为 Uuid 实现。
首先我尝试使用tokio-pg-mapper,但它也显示相同的编译错误。
所以,我尝试 diff 方法并尝试在 Struct 上实现 From 以直接从 Row 中转换它。
当我尝试实现From 以将Row 类型转换为我的结构Shop。
impl From<Row> for Shop {
fn from(row: Row) -> Self {
Self {
id: row.get("id"), // Id is UUID type
name: row.get("name"),
address: row.get("address")
}
}
}
仍然得到 特征 FromSql<'_> 未在 tokio-postgres 中为 Uuid 实现
我知道它要求我为
UUID类型实现FromSql。
但是我查看了tokio-postgresdocs,发现那里已经实现了。
我错过了什么吗?
uuid=0.8tokio-postgres=0.7.2
【问题讨论】:
标签: postgresql rust rust-tokio tokio-postgres