Add 'syncable' feature to 'db' crate to conditionally derive serialization for Partition*

This is leading up syncing with partition support.
This commit is contained in:
Grisha Kruglov 2018-06-27 19:59:19 -04:00
parent 26446ddb05
commit 687b2cf997
4 changed files with 9 additions and 1 deletions

View file

@ -19,7 +19,7 @@ build = "build/version.rs"
default = ["bundled_sqlite3", "syncable"] default = ["bundled_sqlite3", "syncable"]
bundled_sqlite3 = ["rusqlite/bundled"] bundled_sqlite3 = ["rusqlite/bundled"]
sqlcipher = ["rusqlite/sqlcipher", "mentat_db/sqlcipher"] sqlcipher = ["rusqlite/sqlcipher", "mentat_db/sqlcipher"]
syncable = ["mentat_tolstoy"] syncable = ["mentat_tolstoy", "mentat_db/syncable"]
[workspace] [workspace]
members = ["tools/cli", "ffi"] members = ["tools/cli", "ffi"]

View file

@ -6,6 +6,7 @@ workspace = ".."
[features] [features]
default = [] default = []
sqlcipher = ["rusqlite/sqlcipher"] sqlcipher = ["rusqlite/sqlcipher"]
syncable = ["serde", "serde_json", "serde_derive"]
[dependencies] [dependencies]
failure = "0.1.1" failure = "0.1.1"
@ -17,6 +18,9 @@ log = "0.4"
ordered-float = "0.5" ordered-float = "0.5"
time = "0.1" time = "0.1"
petgraph = "0.4.12" 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] [dependencies.rusqlite]
version = "0.13" version = "0.13"

View file

@ -15,6 +15,9 @@ extern crate itertools;
#[macro_use] extern crate lazy_static; #[macro_use] extern crate lazy_static;
#[macro_use] extern crate log; #[macro_use] extern crate log;
#[cfg(feature = "syncable")]
#[macro_use] extern crate serde_derive;
extern crate petgraph; extern crate petgraph;
extern crate rusqlite; extern crate rusqlite;
extern crate tabwriter; extern crate tabwriter;

View file

@ -38,6 +38,7 @@ use errors;
/// Represents one partition of the entid space. /// Represents one partition of the entid space.
#[derive(Clone,Debug,Eq,Hash,Ord,PartialOrd,PartialEq)] #[derive(Clone,Debug,Eq,Hash,Ord,PartialOrd,PartialEq)]
#[cfg_attr(feature = "syncable", derive(Serialize,Deserialize))]
pub struct Partition { pub struct Partition {
/// The first entid in the partition. /// The first entid in the partition.
pub start: i64, pub start: i64,