pub struct VersionVector { /* private fields */ }
Implementations§
Source§impl VersionVector
impl VersionVector
Sourcepub fn new() -> VersionVector
pub fn new() -> VersionVector
Sourcepub fn inc(self, node_id: &str) -> Self
pub fn inc(self, node_id: &str) -> Self
Examples found in repository?
examples/kv.rs (line 36)
33 fn set(mut self, client_id:&str, context: &VersionVector, key: &str, val: i64) -> Self{
34 // if incoming request context descends from local clock, just overwrite.
35 if context.descends(&self.vv) {
36 self.vv = self.vv.inc(client_id);
37 let dot = self.vv.get_dot(client_id);
38 let new_obj = Value{val: val, dot: dot};
39
40 // overwrite all the siblings
41 self.store.insert(key.to_string(), vec![new_obj]);
42 return self
43 }
44
45 let mut frontier = self.vv.merge(&context);
46 frontier = frontier.inc(client_id);
47 let dot = frontier.get_dot(client_id);
48 let new_obj = Value{val: val, dot: dot};
49 self.vv = frontier;
50 return self.merge_siblings(key, new_obj)
51 }
Sourcepub fn descends(&self, w: &VersionVector) -> bool
pub fn descends(&self, w: &VersionVector) -> bool
Examples found in repository?
examples/kv.rs (line 35)
33 fn set(mut self, client_id:&str, context: &VersionVector, key: &str, val: i64) -> Self{
34 // if incoming request context descends from local clock, just overwrite.
35 if context.descends(&self.vv) {
36 self.vv = self.vv.inc(client_id);
37 let dot = self.vv.get_dot(client_id);
38 let new_obj = Value{val: val, dot: dot};
39
40 // overwrite all the siblings
41 self.store.insert(key.to_string(), vec![new_obj]);
42 return self
43 }
44
45 let mut frontier = self.vv.merge(&context);
46 frontier = frontier.inc(client_id);
47 let dot = frontier.get_dot(client_id);
48 let new_obj = Value{val: val, dot: dot};
49 self.vv = frontier;
50 return self.merge_siblings(key, new_obj)
51 }
pub fn concurrent(&self, w: &VersionVector) -> bool
pub fn descends_dot(&self, w: &Dot) -> bool
Sourcepub fn merge(&self, w: &VersionVector) -> VersionVector
pub fn merge(&self, w: &VersionVector) -> VersionVector
merges the two given vectors via point-wise max.
Examples found in repository?
examples/kv.rs (line 45)
33 fn set(mut self, client_id:&str, context: &VersionVector, key: &str, val: i64) -> Self{
34 // if incoming request context descends from local clock, just overwrite.
35 if context.descends(&self.vv) {
36 self.vv = self.vv.inc(client_id);
37 let dot = self.vv.get_dot(client_id);
38 let new_obj = Value{val: val, dot: dot};
39
40 // overwrite all the siblings
41 self.store.insert(key.to_string(), vec![new_obj]);
42 return self
43 }
44
45 let mut frontier = self.vv.merge(&context);
46 frontier = frontier.inc(client_id);
47 let dot = frontier.get_dot(client_id);
48 let new_obj = Value{val: val, dot: dot};
49 self.vv = frontier;
50 return self.merge_siblings(key, new_obj)
51 }
Sourcepub fn get_dot(&self, node_id: &str) -> Dot
pub fn get_dot(&self, node_id: &str) -> Dot
Examples found in repository?
examples/kv.rs (line 37)
33 fn set(mut self, client_id:&str, context: &VersionVector, key: &str, val: i64) -> Self{
34 // if incoming request context descends from local clock, just overwrite.
35 if context.descends(&self.vv) {
36 self.vv = self.vv.inc(client_id);
37 let dot = self.vv.get_dot(client_id);
38 let new_obj = Value{val: val, dot: dot};
39
40 // overwrite all the siblings
41 self.store.insert(key.to_string(), vec![new_obj]);
42 return self
43 }
44
45 let mut frontier = self.vv.merge(&context);
46 frontier = frontier.inc(client_id);
47 let dot = frontier.get_dot(client_id);
48 let new_obj = Value{val: val, dot: dot};
49 self.vv = frontier;
50 return self.merge_siblings(key, new_obj)
51 }
Trait Implementations§
Source§impl Clone for VersionVector
impl Clone for VersionVector
Source§fn clone(&self) -> VersionVector
fn clone(&self) -> VersionVector
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for VersionVector
impl Debug for VersionVector
Source§impl Default for VersionVector
impl Default for VersionVector
Source§fn default() -> VersionVector
fn default() -> VersionVector
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for VersionVector
impl RefUnwindSafe for VersionVector
impl Send for VersionVector
impl Sync for VersionVector
impl Unpin for VersionVector
impl UnwindSafe for VersionVector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more