pub trait FilterableEntity {
// Required method
fn filterable_fields() -> HashSet<String>;
// Provided method
fn sortable_fields() -> HashSet<String> { ... }
}Expand description
Trait for entities to declare which fields are allowed in filter queries.
Implementing this trait on an entity enables field-level access control
for the filter DSL, preventing clients from filtering on internal or
sensitive columns (e.g., password_hash, internal_notes).
§Example
ⓘ
use backbone_orm::FilterableEntity;
use std::collections::HashSet;
struct User;
impl FilterableEntity for User {
fn filterable_fields() -> HashSet<String> {
["id", "username", "email", "status", "created_at"]
.iter().map(|s| s.to_string()).collect()
}
}Required Methods§
Sourcefn filterable_fields() -> HashSet<String>
fn filterable_fields() -> HashSet<String>
Returns the set of field names that are allowed in filter expressions.
Provided Methods§
Sourcefn sortable_fields() -> HashSet<String>
fn sortable_fields() -> HashSet<String>
Returns the set of field names that are allowed in sort expressions. Defaults to the same as filterable_fields.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".