rm_shared/
header.rs

1use ratatui::prelude::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Hash, PartialEq, Eq, Clone, Copy)]
5pub enum Header {
6    Id,
7    Name,
8    SizeWhenDone,
9    Progress,
10    Eta,
11    DownloadRate,
12    UploadRate,
13    DownloadDir,
14    Padding,
15    UploadRatio,
16    UploadedEver,
17    ActivityDate,
18    AddedDate,
19    PeersConnected,
20    SmallStatus,
21    Category,
22    CategoryIcon,
23}
24
25impl Header {
26    pub fn default_constraint(&self) -> Constraint {
27        match self {
28            Self::Name => Constraint::Max(70),
29            Self::SizeWhenDone => Constraint::Length(12),
30            Self::Progress => Constraint::Length(12),
31            Self::Eta => Constraint::Length(12),
32            Self::DownloadRate => Constraint::Length(12),
33            Self::UploadRate => Constraint::Length(12),
34            Self::DownloadDir => Constraint::Max(70),
35            Self::Padding => Constraint::Length(2),
36            Self::UploadRatio => Constraint::Length(6),
37            Self::UploadedEver => Constraint::Length(12),
38            Self::Id => Constraint::Length(4),
39            Self::ActivityDate => Constraint::Length(14),
40            Self::AddedDate => Constraint::Length(12),
41            Self::PeersConnected => Constraint::Length(6),
42            Self::SmallStatus => Constraint::Length(1),
43            Self::Category => Constraint::Max(15),
44            Self::CategoryIcon => Constraint::Length(5),
45        }
46    }
47
48    pub fn header_name(&self) -> &'static str {
49        match *self {
50            Self::Name => "Name",
51            Self::SizeWhenDone => "Size",
52            Self::Progress => "Progress",
53            Self::Eta => "ETA",
54            Self::DownloadRate => "Download",
55            Self::UploadRate => "Upload",
56            Self::DownloadDir => "Directory",
57            Self::Padding => "",
58            Self::UploadRatio => "Ratio",
59            Self::UploadedEver => "Up Ever",
60            Self::Id => "Id",
61            Self::ActivityDate => "Last active",
62            Self::AddedDate => "Added",
63            Self::PeersConnected => "Peers",
64            Self::SmallStatus => "",
65            Self::Category => "Category",
66            Self::CategoryIcon => "",
67        }
68    }
69}