Skip to content

Commit

Permalink
fix: core
Browse files Browse the repository at this point in the history
  • Loading branch information
eatski committed Oct 20, 2021
1 parent a3a9f28 commit d43c5b0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
9 changes: 1 addition & 8 deletions libs/exprocess/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ use std::{cell::RefCell, rc::Rc};

use uuid::Uuid;

pub trait ExprocessCore {
type State;
type Command;
type Result;
fn init() -> Self::State;
fn resolve(prev: &Self::State, command: &Self::Command) -> Self::Result;
fn reducer(prev: &Self::State, result: &Self::Result) -> Self::State;
}
use crate::core::ExprocessCore;
pub struct RecordSync<'a,Core: ExprocessCore> {
pub command: &'a Core::Command,
pub result: &'a Core::Result,
Expand Down
8 changes: 8 additions & 0 deletions libs/exprocess/core.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pub trait ExprocessCore {
type State;
type Command;
type Result;
fn init() -> Self::State;
fn resolve(prev: &Self::State, command: &Self::Command) -> Self::Result;
fn reducer(prev: &Self::State, result: &Self::Result) -> Self::State;
}
4 changes: 3 additions & 1 deletion libs/exprocess/directly.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::{cell::{RefCell, RefMut}, collections::HashSet, rc::Rc};

use super::client::{ExprocessCore, Record, RecordSync, Repository};
use crate::core::ExprocessCore;

use super::client::{Record, RecordSync, Repository};
pub struct DirectlyDispatch<Core: ExprocessCore,Inner: Repository<Core>> {
inner: Inner,
listener: Shared<Box<dyn FnMut(Vec<RecordSync<Core>>)>>,
Expand Down
1 change: 1 addition & 0 deletions libs/exprocess/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod core;
pub mod client;
pub mod directly;
2 changes: 1 addition & 1 deletion src/domain/state.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use exprocess::client::ExprocessCore;
use exprocess::core::ExprocessCore;
use rand::prelude::SliceRandom;
use serde::{Deserialize, Serialize};

Expand Down

0 comments on commit d43c5b0

Please sign in to comment.