der_die_das 0.5.0

der_die_das: Learn german genders like a true geek.
Documentation
use miette::Result;

use crate::{cases::Articles, id::ID};

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Sentence {
    pub before: String,
    pub after: String,
    pub article_cases: Articles,
}

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct SavedSentence {
    pub id: ID,
    pub added: time::OffsetDateTime,
    pub sentence: Sentence,
}

impl From<Sentence> for SavedSentence {
    fn from(sentence: Sentence) -> Self {
        SavedSentence {
            id: ID::new(),
            added: time::OffsetDateTime::now_utc(),
            sentence,
        }
    }
}

pub trait Repo {
    /// Saves a sentence.
    ///
    /// # Errors
    ///
    /// This function will return an error if there are IO errors.
    fn save_sentence(self, sentence: SavedSentence) -> Result<()>;

    /// Returns all the sentences found.
    ///
    /// # Errors
    ///
    /// This function will return an error if there was an IO error.
    fn all_sentences(self) -> Result<Vec<SavedSentence>>;
}