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

pub struct Type {
    pub nullable: bool,
    pub unique: bool,
    pub increments: bool,
    pub indexed: bool,
    pub default: Option<WrappedDefault<'static>>,
    pub size: Option<usize>,
    pub inner: BaseType,
}

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.

A Type is an enum provided to other barrel APIs in order to generate SQL datatypes. Working with them directly is possible but not recommended.

Instead, you can use these helper functions to construct Type enums of different...types and constraints. Field metadata is added via chainable factory pattern functions.

Default values

If no additional arguments are provided, some assumptions will be made about the metadata of a column type.

  • nullable: false
  • indexed: false
  • unique: false
  • default: None
  • size: None (which will error if size is important)

Examples

extern crate barrel;
use barrel::types::*;

// Make your own Primary key :)
let col = integer().increments(true).unique(true);

Fields

nullable: boolunique: boolincrements: boolindexed: booldefault: Option<WrappedDefault<'static>>size: Option<usize>inner: BaseType

Methods

impl Type[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<WrappedDefault<'static>>) -> 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)

Trait Implementations

impl PartialEq<Type> for Type[src]

impl Clone for Type[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Type[src]

Auto Trait Implementations

impl Send for Type

impl Sync for Type

Blanket Implementations

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

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

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

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>, 

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