repox 0.1.0

trait framework for data repository patterns
Documentation
use super::*;

/// Trait contract for the Repo [`insert`] method
///
/// [`insert`]: Repo::insert
/// ---
pub trait Insert<T: Entity>: Repo {
    fn exec(
        &self,
        entity: T,
    ) -> impl Future<Output = Result<(), InsertError<T>>> + Send;
}

#[derive(Debug, ::thiserror::Error)]
pub enum InsertError<E: Entity> {
    #[error("Entity with ID {0:?} taken")]
    IdTaken(E::ID),
    #[error(transparent)]
    Unknown(#[from] ::anyhow::Error),
}