我正在尝试在一个项目中使用柴油,并且我想要一个“可过滤”类型。这个想法是你可以去/api/foo?id=10&bar=11它会返回一个 struct Foo:
struct Foo {
id: Option<i64>,
bar: Option<i64>,
name: Option<String>,
}
Run Code Online (Sandbox Code Playgroud)
例如:
Foo {
id: Some(10),
bar: Some(11),
name: None,
}
Run Code Online (Sandbox Code Playgroud)
我一直在互联网上搜索一种按现有字段进行过滤的方法,但我无法找到有效的解决方案。我最初使用mysql 驱动程序并使用 proc 宏构建 sql 查询,但是diesel 更好用,我想知道是否有一种方法可以获得与柴油机 mysql 驱动程序相同的行为。