1use crate::status::StatusDuration;
4use crate::util::Id;
5#[cfg(feature = "serialization")]
6use serde::{Deserialize, Serialize};
7use std::fmt::Debug;
8use std::hash::Hash;
9
10#[derive(PartialEq, Clone, Debug)]
12#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
13pub struct SimpleStatus<I, V> {
14 id: I,
15 effect: V,
16 max_duration: Option<StatusDuration>,
17}
18
19impl<I: Send, V: Copy> SimpleStatus<I, V> {
20 pub fn new(id: I, effect: V, max_duration: Option<StatusDuration>) -> Self {
22 Self {
23 id,
24 effect,
25 max_duration,
26 }
27 }
28
29 pub fn effect(&self) -> V {
31 self.effect
32 }
33
34 pub fn set_effect(&mut self, effect: V) {
36 self.effect = effect;
37 }
38
39 pub fn max_duration(&self) -> Option<StatusDuration> {
42 self.max_duration
43 }
44}
45
46#[cfg(not(feature = "serialization"))]
47impl<I, V> Id for SimpleStatus<I, V>
48where
49 I: Debug + Hash + Eq + Clone + Send,
50{
51 type Id = I;
52 fn id(&self) -> &Self::Id {
53 &self.id
54 }
55}
56
57#[cfg(feature = "serialization")]
58impl<I, V> Id for SimpleStatus<I, V>
59where
60 I: Debug + Hash + Eq + Clone + Send + Serialize + for<'a> Deserialize<'a>,
61{
62 type Id = I;
63 fn id(&self) -> &Self::Id {
64 &self.id
65 }
66}