Part 6: Lift TxReport to core crate.

The `core` create didn't exist when the `db` was started, but this
type is clearly part of the public interface of Mentat.
This commit is contained in:
Nick Alexander 2018-07-03 13:18:02 -07:00
parent 1cb1847aa6
commit 06056a8468
10 changed files with 50 additions and 28 deletions

View file

@ -60,9 +60,14 @@ pub use cache::{
/// Core types defining a Mentat knowledge base.
mod types;
mod tx_report;
mod value_type_set;
mod sql_types;
pub use tx_report::{
TxReport,
};
pub use types::{
Binding,
Entid,

38
core/src/tx_report.rs Normal file
View file

@ -0,0 +1,38 @@
// 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.
#![allow(dead_code)]
use std::collections::{
BTreeMap,
};
use ::{
DateTime,
Entid,
Utc,
};
/// A transaction report summarizes an applied transaction.
#[derive(Clone, Debug, Eq, Hash, Ord, PartialOrd, PartialEq)]
pub struct TxReport {
/// The transaction ID of the transaction.
pub tx_id: Entid,
/// The timestamp when the transaction began to be committed.
pub tx_instant: DateTime<Utc>,
/// A map from string literal tempid to resolved or allocated entid.
///
/// Every string literal tempid presented to the transactor either resolves via upsert to an
/// existing entid, or is allocated a new entid. (It is possible for multiple distinct string
/// literal tempids to all unify to a single freshly allocated entid.)
pub tempids: BTreeMap<String, Entid>,
}

View file

@ -1131,6 +1131,7 @@ mod tests {
HasSchema,
Keyword,
KnownEntid,
TxReport,
attribute,
};
use mentat_core::util::Either::*;
@ -1142,7 +1143,6 @@ mod tests {
Term,
TermWithTempIds,
};
use types::TxReport;
use tx::{
transact_terms,
};

View file

@ -106,7 +106,6 @@ pub use types::{
DB,
PartitionMap,
TransactableValue,
TxReport,
};
pub fn to_namespaced_keyword(s: &str) -> Result<symbols::Keyword> {

View file

@ -94,6 +94,7 @@ use mentat_core::{
DateTime,
KnownEntid,
Schema,
TxReport,
Utc,
attribute,
now,
@ -119,7 +120,6 @@ use types::{
Entid,
PartitionMap,
TransactableValue,
TxReport,
TypedValue,
ValueType,
};

View file

@ -95,23 +95,6 @@ pub type AVMap<'a> = HashMap<&'a AVPair, Entid>;
// represents a set of entids that are correspond to attributes
pub type AttributeSet = BTreeSet<Entid>;
/// A transaction report summarizes an applied transaction.
#[derive(Clone, Debug, Eq, Hash, Ord, PartialOrd, PartialEq)]
pub struct TxReport {
/// The transaction ID of the transaction.
pub tx_id: Entid,
/// The timestamp when the transaction began to be committed.
pub tx_instant: DateTime<Utc>,
/// A map from string literal tempid to resolved or allocated entid.
///
/// Every string literal tempid presented to the transactor either resolves via upsert to an
/// existing entid, or is allocated a new entid. (It is possible for multiple distinct string
/// literal tempids to all unify to a single freshly allocated entid.)
pub tempids: BTreeMap<String, Entid>,
}
/// The transactor is tied to `edn::ValueAndSpan` right now, but in the future we'd like to support
/// `TypedValue` directly for programmatic use. `TransactableValue` encapsulates the interface
/// value types (i.e., values in the value place) need to support to be transacted.

View file

@ -53,6 +53,7 @@ use mentat_core::{
Keyword,
Schema,
StructuredMap,
TxReport,
TypedValue,
ValueRc,
ValueType,
@ -74,7 +75,6 @@ use mentat_db::{
TransactWatcher,
TxObservationService,
TxObserver,
TxReport,
};
use mentat_db::internal_types::TermWithTempIds;

View file

@ -66,11 +66,8 @@ use edn::entities::{
};
use mentat_core::{
TypedValue,
};
use mentat_db::{
TxReport,
TypedValue,
};
use conn::{
@ -277,8 +274,8 @@ mod testing {
KnownEntid,
MentatError,
Queryable,
TypedValue,
TxReport,
TypedValue,
};
use super::*;

View file

@ -41,6 +41,7 @@ pub use mentat_core::{
Keyword,
Schema,
Binding,
TxReport,
TypedValue,
Uuid,
Utc,
@ -56,7 +57,6 @@ pub use mentat_db::{
DB_SCHEMA_CORE,
AttributeSet,
TxObserver,
TxReport,
new_connection,
};

View file

@ -30,12 +30,12 @@ use mentat_core::{
Entid,
Keyword,
StructuredMap,
TxReport,
TypedValue,
ValueRc,
};
use mentat_db::{
TxObserver,
TxReport,
};
use mentat_tolstoy::Syncer;