EntityDescriptor

Trait EntityDescriptor 

Source
pub trait EntityDescriptor: Send + Sync {
    // Required methods
    fn entity_type(&self) -> &str;
    fn plural(&self) -> &str;
    fn build_routes(&self) -> Router;
}
Expand description

Trait that describes how to build routes for an entity

Each entity (Order, Invoice, Payment, etc.) should implement this trait to provide its CRUD routes.

Required Methods§

Source

fn entity_type(&self) -> &str

The entity type name (singular, e.g., “order”)

Source

fn plural(&self) -> &str

The plural form (e.g., “orders”)

Source

fn build_routes(&self) -> Router

Build the CRUD routes for this entity

Should return a Router with routes like:

  • GET /{plural}
  • POST /{plural}
  • GET /{plural}/:id

Implementors§