Skip to main content

Entity

Trait Entity 

Source
pub trait Entity:
    Send
    + Sync
    + Sized {
    type Id: Debug + Clone + PartialEq + Eq + Hash + Send + Sync + Into<Value>;

    // Required methods
    fn table_name() -> &'static str;
    fn id_column() -> &'static str;
    fn columns() -> &'static [Column];
    fn id(&self) -> Self::Id;
    fn values(&self) -> Vec<Value>;
}
Expand description

Describes the schema of a database-backed entity.

Implementors specify the table name, columns, and primary key column so that fletch can generate SQL for CRUD operations.

Required Associated Types§

Source

type Id: Debug + Clone + PartialEq + Eq + Hash + Send + Sync + Into<Value>

The Rust type of the primary key (e.g. i64, String, Uuid).

Required Methods§

Source

fn table_name() -> &'static str

The database table name for this entity.

Source

fn id_column() -> &'static str

The name of the primary key column.

Source

fn columns() -> &'static [Column]

All columns for this entity (including the id column).

Source

fn id(&self) -> Self::Id

Returns the primary key value of this entity instance.

Source

fn values(&self) -> Vec<Value>

Returns the values for all columns, in the same order as columns.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§