Expand description
The code generation behind the queryweave derives, as an ordinary
library.
Each derive is a function from the derive’s input to the generated code,
generic over the conventions::Conventions it names things by.
queryweave-derive exports every derive with
conventions::DefaultConventions; a crate wanting other rules writes its
own small proc-macro crate calling these functions with its own
conventions:
ⓘ
#[proc_macro_derive(Filters, attributes(filter, sortable, filters, equivalent_field))]
pub fn derive_filters(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
queryweave_codegen::filters::<MyConventions>(input.into()).into()
}Every derive is built as a steps::Derive pipeline, private to the crate
(see docs/macros.md).
Modules§
- conventions
- How the derives name what they generate, and which names they require of the structs they are placed on or link to.
- errors
- Errors spanned to the user’s code, for a
Conventionsimpl to report a name that does not fit. - integrations
- What a
Filtersmirror’s generated code integrates with (serialization, API documentation, validation, …), each opted into per struct with a flag of#[filters(...)]named after it. - names
- Checks on the names of the structs a derive is placed on or links to.
Functions§
- append_
conditions #[derive(AppendConditions)]:queryweave_sql::AppendConditionsfor a filter-options wrapper, appending its set filters to a query as conditions.- append_
to_ query #[derive(AppendToQuery)]: the append to query trait on a wrapper of a domain query model.- columns
#[derive(Columns)]:queryweave_sql::Columnsfor asqlxentity, recording which column stores each field of the domain model named by#[columns(model = Model)].- filters
#[derive(Filters)]: the filtering, sorting and paging types of a struct, from its#[filter(lt|eq|gt|sw|c|ew|bool)]and#[sortable]fields.- merge_
patch #[derive(MergePatch)]: the functions merge patching a model with its merge patch model counterpart.- merge_
patch_ nullable_ fields #[derive(MergePatchNullableFields)]: a function listing the nullable fields of a struct used for merge-patching, i.e. itsOption<Option<T>>fields.- raw_
value #[derive(RawValue)]:queryweave::RawValuefor a value object (a newtype such asstruct Username<T = String>(T);), whose raw value is the wrapped type’s.- validate_
non_ nullable #[derive(ValidateNonNullable)]: a validation function for a merge patch DTO, mirroring a domain merge patch model.