Open lilymara-onesignal opened 4 years ago
Hi @nate-onesignal, Compatible is one of problems that you need to deal with Rust code (TypeSafe). I think you can use this style for this case.
pub trait ToSqlCompat {
fn compat_sql() -> postgres::ToSql;
}
impl ToSqlCompat for tokio_postgres::ToSql {
fn compat_sql() -> postgres::ToSql {
... // Map logic from tokio_postgres -> postgres here.
}
}
let a: tokio_postgres::ToSql = tokio_postgres::ToSql::new(); // I asumes this.
a.compat_sql();
I just find something about Postgres in Rust. So I comes here. I hope this can help you.
postgres::ToSql
and tokio_postgres::ToSql
are the same trait, so as a workaround you can just depend on the postgres
crate as well.
I think the "right" solution here is to split out a postgres-types
crate with a derive
Cargo feature so there's a single canonical place for the traits to be defined in and named from.
Trying to use this crate with the
tokio-postgres
crate will not work, as this crate expects to implementpostgres::ToSql
, and nottokio_postgres::ToSql
. Even though the two traits are identical.