It seems that there are only native sql client libraries in the Rust community. I hope there could be a library like Prisma. Prisma generates TypeScript code according to the schema file and provides typesafety and database abstraction (meaning that you don't need to care about SQL stuff). The ideal Prisma for Rust in my opinion will generate Rust code also based on a schema file. The generated Rust code may look like this:
pub mod schema {
struct User {
name: String
}
}
pub mod db {
use super::schema;
trait Adapter {
fn create(/* ... */) -> /* ... */;
// ...
}
struct User<A: Adapter> {
db: A
}
impl User {
fn create(&self, /* Something like PartialUser */) -> Result</* ... */> {
self.db.create(/* ... */);
// ...
}
fn find(&self, /* Some query */) -> Vec<User> {
// ...
}
fn findUnique(&self, /* ... */) -> User {
// ...
}
// ...
}
}
if not, I think I'm gonna make one.