#[derive(Clone,Debug,PartialEq,Eq,PartialOrd,Ord,clap::ValueEnum)]
pub enum PinReasonKind {
	Activity,
	Category,
	Explicit,
	Seeders,
	SeedTime,
	State,
}

#[derive(Debug,PartialEq,Eq,PartialOrd,Ord)]
pub enum PinReason {
	Activity(std::time::Duration),
	Category(String),
	Explicit,
	Seeders(u64),
	SeedTime(std::time::Duration),
	State(crate::TorrentState),
}

impl PinReason {
	pub fn kind(&self) -> PinReasonKind {
		match self {
			PinReason::Activity(_) => PinReasonKind::Activity,
			PinReason::Category(_) => PinReasonKind::Category,
			PinReason::Explicit => PinReasonKind::Explicit,
			PinReason::Seeders(_) => PinReasonKind::Seeders,
			PinReason::SeedTime(_) => PinReasonKind::SeedTime,
			PinReason::State(_) => PinReasonKind::State,
		}
	}
}

impl std::fmt::Display for PinReason {
	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
		match self {
			PinReason::Activity(d) => write!(f, "last active {}", crate::FmtDuration(*d)),
			PinReason::Category(category) => write!(f, "category {category:?}"),
			PinReason::Explicit => write!(f, "explicilt"),
			PinReason::Seeders(s) => write!(f, "seeders {s}"),
			PinReason::SeedTime(d) => write!(f, "seed time {}", crate::FmtDuration(*d)),
			PinReason::State(s) => write!(f, "state {s:?}"),
		}
	}
}
