Generic Associated Types in Database, replacing HasValueRef, HasArguments, HasStatement (#2973)

* HasValueRef, HasArguments, HasStatement -> Database GATs

replace the associated types from the generic traits
`HasValueRef<'r>`, `HasArguments<'q>` and `HasStatement<'q>`
with generic associated types in `Database`

* fixup after rebase

---------

Co-authored-by: Austin Bonander <austin.bonander@gmail.com>
This commit is contained in:
nitn3lav
2024-03-14 20:35:52 +01:00
committed by GitHub
parent 936744dfd6
commit 9ba488c831
33 changed files with 173 additions and 284 deletions

View File

@@ -5,9 +5,7 @@ use crate::{
PgTypeInfo,
};
pub(crate) use sqlx_core::database::{
Database, HasArguments, HasStatement, HasStatementCache, HasValueRef,
};
pub(crate) use sqlx_core::database::{Database, HasStatementCache};
/// PostgreSQL database driver.
#[derive(Debug)]
@@ -27,30 +25,16 @@ impl Database for Postgres {
type TypeInfo = PgTypeInfo;
type Value = PgValue;
type ValueRef<'r> = PgValueRef<'r>;
type Arguments<'q> = PgArguments;
type ArgumentBuffer<'q> = PgArgumentBuffer;
type Statement<'q> = PgStatement<'q>;
const NAME: &'static str = "PostgreSQL";
const URL_SCHEMES: &'static [&'static str] = &["postgres", "postgresql"];
}
impl<'r> HasValueRef<'r> for Postgres {
type Database = Postgres;
type ValueRef = PgValueRef<'r>;
}
impl HasArguments<'_> for Postgres {
type Database = Postgres;
type Arguments = PgArguments;
type ArgumentBuffer = PgArgumentBuffer;
}
impl<'q> HasStatement<'q> for Postgres {
type Database = Postgres;
type Statement = PgStatement<'q>;
}
impl HasStatementCache for Postgres {}