Entity

Trait Entity 

Source
pub trait Entity:
    Sized
    + Send
    + Sync
    + 'static {
    type Service: Send + Sync;

    // Required methods
    fn resource_name() -> &'static str;
    fn resource_name_singular() -> &'static str;
    fn service_from_host(
        host: &Arc<dyn Any + Send + Sync>,
    ) -> Result<Arc<Self::Service>>;
}
Expand description

Base trait for all entities in the system.

This trait provides the fundamental metadata needed to work with any entity type, including routing information and service access.

Required Associated Types§

Source

type Service: Send + Sync

The service type that handles operations for this entity

Required Methods§

Source

fn resource_name() -> &'static str

The plural resource name used in URLs (e.g., “users”, “companies”)

Source

fn resource_name_singular() -> &'static str

The singular resource name (e.g., “user”, “company”)

Source

fn service_from_host( host: &Arc<dyn Any + Send + Sync>, ) -> Result<Arc<Self::Service>>

Extract the service instance from the application host/state

This allows the framework to access entity-specific services without coupling to specific service implementations

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§