der_die_das 0.5.0

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

use crate::{id::ID, nouns::Article};

#[derive(Debug, Clone)]
pub struct NounAttemptSaved {
    pub id: ID,
    pub at: time::OffsetDateTime,
    pub noun_attempt: NounAttempt,
}

#[derive(Debug, Clone)]
pub struct NounAttempt {
    pub for_word: ID,
    pub what_happened: Conclusion,
}

#[derive(Debug, Clone)]
pub enum Conclusion {
    Success,
    WrongArticle(Article),
}

pub trait Repo: Clone + Send + Sync + std::fmt::Debug {
    /// Saves an attempt
    ///
    /// # Errors
    ///
    /// This function will return an error if the IO fails or the item already
    /// Exists.
    fn save_noun_attempt(self, attempt: NounAttemptSaved) -> Result<()>;

    /// Returns all the attempts
    ///
    /// # Errors
    ///
    /// When IO failed.
    fn all_noun_attempts(self) -> Result<Vec<NounAttemptSaved>>;

    /// Find an attempt by its ID.
    ///
    /// # Errors
    ///
    /// This function will return an error if the item was not found or there
    /// was an IO failure .
    fn find_noun_attempt_by_id(self, id: ID) -> Result<NounAttemptSaved>;

    /// Finds the attempts for an specific noun.
    ///
    /// # Errors
    ///
    /// This function will return an error if the item was not found or there
    /// was an IO failure .
    fn find_noun_attempt_by_noun_id(self, id: ID) -> Result<Vec<NounAttemptSaved>>;

    /// Deletes an attempt by its ID.
    ///
    /// # Errors
    ///
    /// This function will return an error if the item was not found or there
    /// was an IO failure .
    fn delete_noun_attempt_by_id(self, id: ID) -> Result<()>;
}