chow
This commit is contained in:
commit
a79237e286
6 changed files with 81 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/target
|
5
Cargo.lock
generated
Normal file
5
Cargo.lock
generated
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "chow"
|
||||||
|
version = "0.1.0"
|
7
Cargo.toml
Normal file
7
Cargo.toml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[package]
|
||||||
|
name = "chow"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Michael Zhang <mail@mzhang.io>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
6
src/main.rs
Normal file
6
src/main.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
mod sync;
|
||||||
|
mod myers;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
3
src/myers.rs
Normal file
3
src/myers.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
pub fn myers<T>() {
|
||||||
|
|
||||||
|
}
|
59
src/sync.rs
Normal file
59
src/sync.rs
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
pub trait Differentiable {
|
||||||
|
type Diff;
|
||||||
|
fn diff(a: Self, b: Self) -> Self::Diff;
|
||||||
|
fn apply(&mut self, d: Self::Diff);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct List<T>(Vec<T>);
|
||||||
|
|
||||||
|
pub enum ListDiff<T> {
|
||||||
|
Insert(usize, T),
|
||||||
|
Delete(usize),
|
||||||
|
Update(usize, T),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Differentiable> Differentiable for List<T> {
|
||||||
|
type Diff = Vec<(usize, T::Diff)>;
|
||||||
|
|
||||||
|
fn diff(_a: Self, _b: Self) -> Self::Diff {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn apply(&mut self, _d: Self::Diff) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Chow {
|
||||||
|
items: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ChowDiff;
|
||||||
|
|
||||||
|
impl Differentiable for Chow {
|
||||||
|
type Diff = ChowDiff;
|
||||||
|
fn diff(_a: Self, _b: Self) -> Self::Diff {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn apply(&mut self, _d: Self::Diff) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ClientState {
|
||||||
|
text: Chow,
|
||||||
|
shadow: Chow,
|
||||||
|
current_client_version: usize,
|
||||||
|
last_server_version: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ClientState {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ServerState {
|
||||||
|
text: Chow,
|
||||||
|
shadow: Chow,
|
||||||
|
backup_shadow: Chow,
|
||||||
|
}
|
Loading…
Reference in a new issue