From 687b2cf99714073f83855464d6df04baf540ecc5 Mon Sep 17 00:00:00 2001 From: Grisha Kruglov Date: Wed, 27 Jun 2018 19:59:19 -0400 Subject: [PATCH] Add 'syncable' feature to 'db' crate to conditionally derive serialization for Partition* This is leading up syncing with partition support. --- Cargo.toml | 2 +- db/Cargo.toml | 4 ++++ db/src/lib.rs | 3 +++ db/src/types.rs | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d6b0534b..f408a849 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ build = "build/version.rs" default = ["bundled_sqlite3", "syncable"] bundled_sqlite3 = ["rusqlite/bundled"] sqlcipher = ["rusqlite/sqlcipher", "mentat_db/sqlcipher"] -syncable = ["mentat_tolstoy"] +syncable = ["mentat_tolstoy", "mentat_db/syncable"] [workspace] members = ["tools/cli", "ffi"] diff --git a/db/Cargo.toml b/db/Cargo.toml index f89121b7..3cb74d58 100644 --- a/db/Cargo.toml +++ b/db/Cargo.toml @@ -6,6 +6,7 @@ workspace = ".." [features] default = [] sqlcipher = ["rusqlite/sqlcipher"] +syncable = ["serde", "serde_json", "serde_derive"] [dependencies] failure = "0.1.1" @@ -17,6 +18,9 @@ log = "0.4" ordered-float = "0.5" time = "0.1" petgraph = "0.4.12" +serde = { version = "1.0", optional = true } +serde_json = { version = "1.0", optional = true } +serde_derive = { version = "1.0", optional = true } [dependencies.rusqlite] version = "0.13" diff --git a/db/src/lib.rs b/db/src/lib.rs index c42b8eaf..f88aabf5 100644 --- a/db/src/lib.rs +++ b/db/src/lib.rs @@ -15,6 +15,9 @@ extern crate itertools; #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; +#[cfg(feature = "syncable")] +#[macro_use] extern crate serde_derive; + extern crate petgraph; extern crate rusqlite; extern crate tabwriter; diff --git a/db/src/types.rs b/db/src/types.rs index f9404365..8d951e54 100644 --- a/db/src/types.rs +++ b/db/src/types.rs @@ -38,6 +38,7 @@ use errors; /// Represents one partition of the entid space. #[derive(Clone,Debug,Eq,Hash,Ord,PartialOrd,PartialEq)] +#[cfg_attr(feature = "syncable", derive(Serialize,Deserialize))] pub struct Partition { /// The first entid in the partition. pub start: i64,