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

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,
}
Expand description

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

This is a public API, be considered about breaking thigns

Set the nullability of this type

Set the uniqueness of this type

Specify if this type should auto-increment

Specify if this type should be indexed by your SQL implementation

Specify if this type should be a primary key

Provide a default value for a type column

Specify a size limit (important or varchar & similar)

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.