ares/checkers/
checker_type.rs

1/// Checker_type is a type used to define checkers
2/// This means that we can standardise the way we check for plaintext
3use crate::checkers::checker_result::CheckResult;
4use lemmeknow::Identifier;
5
6/// Every checker is of type CheckerType
7/// This will let us pick & choose which checkers to use
8/// at runtime.
9pub struct Checker<Type> {
10    /// The name of the checker
11    pub name: &'static str,
12    /// The description of the checker
13    /// you can take the first line from Wikipedia
14    /// Sometimes our checkers do not exist on Wikipedia so we write our own.
15    pub description: &'static str,
16    /// The link to the checker's website
17    /// Wikipedia link, articles, github etc
18    pub link: &'static str,
19    /// The tags of the checker
20    pub tags: Vec<&'static str>,
21    /// The expected runtime of the checker
22    /// We get this by bench marking the code
23    pub expected_runtime: f32,
24    /// The popularity of the checker
25    pub popularity: f32,
26    /// lemmeknow config object
27    pub lemmeknow_config: Identifier,
28    /// https://doc.rust-lang.org/std/marker/struct.PhantomData.html
29    /// Let's us save memory by telling the compiler that our type
30    /// acts like a type <T> even though it doesn't.
31    /// Stops the compiler complaining, else we'd need to implement
32    /// some magic to make it work.
33    pub _phantom: std::marker::PhantomData<Type>,
34}
35
36/// Every checker must implement this trait
37/// Which checks the given text to see if its plaintext
38/// and returns CheckResult, which is our results object.
39pub trait Check {
40    /// Returns a new struct of type CheckerType
41    fn new() -> Self
42    where
43        Self: Sized;
44    /// Checks the given text to see if its plaintext
45    fn check(&self, text: &str) -> CheckResult;
46}