sea_orm_newtype_id

Trait PrefixedId

Source
pub trait PrefixedId {
    const PREFIX: &'static str;

    // Provided methods
    fn new_id() -> String { ... }
    fn id_prefix() -> String { ... }
}
Expand description

ยงSea-orm Newtype ID is a ID generation system ๐Ÿš

  • ๐ŸŽฒ Currently uses nanoid
  • ๐Ÿฆ“ Stripe style IDs allow for users to see what kind of IDs are being used without having to log them in the database

ยงRationale

  • Stringly typed IDs can be very error prone, think of the case where you are using more than one ID at a time PrefixId

Is a trait that is used to add prefix based ID generation to a given domain object, e.g. an object that gets inserted into the database

Required Associated Constantsยง

Source

const PREFIX: &'static str

The prefix that is desired

Provided Methodsยง

Source

fn new_id() -> String

Generated a new id with the given prefix

Source

fn id_prefix() -> String

Return the prefix

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ยง