diff --git a/sqlx-core/src/decode.rs b/sqlx-core/src/decode.rs index 32774a28..0b1b3a97 100644 --- a/sqlx-core/src/decode.rs +++ b/sqlx-core/src/decode.rs @@ -1,8 +1,8 @@ //! Types and traits for decoding values from the database. -use crate::database::HasRawValue; +use crate::database::{Database, HasRawValue}; -/// Decode a single value from the database. +/// A type that can be decoded from the database. pub trait Decode<'de, DB> where Self: Sized + 'de, @@ -10,3 +10,14 @@ where { fn decode(value: DB::RawValue) -> crate::Result; } + +/// A type that can be decoded without borrowing from the connection. +pub trait DecodeOwned: for<'de> Decode<'de, DB> {} + +impl DecodeOwned for T +where + DB: Database, + T: 'static, + T: for<'de> Decode<'de, DB>, +{ +}