This commit is contained in:
parent
26f14df3f4
commit
415f51ac4c
3 changed files with 24 additions and 56 deletions
|
@ -5,27 +5,19 @@ pub struct GrgStore {}
|
||||||
pub struct GrgRef {}
|
pub struct GrgRef {}
|
||||||
pub struct GrgValue {}
|
pub struct GrgValue {}
|
||||||
|
|
||||||
pub struct GrgTypes {}
|
impl IRowBuilder for GrgCreds {
|
||||||
impl Sto for GrgTypes {
|
|
||||||
type Builder=GrgCreds;
|
|
||||||
type Store=GrgStore;
|
|
||||||
type Ref=GrgRef;
|
|
||||||
type Value=GrgValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RowBuilder<GrgTypes> for GrgCreds {
|
|
||||||
fn row_store(&self) -> GrgStore {
|
fn row_store(&self) -> GrgStore {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RowStore<GrgTypes> for GrgStore {
|
impl IRowStore for GrgStore {
|
||||||
fn new_row(&self, partition: &str, sort: &str) -> GrgRef {
|
fn new_row(&self, partition: &str, sort: &str) -> GrgRef {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RowRef<GrgTypes> for GrgRef {
|
impl IRowRef for GrgRef {
|
||||||
fn set_value(&self, content: Vec<u8>) -> GrgValue {
|
fn set_value(&self, content: Vec<u8>) -> GrgValue {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
@ -40,7 +32,7 @@ impl RowRef<GrgTypes> for GrgRef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RowValue<GrgTypes> for GrgValue {
|
impl IRowValue for GrgValue {
|
||||||
fn to_ref(&self) -> GrgRef {
|
fn to_ref(&self) -> GrgRef {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,27 +5,19 @@ pub struct MemStore {}
|
||||||
pub struct MemRef {}
|
pub struct MemRef {}
|
||||||
pub struct MemValue {}
|
pub struct MemValue {}
|
||||||
|
|
||||||
pub struct MemTypes {}
|
impl IRowBuilder for MemCreds {
|
||||||
impl Sto for MemTypes {
|
|
||||||
type Builder=MemCreds;
|
|
||||||
type Store=MemStore;
|
|
||||||
type Ref=MemRef;
|
|
||||||
type Value=MemValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RowBuilder<MemTypes> for MemCreds {
|
|
||||||
fn row_store(&self) -> MemStore {
|
fn row_store(&self) -> MemStore {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RowStore<MemTypes> for MemStore {
|
impl IRowStore for MemStore {
|
||||||
fn new_row(&self, partition: &str, sort: &str) -> MemRef {
|
fn new_row(&self, partition: &str, sort: &str) -> MemRef {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RowRef<MemTypes> for MemRef {
|
impl IRowRef for MemRef {
|
||||||
fn set_value(&self, content: Vec<u8>) -> MemValue {
|
fn set_value(&self, content: Vec<u8>) -> MemValue {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
@ -40,7 +32,7 @@ impl RowRef<MemTypes> for MemRef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RowValue<MemTypes> for MemValue {
|
impl IRowValue for MemValue {
|
||||||
fn to_ref(&self) -> MemRef {
|
fn to_ref(&self) -> MemRef {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,55 +28,39 @@ pub enum Error {
|
||||||
Internal,
|
Internal,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Sto: Sized {
|
pub struct Engine {
|
||||||
type Builder: RowBuilder<Self>;
|
|
||||||
type Store: RowStore<Self>;
|
|
||||||
type Ref: RowRef<Self>;
|
|
||||||
type Value: RowValue<Self>;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Engine<T: Sto> {
|
|
||||||
pub bucket: String,
|
pub bucket: String,
|
||||||
pub row: T::Builder,
|
pub row: RowBuilder,
|
||||||
}
|
|
||||||
|
|
||||||
pub enum AnyEngine {
|
|
||||||
InMemory(Engine<in_memory::MemTypes>),
|
|
||||||
Garage(Engine<garage::GrgTypes>),
|
|
||||||
}
|
|
||||||
impl AnyEngine {
|
|
||||||
pub fn engine<X: Sto>(&self) -> &Engine<X> {
|
|
||||||
match self {
|
|
||||||
Self::InMemory(x) => x,
|
|
||||||
Self::Garage(x) => x,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------ Row Builder
|
// ------ Row Builder
|
||||||
pub trait RowBuilder<R: Sto>
|
pub trait IRowBuilder
|
||||||
{
|
{
|
||||||
fn row_store(&self) -> R::Store;
|
fn row_store(&self) -> RowStore;
|
||||||
}
|
}
|
||||||
|
pub type RowBuilder = Box<dyn IRowBuilder>;
|
||||||
|
|
||||||
// ------ Row Store
|
// ------ Row Store
|
||||||
pub trait RowStore<R: Sto>
|
pub trait IRowStore
|
||||||
{
|
{
|
||||||
fn new_row(&self, partition: &str, sort: &str) -> R::Ref;
|
fn new_row(&self, partition: &str, sort: &str) -> RowRef;
|
||||||
}
|
}
|
||||||
|
type RowStore = Box<dyn IRowStore>;
|
||||||
|
|
||||||
// ------- Row Item
|
// ------- Row Item
|
||||||
pub trait RowRef<R: Sto>
|
pub trait IRowRef
|
||||||
{
|
{
|
||||||
fn set_value(&self, content: Vec<u8>) -> R::Value;
|
fn set_value(&self, content: Vec<u8>) -> RowValue;
|
||||||
async fn fetch(&self) -> Result<R::Value, Error>;
|
async fn fetch(&self) -> Result<RowValue, Error>;
|
||||||
async fn rm(&self) -> Result<(), Error>;
|
async fn rm(&self) -> Result<(), Error>;
|
||||||
async fn poll(&self) -> Result<Option<R::Value>, Error>;
|
async fn poll(&self) -> Result<Option<RowValue>, Error>;
|
||||||
}
|
}
|
||||||
|
type RowRef = Box<dyn IRowRef>;
|
||||||
|
|
||||||
pub trait RowValue<R: Sto>
|
pub trait IRowValue
|
||||||
{
|
{
|
||||||
fn to_ref(&self) -> R::Ref;
|
fn to_ref(&self) -> RowRef;
|
||||||
fn content(&self) -> ConcurrentValues;
|
fn content(&self) -> ConcurrentValues;
|
||||||
async fn push(&self) -> Result<(), Error>;
|
async fn push(&self) -> Result<(), Error>;
|
||||||
}
|
}
|
||||||
|
type RowValue = Box<dyn IRowValue>;
|
||||||
|
|
Loading…
Reference in a new issue