[][src]Struct barrel::types::Type

pub struct Type<T> {
    pub nullable: bool,
    pub unique: bool,
    pub increments: bool,
    pub indexed: bool,
    pub default: Option<T>,
    pub size: Option<usize>,
    // some fields omitted
}

A database column type and all the metadata attached to it

Using this struct directly is not recommended. Instead, you should be using the constructor APIs in the types module.

use barrel::types::*;

let column = varchar()
                .size(255)
                .nullable(true)
                .indexed(true)
                .unique(true);

Please see the default vaulues section in the types module docs!

Fields

nullable: boolunique: boolincrements: boolindexed: booldefault: Option<T>size: Option<usize>

Methods

impl<T> Type<T>[src]

This is a public API, be considered about breaking thigns

pub fn nullable(self, arg: bool) -> Self[src]

Set the nullability of this type

pub fn unique(self, arg: bool) -> Self[src]

Set the uniqueness of this type

pub fn increments(self, arg: bool) -> Self[src]

Specify if this type should auto-increment

pub fn indexed(self, arg: bool) -> Self[src]

Specify if this type should be indexed by your SQL implementation

pub fn default(self, arg: impl Into<T>) -> Self[src]

Provide a default value for a type column

pub fn size(self, arg: usize) -> Self[src]

Specify a size limit (important or varchar & similar)

Auto Trait Implementations

impl<T> Send for Type<T> where
    T: Send

impl<T> Sync for Type<T> where
    T: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> IntoSql for T[src]

fn into_sql<T>(self) -> Self::Expression where
    Self: AsExpression<T>, 
[src]

Convert self to an expression for Diesel's query builder. Read more

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression where
    &'a Self: AsExpression<T>, 
[src]

Convert &self to an expression for Diesel's query builder. Read more