pub trait Sortable: PartialEq {
// Required method
fn sort_by(&self) -> Option<SortBy>;
// Provided method
fn null_handling(&self) -> NullHandling { ... }
}Expand description
Trait used to describe how a field can be sorted. This must be implemented on the field enum.
Our PartialOrdBy fn may result in None values which we refer to as NULL. We borrow from SQL here to handle these values in a similar way to the SQL ORDER BY clause. The PostgreSQL general form is ORDER BY expression [ ASC | DESC | USING operator ] [ NULLS { FIRST | LAST } ] [, ...] where:
expressionis the field being sorted.ASCandDESCare the sortDirection.USING operatoris implied byPartialOrdBy.NULLS { FIRST | LAST }corresponds toNullHandling. Meaning you can sort by ascending or descending and optionally specifyNULLordering.
Required Methods§
Provided Methods§
Sourcefn null_handling(&self) -> NullHandling
fn null_handling(&self) -> NullHandling
Describes how NULL values (when PartialOrdBy returns None) should be ordered when sorting. Either all at the start or the end.
Provided implementation relies on the default (all at the end) and should be overridden if you want to change this generally or on a per-field basis.
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.