[−][src]Struct barrel::types::Type
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: bool
unique: bool
increments: bool
indexed: bool
default: 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(&self) -> 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
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> IntoSql for T
fn into_sql<T>(self) -> Self::Expression where
Self: AsExpression<T>,
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>,
&'a Self: AsExpression<T>,
Convert &self
to an expression for Diesel's query builder. Read more