pub trait EsRepo: Send {
type Entity: EsEntity;
type Err: From<EsEntityError> + From<Error>;
type EsQueryFlavor;
// Required method
fn load_all_nested_in_op<OP>(
op: &mut OP,
entities: &mut [Self::Entity],
) -> impl Future<Output = Result<(), Self::Err>> + Send
where OP: AtomicOperation;
}Expand description
Required trait for all repositories to be compatible with es-entity and generate functions.
All repositories implement this trait to satisfy the basic requirements for
type-safe database operations with the associated entity. The trait ensures validation
that required fields (like entity) are present with compile-time errors.
Implemented by the EsRepo derive macro with #[es_repo] attributes.
§Example
ⓘ
// Would show error for missing entity field if not provided in the `es_repo` attribute
#[derive(EsRepo, Debug)]
#[es_repo(entity = "User", columns(name(ty = "String")))]
pub struct Users {
pool: PgPool, // Required field for database operations
}
impl Users {
pub fn new(pool: PgPool) -> Self {
Self { pool }
}
}Required Associated Types§
type Entity: EsEntity
type Err: From<EsEntityError> + From<Error>
type EsQueryFlavor
Required Methods§
Sourcefn load_all_nested_in_op<OP>(
op: &mut OP,
entities: &mut [Self::Entity],
) -> impl Future<Output = Result<(), Self::Err>> + Sendwhere
OP: AtomicOperation,
fn load_all_nested_in_op<OP>(
op: &mut OP,
entities: &mut [Self::Entity],
) -> impl Future<Output = Result<(), Self::Err>> + Sendwhere
OP: AtomicOperation,
Loads all nested entities for a given set of parent entities within an atomic operation.
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.