pub struct HeaderSortState {
pub column: Option<usize>,
pub ascending: bool,
}Expand description
UI sort state tracked per column-header click.
Unlike the lower-level SortState (which records which column and an
enum direction), HeaderSortState uses a simple ascending: bool toggle
and an Option<usize> for the active column, matching the UI interaction
model (click to sort ascending, click again to reverse).
Use HeaderSortState::as_sort_state to convert into the algorithm-level
SortState accepted by sort_indices.
Fields§
§column: Option<usize>The column currently sorted, or None when unsorted.
ascending: booltrue for ascending, false for descending.
Implementations§
Source§impl HeaderSortState
impl HeaderSortState
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new, unsorted HeaderSortState.
Sourcepub fn toggle(&mut self, col: usize)
pub fn toggle(&mut self, col: usize)
Toggle the sort for col:
- If
colis not currently sorted, sort it ascending. - If
colis currently sorted ascending, switch to descending. - If
colis currently sorted descending, clear the sort.
Sourcepub fn indicator(&self, col: usize) -> &'static str
pub fn indicator(&self, col: usize) -> &'static str
Return the indicator symbol for col:
"▲"if this column is sorted ascending"▼"if this column is sorted descending""otherwise
Sourcepub fn as_sort_state(&self) -> Option<SortState>
pub fn as_sort_state(&self) -> Option<SortState>
Convert to the algorithm-level SortState for use with sort_indices.
Returns None when unsorted.
Trait Implementations§
Source§impl Clone for HeaderSortState
impl Clone for HeaderSortState
Source§fn clone(&self) -> HeaderSortState
fn clone(&self) -> HeaderSortState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HeaderSortState
impl Debug for HeaderSortState
Source§impl Default for HeaderSortState
impl Default for HeaderSortState
Source§fn default() -> HeaderSortState
fn default() -> HeaderSortState
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for HeaderSortState
impl RefUnwindSafe for HeaderSortState
impl Send for HeaderSortState
impl Sync for HeaderSortState
impl Unpin for HeaderSortState
impl UnsafeUnpin for HeaderSortState
impl UnwindSafe for HeaderSortState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more