Sortable

Trait Sortable 

Source
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:

  • expression is the field being sorted.
  • ASC and DESC are the sort Direction.
  • USING operator is implied by PartialOrdBy.
  • NULLS { FIRST | LAST } corresponds to NullHandling. Meaning you can sort by ascending or descending and optionally specify NULL ordering.

Required Methods§

Source

fn sort_by(&self) -> Option<SortBy>

Describes how this field can be sorted.

Provided Methods§

Source

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.

Implementors§