From c8e6a511f4df91eafb07da6935013f815e32dc2f Mon Sep 17 00:00:00 2001 From: Grisha Kruglov Date: Wed, 8 Aug 2018 14:33:53 -0700 Subject: [PATCH] Pre: Move tolstoy/errors into tolstoy-traits --- Cargo.toml | 6 +++++- src/errors.rs | 10 ++++++---- src/lib.rs | 3 +++ tests/tolstoy.rs | 5 ++++- tolstoy-traits/Cargo.toml | 22 ++++++++++++++++++++++ {tolstoy/src => tolstoy-traits}/errors.rs | 0 tolstoy-traits/lib.rs | 22 ++++++++++++++++++++++ tolstoy/Cargo.toml | 4 +++- tolstoy/src/lib.rs | 9 ++------- tolstoy/src/metadata.rs | 2 +- tolstoy/src/schema.rs | 2 +- tolstoy/src/syncer.rs | 2 +- tolstoy/src/tx_mapper.rs | 2 +- tolstoy/src/tx_processor.rs | 2 +- 14 files changed, 72 insertions(+), 19 deletions(-) create mode 100644 tolstoy-traits/Cargo.toml rename {tolstoy/src => tolstoy-traits}/errors.rs (100%) create mode 100644 tolstoy-traits/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 7945aa2f..f8d722ce 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", "mentat_db/syncable"] +syncable = ["mentat_tolstoy", "tolstoy_traits", "mentat_db/syncable"] [workspace] members = ["tools/cli", "ffi"] @@ -86,6 +86,10 @@ path = "sql-traits" path = "tolstoy" optional = true +[dependencies.tolstoy_traits] +path = "tolstoy-traits" +optional = true + [profile.release] opt-level = 3 debug = false diff --git a/src/errors.rs b/src/errors.rs index 18103a18..37a3be4c 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -38,7 +38,9 @@ use sql_traits::errors::{ }; #[cfg(feature = "syncable")] -use mentat_tolstoy; +use tolstoy_traits::errors::{ + TolstoyError, +}; pub type Result = std::result::Result; @@ -118,7 +120,7 @@ pub enum MentatError { #[cfg(feature = "syncable")] #[fail(display = "{}", _0)] - TolstoyError(#[cause] mentat_tolstoy::TolstoyError), + TolstoyError(#[cause] TolstoyError), } impl From for MentatError { @@ -170,8 +172,8 @@ impl From for MentatError { } #[cfg(feature = "syncable")] -impl From for MentatError { - fn from(error: mentat_tolstoy::TolstoyError) -> MentatError { +impl From for MentatError { + fn from(error: TolstoyError) -> MentatError { MentatError::TolstoyError(error) } } diff --git a/src/lib.rs b/src/lib.rs index 06ad3eca..ffcb3f50 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,6 +38,9 @@ extern crate mentat_sql; #[cfg(feature = "syncable")] extern crate mentat_tolstoy; +#[cfg(feature = "syncable")] +extern crate tolstoy_traits; + pub use core_traits::{ Attribute, Binding, diff --git a/tests/tolstoy.rs b/tests/tolstoy.rs index dc5ccab9..34ef0361 100644 --- a/tests/tolstoy.rs +++ b/tests/tolstoy.rs @@ -14,6 +14,9 @@ extern crate core_traits; #[cfg(feature = "syncable")] extern crate mentat_tolstoy; +#[cfg(feature = "syncable")] +extern crate tolstoy_traits; + #[cfg(feature = "syncable")] mod tests { use std::collections::BTreeMap; @@ -26,7 +29,7 @@ mod tests { TxReceiver, TxPart, }; - use mentat_tolstoy::errors::Result; + use tolstoy_traits::errors::Result; use core_traits::{ Entid, TypedValue, diff --git a/tolstoy-traits/Cargo.toml b/tolstoy-traits/Cargo.toml new file mode 100644 index 00000000..79a12203 --- /dev/null +++ b/tolstoy-traits/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "tolstoy_traits" +version = "0.0.1" +workspace = ".." + +[lib] +name = "tolstoy_traits" +path = "lib.rs" + +[dependencies] +failure = "0.1.1" +failure_derive = "0.1.1" +hyper = "0.11" +serde_json = "1.0" +uuid = { version = "0.5" } + +[dependencies.db_traits] +path = "../db-traits" + +[dependencies.rusqlite] +version = "0.13" +features = ["limits"] diff --git a/tolstoy/src/errors.rs b/tolstoy-traits/errors.rs similarity index 100% rename from tolstoy/src/errors.rs rename to tolstoy-traits/errors.rs diff --git a/tolstoy-traits/lib.rs b/tolstoy-traits/lib.rs new file mode 100644 index 00000000..3cdd9c3c --- /dev/null +++ b/tolstoy-traits/lib.rs @@ -0,0 +1,22 @@ +// Copyright 2018 Mozilla +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use +// this file except in compliance with the License. You may obtain a copy of the +// License at http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software distributed +// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. + +extern crate failure; +#[macro_use] +extern crate failure_derive; + +extern crate hyper; +extern crate rusqlite; +extern crate uuid; +extern crate serde_json; + +extern crate db_traits; + +pub mod errors; diff --git a/tolstoy/Cargo.toml b/tolstoy/Cargo.toml index d5c4a314..bfb55186 100644 --- a/tolstoy/Cargo.toml +++ b/tolstoy/Cargo.toml @@ -6,7 +6,6 @@ authors = ["Grisha Kruglov "] [dependencies] failure = "0.1.1" -failure_derive = "0.1.1" futures = "0.1" hyper = "0.11" log = "0.4" @@ -33,6 +32,9 @@ path = "../db" [dependencies.db_traits] path = "../db-traits" +[dependencies.tolstoy_traits] +path = "../tolstoy-traits" + [dependencies.rusqlite] version = "0.13" features = ["limits"] diff --git a/tolstoy/src/lib.rs b/tolstoy/src/lib.rs index 7ff9fd08..95ada1f4 100644 --- a/tolstoy/src/lib.rs +++ b/tolstoy/src/lib.rs @@ -9,8 +9,6 @@ // specific language governing permissions and limitations under the License. extern crate failure; -#[macro_use] -extern crate failure_derive; #[macro_use] extern crate lazy_static; @@ -40,14 +38,11 @@ extern crate rusqlite; extern crate uuid; #[macro_use] -pub mod errors; +extern crate tolstoy_traits; + pub mod schema; pub mod metadata; pub mod tx_processor; pub mod syncer; pub mod tx_mapper; pub use syncer::Syncer; -pub use errors::{ - TolstoyError, - Result, -}; diff --git a/tolstoy/src/metadata.rs b/tolstoy/src/metadata.rs index 8c9b6579..8eeb58ef 100644 --- a/tolstoy/src/metadata.rs +++ b/tolstoy/src/metadata.rs @@ -14,7 +14,7 @@ use rusqlite; use uuid::Uuid; use schema; -use errors::{ +use tolstoy_traits::errors::{ TolstoyError, Result, }; diff --git a/tolstoy/src/schema.rs b/tolstoy/src/schema.rs index 9bd175ff..cc7593d3 100644 --- a/tolstoy/src/schema.rs +++ b/tolstoy/src/schema.rs @@ -9,7 +9,7 @@ // specific language governing permissions and limitations under the License. use rusqlite; -use errors::Result; +use tolstoy_traits::errors::Result; pub static REMOTE_HEAD_KEY: &str = r#"remote_head"#; diff --git a/tolstoy/src/syncer.rs b/tolstoy/src/syncer.rs index 6cdf06e6..6b535094 100644 --- a/tolstoy/src/syncer.rs +++ b/tolstoy/src/syncer.rs @@ -33,7 +33,7 @@ use metadata::SyncMetadataClient; use metadata::HeadTrackable; use schema::ensure_current_version; -use errors::{ +use tolstoy_traits::errors::{ TolstoyError, Result, }; diff --git a/tolstoy/src/tx_mapper.rs b/tolstoy/src/tx_mapper.rs index e71ee7a8..a66fbe88 100644 --- a/tolstoy/src/tx_mapper.rs +++ b/tolstoy/src/tx_mapper.rs @@ -16,7 +16,7 @@ use core_traits::{ Entid, }; -use errors::{ +use tolstoy_traits::errors::{ TolstoyError, Result, }; diff --git a/tolstoy/src/tx_processor.rs b/tolstoy/src/tx_processor.rs index d602de70..fcf482a4 100644 --- a/tolstoy/src/tx_processor.rs +++ b/tolstoy/src/tx_processor.rs @@ -11,7 +11,7 @@ use std::iter::Peekable; use rusqlite; -use errors::{ +use tolstoy_traits::errors::{ Result, };