pub trait Conventions {
// Required methods
fn filters_names(input: &Ident) -> Result<FiltersNames>;
fn check_model_name(name: &Ident) -> Result<()>;
fn check_merge_patch_name<S: ToTokens + ?Sized>(
name: &Ident,
span: &S,
what: &str,
) -> Result<()>;
fn sort_variant(field: &Ident, span: Span) -> Ident;
fn filter_field(field: &Ident, operator: &str, span: Span) -> Ident;
fn check_wrapper_name<S: ToTokens + ?Sized>(
name: &Ident,
span: &S,
what: &str,
) -> Result<()>;
// Provided methods
fn core_crate() -> Path { ... }
fn api_crate() -> Path { ... }
fn sql_crate() -> Path { ... }
fn integrations() -> Vec<&'static dyn Integration> { ... }
}Expand description
The naming rules of the derives.
Its functions report a name that does not fit through
crate::errors, at what the user wrote: the struct’s name, or the path
inside the attribute naming another struct.
Required Methods§
Sourcefn filters_names(input: &Ident) -> Result<FiltersNames>
fn filters_names(input: &Ident) -> Result<FiltersNames>
The names of the types #[derive(Filters)] generates for input.
§Errors
Returns an error, at input, when the struct’s name does not fit.
Sourcefn check_model_name(name: &Ident) -> Result<()>
fn check_model_name(name: &Ident) -> Result<()>
Check the name of a model deriving MergePatch.
§Errors
Returns an error, at name, when it does not fit.
Sourcefn check_merge_patch_name<S: ToTokens + ?Sized>(
name: &Ident,
span: &S,
what: &str,
) -> Result<()>
fn check_merge_patch_name<S: ToTokens + ?Sized>( name: &Ident, span: &S, what: &str, ) -> Result<()>
Check the name of a merge patch struct: the struct a derive is placed
on (MergePatchNullableFields, ValidateNonNullable), or one an
attribute links to (#[merge_patch(patch = path)], or
#[validate_non_nullable(mirrors = path)]), calling it
what.
§Errors
Returns an error, at span, when the name does not fit.
Sourcefn sort_variant(field: &Ident, span: Span) -> Ident
fn sort_variant(field: &Ident, span: Span) -> Ident
The variant of the generated sortable-fields enum for the #[sortable]
field field, spanned to span.
Shared across layers: a mirror names the mirrored model’s variants with it.
Sourcefn filter_field(field: &Ident, operator: &str, span: Span) -> Ident
fn filter_field(field: &Ident, operator: &str, span: Span) -> Ident
The generated filter field (and, on a DTO, query parameter) filtering
field with the operator written operator in #[filter(...)] (lt,
eq, gt, sw, c, ew or bool), spanned to span.
Shared across layers: a mirror names the mirrored model’s filter fields with it.
Provided Methods§
Sourcefn core_crate() -> Path
fn core_crate() -> Path
The path of the core runtime crate, named by the code generated for a
root model (Filters, MergePatch, MergePatchNullableFields,
RawValue).
Defaults to ::queryweave: absolute, so a local item of the same name
cannot shadow it. Override it when the crate is renamed or re-exported.
Sourcefn api_crate() -> Path
fn api_crate() -> Path
The path of the API runtime crate, named by the code generated for an
API type (a Filters mirror with serde or utoipa,
ValidateNonNullable). Defaults to ::queryweave_api.
Sourcefn sql_crate() -> Path
fn sql_crate() -> Path
The path of the SQL runtime crate, named by the code generated for the
persistence layer (Columns, AppendToQuery,
AppendToQueryWithSeparator). Defaults to ::queryweave_sql.
Sourcefn integrations() -> Vec<&'static dyn Integration>
fn integrations() -> Vec<&'static dyn Integration>
The integrations a Filters mirror may opt into, each with the flag
of #[filters(...)] named after it, in the order their additions are
generated. Their names must differ from each other and from mirrors.
Defaults to the built-in ones (crate::integrations::BUILT_IN:
serde, utoipa, validator). Override it to add a crate’s own (e.g.
a GraphQL integration) or to replace some (e.g. serde by another
serializer).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".