mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-01-20 07:36:34 +00:00
* removes the lifetime from Row * removes MySqlQueryAs, SqliteQueryAs, etc. (no longer needed) * introduce query_scalar * introduce Decode::accepts to allow overriding runtime type checking per-type (replaces TypeInfo::compatible) * introduce Encode::produces to allow overriding the encoded type per-value * adds a lifetime to Arguments (and introduce the HRTB HasArguments) to support zero-copy encoding with SQLite * renames Database::RawBuffer to HasArguments::ArgumentBuffer * introduce Connect::connect_with to provide an ConnectOptions type explicitly to opt-out of connection string parsing * introduce Value and ValueRef traits to allow decoding-deferred extraction of values from Rows * introduce Encode::encode_by_ref and change Encode::encode to take by-value to try and re-use memory where possible * use thiserror to generate sqlx::Error * [!] temporarily removes query logging * [!] temporarily removes transactions
30 lines
543 B
Rust
30 lines
543 B
Rust
use bytes::Bytes;
|
|
|
|
use crate::error::Error;
|
|
|
|
pub trait Decode<'de, Context = ()>
|
|
where
|
|
Self: Sized,
|
|
{
|
|
fn decode(buf: Bytes) -> Result<Self, Error>
|
|
where
|
|
Self: Decode<'de, ()>,
|
|
{
|
|
Self::decode_with(buf, ())
|
|
}
|
|
|
|
fn decode_with(buf: Bytes, context: Context) -> Result<Self, Error>;
|
|
}
|
|
|
|
impl Decode<'_> for Bytes {
|
|
fn decode_with(buf: Bytes, _: ()) -> Result<Self, Error> {
|
|
Ok(buf)
|
|
}
|
|
}
|
|
|
|
impl Decode<'_> for () {
|
|
fn decode_with(_: Bytes, _: ()) -> Result<(), Error> {
|
|
Ok(())
|
|
}
|
|
}
|