Macro diesel::Queryable [] [src]

macro_rules! Queryable {
    (() $($body:tt)*) => { ... };
    (
        $(#[$ignore:meta])*
        $(pub)* struct $($body:tt)*
    ) => { ... };
    (
        (
            struct_name = $struct_name:ident,
            $($headers:tt)*
        ),
        fields = [$({
            field_name: $field_name:ident,
            column_name: $column_name:ident,
            field_ty: $field_ty:ty,
            field_kind: $field_kind:ident,
        })+],
    ) => { ... };
    (
        $headers:tt,
        fields = [$({
            column_name: $column_name:ident,
            field_ty: $field_ty:ty,
            field_kind: $field_kind:ident,
        })+],
    ) => { ... };
    (
        (
            struct_name = $struct_name:ident,
            $($headers:tt)*
        ),
        fields = [$({
            field_ty: $field_ty:ty,
            field_kind: $field_kind:ident,
        })+],
    ) => { ... };
    (
        struct_ty = $struct_ty:ty,
        generics = ($($generics:ident),*),
        lifetimes = ($($lifetimes:tt),*),
        row_ty = $row_ty:ty,
        row_pat = $row_pat:pat,
        build_expr = $build_expr:expr,
    ) => { ... };
    (
        $struct_name:ident <$($generics:ident),*>
        $body:tt $(;)*
    ) => { ... };
    (
        $struct_name:ident
        $body:tt $(;)*
    ) => { ... };
}

Implements the Queryable trait for a given struct. This macro should be called by copy/pasting the definition of the struct into it.

Example

struct User {
    name: String,
    hair_color: Option<String>,
}

Queryable! {
    struct User {
        name: String,
        hair_color: Option<String>,
    }
}