Skip to main content

UniqueEntityImplementationHelper

Trait UniqueEntityImplementationHelper 

Source
pub trait UniqueEntityImplementationHelper {
    const TABLE_NAME: &str;

    // Required methods
    fn new(content: Vec<u8>) -> Self;
    fn content(&self) -> &[u8] ;
}
Expand description

Unique entity implementation/migration helper.

Few unique entities actually care about what key gets used; it’s arbitrary, imposed only by the requirement that an Entity has a PrimaryKey. Really they only need to know what table name to use, and how to serialize/deserialize. For reasons of historical compatibility we express the serialization requirements in terms of inline methods here instead of a trait implementation.

If you implement this trait, you get the following traits auto-implemented:

  • PrimaryKey
  • UniqueEntity
  • Entity
  • EntityDatabaseMutation

Required Associated Constants§

Source

const TABLE_NAME: &str

Table name for this entity.

Required Methods§

Source

fn new(content: Vec<u8>) -> Self

Source

fn content(&self) -> &[u8]

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§