lastfm_client/types/
period.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
3#[non_exhaustive]
4pub enum Period {
5 Overall,
7 Week,
9 Month,
11 ThreeMonth,
13 SixMonth,
15 TwelveMonth,
17}
18
19impl Period {}
20
21#[derive(Debug, Clone, Copy, PartialEq, Eq)]
23#[non_exhaustive]
24pub enum TrackLimit {
25 Limited(u32),
27 Unlimited,
29}
30
31impl From<Option<u32>> for TrackLimit {
32 fn from(opt: Option<u32>) -> Self {
33 opt.map_or(Self::Unlimited, Self::Limited)
34 }
35}
36
37impl From<u32> for TrackLimit {
38 fn from(limit: u32) -> Self {
39 Self::Limited(limit)
40 }
41}
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn test_track_limit_from_option() {
49 let limited: TrackLimit = Some(100).into();
50 assert_eq!(limited, TrackLimit::Limited(100));
51
52 let unlimited: TrackLimit = None.into();
53 assert_eq!(unlimited, TrackLimit::Unlimited);
54 }
55
56 #[test]
57 fn test_track_limit_from_u32() {
58 let limited: TrackLimit = 50.into();
59 assert_eq!(limited, TrackLimit::Limited(50));
60 }
61}