pub mod base {
pub trait Entity {
}
pub trait Gateway {
type Connection;
fn new(connection: &Self::Connection) -> Self;
}
}
pub mod domain_logic {
pub trait TransactionScript {
fn execute(self: &Self) -> bool;
}
pub trait TableModule {
}
pub trait ServiceLayer {
}
}
pub mod object_relational {
use super::base::Gateway;
pub mod structural {
pub trait IdentityField {
type IdType;
fn id(self: &Self) -> Self::IdType;
}
}
pub mod behavioral {
use super::{structural::IdentityField, Gateway};
pub trait UnitOfWork: Gateway {
}
pub trait IdentityMap {
type IdType;
type Model: IdentityField;
type Error;
fn get(self: Self, id: &Self::IdType) -> Result<Self::Model, Self::Error>;
fn set(
self: Self,
id: &Self::IdType,
model: Self::Model,
) -> Result<Self::Model, Self::Error>;
}
pub trait LazyLoad {
}
}
}
pub mod data_source {
use super::base::Gateway;
pub trait TableGateway: Gateway {
type Model;
type Params;
type Error;
fn create_table(self: &Self) -> Result<(), Self::Error>;
fn drop_table(self: &Self) -> Result<(), Self::Error>;
fn insert(self: &Self, params: &Self::Params) -> Result<i64, Self::Error>;
fn find(self: &Self, params: &Self::Params) -> Option<Self::Model>;
fn update(self: &Self, params: &Self::Params) -> Result<(), Self::Error>;
fn delete(self: &Self, params: &Self::Params) -> Result<(), Self::Error>;
}
pub trait RowDataGateway: Gateway {
type Model;
type Params;
type Error;
fn insert(params: &Self::Params) -> Result<i64, Self::Error>;
fn find(params: &Self::Params) -> Option<Self::Model>;
fn delete(params: &Self::Params) -> Result<(), Self::Error>;
}
pub trait ActiveRecord: Gateway {
type Model;
type Params;
type Error;
fn insert<T: Sized>(self: &Self) -> Result<T, Self::Error>;
fn update(self: &Self) -> Result<(), Self::Error>;
fn delete(self: &Self) -> Result<(), Self::Error>;
}
pub trait DataMapper {
type Model;
type Params;
type Error;
fn insert(model: &Self::Model) -> Result<(), Self::Error>;
fn update(model: &Self::Model) -> Result<(), Self::Error>;
fn delete(model: &Self::Model) -> Result<(), Self::Error>;
}
}