Trait elephantry::entity::Entity

source ·
pub trait Entity {
    // Required methods
    fn from(tuple: &Tuple<'_>) -> Self;
    fn get(&self, field: &str) -> Option<&dyn ToSql>;
}
Expand description

Trait to translate SQL row to struct and vice versa.

You probably should use the Entity derive macro instead of writing the impl by yourself.

Required Methods§

source

fn from(tuple: &Tuple<'_>) -> Self

Create a new struct from SQL result.

source

fn get(&self, field: &str) -> Option<&dyn ToSql>

Get the value of the field named field.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T: FromSql + ToSql, S: BuildHasher + Default> Entity for HashMap<usize, T, S>

source§

fn from(tuple: &Tuple<'_>) -> Self

source§

fn get(&self, field: &str) -> Option<&dyn ToSql>

source§

impl<T: FromSql + ToSql, S: BuildHasher + Default> Entity for HashMap<String, T, S>

source§

fn from(tuple: &Tuple<'_>) -> Self

source§

fn get(&self, field: &str) -> Option<&dyn ToSql>

Implementors§

source§

impl Entity for Constraint

Available on crate feature inspect only.
source§

impl Entity for Index

Available on crate feature inspect only.
source§

impl Entity for Column

Available on crate feature inspect only.
source§

impl Entity for Composite

Available on crate feature inspect only.
source§

impl Entity for Domain

Available on crate feature inspect only.
source§

impl Entity for Enum

Available on crate feature inspect only.
source§

impl Entity for Extension

Available on crate feature inspect only.
source§

impl Entity for Function

Available on crate feature inspect only.
source§

impl Entity for Relation

Available on crate feature inspect only.
source§

impl Entity for Schema

Available on crate feature inspect only.
source§

impl Entity for Trigger

Available on crate feature inspect only.
source§

impl<T: Simple> Entity for T