Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ authors = [
"Thom Chiovoloni <tchiovoloni@mozilla.com>",
]
name = "mentat"
version = "0.11.1"
version = "0.11.2"
build = "build/version.rs"

[features]
Expand Down
10 changes: 10 additions & 0 deletions ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1978,6 +1978,16 @@ pub unsafe extern "C" fn store_entid_for_attribute(store: *mut Store, attr: *con
current_schema.get_entid(&kw).expect("Unable to find entid for invalid attribute").into()
}

/// Returns the current schema as an edn C `String`.
///
#[no_mangle]
pub unsafe extern "C" fn store_current_schema(store: *mut Store) -> *mut c_char {
assert_not_null!(store);
let store = &mut *store;
let value = store.conn().current_schema().to_edn_value().to_string();
string_to_c_char(value.clone())
}

/// Returns the value at the provided `index` as a [TransactionChange](TransactionChange) .
///
/// # Panics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class EntityBuilder extends PointerType {}
void store_register_observer(Store store, String key, Pointer attributes, int len, TxObserverCallback callback);
void store_unregister_observer(Store store, String key);
long store_entid_for_attribute(Store store, String attr);
Pointer store_current_schema(Store store);

// Query Building
QueryBuilder store_query(Store store, String query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ public long entIdForAttribute(String attribute) {
return JNA.INSTANCE.store_entid_for_attribute(this.validPointer(), attribute);
}

/**
* Get the current schema.
* @return An EDN string of the current schema.
*/
public String currentSchema() {
return getAndConsumeMentatString(
JNA.INSTANCE.store_current_schema(this.validPointer()));
}

/**
* Start a query.
* @param query The string represeting the the query to be executed.
Expand Down