1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::db::db_dictionary::DbDictionary;
use crate::lang::locale::AppLanguage;
use std::env;
use dotenv::dotenv;
pub trait Dictionary {
fn get_random_word(&self) -> Option<DictionaryEntry>;
fn find_word(&self, text: &str) -> Option<DictionaryEntry>;
fn create_word(&self, word_entry: DictionaryEntry) -> Option<DictionaryEntry>;
fn guessed_word(&self, word_entry: DictionaryEntry);
}
pub struct DictionaryEntry {
pub word: String,
pub guessed: bool
}
pub fn get_dictionary(app_language: AppLanguage) -> DbDictionary {
dotenv().ok();
DbDictionary::new(env::var("DATABASE_URL")
.expect("DATABASE_URL must be set"), app_language)
}