pub trait Sortable: Sized {
type SortField;
// Provided methods
fn sort(
self,
field: Self::SortField,
dir: SortDir,
) -> Sorted<Self, Self::SortField> { ... }
fn sort_random(self) -> Sorted<Self, Random> { ... }
}Available on crate feature
utils only.Expand description
Trait that adds sorting support to query builders.
Per-entity sort-field enums (e.g. PostSort, AuthorSort) are generated
automatically by the impl_sortable! macro.
Required Associated Types§
Sourcetype SortField
type SortField
The sortable field enum type, defined in each sub-module by impl_sortable!.
Provided Methods§
Sourcefn sort(
self,
field: Self::SortField,
dir: SortDir,
) -> Sorted<Self, Self::SortField>
fn sort( self, field: Self::SortField, dir: SortDir, ) -> Sorted<Self, Self::SortField>
Sort by the given field and direction, returning Sorted<Self, SortField>.
Sourcefn sort_random(self) -> Sorted<Self, Random>
fn sort_random(self) -> Sorted<Self, Random>
Sort results randomly using ORDER BY RANDOM().
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.