Trait IntoField

Source
pub trait IntoField<T> {
    // Required method
    fn into_field(self) -> T;
}
Available on crate feature db only.
Expand description

A trait for database types that can be converted to the field type.

This trait is mostly a helper trait to make comparisons like $id == 5 where id is of type Auto or ForeignKey easier to write and more readable.

§Example

use cot::db::query::{Expr, ExprEq, Query};
use cot::db::{Auto, model, query};

#[model]
struct MyModel {
    #[model(primary_key)]
    id: Auto<i32>,
};

// uses the `IntoField` trait to convert the `5` to `Auto<i32>`
let expr = <MyModel as cot::db::Model>::Fields::id.eq(5);

Required Methods§

Source

fn into_field(self) -> T

Converts the type to the field type.

Implementations on Foreign Types§

Source§

impl IntoField<String> for &str

Source§

impl<T: Model + Send + Sync> IntoField<ForeignKey<T>> for &T

Implementors§

Source§

impl<T> IntoField<Auto<T>> for T

Source§

impl<T: Model + Send + Sync> IntoField<ForeignKey<T>> for T

Source§

impl<T: ToDbFieldValue> IntoField<T> for T