[][src]Struct latitude::prelude::types::Type

pub struct Type {
    pub nullable: bool,
    pub unique: bool,
    pub increments: bool,
    pub indexed: bool,
    pub primary: 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: boolprimary: booldefault: Option<WrappedDefault<'static>>size: Option<usize>inner: BaseType

Implementations

impl Type[src]

This is a public API, be considered about breaking thigns

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

Set the nullability of this type

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

Set the uniqueness of this type

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

Specify if this type should auto-increment

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

Specify if this type should be indexed by your SQL implementation

pub fn primary(self, arg: bool) -> Type[src]

Specify if this type should be a primary key

pub fn default(self, arg: impl Into<WrappedDefault<'static>>) -> Type[src]

Provide a default value for a type column

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

Specify a size limit (important or varchar & similar)

Trait Implementations

impl Clone for Type[src]

impl Debug for Type[src]

impl PartialEq<Type> for Type[src]

impl StructuralPartialEq for Type[src]

Auto Trait Implementations

impl RefUnwindSafe for Type

impl Send for Type

impl Sync for Type

impl Unpin for Type

impl UnwindSafe for Type

Blanket Implementations

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

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

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

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

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

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T> TryConv for T

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

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> 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<V, T> VZip<V> for T where
    V: MultiLane<T>,