Trait sqlx_clickhouse_ext::value::Decode [−][src]
A type that can be decoded from the database.
How can I implement Decode?
A manual implementation of Decode can be useful when adding support for
types externally to SQLx.
The following showcases how to implement Decode to be generic over Database. The
implementation can be marginally simpler if you remove the DB type parameter and explicitly
use the concrete ValueRef and TypeInfo types.
struct MyType; // DB is the database driver // `'r` is the lifetime of the `Row` being decoded impl<'r, DB: Database> Decode<'r, DB> for MyType where // we want to delegate some of the work to string decoding so let's make sure strings // are supported by the database &'r str: Decode<'r, DB> { fn decode( value: <DB as HasValueRef<'r>>::ValueRef, ) -> Result<MyType, Box<dyn Error + 'static + Send + Sync>> { // the interface of ValueRef is largely unstable at the moment // so this is not directly implementable // however, you can delegate to a type that matches the format of the type you want // to decode (such as a UTF-8 string) let value = <&str as Decode<DB>>::decode(value)?; // now you can parse this into your type (assuming there is a `FromStr`) Ok(value.parse()?) } }
Required methods
pub fn decode(
value: <DB as HasValueRef<'r>>::ValueRef
) -> Result<Self, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: <DB as HasValueRef<'r>>::ValueRef
) -> Result<Self, Box<dyn Error + 'static + Sync + Send, Global>>
Decode a new value of this type using a raw value from the database.
Implementations on Foreign Types
impl<'r, T> Decode<'r, Postgres> for Vec<T, Global> where
T: for<'a> Decode<'a, Postgres> + Type<Postgres>,
Vec<T, Global>: Type<Postgres>, [src]
T: for<'a> Decode<'a, Postgres> + Type<Postgres>,
Vec<T, Global>: Type<Postgres>,
pub fn decode(
value: PgValueRef<'r>
) -> Result<Vec<T, Global>, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<Vec<T, Global>, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r> Decode<'r, Postgres> for DateTime<FixedOffset>[src]
pub fn decode(
value: PgValueRef<'r>
) -> Result<DateTime<FixedOffset>, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<DateTime<FixedOffset>, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r, T> Decode<'r, Postgres> for Json<T> where
T: 'r + Deserialize<'r>, [src]
T: 'r + Deserialize<'r>,
pub fn decode(
value: PgValueRef<'r>
) -> Result<Json<T>, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<Json<T>, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r, T1, T2, T3, T4, T5, T6, T7, T8> Decode<'r, Postgres> for (T1, T2, T3, T4, T5, T6, T7, T8) where
T8: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T2: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T3: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T4: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T5: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T6: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T7: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>, [src]
T8: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T2: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T3: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T4: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T5: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T6: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T7: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
pub fn decode(
value: PgValueRef<'r>
) -> Result<(T1, T2, T3, T4, T5, T6, T7, T8), Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<(T1, T2, T3, T4, T5, T6, T7, T8), Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r> Decode<'r, Postgres> for &'r [u8][src]
pub fn decode(
value: PgValueRef<'r>
) -> Result<&'r [u8], Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<&'r [u8], Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r, DB, T> Decode<'r, DB> for Option<T> where
DB: Database,
T: Decode<'r, DB>, [src]
DB: Database,
T: Decode<'r, DB>,
pub fn decode(
value: <DB as HasValueRef<'r>>::ValueRef
) -> Result<Option<T>, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: <DB as HasValueRef<'r>>::ValueRef
) -> Result<Option<T>, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r> Decode<'r, Postgres> for ()[src]
pub fn decode(
_value: PgValueRef<'r>
) -> Result<(), Box<dyn Error + 'static + Sync + Send, Global>>[src]
_value: PgValueRef<'r>
) -> Result<(), Box<dyn Error + 'static + Sync + Send, Global>>
impl<'de> Decode<'de, Postgres> for PgInterval[src]
pub fn decode(
value: PgValueRef<'de>
) -> Result<PgInterval, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'de>
) -> Result<PgInterval, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r> Decode<'r, Postgres> for NaiveDateTime[src]
pub fn decode(
value: PgValueRef<'r>
) -> Result<NaiveDateTime, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<NaiveDateTime, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'_> Decode<'_, Postgres> for f64[src]
pub fn decode(
value: PgValueRef<'_>
) -> Result<f64, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'_>
) -> Result<f64, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r, DB> Decode<'r, DB> for Value where
DB: Database,
Value: Type<DB>,
Json<Value>: Decode<'r, DB>, [src]
DB: Database,
Value: Type<DB>,
Json<Value>: Decode<'r, DB>,
pub fn decode(
value: <DB as HasValueRef<'r>>::ValueRef
) -> Result<Value, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: <DB as HasValueRef<'r>>::ValueRef
) -> Result<Value, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r> Decode<'r, Postgres> for &'r str[src]
pub fn decode(
value: PgValueRef<'r>
) -> Result<&'r str, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<&'r str, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'_> Decode<'_, Postgres> for i8[src]
pub fn decode(
value: PgValueRef<'_>
) -> Result<i8, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'_>
) -> Result<i8, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r, T1, T2, T3, T4, T5, T6, T7> Decode<'r, Postgres> for (T1, T2, T3, T4, T5, T6, T7) where
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T2: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T3: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T4: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T5: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T6: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T7: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>, [src]
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T2: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T3: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T4: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T5: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T6: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T7: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
pub fn decode(
value: PgValueRef<'r>
) -> Result<(T1, T2, T3, T4, T5, T6, T7), Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<(T1, T2, T3, T4, T5, T6, T7), Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r> Decode<'r, Postgres> for NaiveDate[src]
pub fn decode(
value: PgValueRef<'r>
) -> Result<NaiveDate, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<NaiveDate, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r, T> Decode<'r, Postgres> for PgRange<T> where
T: Type<Postgres> + for<'a> Decode<'a, Postgres>, [src]
T: Type<Postgres> + for<'a> Decode<'a, Postgres>,
pub fn decode(
value: PgValueRef<'r>
) -> Result<PgRange<T>, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<PgRange<T>, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r> Decode<'r, Postgres> for DateTime<Local>[src]
pub fn decode(
value: PgValueRef<'r>
) -> Result<DateTime<Local>, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<DateTime<Local>, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r, T1, T2, T3, T4, T5> Decode<'r, Postgres> for (T1, T2, T3, T4, T5) where
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T2: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T3: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T4: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T5: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>, [src]
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T2: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T3: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T4: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T5: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
pub fn decode(
value: PgValueRef<'r>
) -> Result<(T1, T2, T3, T4, T5), Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<(T1, T2, T3, T4, T5), Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r, T1, T2, T3> Decode<'r, Postgres> for (T1, T2, T3) where
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T2: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T3: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>, [src]
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T2: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T3: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
pub fn decode(
value: PgValueRef<'r>
) -> Result<(T1, T2, T3), Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<(T1, T2, T3), Box<dyn Error + 'static + Sync + Send, Global>>
impl<'_> Decode<'_, Postgres> for i64[src]
pub fn decode(
value: PgValueRef<'_>
) -> Result<i64, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'_>
) -> Result<i64, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r> Decode<'r, Postgres> for DateTime<Utc>[src]
pub fn decode(
value: PgValueRef<'r>
) -> Result<DateTime<Utc>, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<DateTime<Utc>, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r, T1> Decode<'r, Postgres> for (T1,) where
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>, [src]
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
pub fn decode(
value: PgValueRef<'r>
) -> Result<(T1,), Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<(T1,), Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r, T1, T2, T3, T4, T5, T6> Decode<'r, Postgres> for (T1, T2, T3, T4, T5, T6) where
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T2: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T3: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T4: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T5: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T6: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>, [src]
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T2: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T3: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T4: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T5: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T6: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
pub fn decode(
value: PgValueRef<'r>
) -> Result<(T1, T2, T3, T4, T5, T6), Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<(T1, T2, T3, T4, T5, T6), Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r, DB> Decode<'r, DB> for &'r RawValue where
DB: Database,
&'r RawValue: Type<DB>,
Json<&'r RawValue>: Decode<'r, DB>, [src]
DB: Database,
&'r RawValue: Type<DB>,
Json<&'r RawValue>: Decode<'r, DB>,
pub fn decode(
value: <DB as HasValueRef<'r>>::ValueRef
) -> Result<&'r RawValue, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: <DB as HasValueRef<'r>>::ValueRef
) -> Result<&'r RawValue, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'_> Decode<'_, Postgres> for BigDecimal[src]
pub fn decode(
value: PgValueRef<'_>
) -> Result<BigDecimal, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'_>
) -> Result<BigDecimal, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'_> Decode<'_, Postgres> for f32[src]
pub fn decode(
value: PgValueRef<'_>
) -> Result<f32, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'_>
) -> Result<f32, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'_> Decode<'_, Postgres> for String[src]
pub fn decode(
value: PgValueRef<'_>
) -> Result<String, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'_>
) -> Result<String, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'_> Decode<'_, Postgres> for Vec<u8, Global>[src]
pub fn decode(
value: PgValueRef<'_>
) -> Result<Vec<u8, Global>, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'_>
) -> Result<Vec<u8, Global>, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r, T1, T2> Decode<'r, Postgres> for (T1, T2) where
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T2: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>, [src]
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T2: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
pub fn decode(
value: PgValueRef<'r>
) -> Result<(T1, T2), Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<(T1, T2), Box<dyn Error + 'static + Sync + Send, Global>>
impl<'_> Decode<'_, Postgres> for i32[src]
pub fn decode(
value: PgValueRef<'_>
) -> Result<i32, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'_>
) -> Result<i32, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'_> Decode<'_, Postgres> for PgMoney[src]
pub fn decode(
value: PgValueRef<'_>
) -> Result<PgMoney, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'_>
) -> Result<PgMoney, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'_> Decode<'_, Postgres> for bool[src]
pub fn decode(
value: PgValueRef<'_>
) -> Result<bool, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'_>
) -> Result<bool, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r> Decode<'r, Postgres> for NaiveTime[src]
pub fn decode(
value: PgValueRef<'r>
) -> Result<NaiveTime, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<NaiveTime, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r, T1, T2, T3, T4> Decode<'r, Postgres> for (T1, T2, T3, T4) where
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T2: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T3: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T4: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>, [src]
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T2: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T3: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T4: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
pub fn decode(
value: PgValueRef<'r>
) -> Result<(T1, T2, T3, T4), Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<(T1, T2, T3, T4), Box<dyn Error + 'static + Sync + Send, Global>>
impl<'_> Decode<'_, Postgres> for Uuid[src]
pub fn decode(
value: PgValueRef<'_>
) -> Result<Uuid, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'_>
) -> Result<Uuid, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'_> Decode<'_, Postgres> for u32[src]
pub fn decode(
value: PgValueRef<'_>
) -> Result<u32, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'_>
) -> Result<u32, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'_> Decode<'_, Postgres> for i16[src]
pub fn decode(
value: PgValueRef<'_>
) -> Result<i16, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'_>
) -> Result<i16, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r> Decode<'r, Postgres> for PgTimeTz<NaiveTime, FixedOffset>[src]
pub fn decode(
value: PgValueRef<'r>
) -> Result<PgTimeTz<NaiveTime, FixedOffset>, Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<PgTimeTz<NaiveTime, FixedOffset>, Box<dyn Error + 'static + Sync + Send, Global>>
impl<'r, T1, T2, T3, T4, T5, T6, T7, T8, T9> Decode<'r, Postgres> for (T1, T2, T3, T4, T5, T6, T7, T8, T9) where
T8: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T9: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T2: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T3: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T4: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T5: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T6: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T7: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>, [src]
T8: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T9: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T1: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T2: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T3: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T4: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T5: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T6: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
T7: 'r + Type<Postgres> + for<'a> Decode<'a, Postgres>,
pub fn decode(
value: PgValueRef<'r>
) -> Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9), Box<dyn Error + 'static + Sync + Send, Global>>[src]
value: PgValueRef<'r>
) -> Result<(T1, T2, T3, T4, T5, T6, T7, T8, T9), Box<dyn Error + 'static + Sync + Send, Global>>