fish-lib 0.2.3

A work-in-progress fishing game library containing the game/storage logic for a discord fishing game I'm working on.
Documentation
use crate::database::DatabaseInterface;
use crate::game::errors::database::GameDatabaseError;
use crate::game::errors::repository::GameRepositoryError;
use crate::traits::model::Model;
use diesel::r2d2::{ConnectionManager, PooledConnection};
use diesel::PgConnection;
use std::sync::{Arc, RwLock};

pub trait Repository<T: Model>: Send + Sync {
    fn get_db(&self) -> Arc<RwLock<dyn DatabaseInterface>>;
    fn create(&self, new_entity: T::InsertType) -> Result<T, GameRepositoryError>;
    fn find(&self, id: T::PrimaryKeyType) -> Result<Option<T>, GameRepositoryError>;
    fn save(&self, entity: T) -> Result<T, GameRepositoryError>;
    fn delete(&self, entity: T) -> Result<bool, GameRepositoryError>;
    fn get_connection(
        &self,
    ) -> Result<PooledConnection<ConnectionManager<PgConnection>>, GameDatabaseError> {
        self.get_db()
            .read()
            .expect("Failed to get read lock on DB")
            .get_connection()
    }
}