From a57ba5d79f76931d6bf34ae6ff20b8c5826a9804 Mon Sep 17 00:00:00 2001 From: Grisha Kruglov Date: Wed, 8 Aug 2018 10:35:06 -0700 Subject: [PATCH] Pre: Move Entid and KnownEntid into core_traits --- Cargo.toml | 3 + core-traits/Cargo.toml | 11 ++++ core-traits/lib.rs | 55 +++++++++++++++++++ core/Cargo.toml | 3 + core/src/cache.rs | 5 +- core/src/lib.rs | 9 ++- core/src/tx_report.rs | 5 +- core/src/types.rs | 43 ++------------- db/Cargo.toml | 3 + db/src/cache.rs | 5 +- db/src/db.rs | 10 +++- db/src/debug.rs | 5 ++ db/src/entids.rs | 4 +- db/src/errors.rs | 6 +- db/src/internal_types.rs | 6 +- db/src/lib.rs | 1 + db/src/metadata.rs | 6 +- db/src/schema.rs | 8 ++- db/src/timelines.rs | 7 ++- db/src/tx.rs | 7 ++- db/src/tx_checking.rs | 5 +- db/src/tx_observer.rs | 5 +- db/src/types.rs | 5 +- db/src/upsert_resolution.rs | 5 +- db/src/watcher.rs | 5 +- query-algebrizer/Cargo.toml | 3 + query-algebrizer/src/clauses/mod.rs | 7 ++- query-algebrizer/src/clauses/pattern.rs | 5 +- query-algebrizer/src/lib.rs | 6 +- query-algebrizer/src/types.rs | 5 +- query-algebrizer/tests/fulltext.rs | 1 + query-algebrizer/tests/ground.rs | 1 + query-algebrizer/tests/predicate.rs | 1 + query-algebrizer/tests/type_reqs.rs | 1 + query-algebrizer/tests/utils/mod.rs | 5 +- query-projector/Cargo.toml | 3 + query-projector/src/lib.rs | 1 + .../src/projectors/pull_two_stage.rs | 2 +- query-projector/src/pull.rs | 5 +- query-projector/tests/aggregates.rs | 6 +- query-pull/Cargo.toml | 3 + query-pull/src/errors.rs | 2 +- query-pull/src/lib.rs | 6 +- query-sql/Cargo.toml | 3 + query-sql/src/lib.rs | 7 ++- query-translator/Cargo.toml | 3 + query-translator/tests/translate.rs | 6 +- src/conn.rs | 7 ++- src/lib.rs | 8 ++- src/query.rs | 7 ++- src/query_builder.rs | 5 +- src/store.rs | 5 +- src/vocabulary.rs | 2 +- tests/query.rs | 8 ++- tests/tolstoy.rs | 5 +- tolstoy/Cargo.toml | 3 + tolstoy/src/lib.rs | 1 + tolstoy/src/syncer.rs | 5 +- tolstoy/src/tx_mapper.rs | 5 +- tolstoy/src/tx_processor.rs | 5 +- 60 files changed, 284 insertions(+), 91 deletions(-) create mode 100644 core-traits/Cargo.toml create mode 100644 core-traits/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 72c9d8ed..eb44ef5a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,6 +43,9 @@ features = ["limits"] [dependencies.edn] path = "edn" +[dependencies.core_traits] +path = "core-traits" + [dependencies.mentat_core] path = "core" diff --git a/core-traits/Cargo.toml b/core-traits/Cargo.toml new file mode 100644 index 00000000..a3ead9ce --- /dev/null +++ b/core-traits/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "core_traits" +version = "0.0.1" +workspace = ".." + +[lib] +name = "core_traits" +path = "lib.rs" + +[dependencies.edn] +path = "../edn" diff --git a/core-traits/lib.rs b/core-traits/lib.rs new file mode 100644 index 00000000..1ec67a02 --- /dev/null +++ b/core-traits/lib.rs @@ -0,0 +1,55 @@ +// 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 edn; + +use edn::entities::{ + AttributePlace, + EntityPlace, + EntidOrIdent, + ValuePlace, + TransactableValueMarker, +}; + +/// Represents one entid in the entid space. +/// +/// Per https://www.sqlite.org/datatype3.html (see also http://stackoverflow.com/a/8499544), SQLite +/// stores signed integers up to 64 bits in size. Since u32 is not appropriate for our use case, we +/// use i64 rather than manually truncating u64 to u63 and casting to i64 throughout the codebase. +pub type Entid = i64; + +/// An entid that's either already in the store, or newly allocated to a tempid. +/// TODO: we'd like to link this in some way to the lifetime of a particular PartitionMap. +#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)] +pub struct KnownEntid(pub Entid); + +impl From for Entid { + fn from(k: KnownEntid) -> Entid { + k.0 + } +} + +impl Into> for KnownEntid { + fn into(self) -> EntityPlace { + EntityPlace::Entid(EntidOrIdent::Entid(self.0)) + } +} + +impl Into for KnownEntid { + fn into(self) -> AttributePlace { + AttributePlace::Entid(EntidOrIdent::Entid(self.0)) + } +} + +impl Into> for KnownEntid { + fn into(self) -> ValuePlace { + ValuePlace::Entid(EntidOrIdent::Entid(self.0)) + } +} diff --git a/core/Cargo.toml b/core/Cargo.toml index 4cb4dfe5..6aa5cf5b 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -14,6 +14,9 @@ uuid = { version = "0.5", features = ["v4", "serde"] } serde = { version = "1.0", features = ["rc"] } serde_derive = "1.0" +[dependencies.core_traits] +path = "../core-traits" + [dependencies.edn] path = "../edn" features = ["serde_support"] diff --git a/core/src/cache.rs b/core/src/cache.rs index 61b23656..44e7aaf5 100644 --- a/core/src/cache.rs +++ b/core/src/cache.rs @@ -14,8 +14,11 @@ use std::collections::{ BTreeSet, }; -use ::{ +use core_traits::{ Entid, +}; + +use ::{ Schema, TypedValue, }; diff --git a/core/src/lib.rs b/core/src/lib.rs index 5e406554..012b4d6f 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -16,6 +16,8 @@ extern crate ordered_float; extern crate uuid; extern crate serde; +extern crate core_traits; + #[macro_use] extern crate lazy_static; @@ -24,6 +26,11 @@ extern crate serde_derive; extern crate edn; +use core_traits::{ + Entid, + KnownEntid, +}; + pub mod values; mod cache; @@ -70,8 +77,6 @@ pub use tx_report::{ pub use types::{ Binding, - Entid, - KnownEntid, StructuredMap, TypedValue, ValueType, diff --git a/core/src/tx_report.rs b/core/src/tx_report.rs index 1b30278f..b88f0f92 100644 --- a/core/src/tx_report.rs +++ b/core/src/tx_report.rs @@ -14,9 +14,12 @@ use std::collections::{ BTreeMap, }; +use core_traits::{ + Entid, +}; + use ::{ DateTime, - Entid, Utc, }; diff --git a/core/src/types.rs b/core/src/types.rs index 15aec5ee..0d6b9749 100644 --- a/core/src/types.rs +++ b/core/src/types.rs @@ -57,32 +57,15 @@ use ::edn::{ }; use ::edn::entities::{ - AttributePlace, - EntidOrIdent, - EntityPlace, - ValuePlace, TransactableValueMarker, }; use values; -/// Represents one entid in the entid space. -/// -/// Per https://www.sqlite.org/datatype3.html (see also http://stackoverflow.com/a/8499544), SQLite -/// stores signed integers up to 64 bits in size. Since u32 is not appropriate for our use case, we -/// use i64 rather than manually truncating u64 to u63 and casting to i64 throughout the codebase. -pub type Entid = i64; - -/// An entid that's either already in the store, or newly allocated to a tempid. -/// TODO: we'd like to link this in some way to the lifetime of a particular PartitionMap. -#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)] -pub struct KnownEntid(pub Entid); - -impl From for Entid { - fn from(k: KnownEntid) -> Entid { - k.0 - } -} +use core_traits::{ + Entid, + KnownEntid, +}; impl From for TypedValue { fn from(k: KnownEntid) -> TypedValue { @@ -90,24 +73,6 @@ impl From for TypedValue { } } -impl Into> for KnownEntid { - fn into(self) -> EntityPlace { - EntityPlace::Entid(EntidOrIdent::Entid(self.0)) - } -} - -impl Into for KnownEntid { - fn into(self) -> AttributePlace { - AttributePlace::Entid(EntidOrIdent::Entid(self.0)) - } -} - -impl Into> for KnownEntid { - fn into(self) -> ValuePlace { - ValuePlace::Entid(EntidOrIdent::Entid(self.0)) - } -} - /// The attribute of each Mentat assertion has a :db/valueType constraining the value to a /// particular set. Mentat recognizes the following :db/valueType values. #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialOrd, PartialEq)] diff --git a/db/Cargo.toml b/db/Cargo.toml index 3cb74d58..9fa88ed1 100644 --- a/db/Cargo.toml +++ b/db/Cargo.toml @@ -32,6 +32,9 @@ path = "../edn" [dependencies.mentat_core] path = "../core" +[dependencies.core_traits] +path = "../core-traits" + [dependencies.mentat_sql] path = "../sql" diff --git a/db/src/cache.rs b/db/src/cache.rs index ef1a7bb4..1c1ce5f2 100644 --- a/db/src/cache.rs +++ b/db/src/cache.rs @@ -78,10 +78,13 @@ use failure::{ use rusqlite; +use core_traits::{ + Entid, +}; + use mentat_core::{ Binding, CachedAttributes, - Entid, HasSchema, Schema, TypedValue, diff --git a/db/src/db.rs b/db/src/db.rs index ffe46558..df4c00d7 100644 --- a/db/src/db.rs +++ b/db/src/db.rs @@ -40,11 +40,15 @@ use edn::{ }; use entids; + +use core_traits::{ + Entid, +}; + use mentat_core::{ attribute, Attribute, AttributeBitFlags, - Entid, FromMicros, IdentMap, Schema, @@ -1221,10 +1225,12 @@ mod tests { use edn::entities::{ OpType, }; + use core_traits::{ + KnownEntid, + }; use mentat_core::{ HasSchema, Keyword, - KnownEntid, attribute, }; use mentat_core::util::Either::*; diff --git a/db/src/debug.rs b/db/src/debug.rs index e84ea65e..da2fedef 100644 --- a/db/src/debug.rs +++ b/db/src/debug.rs @@ -66,6 +66,11 @@ use db::{read_attribute_map,read_ident_map}; use edn; use entids; use errors::Result; + +use core_traits::{ + Entid, +}; + use mentat_core::{ HasSchema, SQLValueType, diff --git a/db/src/entids.rs b/db/src/entids.rs index 44b73ccd..05f7d664 100644 --- a/db/src/entids.rs +++ b/db/src/entids.rs @@ -14,7 +14,9 @@ /// /// Used through-out the transactor to match core DB constructs. -use types::{Entid}; +use core_traits::{ + Entid, +}; // Added in SQL schema v1. pub const DB_IDENT: Entid = 1; diff --git a/db/src/errors.rs b/db/src/errors.rs index 85ea188d..5ed46924 100644 --- a/db/src/errors.rs +++ b/db/src/errors.rs @@ -26,11 +26,13 @@ use rusqlite; use edn::entities::{ TempId, }; -use mentat_core::{ + +use core_traits::{ + Entid, KnownEntid, }; + use types::{ - Entid, TypedValue, ValueType, }; diff --git a/db/src/internal_types.rs b/db/src/internal_types.rs index ff417c7c..98a958dd 100644 --- a/db/src/internal_types.rs +++ b/db/src/internal_types.rs @@ -18,7 +18,10 @@ use std::collections::{ HashMap, }; -use mentat_core::KnownEntid; +use core_traits::{ + Entid, + KnownEntid, +}; use mentat_core::util::Either; @@ -48,7 +51,6 @@ use types::{ Attribute, AVMap, AVPair, - Entid, Schema, TransactableValue, TypedValue, diff --git a/db/src/lib.rs b/db/src/lib.rs index 22f5e944..fd52f1cd 100644 --- a/db/src/lib.rs +++ b/db/src/lib.rs @@ -25,6 +25,7 @@ extern crate time; #[macro_use] extern crate edn; #[macro_use] extern crate mentat_core; +extern crate core_traits; extern crate mentat_sql; use std::iter::repeat; diff --git a/db/src/metadata.rs b/db/src/metadata.rs index ab257f7d..189a840d 100644 --- a/db/src/metadata.rs +++ b/db/src/metadata.rs @@ -38,9 +38,13 @@ use errors::{ DbErrorKind, Result, }; + +use core_traits::{ + Entid, +}; + use mentat_core::{ attribute, - Entid, Schema, AttributeMap, TypedValue, diff --git a/db/src/schema.rs b/db/src/schema.rs index d7db8384..29e9a7ce 100644 --- a/db/src/schema.rs +++ b/db/src/schema.rs @@ -17,14 +17,18 @@ use errors::{ Result, }; use edn::symbols; + +use core_traits::{ + Entid, + KnownEntid, +}; + use mentat_core::{ attribute, Attribute, - Entid, EntidMap, HasSchema, IdentMap, - KnownEntid, Schema, AttributeMap, TypedValue, diff --git a/db/src/timelines.rs b/db/src/timelines.rs index 4646a23e..971e987e 100644 --- a/db/src/timelines.rs +++ b/db/src/timelines.rs @@ -17,11 +17,14 @@ use errors::{ Result, }; -use mentat_core::{ +use core_traits::{ Entid, + KnownEntid, +}; + +use mentat_core::{ Schema, TypedValue, - KnownEntid, }; use edn::{ diff --git a/db/src/tx.rs b/db/src/tx.rs index dc58b6e7..09badf21 100644 --- a/db/src/tx.rs +++ b/db/src/tx.rs @@ -89,9 +89,13 @@ use internal_types::{ use mentat_core::util::Either; +use core_traits::{ + Entid, + KnownEntid, +}; + use mentat_core::{ DateTime, - KnownEntid, Schema, TxReport, Utc, @@ -116,7 +120,6 @@ use types::{ AVMap, AVPair, Attribute, - Entid, PartitionMap, TransactableValue, TypedValue, diff --git a/db/src/tx_checking.rs b/db/src/tx_checking.rs index 64b1eb78..0d84b96d 100644 --- a/db/src/tx_checking.rs +++ b/db/src/tx_checking.rs @@ -13,8 +13,11 @@ use std::collections::{ BTreeMap, }; -use mentat_core::{ +use core_traits::{ Entid, +}; + +use mentat_core::{ TypedValue, ValueType, }; diff --git a/db/src/tx_observer.rs b/db/src/tx_observer.rs index 10c49bb8..589752be 100644 --- a/db/src/tx_observer.rs +++ b/db/src/tx_observer.rs @@ -26,8 +26,11 @@ use indexmap::{ IndexMap, }; -use mentat_core::{ +use core_traits::{ Entid, +}; + +use mentat_core::{ Schema, TypedValue, }; diff --git a/db/src/types.rs b/db/src/types.rs index fb89fb0f..208e0116 100644 --- a/db/src/types.rs +++ b/db/src/types.rs @@ -26,11 +26,14 @@ use std::ops::{ extern crate mentat_core; +use core_traits::{ + Entid, +}; + pub use self::mentat_core::{ Attribute, AttributeBitFlags, DateTime, - Entid, Schema, TypedValue, Utc, diff --git a/db/src/upsert_resolution.rs b/db/src/upsert_resolution.rs index 4aef115c..2d9a6816 100644 --- a/db/src/upsert_resolution.rs +++ b/db/src/upsert_resolution.rs @@ -40,10 +40,13 @@ use internal_types::{ use mentat_core::util::Either::*; +use core_traits::{ + Entid, +}; + use mentat_core::{ attribute, Attribute, - Entid, Schema, TypedValue, }; diff --git a/db/src/watcher.rs b/db/src/watcher.rs index d646fbde..1deb4585 100644 --- a/db/src/watcher.rs +++ b/db/src/watcher.rs @@ -17,8 +17,11 @@ // - When observers are registered we want to flip some flags as writes occur so that we can // notifying them outside the transaction. -use mentat_core::{ +use core_traits::{ Entid, +}; + +use mentat_core::{ Schema, TypedValue, }; diff --git a/query-algebrizer/Cargo.toml b/query-algebrizer/Cargo.toml index 5d44143e..0ba96fa2 100644 --- a/query-algebrizer/Cargo.toml +++ b/query-algebrizer/Cargo.toml @@ -10,6 +10,9 @@ failure_derive = "0.1.1" [dependencies.mentat_core] path = "../core" +[dependencies.core_traits] +path = "../core-traits" + [dependencies.mentat_query] path = "../query" diff --git a/query-algebrizer/src/clauses/mod.rs b/query-algebrizer/src/clauses/mod.rs index 2fca66b0..31e259b7 100644 --- a/query-algebrizer/src/clauses/mod.rs +++ b/query-algebrizer/src/clauses/mod.rs @@ -25,12 +25,15 @@ use std::fmt::{ Formatter, }; +use core_traits::{ + Entid, + KnownEntid, +}; + use mentat_core::{ Attribute, Cloned, - Entid, HasSchema, - KnownEntid, Schema, TypedValue, ValueType, diff --git a/query-algebrizer/src/clauses/pattern.rs b/query-algebrizer/src/clauses/pattern.rs index 7cf62c6a..bd06fcb3 100644 --- a/query-algebrizer/src/clauses/pattern.rs +++ b/query-algebrizer/src/clauses/pattern.rs @@ -8,9 +8,12 @@ // CONDITIONS OF ANY KIND, either express or implied. See the License for the // specific language governing permissions and limitations under the License. +use core_traits::{ + Entid, +}; + use mentat_core::{ Cloned, - Entid, HasSchema, TypedValue, ValueType, diff --git a/query-algebrizer/src/lib.rs b/query-algebrizer/src/lib.rs index 09e18bdc..87aa7d97 100644 --- a/query-algebrizer/src/lib.rs +++ b/query-algebrizer/src/lib.rs @@ -13,6 +13,7 @@ extern crate failure; #[macro_use] extern crate failure_derive; extern crate mentat_core; +extern crate core_traits; extern crate mentat_query; use std::collections::BTreeSet; @@ -25,9 +26,12 @@ mod types; mod validate; mod clauses; +use core_traits::{ + Entid, +}; + use mentat_core::{ CachedAttributes, - Entid, Schema, TypedValue, ValueType, diff --git a/query-algebrizer/src/types.rs b/query-algebrizer/src/types.rs index 11d33fae..0cc018ef 100644 --- a/query-algebrizer/src/types.rs +++ b/query-algebrizer/src/types.rs @@ -14,8 +14,11 @@ use std::fmt::{ Formatter, }; -use mentat_core::{ +use core_traits::{ Entid, +}; + +use mentat_core::{ TypedValue, ValueRc, ValueType, diff --git a/query-algebrizer/tests/fulltext.rs b/query-algebrizer/tests/fulltext.rs index 02bc493f..3c735dec 100644 --- a/query-algebrizer/tests/fulltext.rs +++ b/query-algebrizer/tests/fulltext.rs @@ -9,6 +9,7 @@ // specific language governing permissions and limitations under the License. extern crate mentat_core; +extern crate core_traits; extern crate mentat_query; extern crate mentat_query_algebrizer; diff --git a/query-algebrizer/tests/ground.rs b/query-algebrizer/tests/ground.rs index a78c9a09..447fa1fa 100644 --- a/query-algebrizer/tests/ground.rs +++ b/query-algebrizer/tests/ground.rs @@ -9,6 +9,7 @@ // specific language governing permissions and limitations under the License. extern crate mentat_core; +extern crate core_traits; extern crate mentat_query; extern crate mentat_query_algebrizer; diff --git a/query-algebrizer/tests/predicate.rs b/query-algebrizer/tests/predicate.rs index 8724b145..0e5e2922 100644 --- a/query-algebrizer/tests/predicate.rs +++ b/query-algebrizer/tests/predicate.rs @@ -9,6 +9,7 @@ // specific language governing permissions and limitations under the License. extern crate mentat_core; +extern crate core_traits; extern crate mentat_query; extern crate mentat_query_algebrizer; diff --git a/query-algebrizer/tests/type_reqs.rs b/query-algebrizer/tests/type_reqs.rs index b2cd66a1..3bdca15a 100644 --- a/query-algebrizer/tests/type_reqs.rs +++ b/query-algebrizer/tests/type_reqs.rs @@ -9,6 +9,7 @@ // specific language governing permissions and limitations under the License. extern crate mentat_core; +extern crate core_traits; extern crate mentat_query; extern crate mentat_query_algebrizer; diff --git a/query-algebrizer/tests/utils/mod.rs b/query-algebrizer/tests/utils/mod.rs index fb4e5c4f..488f9f58 100644 --- a/query-algebrizer/tests/utils/mod.rs +++ b/query-algebrizer/tests/utils/mod.rs @@ -13,9 +13,12 @@ // this module will get warnings otherwise). #![allow(dead_code)] +use core_traits::{ + Entid, +}; + use mentat_core::{ Attribute, - Entid, Schema, ValueType, }; diff --git a/query-projector/Cargo.toml b/query-projector/Cargo.toml index be414ef0..7be36be2 100644 --- a/query-projector/Cargo.toml +++ b/query-projector/Cargo.toml @@ -12,6 +12,9 @@ indexmap = "1" version = "0.13" features = ["limits"] +[dependencies.core_traits] +path = "../core-traits" + [dependencies.mentat_core] path = "../core" diff --git a/query-projector/src/lib.rs b/query-projector/src/lib.rs index 0e345fe7..18177f17 100644 --- a/query-projector/src/lib.rs +++ b/query-projector/src/lib.rs @@ -16,6 +16,7 @@ extern crate indexmap; extern crate rusqlite; extern crate mentat_core; +extern crate core_traits; extern crate mentat_db; // For value conversion. extern crate mentat_query; extern crate mentat_query_algebrizer; diff --git a/query-projector/src/projectors/pull_two_stage.rs b/query-projector/src/projectors/pull_two_stage.rs index f7197c38..63de6401 100644 --- a/query-projector/src/projectors/pull_two_stage.rs +++ b/query-projector/src/projectors/pull_two_stage.rs @@ -18,7 +18,7 @@ use mentat_query_pull::{ Puller, }; -use mentat_core::{ +use core_traits::{ Entid, }; diff --git a/query-projector/src/pull.rs b/query-projector/src/pull.rs index b0ee05e1..040acec7 100644 --- a/query-projector/src/pull.rs +++ b/query-projector/src/pull.rs @@ -13,9 +13,12 @@ use std::collections::{ BTreeSet, }; +use core_traits::{ + Entid, +}; + use mentat_core::{ Binding, - Entid, Schema, StructuredMap, TypedValue, diff --git a/query-projector/tests/aggregates.rs b/query-projector/tests/aggregates.rs index d2d676ea..e7bc03a1 100644 --- a/query-projector/tests/aggregates.rs +++ b/query-projector/tests/aggregates.rs @@ -9,13 +9,17 @@ // specific language governing permissions and limitations under the License. extern crate mentat_core; +extern crate core_traits; extern crate mentat_query; extern crate mentat_query_algebrizer; extern crate mentat_query_projector; +use core_traits::{ + Entid, +}; + use mentat_core::{ Attribute, - Entid, Schema, ValueType, }; diff --git a/query-pull/Cargo.toml b/query-pull/Cargo.toml index fe7b44c7..6c037461 100644 --- a/query-pull/Cargo.toml +++ b/query-pull/Cargo.toml @@ -14,6 +14,9 @@ features = ["limits"] [dependencies.mentat_core] path = "../core" +[dependencies.core_traits] +path = "../core-traits" + [dependencies.mentat_db] path = "../db" diff --git a/query-pull/src/errors.rs b/query-pull/src/errors.rs index 4ec4f221..3705d269 100644 --- a/query-pull/src/errors.rs +++ b/query-pull/src/errors.rs @@ -14,7 +14,7 @@ use mentat_db::{ DbError, }; -use mentat_core::{ +use core_traits::{ Entid, }; diff --git a/query-pull/src/lib.rs b/query-pull/src/lib.rs index 39b6e903..2442144a 100644 --- a/query-pull/src/lib.rs +++ b/query-pull/src/lib.rs @@ -65,6 +65,7 @@ extern crate failure_derive; extern crate rusqlite; extern crate mentat_core; +extern crate core_traits; extern crate mentat_db; extern crate mentat_query; extern crate mentat_query_algebrizer; @@ -80,10 +81,13 @@ use std::iter::{ once, }; +use core_traits::{ + Entid, +}; + use mentat_core::{ Binding, Cloned, - Entid, HasSchema, Keyword, Schema, diff --git a/query-sql/Cargo.toml b/query-sql/Cargo.toml index 72cfaee5..258f27b8 100644 --- a/query-sql/Cargo.toml +++ b/query-sql/Cargo.toml @@ -5,6 +5,9 @@ workspace = ".." [dependencies] +[dependencies.core_traits] +path = "../core-traits" + [dependencies.mentat_core] path = "../core" diff --git a/query-sql/src/lib.rs b/query-sql/src/lib.rs index 32a9ae60..a22b5cb4 100644 --- a/query-sql/src/lib.rs +++ b/query-sql/src/lib.rs @@ -9,13 +9,18 @@ // specific language governing permissions and limitations under the License. #[macro_use] extern crate mentat_core; +extern crate core_traits; extern crate mentat_query; extern crate mentat_query_algebrizer; extern crate mentat_sql; use std::boxed::Box; -use mentat_core::{ + +use core_traits::{ Entid, +}; + +use mentat_core::{ SQLTypeAffinity, TypedValue, ValueType, diff --git a/query-translator/Cargo.toml b/query-translator/Cargo.toml index b77b449b..16bc87c1 100644 --- a/query-translator/Cargo.toml +++ b/query-translator/Cargo.toml @@ -10,6 +10,9 @@ failure_derive = "0.1.1" [dependencies.mentat_core] path = "../core" +[dependencies.core_traits] +path = "../core-traits" + [dependencies.mentat_sql] path = "../sql" diff --git a/query-translator/tests/translate.rs b/query-translator/tests/translate.rs index 30306904..ae2ba48d 100644 --- a/query-translator/tests/translate.rs +++ b/query-translator/tests/translate.rs @@ -9,6 +9,7 @@ // specific language governing permissions and limitations under the License. extern crate mentat_core; +extern crate core_traits; extern crate mentat_query; extern crate mentat_query_algebrizer; extern crate mentat_query_projector; @@ -25,9 +26,12 @@ use mentat_query::{ Variable, }; +use core_traits::{ + Entid, +}; + use mentat_core::{ Attribute, - Entid, Schema, TypedValue, ValueType, diff --git a/src/conn.rs b/src/conn.rs index 5a56e0f5..a0c9d93f 100644 --- a/src/conn.rs +++ b/src/conn.rs @@ -45,11 +45,14 @@ use edn::{ InternSet, }; +pub use core_traits::{ + Entid, + KnownEntid, +}; + use mentat_core::{ Attribute, - Entid, HasSchema, - KnownEntid, Keyword, Schema, StructuredMap, diff --git a/src/lib.rs b/src/lib.rs index 9e12f38a..eee2df5d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,6 +23,7 @@ extern crate uuid; pub extern crate edn; extern crate mentat_core; +extern crate core_traits; extern crate mentat_db; extern crate mentat_query; extern crate mentat_query_algebrizer; @@ -34,14 +35,17 @@ extern crate mentat_sql; #[cfg(feature = "syncable")] extern crate mentat_tolstoy; +pub use core_traits::{ + Entid, + KnownEntid, +}; + pub use mentat_core::{ Attribute, Binding, DateTime, - Entid, HasSchema, Keyword, - KnownEntid, Schema, StructuredMap, TxReport, diff --git a/src/query.rs b/src/query.rs index a4f4a979..ed35ac97 100644 --- a/src/query.rs +++ b/src/query.rs @@ -13,11 +13,14 @@ use rusqlite::types::ToSql; use std::rc::Rc; +use core_traits::{ + Entid, + KnownEntid, +}; + use mentat_core::{ Binding, - Entid, HasSchema, - KnownEntid, Schema, TypedValue, }; diff --git a/src/query_builder.rs b/src/query_builder.rs index 6be1d2e0..8e0a386b 100644 --- a/src/query_builder.rs +++ b/src/query_builder.rs @@ -13,9 +13,12 @@ use std::collections::{ BTreeMap, }; +pub use core_traits::{ + Entid, +}; + use mentat_core::{ DateTime, - Entid, Keyword, Binding, TypedValue, diff --git a/src/store.rs b/src/store.rs index 314e0a48..a58a6840 100644 --- a/src/store.rs +++ b/src/store.rs @@ -26,8 +26,11 @@ use rusqlite; use edn; -use mentat_core::{ +use core_traits::{ Entid, +}; + +use mentat_core::{ Keyword, StructuredMap, TxReport, diff --git a/src/vocabulary.rs b/src/vocabulary.rs index b3cb6f24..8eb277fa 100644 --- a/src/vocabulary.rs +++ b/src/vocabulary.rs @@ -99,7 +99,7 @@ use mentat_core::attribute::{ Unique, }; -use mentat_core::{ +use core_traits::{ KnownEntid, }; diff --git a/tests/query.rs b/tests/query.rs index 6cbe188e..c52d4a74 100644 --- a/tests/query.rs +++ b/tests/query.rs @@ -14,6 +14,7 @@ extern crate time; #[macro_use] extern crate mentat; extern crate mentat_core; +extern crate core_traits; extern crate mentat_db; // TODO: when we switch to `failure`, make this more humane. @@ -25,11 +26,14 @@ use std::str::FromStr; use chrono::FixedOffset; +use core_traits::{ + Entid, + KnownEntid, +}; + use mentat_core::{ DateTime, - Entid, HasSchema, - KnownEntid, Utc, Uuid, ValueType, diff --git a/tests/tolstoy.rs b/tests/tolstoy.rs index fff655aa..032b1113 100644 --- a/tests/tolstoy.rs +++ b/tests/tolstoy.rs @@ -10,6 +10,7 @@ extern crate mentat; extern crate mentat_core; +extern crate core_traits; #[cfg(feature = "syncable")] extern crate mentat_tolstoy; @@ -27,8 +28,10 @@ mod tests { TxPart, }; use mentat_tolstoy::errors::Result; - use mentat_core::{ + use core_traits::{ Entid, + }; + use mentat_core::{ TypedValue, ValueType, }; diff --git a/tolstoy/Cargo.toml b/tolstoy/Cargo.toml index cd10b340..7741ddcc 100644 --- a/tolstoy/Cargo.toml +++ b/tolstoy/Cargo.toml @@ -24,6 +24,9 @@ path = "../edn" [dependencies.mentat_core] path = "../core" +[dependencies.core_traits] +path = "../core-traits" + [dependencies.mentat_db] path = "../db" diff --git a/tolstoy/src/lib.rs b/tolstoy/src/lib.rs index d41b1455..0565c7bc 100644 --- a/tolstoy/src/lib.rs +++ b/tolstoy/src/lib.rs @@ -34,6 +34,7 @@ extern crate serde_json; #[cfg_attr(test, macro_use)] extern crate mentat_db; extern crate mentat_core; +extern crate core_traits; extern crate rusqlite; extern crate uuid; diff --git a/tolstoy/src/syncer.rs b/tolstoy/src/syncer.rs index 9bc90fb1..6cdf06e6 100644 --- a/tolstoy/src/syncer.rs +++ b/tolstoy/src/syncer.rs @@ -25,7 +25,10 @@ use serde_json; use tokio_core::reactor::Core; use uuid::Uuid; -use mentat_core::Entid; +use core_traits::{ + Entid, +}; + use metadata::SyncMetadataClient; use metadata::HeadTrackable; use schema::ensure_current_version; diff --git a/tolstoy/src/tx_mapper.rs b/tolstoy/src/tx_mapper.rs index 1ad8521b..e71ee7a8 100644 --- a/tolstoy/src/tx_mapper.rs +++ b/tolstoy/src/tx_mapper.rs @@ -11,7 +11,10 @@ use std::collections::HashMap; use rusqlite; use uuid::Uuid; -use mentat_core::Entid; + +use core_traits::{ + Entid, +}; use errors::{ TolstoyError, diff --git a/tolstoy/src/tx_processor.rs b/tolstoy/src/tx_processor.rs index ebc12cae..808cce8c 100644 --- a/tolstoy/src/tx_processor.rs +++ b/tolstoy/src/tx_processor.rs @@ -19,8 +19,11 @@ use mentat_db::{ TypedSQLValue, }; -use mentat_core::{ +use core_traits::{ Entid, +}; + +use mentat_core::{ TypedValue, };