From e4b9e4e24d006373a20cfcbdac9dba5e399ee182 Mon Sep 17 00:00:00 2001 From: Trinity Pointard Date: Sun, 2 May 2021 23:13:08 +0200 Subject: rename types to CamelCase --- src/table/crdt/bool.rs | 2 +- src/table/crdt/crdt.rs | 14 +++++++------- src/table/crdt/lww.rs | 10 +++++----- src/table/crdt/lww_map.rs | 14 +++++++------- src/table/crdt/map.rs | 8 ++++---- 5 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src/table/crdt') diff --git a/src/table/crdt/bool.rs b/src/table/crdt/bool.rs index 1989c92e..53af8f82 100644 --- a/src/table/crdt/bool.rs +++ b/src/table/crdt/bool.rs @@ -27,7 +27,7 @@ impl From for Bool { } } -impl CRDT for Bool { +impl Crdt for Bool { fn merge(&mut self, other: &Self) { self.0 = self.0 || other.0; } diff --git a/src/table/crdt/crdt.rs b/src/table/crdt/crdt.rs index 7abe8ba9..a8f1b9aa 100644 --- a/src/table/crdt/crdt.rs +++ b/src/table/crdt/crdt.rs @@ -18,7 +18,7 @@ use garage_util::data::*; /// Moreover, the relationship `≥` defined by `a ≥ b ⇔ ∃c. a = b ⊔ c` must be a partial order. /// This implies a few properties such as: if `a ⊔ b ≠ a`, then there is no `c` such that `(a ⊔ b) ⊔ c = a`, /// as this would imply a cycle in the partial order. -pub trait CRDT { +pub trait Crdt { /// Merge the two datastructures according to the CRDT rules. /// `self` is modified to contain the merged CRDT value. `other` is not modified. /// @@ -31,16 +31,16 @@ pub trait CRDT { /// All types that implement `Ord` (a total order) can also implement a trivial CRDT /// defined by the merge rule: `a ⊔ b = max(a, b)`. Implement this trait for your type /// to enable this behavior. -pub trait AutoCRDT: Ord + Clone + std::fmt::Debug { +pub trait AutoCrdt: Ord + Clone + std::fmt::Debug { /// WARN_IF_DIFFERENT: emit a warning when values differ. Set this to true if /// different values in your application should never happen. Set this to false /// if you are actually relying on the semantics of `a ⊔ b = max(a, b)`. const WARN_IF_DIFFERENT: bool; } -impl CRDT for T +impl Crdt for T where - T: AutoCRDT, + T: AutoCrdt, { fn merge(&mut self, other: &Self) { if Self::WARN_IF_DIFFERENT && self != other { @@ -58,14 +58,14 @@ where } } -impl AutoCRDT for String { +impl AutoCrdt for String { const WARN_IF_DIFFERENT: bool = true; } -impl AutoCRDT for bool { +impl AutoCrdt for bool { const WARN_IF_DIFFERENT: bool = true; } -impl AutoCRDT for FixedBytes32 { +impl AutoCrdt for FixedBytes32 { const WARN_IF_DIFFERENT: bool = true; } diff --git a/src/table/crdt/lww.rs b/src/table/crdt/lww.rs index 3b1b2406..be197d88 100644 --- a/src/table/crdt/lww.rs +++ b/src/table/crdt/lww.rs @@ -36,14 +36,14 @@ use crate::crdt::crdt::*; /// This scheme is used by AWS S3 or Soundcloud and often without knowing /// in enterprise when reconciliating databases with ad-hoc scripts. #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] -pub struct LWW { +pub struct Lww { ts: u64, v: T, } -impl LWW +impl Lww where - T: CRDT, + T: Crdt, { /// Creates a new CRDT /// @@ -99,9 +99,9 @@ where } } -impl CRDT for LWW +impl Crdt for Lww where - T: Clone + CRDT, + T: Clone + Crdt, { fn merge(&mut self, other: &Self) { if other.ts > self.ts { diff --git a/src/table/crdt/lww_map.rs b/src/table/crdt/lww_map.rs index 4ed26809..36bbf667 100644 --- a/src/table/crdt/lww_map.rs +++ b/src/table/crdt/lww_map.rs @@ -22,14 +22,14 @@ use crate::crdt::crdt::*; /// the serialization cost `O(n)` would still have to be paid at each modification, so we are /// actually not losing anything here. #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] -pub struct LWWMap { +pub struct LwwMap { vals: Vec<(K, u64, V)>, } -impl LWWMap +impl LwwMap where K: Ord, - V: CRDT, + V: Crdt, { /// Create a new empty map CRDT pub fn new() -> Self { @@ -125,10 +125,10 @@ where } } -impl CRDT for LWWMap +impl Crdt for LwwMap where K: Clone + Ord, - V: Clone + CRDT, + V: Clone + Crdt, { fn merge(&mut self, other: &Self) { for (k, ts2, v2) in other.vals.iter() { @@ -150,10 +150,10 @@ where } } -impl Default for LWWMap +impl Default for LwwMap where K: Ord, - V: CRDT, + V: Crdt, { fn default() -> Self { Self::new() diff --git a/src/table/crdt/map.rs b/src/table/crdt/map.rs index c4dd1613..e2aee40a 100644 --- a/src/table/crdt/map.rs +++ b/src/table/crdt/map.rs @@ -22,7 +22,7 @@ pub struct Map { impl Map where K: Clone + Ord, - V: Clone + CRDT, + V: Clone + Crdt, { /// Create a new empty map CRDT pub fn new() -> Self { @@ -69,10 +69,10 @@ where } } -impl CRDT for Map +impl Crdt for Map where K: Clone + Ord, - V: Clone + CRDT, + V: Clone + Crdt, { fn merge(&mut self, other: &Self) { for (k, v2) in other.vals.iter() { @@ -91,7 +91,7 @@ where impl Default for Map where K: Clone + Ord, - V: Clone + CRDT, + V: Clone + Crdt, { fn default() -> Self { Self::new() -- cgit v1.2.3