cosmic/widget/table/model/
category.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use std::borrow::Cow;

use crate::widget::Icon;

/// Implementation of std::fmt::Display allows user to customize the header
/// Ideally, this is implemented on an enum.
pub trait ItemCategory:
    Default + std::fmt::Display + Clone + Copy + PartialEq + Eq + std::hash::Hash
{
    /// Function that gets the width of the data
    fn width(&self) -> iced::Length;
}

pub trait ItemInterface<Category: ItemCategory> {
    fn get_icon(&self, category: Category) -> Option<Icon>;
    fn get_text(&self, category: Category) -> Cow<'static, str>;

    fn compare(&self, other: &Self, category: Category) -> std::cmp::Ordering;
}