Skip to main content

PrimaryKey

Trait PrimaryKey 

Source
pub trait PrimaryKey:
    Copy
    + Eq
    + Hash
    + Debug
    + Send
    + Sync
    + 'static
    + ToSqlValue
    + Serialize
    + DeserializeOwned {
    const COLUMN_TYPE: ColumnType;

    // Required methods
    fn null_value() -> SqlValue;
    fn from_row(row: &dyn RangoRow, col: &str) -> Result<Self, RowError>;
}
Expand description

A primary key value type that a ForeignKey<M> column can hold: Uuid (the default), i32 (FieldAutoInt / FieldInt) or i64 (FieldAutoBigInt / FieldBigInt).

Required Associated Constants§

Source

const COLUMN_TYPE: ColumnType

Type of a foreign key column pointing at this key.

Required Methods§

Source

fn null_value() -> SqlValue

The SQL NULL of this type (for Option<ForeignKey<M>>).

Source

fn from_row(row: &dyn RangoRow, col: &str) -> Result<Self, RowError>

Reads the key from col.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl PrimaryKey for Uuid

Source§

const COLUMN_TYPE: ColumnType = crate::ColumnType::Uuid

Source§

fn null_value() -> SqlValue

Source§

fn from_row(row: &dyn RangoRow, col: &str) -> Result<Self, RowError>

Source§

impl PrimaryKey for i32

Source§

const COLUMN_TYPE: ColumnType = crate::ColumnType::Int

Source§

fn null_value() -> SqlValue

Source§

fn from_row(row: &dyn RangoRow, col: &str) -> Result<Self, RowError>

Source§

impl PrimaryKey for i64

Source§

const COLUMN_TYPE: ColumnType = crate::ColumnType::BigInt

Source§

fn null_value() -> SqlValue

Source§

fn from_row(row: &dyn RangoRow, col: &str) -> Result<Self, RowError>

Implementors§

Source§

impl PrimaryKey for UnsupportedPk

Source§

const COLUMN_TYPE: ColumnType = crate::ColumnType::Uuid