diesel::serialize

Trait WriteTuple

Source
pub trait WriteTuple<ST> {
    // Required method
    fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result;
}
Available on crate feature postgres_backend only.
Expand description

Helper trait for writing tuples as named composite types

This trait is essentially ToSql<Record<ST>> for tuples. While we can provide a valid body of to_sql, PostgreSQL doesn’t allow the use of bind parameters for unnamed composite types. For this reason, we avoid implementing ToSql directly.

This trait can be used by ToSql impls of named composite types.

§Example

    #[derive(SqlType)]
    #[diesel(postgres_type(name = "my_type"))]
    struct MyType;

    #[derive(Debug)]
    struct MyStruct<'a>(i32, &'a str);

    impl<'a> ToSql<MyType, Pg> for MyStruct<'a> {
        fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
            WriteTuple::<(Integer, Text)>::write_tuple(
                &(self.0, self.1),
                &mut out.reborrow(),
            )
        }
    }

Required Methods§

Source

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

See trait documentation.

Implementations on Foreign Types§

Source§

impl<T0, ST0> WriteTuple<(ST0,)> for (T0,)
where T0: ToSql<ST0, Pg>, Pg: HasSqlType<ST0>,

Source§

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

Source§

impl<T0, T1, ST0, ST1> WriteTuple<(ST0, ST1)> for (T0, T1)
where T0: ToSql<ST0, Pg>, T1: ToSql<ST1, Pg>, Pg: HasSqlType<ST0> + HasSqlType<ST1>,

Source§

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

Source§

impl<T0, T1, T2, ST0, ST1, ST2> WriteTuple<(ST0, ST1, ST2)> for (T0, T1, T2)
where T0: ToSql<ST0, Pg>, T1: ToSql<ST1, Pg>, T2: ToSql<ST2, Pg>, Pg: HasSqlType<ST0> + HasSqlType<ST1> + HasSqlType<ST2>,

Source§

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

Source§

impl<T0, T1, T2, T3, ST0, ST1, ST2, ST3> WriteTuple<(ST0, ST1, ST2, ST3)> for (T0, T1, T2, T3)
where T0: ToSql<ST0, Pg>, T1: ToSql<ST1, Pg>, T2: ToSql<ST2, Pg>, T3: ToSql<ST3, Pg>, Pg: HasSqlType<ST0> + HasSqlType<ST1> + HasSqlType<ST2> + HasSqlType<ST3>,

Source§

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

Source§

impl<T0, T1, T2, T3, T4, ST0, ST1, ST2, ST3, ST4> WriteTuple<(ST0, ST1, ST2, ST3, ST4)> for (T0, T1, T2, T3, T4)
where T0: ToSql<ST0, Pg>, T1: ToSql<ST1, Pg>, T2: ToSql<ST2, Pg>, T3: ToSql<ST3, Pg>, T4: ToSql<ST4, Pg>, Pg: HasSqlType<ST0> + HasSqlType<ST1> + HasSqlType<ST2> + HasSqlType<ST3> + HasSqlType<ST4>,

Source§

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

Source§

impl<T0, T1, T2, T3, T4, T5, ST0, ST1, ST2, ST3, ST4, ST5> WriteTuple<(ST0, ST1, ST2, ST3, ST4, ST5)> for (T0, T1, T2, T3, T4, T5)
where T0: ToSql<ST0, Pg>, T1: ToSql<ST1, Pg>, T2: ToSql<ST2, Pg>, T3: ToSql<ST3, Pg>, T4: ToSql<ST4, Pg>, T5: ToSql<ST5, Pg>, Pg: HasSqlType<ST0> + HasSqlType<ST1> + HasSqlType<ST2> + HasSqlType<ST3> + HasSqlType<ST4> + HasSqlType<ST5>,

Source§

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

Source§

impl<T0, T1, T2, T3, T4, T5, T6, ST0, ST1, ST2, ST3, ST4, ST5, ST6> WriteTuple<(ST0, ST1, ST2, ST3, ST4, ST5, ST6)> for (T0, T1, T2, T3, T4, T5, T6)
where T0: ToSql<ST0, Pg>, T1: ToSql<ST1, Pg>, T2: ToSql<ST2, Pg>, T3: ToSql<ST3, Pg>, T4: ToSql<ST4, Pg>, T5: ToSql<ST5, Pg>, T6: ToSql<ST6, Pg>, Pg: HasSqlType<ST0> + HasSqlType<ST1> + HasSqlType<ST2> + HasSqlType<ST3> + HasSqlType<ST4> + HasSqlType<ST5> + HasSqlType<ST6>,

Source§

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

Source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7> WriteTuple<(ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7)> for (T0, T1, T2, T3, T4, T5, T6, T7)
where T0: ToSql<ST0, Pg>, T1: ToSql<ST1, Pg>, T2: ToSql<ST2, Pg>, T3: ToSql<ST3, Pg>, T4: ToSql<ST4, Pg>, T5: ToSql<ST5, Pg>, T6: ToSql<ST6, Pg>, T7: ToSql<ST7, Pg>, Pg: HasSqlType<ST0> + HasSqlType<ST1> + HasSqlType<ST2> + HasSqlType<ST3> + HasSqlType<ST4> + HasSqlType<ST5> + HasSqlType<ST6> + HasSqlType<ST7>,

Source§

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

Source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8> WriteTuple<(ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8)> for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
where T0: ToSql<ST0, Pg>, T1: ToSql<ST1, Pg>, T2: ToSql<ST2, Pg>, T3: ToSql<ST3, Pg>, T4: ToSql<ST4, Pg>, T5: ToSql<ST5, Pg>, T6: ToSql<ST6, Pg>, T7: ToSql<ST7, Pg>, T8: ToSql<ST8, Pg>, Pg: HasSqlType<ST0> + HasSqlType<ST1> + HasSqlType<ST2> + HasSqlType<ST3> + HasSqlType<ST4> + HasSqlType<ST5> + HasSqlType<ST6> + HasSqlType<ST7> + HasSqlType<ST8>,

Source§

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

Source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9> WriteTuple<(ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9)> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9)
where T0: ToSql<ST0, Pg>, T1: ToSql<ST1, Pg>, T2: ToSql<ST2, Pg>, T3: ToSql<ST3, Pg>, T4: ToSql<ST4, Pg>, T5: ToSql<ST5, Pg>, T6: ToSql<ST6, Pg>, T7: ToSql<ST7, Pg>, T8: ToSql<ST8, Pg>, T9: ToSql<ST9, Pg>, Pg: HasSqlType<ST0> + HasSqlType<ST1> + HasSqlType<ST2> + HasSqlType<ST3> + HasSqlType<ST4> + HasSqlType<ST5> + HasSqlType<ST6> + HasSqlType<ST7> + HasSqlType<ST8> + HasSqlType<ST9>,

Source§

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

Source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10> WriteTuple<(ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10)> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)
where T0: ToSql<ST0, Pg>, T1: ToSql<ST1, Pg>, T2: ToSql<ST2, Pg>, T3: ToSql<ST3, Pg>, T4: ToSql<ST4, Pg>, T5: ToSql<ST5, Pg>, T6: ToSql<ST6, Pg>, T7: ToSql<ST7, Pg>, T8: ToSql<ST8, Pg>, T9: ToSql<ST9, Pg>, T10: ToSql<ST10, Pg>, Pg: HasSqlType<ST0> + HasSqlType<ST1> + HasSqlType<ST2> + HasSqlType<ST3> + HasSqlType<ST4> + HasSqlType<ST5> + HasSqlType<ST6> + HasSqlType<ST7> + HasSqlType<ST8> + HasSqlType<ST9> + HasSqlType<ST10>,

Source§

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

Source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10, ST11> WriteTuple<(ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10, ST11)> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)
where T0: ToSql<ST0, Pg>, T1: ToSql<ST1, Pg>, T2: ToSql<ST2, Pg>, T3: ToSql<ST3, Pg>, T4: ToSql<ST4, Pg>, T5: ToSql<ST5, Pg>, T6: ToSql<ST6, Pg>, T7: ToSql<ST7, Pg>, T8: ToSql<ST8, Pg>, T9: ToSql<ST9, Pg>, T10: ToSql<ST10, Pg>, T11: ToSql<ST11, Pg>, Pg: HasSqlType<ST0> + HasSqlType<ST1> + HasSqlType<ST2> + HasSqlType<ST3> + HasSqlType<ST4> + HasSqlType<ST5> + HasSqlType<ST6> + HasSqlType<ST7> + HasSqlType<ST8> + HasSqlType<ST9> + HasSqlType<ST10> + HasSqlType<ST11>,

Source§

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

Source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10, ST11, ST12> WriteTuple<(ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10, ST11, ST12)> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)
where T0: ToSql<ST0, Pg>, T1: ToSql<ST1, Pg>, T2: ToSql<ST2, Pg>, T3: ToSql<ST3, Pg>, T4: ToSql<ST4, Pg>, T5: ToSql<ST5, Pg>, T6: ToSql<ST6, Pg>, T7: ToSql<ST7, Pg>, T8: ToSql<ST8, Pg>, T9: ToSql<ST9, Pg>, T10: ToSql<ST10, Pg>, T11: ToSql<ST11, Pg>, T12: ToSql<ST12, Pg>, Pg: HasSqlType<ST0> + HasSqlType<ST1> + HasSqlType<ST2> + HasSqlType<ST3> + HasSqlType<ST4> + HasSqlType<ST5> + HasSqlType<ST6> + HasSqlType<ST7> + HasSqlType<ST8> + HasSqlType<ST9> + HasSqlType<ST10> + HasSqlType<ST11> + HasSqlType<ST12>,

Source§

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

Source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10, ST11, ST12, ST13> WriteTuple<(ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10, ST11, ST12, ST13)> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)
where T0: ToSql<ST0, Pg>, T1: ToSql<ST1, Pg>, T2: ToSql<ST2, Pg>, T3: ToSql<ST3, Pg>, T4: ToSql<ST4, Pg>, T5: ToSql<ST5, Pg>, T6: ToSql<ST6, Pg>, T7: ToSql<ST7, Pg>, T8: ToSql<ST8, Pg>, T9: ToSql<ST9, Pg>, T10: ToSql<ST10, Pg>, T11: ToSql<ST11, Pg>, T12: ToSql<ST12, Pg>, T13: ToSql<ST13, Pg>, Pg: HasSqlType<ST0> + HasSqlType<ST1> + HasSqlType<ST2> + HasSqlType<ST3> + HasSqlType<ST4> + HasSqlType<ST5> + HasSqlType<ST6> + HasSqlType<ST7> + HasSqlType<ST8> + HasSqlType<ST9> + HasSqlType<ST10> + HasSqlType<ST11> + HasSqlType<ST12> + HasSqlType<ST13>,

Source§

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

Source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10, ST11, ST12, ST13, ST14> WriteTuple<(ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10, ST11, ST12, ST13, ST14)> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)
where T0: ToSql<ST0, Pg>, T1: ToSql<ST1, Pg>, T2: ToSql<ST2, Pg>, T3: ToSql<ST3, Pg>, T4: ToSql<ST4, Pg>, T5: ToSql<ST5, Pg>, T6: ToSql<ST6, Pg>, T7: ToSql<ST7, Pg>, T8: ToSql<ST8, Pg>, T9: ToSql<ST9, Pg>, T10: ToSql<ST10, Pg>, T11: ToSql<ST11, Pg>, T12: ToSql<ST12, Pg>, T13: ToSql<ST13, Pg>, T14: ToSql<ST14, Pg>, Pg: HasSqlType<ST0> + HasSqlType<ST1> + HasSqlType<ST2> + HasSqlType<ST3> + HasSqlType<ST4> + HasSqlType<ST5> + HasSqlType<ST6> + HasSqlType<ST7> + HasSqlType<ST8> + HasSqlType<ST9> + HasSqlType<ST10> + HasSqlType<ST11> + HasSqlType<ST12> + HasSqlType<ST13> + HasSqlType<ST14>,

Source§

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

Source§

impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10, ST11, ST12, ST13, ST14, ST15> WriteTuple<(ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8, ST9, ST10, ST11, ST12, ST13, ST14, ST15)> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)
where T0: ToSql<ST0, Pg>, T1: ToSql<ST1, Pg>, T2: ToSql<ST2, Pg>, T3: ToSql<ST3, Pg>, T4: ToSql<ST4, Pg>, T5: ToSql<ST5, Pg>, T6: ToSql<ST6, Pg>, T7: ToSql<ST7, Pg>, T8: ToSql<ST8, Pg>, T9: ToSql<ST9, Pg>, T10: ToSql<ST10, Pg>, T11: ToSql<ST11, Pg>, T12: ToSql<ST12, Pg>, T13: ToSql<ST13, Pg>, T14: ToSql<ST14, Pg>, T15: ToSql<ST15, Pg>, Pg: HasSqlType<ST0> + HasSqlType<ST1> + HasSqlType<ST2> + HasSqlType<ST3> + HasSqlType<ST4> + HasSqlType<ST5> + HasSqlType<ST6> + HasSqlType<ST7> + HasSqlType<ST8> + HasSqlType<ST9> + HasSqlType<ST10> + HasSqlType<ST11> + HasSqlType<ST12> + HasSqlType<ST13> + HasSqlType<ST14> + HasSqlType<ST15>,

Source§

fn write_tuple(&self, out: &mut Output<'_, '_, Pg>) -> Result

Implementors§