Skip to main content

filters

Function filters 

Source
pub fn filters<C: Conventions>(input: TokenStream) -> TokenStream
Expand description

#[derive(Filters)]: the filtering, sorting and paging types of a struct, from its #[filter(lt|eq|gt|sw|c|ew|bool)] and #[sortable] fields.

The struct is either:

  • a root model (no #[filters(mirrors = ...)]): it gets the query, filter-options, sort-field and sort-details models handing filters and sorting to the persistence layer as data, and publishes them through queryweave::Filterable;
  • a mirror of a model (#[filters(mirrors = path)], e.g. an API DTO): it gets its own sort types and query parameters, converting into the mirrored model’s types. A plain mirror names only the core runtime; the flags #[filters(mirrors = path, serde, utoipa, validator)] opt into deserializable query parameters (and a PageDto alias), API documentation schemas and validation (which needs serde), and schemars and garde into their alternatives (JSON schemas, validation needing no serializer), each needing only its own crate. A field named differently on the mirrored model maps onto it with #[equivalent_field(name)]; the query parameters keep the mirror’s names. The mirrored model is a root model or another mirror (e.g. a gRPC DTO mirroring an API DTO): a mirror publishes its own types through queryweave::Filterable too, every chain ending at a root model, and queryweave::IntoRootQuery converts a query straight into the root’s.

Attributes: filter, sortable, filters, equivalent_field.