audiot_core 0.2.0

Library that helps build the search database through the CLI, and eventually can be used to read data from that same database.
Documentation
use std::{fmt::Display, str::FromStr};

#[derive(Debug, Clone)]
#[derive(Default)]
pub enum Tokenizer {
    #[default]
    Porter,
    Trigram,
}


impl FromStr for Tokenizer {
    type Err = String;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "porter" => Ok(Self::Porter),
            "Porter" => Ok(Self::Porter),
            "trigram" => Ok(Self::Trigram),
            "Trigram" => Ok(Self::Trigram),
            _ => Err("Invalid value".to_string()),
        }
    }
}

impl Display for Tokenizer {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let text = match self {
            Tokenizer::Porter => "porter",
            Tokenizer::Trigram => "trigram",
        };

        f.write_str(text)
    }
}