pub trait EntityRepoMeta {
// Required methods
fn column_types() -> HashMap<String, String>;
fn search_fields() -> &'static [&'static str];
// Provided methods
fn private_fields() -> &'static [&'static str] { ... }
fn owner_field() -> Option<&'static str> { ... }
fn company_field() -> Option<&'static str> { ... }
fn relations() -> &'static [(&'static str, &'static str, &'static str)] { ... }
}Expand description
Metadata trait that entities implement so GenericCrudRepository can provide
list_paginated_filtered and list_deleted_filtered without per-entity boilerplate.
Generated once per entity by the rust generator.
| Method | Purpose |
|---|---|
column_types | PostgreSQL cast hints (e.g. {"id": "uuid"}) |
search_fields | Text columns searched with ILIKE |
Required Methods§
Sourcefn column_types() -> HashMap<String, String>
fn column_types() -> HashMap<String, String>
PostgreSQL type hints for filter/sort (e.g. {"id": "uuid"}).
Sourcefn search_fields() -> &'static [&'static str]
fn search_fields() -> &'static [&'static str]
Text columns to include in full-text / ILIKE search.
Provided Methods§
Sourcefn private_fields() -> &'static [&'static str]
fn private_fields() -> &'static [&'static str]
Response fields visible only to the row owner and platform/root callers
(@private). Stripped for everyone else.
Sourcefn owner_field() -> Option<&'static str>
fn owner_field() -> Option<&'static str>
The response field (camelCase) holding the owner/company id (@owner),
compared against the caller’s access scope to decide private-field
visibility. None = the entity has no owner concept.
Sourcefn company_field() -> Option<&'static str>
fn company_field() -> Option<&'static str>
The DB column that scopes rows to a company (snake_case, e.g. company_id).
None = the entity is global (reference data) and is not fenced.
The generator emits this structurally — from the presence of the company
column, a fact it cannot forget — and an entity opts OUT with @global.
The polarity is deliberate: owner_field() above is opt-IN via @owner, and
in a year of generated entities not one model ever declared it, so the whole
field-security path silently never ran. Security that must be remembered, in a
file nobody edits for security reasons, defaults to open and stays open. Here
silence means fenced, and forgetting is the safe direction.
This is a row-visibility fence, the same category as SoftDelete’s
unconditional deleted_at IS NULL — not domain logic.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".