cock_lib/cock_parts/
aesthetic.rs

1use crate::{FromString, GetVariants, Score};
2
3/// /// The [Aesthetic] enum represents different aesthetic values of a cock.
4#[derive(Debug, PartialEq, Clone, serde::Deserialize)]
5pub enum Aesthetic {
6    JustChopItOff,
7    TooBigToBeFunctional,
8    Gross,
9    UglyButUsable,
10    KindaMediocre,
11    Normal,
12    ABitBetterThanNormal,
13    NiceOne,
14    Cockalicious,
15    Perfect,
16}
17
18/// The [Score] trait implementation for [Aesthetic] provides a score value based on the aesthetic.
19impl Score for Aesthetic {
20    fn score(&self) -> u32 {
21        match self {
22            Aesthetic::JustChopItOff => 1,
23            Aesthetic::TooBigToBeFunctional => 2,
24            Aesthetic::Gross => 3,
25            Aesthetic::UglyButUsable => 4,
26            Aesthetic::KindaMediocre => 5,
27            Aesthetic::Normal => 6,
28            Aesthetic::ABitBetterThanNormal => 7,
29            Aesthetic::NiceOne => 8,
30            Aesthetic::Cockalicious => 9,
31            Aesthetic::Perfect => 10,
32        }
33    }
34}
35
36/// The [GetVariants] trait implementation for [Aesthetic] returns a vector of the possible variants of [Aesthetic].
37impl GetVariants for Aesthetic {
38    fn get_variants() -> Vec<String> {
39        vec![
40            String::from("JustChopItOff"),
41            String::from("TooBigToBeFunctional"),
42            String::from("Gross"),
43            String::from("UglyButUsable"),
44            String::from("KindaMediocre"),
45            String::from("Normal"),
46            String::from("ABitBetterThanNormal"),
47            String::from("NiceOne"),
48            String::from("Cockalicious"),
49            String::from("Perfect"),
50        ]
51    }
52}
53
54/// The [FromString] trait implementation for [Aesthetic] returns an [Aesthetic] variant based on the string provided.
55impl FromString for Aesthetic {
56    fn from_string(aesthetic: &str) -> Aesthetic {
57        match aesthetic {
58            "JustChopItOff" => Aesthetic::JustChopItOff,
59            "TooBigToBeFunctional" => Aesthetic::TooBigToBeFunctional,
60            "Gross" => Aesthetic::Gross,
61            "UglyButUsable" => Aesthetic::UglyButUsable,
62            "KindaMediocre" => Aesthetic::KindaMediocre,
63            "Normal" => Aesthetic::Normal,
64            "ABitBetterThanNormal" => Aesthetic::ABitBetterThanNormal,
65            "NiceOne" => Aesthetic::NiceOne,
66            "Cockalicious" => Aesthetic::Cockalicious,
67            "Perfect" => Aesthetic::Perfect,
68            _ => panic!("Invalid aesthetic"),
69        }
70    }
71}
72
73/// [std::fmt::Display] implementation for [Aesthetic].
74impl std::fmt::Display for Aesthetic {
75    /// Returns a string representation of the [Aesthetic] variant.
76    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
77        match self {
78            Aesthetic::JustChopItOff => write!(f, "Just chop it off"),
79            Aesthetic::TooBigToBeFunctional => write!(f, "Too big to be functional"),
80            Aesthetic::Gross => write!(f, "Gross"),
81            Aesthetic::UglyButUsable => write!(f, "Ugly but usable"),
82            Aesthetic::KindaMediocre => write!(f, "Kinda mediocre"),
83            Aesthetic::Normal => write!(f, "Normal"),
84            Aesthetic::ABitBetterThanNormal => write!(f, "A bit better than normal"),
85            Aesthetic::NiceOne => write!(f, "Nice one"),
86            Aesthetic::Cockalicious => write!(f, "Cockalicious"),
87            Aesthetic::Perfect => write!(f, "Perfect"),
88        }
89    }
90}
91
92/// Unit tests for [Aesthetic].
93#[cfg(test)]
94mod tests {
95    use super::*;
96
97    #[test]
98    fn test_aesthetic_score() {
99        assert_eq!(Aesthetic::JustChopItOff.score(), 1);
100        assert_eq!(Aesthetic::TooBigToBeFunctional.score(), 2);
101        assert_eq!(Aesthetic::Gross.score(), 3);
102        assert_eq!(Aesthetic::UglyButUsable.score(), 4);
103        assert_eq!(Aesthetic::KindaMediocre.score(), 5);
104        assert_eq!(Aesthetic::Normal.score(), 6);
105        assert_eq!(Aesthetic::ABitBetterThanNormal.score(), 7);
106        assert_eq!(Aesthetic::NiceOne.score(), 8);
107        assert_eq!(Aesthetic::Cockalicious.score(), 9);
108        assert_eq!(Aesthetic::Perfect.score(), 10);
109    }
110}