pub trait EsRepo: Send {
type Entity: EsEntity;
type CreateError;
type ModifyError;
type FindError: From<Error> + From<EntityHydrationError> + Send;
type QueryError: From<Error> + From<EntityHydrationError> + Send;
type EsQueryFlavor;
// Required methods
fn nested_tree_spec() -> TreeSpec;
fn hydrate_nested_from_rows<E>(
rows_by_tag: &mut HashMap<i32, Vec<Row>>,
tag_cursor: &mut i32,
entities: &mut [Self::Entity],
) -> Result<(), E>
where E: From<Error> + From<EntityHydrationError>;
}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 CreateError
type ModifyError
type FindError: From<Error> + From<EntityHydrationError> + Send
type QueryError: From<Error> + From<EntityHydrationError> + Send
type EsQueryFlavor
Required Methods§
fn nested_tree_spec() -> TreeSpec
fn hydrate_nested_from_rows<E>( rows_by_tag: &mut HashMap<i32, Vec<Row>>, tag_cursor: &mut i32, entities: &mut [Self::Entity], ) -> Result<(), E>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".