Derive Macro django_query::sorting::SortableWithPersianRug
source · [−]#[derive(SortableWithPersianRug)]
{
// Attributes available to this derive:
#[django]
}
sort
and persian-rug
only.Expand description
Derive the SortableWithContext
trait for persian-rug
types.
This is only implemented for structs with named fields. No fields
will be available to use as sort orders, unless there are
annotations to indicate otherwise. The annotations use the
django
attribute, which has the following significant options
here:
-
#[django(rename="new_name")]
Expose the annotated member for sorting as `new_name instead of using its name in the source code. -
#[django(sort)]
The field, which must be Ord, will be exposed as a sort order for the enclosing type. The ordering is taken directly from Ord. -
#[django(sort="name","age")]
The field has a type which is itselfSortable
. Expose this field as defining a sort order of the same name, and When sorting by this field make the order defined by the field’s own membername
, and then by its own memberage
as a secondary sort.
The struct itself must also be annotated with the django
attribute, which gives the persian-rug
constraints to apply to
to each derived impl
:
-
#[django(persian_rug(context=Rug))]
The persian-rug context type for this type isRug
. -
#[django(persian_rug(context=C, access(Foo<C>)))]
The persian-rug context type is the template parameterC
. The context must provide access toFoo<C>
.