mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-29 21:00:54 +00:00
feat(core): add TypeEncode::compatible
This commit is contained in:
parent
ed3e9fdd38
commit
46f314103a
@ -33,11 +33,19 @@ pub trait Type<Db: Database> {
|
||||
|
||||
#[allow(clippy::module_name_repetitions)]
|
||||
pub trait TypeEncode<Db: Database>: Type<Db> + Encode<Db> {
|
||||
/// Returns the SQL type identifier that best hints to the database
|
||||
/// at the incoming value for a bind parameter.
|
||||
/// Returns the canonical SQL type identifier for this Rust type.
|
||||
#[allow(unused_variables)]
|
||||
fn type_id(&self, ty: &Db::TypeInfo) -> Db::TypeId;
|
||||
|
||||
/// Determines if this Rust type is compatible with the specified SQL type.
|
||||
///
|
||||
/// To be compatible, the Rust type must support encoding _and_ decoding
|
||||
/// from the specified SQL type.
|
||||
///
|
||||
fn compatible(&self, ty: &Db::TypeInfo) -> bool {
|
||||
ty.id() == self.type_id(ty)
|
||||
}
|
||||
|
||||
/// Returns the Rust type name of this.
|
||||
#[doc(hidden)]
|
||||
#[inline]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user