Support consumption by Carthage; bump iOS minimum version to 11. r=nalexander
Principally, this adds producing libmentat_ffi.a for consumption by Carthage. To achieve this, we disable bitcode and bump the miniumum iOS version to 11. In addition, we make things open and public so that consumers can, well, consume.
This commit is contained in:
parent
3d5ae797b2
commit
c0d4568970
16 changed files with 177 additions and 150 deletions
4
scripts/ios_build.sh
Executable file
4
scripts/ios_build.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
cd ffi
|
||||
cargo lipo --release
|
||||
cd ..
|
||||
cp target/universal/release/libmentat_ffi.a sdks/swift/Mentat/External-Dependencies/
|
|
@ -7,11 +7,11 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
7B45C8BE20CA982800BC83C0 /* libmentat_ffi.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B45C8BD20CA982800BC83C0 /* libmentat_ffi.a */; };
|
||||
7B64E44D209094520063909F /* InProgressBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B64E44A209094510063909F /* InProgressBuilder.swift */; };
|
||||
7B64E44E209094520063909F /* EntityBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B64E44B209094510063909F /* EntityBuilder.swift */; };
|
||||
7B64E44F209094520063909F /* InProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B64E44C209094520063909F /* InProgress.swift */; };
|
||||
7B74483D208DF667006CFFB0 /* Result+Unwrap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B74483C208DF667006CFFB0 /* Result+Unwrap.swift */; };
|
||||
7BAE75A22089020E00895D37 /* libmentat_ffi.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7BEB7D23207BE2AF000369AD /* libmentat_ffi.a */; };
|
||||
7BAE75A42089022B00895D37 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 7BAE75A32089022B00895D37 /* libsqlite3.tbd */; };
|
||||
7BDB96942077C299009D0651 /* Mentat.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7BDB968A2077C299009D0651 /* Mentat.framework */; };
|
||||
7BDB96992077C299009D0651 /* MentatTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BDB96982077C299009D0651 /* MentatTests.swift */; };
|
||||
|
@ -41,12 +41,24 @@
|
|||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
7B45C8B420CA926D00BC83C0 /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 12;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 0;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
7B45C8BD20CA982800BC83C0 /* libmentat_ffi.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmentat_ffi.a; path = "External-Dependencies/libmentat_ffi.a"; sourceTree = "<group>"; };
|
||||
7B64E44A209094510063909F /* InProgressBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InProgressBuilder.swift; sourceTree = "<group>"; };
|
||||
7B64E44B209094510063909F /* EntityBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EntityBuilder.swift; sourceTree = "<group>"; };
|
||||
7B64E44C209094520063909F /* InProgress.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InProgress.swift; sourceTree = "<group>"; };
|
||||
7B74483C208DF667006CFFB0 /* Result+Unwrap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "Result+Unwrap.swift"; path = "Mentat/Extensions/Result+Unwrap.swift"; sourceTree = SOURCE_ROOT; };
|
||||
7B911E1A2085081D000998CB /* libtoodle.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtoodle.a; path = "../../../../sync-storage-prototype/rust/target/universal/release/libtoodle.a"; sourceTree = "<group>"; };
|
||||
7BAE75A32089022B00895D37 /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; };
|
||||
7BDB968A2077C299009D0651 /* Mentat.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Mentat.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
7BDB968D2077C299009D0651 /* Mentat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Mentat.h; sourceTree = "<group>"; };
|
||||
|
@ -62,13 +74,11 @@
|
|||
7BDB96AB2077C38E009D0651 /* OptionalRustObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OptionalRustObject.swift; sourceTree = "<group>"; };
|
||||
7BDB96AC2077C38E009D0651 /* TupleResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TupleResult.swift; sourceTree = "<group>"; };
|
||||
7BDB96AE2077C38E009D0651 /* TypedValue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TypedValue.swift; sourceTree = "<group>"; };
|
||||
7BDB96BF2077CD7A009D0651 /* libmentat.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmentat.a; path = ../../../target/universal/release/libmentat.a; sourceTree = "<group>"; };
|
||||
7BDB96C12077CD98009D0651 /* libresolv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = usr/lib/libresolv.tbd; sourceTree = SDKROOT; };
|
||||
7BDB96C32077D090009D0651 /* module.map */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.map; sourceTree = "<group>"; };
|
||||
7BDB96C52077D346009D0651 /* Date+Int64.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Date+Int64.swift"; sourceTree = "<group>"; };
|
||||
7BDB96C8207B735A009D0651 /* fixtures */ = {isa = PBXFileReference; lastKnownFileType = folder; name = fixtures; path = ../../../../fixtures; sourceTree = "<group>"; };
|
||||
7BDB96CB207B7684009D0651 /* Errors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = "<group>"; };
|
||||
7BEB7D21207BDDEF000369AD /* libtoodle.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtoodle.a; path = ../../../target/universal/release/libtoodle.a; sourceTree = "<group>"; };
|
||||
7BEB7D23207BE2AF000369AD /* libmentat_ffi.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmentat_ffi.a; path = ../../../target/universal/release/libmentat_ffi.a; sourceTree = "<group>"; };
|
||||
7BEB7D2B207D03DA000369AD /* TxReport.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TxReport.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
@ -78,9 +88,9 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7B45C8BE20CA982800BC83C0 /* libmentat_ffi.a in Frameworks */,
|
||||
7BAE75A42089022B00895D37 /* libsqlite3.tbd in Frameworks */,
|
||||
7BDB96C22077CD98009D0651 /* libresolv.tbd in Frameworks */,
|
||||
7BAE75A22089020E00895D37 /* libmentat_ffi.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -172,12 +182,10 @@
|
|||
7BDB96BE2077CD7A009D0651 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7B45C8BD20CA982800BC83C0 /* libmentat_ffi.a */,
|
||||
7BAE75A32089022B00895D37 /* libsqlite3.tbd */,
|
||||
7B911E1A2085081D000998CB /* libtoodle.a */,
|
||||
7BEB7D23207BE2AF000369AD /* libmentat_ffi.a */,
|
||||
7BEB7D21207BDDEF000369AD /* libtoodle.a */,
|
||||
7BDB96C12077CD98009D0651 /* libresolv.tbd */,
|
||||
7BDB96BF2077CD7A009D0651 /* libmentat.a */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
|
@ -229,6 +237,7 @@
|
|||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 7BDB969E2077C299009D0651 /* Build configuration list for PBXNativeTarget "Mentat" */;
|
||||
buildPhases = (
|
||||
7B45C8B420CA926D00BC83C0 /* CopyFiles */,
|
||||
7BDB96852077C299009D0651 /* Sources */,
|
||||
7BDB96862077C299009D0651 /* Frameworks */,
|
||||
7BDB96872077C299009D0651 /* Headers */,
|
||||
|
@ -409,7 +418,7 @@
|
|||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 11.3;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_CFLAGS = "-fembed-bitcode";
|
||||
|
@ -470,7 +479,7 @@
|
|||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 11.3;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
OTHER_CFLAGS = "-fembed-bitcode";
|
||||
OTHER_LDFLAGS = "";
|
||||
|
@ -496,6 +505,7 @@
|
|||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Mentat/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
|
@ -503,7 +513,11 @@
|
|||
"@executable_path/Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/../../../target/universal/release";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(PROJECT_DIR)/../../../target/universal/release",
|
||||
"$(PROJECT_DIR)/Mentat",
|
||||
"$(PROJECT_DIR)/External-Dependencies",
|
||||
);
|
||||
OTHER_CFLAGS = "-fembed-bitcode";
|
||||
OTHER_LDFLAGS = "";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.mozilla.Mentat;
|
||||
|
@ -528,6 +542,7 @@
|
|||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_BITCODE = NO;
|
||||
ENABLE_TESTABILITY = NO;
|
||||
INFOPLIST_FILE = Mentat/Info.plist;
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
|
@ -536,7 +551,11 @@
|
|||
"@executable_path/Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/../../../target/universal/release";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(PROJECT_DIR)/../../../target/universal/release",
|
||||
"$(PROJECT_DIR)/Mentat",
|
||||
"$(PROJECT_DIR)/External-Dependencies",
|
||||
);
|
||||
OTHER_CFLAGS = "-fembed-bitcode";
|
||||
OTHER_LDFLAGS = "";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.mozilla.Mentat;
|
||||
|
|
|
@ -21,7 +21,7 @@ import MentatStore
|
|||
Also, due to the consuming nature of the FFI layer, this class also manages it's raw pointer, nilling it after calling the
|
||||
FFI conversion function so that the underlying base class can manage cleanup.
|
||||
*/
|
||||
class TypedValue: OptionalRustObject {
|
||||
open class TypedValue: OptionalRustObject {
|
||||
|
||||
private var value: Any?
|
||||
|
||||
|
@ -43,7 +43,7 @@ class TypedValue: OptionalRustObject {
|
|||
|
||||
- Returns: the value of this `TypedValue` as a `Int64`
|
||||
*/
|
||||
func asLong() -> Int64 {
|
||||
open func asLong() -> Int64 {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ class TypedValue: OptionalRustObject {
|
|||
|
||||
- Returns: the value of this `TypedValue` as an `Entid`
|
||||
*/
|
||||
func asEntid() -> Entid {
|
||||
open func asEntid() -> Entid {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ class TypedValue: OptionalRustObject {
|
|||
|
||||
- Returns: the value of this `TypedValue` as a keyword `String`
|
||||
*/
|
||||
func asKeyword() -> String {
|
||||
open func asKeyword() -> String {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ class TypedValue: OptionalRustObject {
|
|||
|
||||
- Returns: the value of this `TypedValue` as a `Bool`
|
||||
*/
|
||||
func asBool() -> Bool {
|
||||
open func asBool() -> Bool {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class TypedValue: OptionalRustObject {
|
|||
|
||||
- Returns: the value of this `TypedValue` as a `Double`
|
||||
*/
|
||||
func asDouble() -> Double {
|
||||
open func asDouble() -> Double {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ class TypedValue: OptionalRustObject {
|
|||
|
||||
- Returns: the value of this `TypedValue` as a `Date`
|
||||
*/
|
||||
func asDate() -> Date {
|
||||
open func asDate() -> Date {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ class TypedValue: OptionalRustObject {
|
|||
|
||||
- Returns: the value of this `TypedValue` as a `String`
|
||||
*/
|
||||
func asString() -> String {
|
||||
open func asString() -> String {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ class TypedValue: OptionalRustObject {
|
|||
|
||||
- Returns: the value of this `TypedValue` as a `UUID?`. If the `UUID` is not valid then this function returns nil.
|
||||
*/
|
||||
func asUUID() -> UUID? {
|
||||
open func asUUID() -> UUID? {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ class TypedValue: OptionalRustObject {
|
|||
return self.value as! UUID?
|
||||
}
|
||||
|
||||
override func cleanup(pointer: OpaquePointer) {
|
||||
override open func cleanup(pointer: OpaquePointer) {
|
||||
typed_value_destroy(pointer)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
extension Date {
|
||||
public extension Date {
|
||||
/**
|
||||
This `Date` as microseconds.
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
import Foundation
|
||||
import MentatStore
|
||||
|
||||
extension Result {
|
||||
public extension Result {
|
||||
/**
|
||||
Force unwraps a result.
|
||||
Expects there to be a value attached and throws an error is there is not.
|
||||
|
|
|
@ -12,24 +12,24 @@ import Foundation
|
|||
|
||||
import MentatStore
|
||||
|
||||
typealias Entid = Int64
|
||||
public typealias Entid = Int64
|
||||
|
||||
/**
|
||||
Protocol to be implemented by any object that wishes to register for transaction observation
|
||||
*/
|
||||
protocol Observing {
|
||||
public protocol Observing {
|
||||
func transactionDidOccur(key: String, reports: [TxChange])
|
||||
}
|
||||
|
||||
/**
|
||||
Protocol to be implemented by any object that provides an interface to Mentat's transaction observers.
|
||||
*/
|
||||
protocol Observable {
|
||||
public protocol Observable {
|
||||
func register(key: String, observer: Observing, attributes: [String])
|
||||
func unregister(key: String)
|
||||
}
|
||||
|
||||
enum CacheDirection {
|
||||
public enum CacheDirection {
|
||||
case forward;
|
||||
case reverse;
|
||||
case both;
|
||||
|
@ -40,14 +40,14 @@ enum CacheDirection {
|
|||
This class provides all of the basic API that can be found in Mentat's Store struct.
|
||||
The raw pointer it holds is a pointer to a Store.
|
||||
*/
|
||||
class Mentat: RustObject {
|
||||
open class Mentat: RustObject {
|
||||
fileprivate static var observers = [String: Observing]()
|
||||
|
||||
/**
|
||||
Create a new Mentat with the provided pointer to a Mentat Store
|
||||
- Parameter raw: A pointer to a Mentat Store.
|
||||
*/
|
||||
required override init(raw: OpaquePointer) {
|
||||
public required override init(raw: OpaquePointer) {
|
||||
super.init(raw: raw)
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ class Mentat: RustObject {
|
|||
- Parameter storeURI: The URI as a String of the store to open.
|
||||
If no store URI is provided, an in-memory store will be opened.
|
||||
*/
|
||||
convenience init(storeURI: String = "") {
|
||||
public convenience init(storeURI: String = "") {
|
||||
self.init(raw: store_open(storeURI))
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ class Mentat: RustObject {
|
|||
|
||||
- Throws: `ResultError.error` if an error occured while trying to cache the attribute.
|
||||
*/
|
||||
func cache(attribute: String, direction: CacheDirection) throws {
|
||||
open func cache(attribute: String, direction: CacheDirection) throws {
|
||||
switch direction {
|
||||
case .forward:
|
||||
try store_cache_attribute_forward(self.raw, attribute).pointee.tryUnwrap()
|
||||
|
@ -95,7 +95,7 @@ class Mentat: RustObject {
|
|||
|
||||
- Returns: The `TxReport` of the completed transaction
|
||||
*/
|
||||
func transact(transaction: String) throws -> TxReport {
|
||||
open func transact(transaction: String) throws -> TxReport {
|
||||
let result = store_transact(self.raw, transaction).pointee
|
||||
return TxReport(raw: try result.unwrap())
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class Mentat: RustObject {
|
|||
|
||||
- Returns: The `InProgress` used to manage the transaction
|
||||
*/
|
||||
func beginTransaction() throws -> InProgress {
|
||||
open func beginTransaction() throws -> InProgress {
|
||||
let result = store_begin_transaction(self.raw).pointee;
|
||||
return InProgress(raw: try result.unwrap())
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ class Mentat: RustObject {
|
|||
|
||||
- Returns: an `InProgressBuilder` for this `InProgress`
|
||||
*/
|
||||
func entityBuilder() throws -> InProgressBuilder {
|
||||
open func entityBuilder() throws -> InProgressBuilder {
|
||||
let result = store_in_progress_builder(self.raw).pointee
|
||||
return InProgressBuilder(raw: try result.unwrap())
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ class Mentat: RustObject {
|
|||
|
||||
- Returns: an `EntityBuilder` for this `InProgress`
|
||||
*/
|
||||
func entityBuilder(forEntid entid: Entid) throws -> EntityBuilder {
|
||||
open func entityBuilder(forEntid entid: Entid) throws -> EntityBuilder {
|
||||
let result = store_entity_builder_from_entid(self.raw, entid).pointee
|
||||
return EntityBuilder(raw: try result.unwrap())
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ class Mentat: RustObject {
|
|||
|
||||
- Returns: an `EntityBuilder` for this `InProgress`
|
||||
*/
|
||||
func entityBuilder(forTempId tempId: String) throws -> EntityBuilder {
|
||||
open func entityBuilder(forTempId tempId: String) throws -> EntityBuilder {
|
||||
let result = store_entity_builder_from_temp_id(self.raw, tempId).pointee
|
||||
return EntityBuilder(raw: try result.unwrap())
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ class Mentat: RustObject {
|
|||
|
||||
- Returns: The `Entid` associated with the attribute.
|
||||
*/
|
||||
func entidForAttribute(attribute: String) -> Entid {
|
||||
open func entidForAttribute(attribute: String) -> Entid {
|
||||
return Entid(store_entid_for_attribute(self.raw, attribute))
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ class Mentat: RustObject {
|
|||
|
||||
- Returns: The `Query` representing the query that can be executed.
|
||||
*/
|
||||
func query(query: String) -> Query {
|
||||
open func query(query: String) -> Query {
|
||||
return Query(raw: store_query(self.raw, query))
|
||||
}
|
||||
|
||||
|
@ -188,13 +188,13 @@ class Mentat: RustObject {
|
|||
|
||||
- Returns: The `TypedValue` containing the value of the attribute for the entity.
|
||||
*/
|
||||
func value(forAttribute attribute: String, ofEntity entid: Entid) throws -> TypedValue? {
|
||||
open func value(forAttribute attribute: String, ofEntity entid: Entid) throws -> TypedValue? {
|
||||
let result = store_value_for_attribute(self.raw, entid, attribute).pointee
|
||||
return TypedValue(raw: try result.unwrap())
|
||||
}
|
||||
|
||||
// Destroys the pointer by passing it back into Rust to be cleaned up
|
||||
override func cleanup(pointer: OpaquePointer) {
|
||||
override open func cleanup(pointer: OpaquePointer) {
|
||||
store_destroy(pointer)
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ extension Mentat: Observable {
|
|||
- Parameter attributes: An `Array` of `Strings` representing the attributes that the `Observing`
|
||||
wishes to be notified about if they are referenced in a transaction.
|
||||
*/
|
||||
func register(key: String, observer: Observing, attributes: [String]) {
|
||||
open func register(key: String, observer: Observing, attributes: [String]) {
|
||||
let attrEntIds = attributes.map({ (kw) -> Entid in
|
||||
let entid = Entid(self.entidForAttribute(attribute: kw));
|
||||
return entid
|
||||
|
@ -240,7 +240,7 @@ extension Mentat: Observable {
|
|||
|
||||
- Parameter key: `String` representing an identifier for the `Observing`.
|
||||
*/
|
||||
func unregister(key: String) {
|
||||
open func unregister(key: String) {
|
||||
Mentat.observers.removeValue(forKey: key)
|
||||
store_unregister_observer(self.raw, key)
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ import MentatStore
|
|||
}
|
||||
```
|
||||
*/
|
||||
class Query: OptionalRustObject {
|
||||
open class Query: OptionalRustObject {
|
||||
|
||||
/**
|
||||
Binds a `Int64` value to the provided variable name.
|
||||
|
@ -105,7 +105,7 @@ class Query: OptionalRustObject {
|
|||
|
||||
- Returns: This `Query` such that further function can be called.
|
||||
*/
|
||||
func bind(varName: String, toLong value: Int64) throws -> Query {
|
||||
open func bind(varName: String, toLong value: Int64) throws -> Query {
|
||||
query_builder_bind_long(try! self.validPointer(), varName, value)
|
||||
return self
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ class Query: OptionalRustObject {
|
|||
|
||||
- Returns: This `Query` such that further function can be called.
|
||||
*/
|
||||
func bind(varName: String, toReference value: Entid) throws -> Query {
|
||||
open func bind(varName: String, toReference value: Entid) throws -> Query {
|
||||
query_builder_bind_ref(try! self.validPointer(), varName, value)
|
||||
return self
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ class Query: OptionalRustObject {
|
|||
|
||||
- Returns: This `Query` such that further function can be called.
|
||||
*/
|
||||
func bind(varName: String, toReference value: String) throws -> Query {
|
||||
open func bind(varName: String, toReference value: String) throws -> Query {
|
||||
query_builder_bind_ref_kw(try! self.validPointer(), varName, value)
|
||||
return self
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ class Query: OptionalRustObject {
|
|||
|
||||
- Returns: This `Query` such that further function can be called.
|
||||
*/
|
||||
func bind(varName: String, toKeyword value: String) throws -> Query {
|
||||
open func bind(varName: String, toKeyword value: String) throws -> Query {
|
||||
query_builder_bind_kw(try! self.validPointer(), varName, value)
|
||||
return self
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ class Query: OptionalRustObject {
|
|||
|
||||
- Returns: This `Query` such that further function can be called.
|
||||
*/
|
||||
func bind(varName: String, toBoolean value: Bool) throws -> Query {
|
||||
open func bind(varName: String, toBoolean value: Bool) throws -> Query {
|
||||
query_builder_bind_boolean(try! self.validPointer(), varName, value ? 1 : 0)
|
||||
return self
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ class Query: OptionalRustObject {
|
|||
|
||||
- Returns: This `Query` such that further function can be called.
|
||||
*/
|
||||
func bind(varName: String, toDouble value: Double) throws -> Query {
|
||||
open func bind(varName: String, toDouble value: Double) throws -> Query {
|
||||
query_builder_bind_double(try! self.validPointer(), varName, value)
|
||||
return self
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ class Query: OptionalRustObject {
|
|||
|
||||
- Returns: This `Query` such that further function can be called.
|
||||
*/
|
||||
func bind(varName: String, toDate value: Date) throws -> Query {
|
||||
open func bind(varName: String, toDate value: Date) throws -> Query {
|
||||
query_builder_bind_timestamp(try! self.validPointer(), varName, value.toMicroseconds())
|
||||
return self
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ class Query: OptionalRustObject {
|
|||
|
||||
- Returns: This `Query` such that further function can be called.
|
||||
*/
|
||||
func bind(varName: String, toString value: String) throws -> Query {
|
||||
open func bind(varName: String, toString value: String) throws -> Query {
|
||||
query_builder_bind_string(try! self.validPointer(), varName, value)
|
||||
return self
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ class Query: OptionalRustObject {
|
|||
|
||||
- Returns: This `Query` such that further function can be called.
|
||||
*/
|
||||
func bind(varName: String, toUuid value: UUID) throws -> Query {
|
||||
open func bind(varName: String, toUuid value: UUID) throws -> Query {
|
||||
var rawUuid = value.uuid
|
||||
withUnsafePointer(to: &rawUuid) { uuidPtr in
|
||||
query_builder_bind_uuid(try! self.validPointer(), varName, uuidPtr)
|
||||
|
@ -244,7 +244,7 @@ class Query: OptionalRustObject {
|
|||
variable we incorrectly bound, or that the query provided was not `Rel`.
|
||||
- Throws: `PointerError.pointerConsumed` if the underlying raw pointer has already consumed, which will occur if the query has previously been executed.
|
||||
*/
|
||||
func run(callback: @escaping (RelResult?) -> Void) throws {
|
||||
open func run(callback: @escaping (RelResult?) -> Void) throws {
|
||||
let result = query_builder_execute(try! self.validPointer())
|
||||
self.raw = nil
|
||||
|
||||
|
@ -268,7 +268,7 @@ class Query: OptionalRustObject {
|
|||
variable we incorrectly bound, or that the query provided was not `Scalar`.
|
||||
- Throws: `PointerError.pointerConsumed` if the underlying raw pointer has already consumed, which will occur if the query has previously been executed.
|
||||
*/
|
||||
func runScalar(callback: @escaping (TypedValue?) -> Void) throws {
|
||||
open func runScalar(callback: @escaping (TypedValue?) -> Void) throws {
|
||||
let result = query_builder_execute_scalar(try! self.validPointer())
|
||||
self.raw = nil
|
||||
|
||||
|
@ -292,7 +292,7 @@ class Query: OptionalRustObject {
|
|||
variable we incorrectly bound, or that the query provided was not `Coll`.
|
||||
- Throws: `PointerError.pointerConsumed` if the underlying raw pointer has already consumed, which will occur if the query has previously been executed.
|
||||
*/
|
||||
func runColl(callback: @escaping (ColResult?) -> Void) throws {
|
||||
open func runColl(callback: @escaping (ColResult?) -> Void) throws {
|
||||
let result = query_builder_execute_coll(try! self.validPointer())
|
||||
self.raw = nil
|
||||
|
||||
|
@ -316,7 +316,7 @@ class Query: OptionalRustObject {
|
|||
variable we incorrectly bound, or that the query provided was not `Tuple`.
|
||||
- Throws: `PointerError.pointerConsumed` if the underlying raw pointer has already consumed, which will occur if the query has previously been executed.
|
||||
*/
|
||||
func runTuple(callback: @escaping (TupleResult?) -> Void) throws {
|
||||
open func runTuple(callback: @escaping (TupleResult?) -> Void) throws {
|
||||
let result = query_builder_execute_tuple(try! self.validPointer())
|
||||
self.raw = nil
|
||||
|
||||
|
@ -331,7 +331,7 @@ class Query: OptionalRustObject {
|
|||
callback(TupleResult(raw: OpaquePointer(results)))
|
||||
}
|
||||
|
||||
override func cleanup(pointer: OpaquePointer) {
|
||||
override open func cleanup(pointer: OpaquePointer) {
|
||||
query_builder_destroy(pointer)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ import MentatStore
|
|||
|
||||
Note that iteration is consuming and can only be done once.
|
||||
*/
|
||||
class RelResult: OptionalRustObject {
|
||||
open class RelResult: OptionalRustObject {
|
||||
|
||||
/**
|
||||
Fetch the row at the requested index.
|
||||
|
@ -47,14 +47,14 @@ class RelResult: OptionalRustObject {
|
|||
|
||||
- Returns: The row at the requested index as a `TupleResult`, if present, or nil if there is no row at that index.
|
||||
*/
|
||||
func row(index: Int32) throws -> TupleResult? {
|
||||
open func row(index: Int32) throws -> TupleResult? {
|
||||
guard let row = row_at_index(try self.validPointer(), index) else {
|
||||
return nil
|
||||
}
|
||||
return TupleResult(raw: row)
|
||||
}
|
||||
|
||||
override func cleanup(pointer: OpaquePointer) {
|
||||
override open func cleanup(pointer: OpaquePointer) {
|
||||
destroy(UnsafeMutableRawPointer(pointer))
|
||||
}
|
||||
}
|
||||
|
@ -73,14 +73,14 @@ class RelResult: OptionalRustObject {
|
|||
|
||||
Note that iteration is consuming and can only be done once.
|
||||
*/
|
||||
class RelResultIterator: OptionalRustObject, IteratorProtocol {
|
||||
typealias Element = TupleResult
|
||||
open class RelResultIterator: OptionalRustObject, IteratorProtocol {
|
||||
public typealias Element = TupleResult
|
||||
|
||||
init(iter: OpaquePointer?) {
|
||||
super.init(raw: iter)
|
||||
}
|
||||
|
||||
func next() -> Element? {
|
||||
open func next() -> Element? {
|
||||
guard let iter = self.raw,
|
||||
let rowPtr = typed_value_result_set_iter_next(iter) else {
|
||||
return nil
|
||||
|
@ -88,13 +88,13 @@ class RelResultIterator: OptionalRustObject, IteratorProtocol {
|
|||
return TupleResult(raw: rowPtr)
|
||||
}
|
||||
|
||||
override func cleanup(pointer: OpaquePointer) {
|
||||
override open func cleanup(pointer: OpaquePointer) {
|
||||
typed_value_result_set_iter_destroy(pointer)
|
||||
}
|
||||
}
|
||||
|
||||
extension RelResult: Sequence {
|
||||
func makeIterator() -> RelResultIterator {
|
||||
open func makeIterator() -> RelResultIterator {
|
||||
do {
|
||||
let rowIter = typed_value_result_set_into_iter(try self.validPointer())
|
||||
self.raw = nil
|
||||
|
|
|
@ -27,7 +27,7 @@ import MentatStore
|
|||
- `String`
|
||||
- `UUID`.
|
||||
*/
|
||||
class TupleResult: OptionalRustObject {
|
||||
open class TupleResult: OptionalRustObject {
|
||||
|
||||
/**
|
||||
Return the `TypedValue` at the specified index.
|
||||
|
@ -37,7 +37,7 @@ class TupleResult: OptionalRustObject {
|
|||
|
||||
- Returns: The `TypedValue` at that index.
|
||||
*/
|
||||
func get(index: Int) -> TypedValue {
|
||||
open func get(index: Int) -> TypedValue {
|
||||
return TypedValue(raw: value_at_index(self.raw!, Int32(index)))
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class TupleResult: OptionalRustObject {
|
|||
|
||||
- Returns: The `Int64` at that index.
|
||||
*/
|
||||
func asLong(index: Int) -> Int64 {
|
||||
open func asLong(index: Int) -> Int64 {
|
||||
return value_at_index_into_long(self.raw!, Int32(index))
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ class TupleResult: OptionalRustObject {
|
|||
|
||||
- Returns: The `Entid` at that index.
|
||||
*/
|
||||
func asEntid(index: Int) -> Entid {
|
||||
open func asEntid(index: Int) -> Entid {
|
||||
return value_at_index_into_entid(self.raw!, Int32(index))
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ class TupleResult: OptionalRustObject {
|
|||
|
||||
- Returns: The keyword `String` at that index.
|
||||
*/
|
||||
func asKeyword(index: Int) -> String {
|
||||
open func asKeyword(index: Int) -> String {
|
||||
return String(cString: value_at_index_into_kw(self.raw!, Int32(index)))
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ class TupleResult: OptionalRustObject {
|
|||
|
||||
- Returns: The `Bool` at that index.
|
||||
*/
|
||||
func asBool(index: Int) -> Bool {
|
||||
open func asBool(index: Int) -> Bool {
|
||||
return value_at_index_into_boolean(self.raw!, Int32(index)) == 0 ? false : true
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ class TupleResult: OptionalRustObject {
|
|||
|
||||
- Returns: The `Double` at that index.
|
||||
*/
|
||||
func asDouble(index: Int) -> Double {
|
||||
open func asDouble(index: Int) -> Double {
|
||||
return value_at_index_into_double(self.raw!, Int32(index))
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ class TupleResult: OptionalRustObject {
|
|||
|
||||
- Returns: The `Date` at that index.
|
||||
*/
|
||||
func asDate(index: Int) -> Date {
|
||||
open func asDate(index: Int) -> Date {
|
||||
return Date(timeIntervalSince1970: TimeInterval(value_at_index_into_timestamp(self.raw!, Int32(index))))
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ class TupleResult: OptionalRustObject {
|
|||
|
||||
- Returns: The `String` at that index.
|
||||
*/
|
||||
func asString(index: Int) -> String {
|
||||
open func asString(index: Int) -> String {
|
||||
return String(cString: value_at_index_into_string(self.raw!, Int32(index)))
|
||||
}
|
||||
|
||||
|
@ -141,11 +141,11 @@ class TupleResult: OptionalRustObject {
|
|||
|
||||
- Returns: The `UUID` at that index.
|
||||
*/
|
||||
func asUUID(index: Int) -> UUID? {
|
||||
open func asUUID(index: Int) -> UUID? {
|
||||
return UUID(uuid: value_at_index_into_uuid(self.raw!, Int32(index)).pointee)
|
||||
}
|
||||
|
||||
override func cleanup(pointer: OpaquePointer) {
|
||||
override open func cleanup(pointer: OpaquePointer) {
|
||||
typed_value_list_destroy(pointer)
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ class TupleResult: OptionalRustObject {
|
|||
- `String`
|
||||
- `UUID`.
|
||||
*/
|
||||
class ColResult: TupleResult {
|
||||
open class ColResult: TupleResult {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -183,14 +183,14 @@ class ColResult: TupleResult {
|
|||
|
||||
Note that iteration is consuming and can only be done once.
|
||||
*/
|
||||
class ColResultIterator: OptionalRustObject, IteratorProtocol {
|
||||
typealias Element = TypedValue
|
||||
open class ColResultIterator: OptionalRustObject, IteratorProtocol {
|
||||
public typealias Element = TypedValue
|
||||
|
||||
init(iter: OpaquePointer?) {
|
||||
super.init(raw: iter)
|
||||
}
|
||||
|
||||
func next() -> Element? {
|
||||
open func next() -> Element? {
|
||||
guard let iter = self.raw,
|
||||
let rowPtr = typed_value_list_iter_next(iter) else {
|
||||
return nil
|
||||
|
@ -198,13 +198,13 @@ class ColResultIterator: OptionalRustObject, IteratorProtocol {
|
|||
return TypedValue(raw: rowPtr)
|
||||
}
|
||||
|
||||
override func cleanup(pointer: OpaquePointer) {
|
||||
override open func cleanup(pointer: OpaquePointer) {
|
||||
typed_value_list_iter_destroy(pointer)
|
||||
}
|
||||
}
|
||||
|
||||
extension ColResult: Sequence {
|
||||
func makeIterator() -> ColResultIterator {
|
||||
open func makeIterator() -> ColResultIterator {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
|
|
|
@ -23,21 +23,21 @@ import MentatStore
|
|||
The optional pointer is managed here such that is the pointer is nil, then the cleanup function is not called
|
||||
ensuring that we do not double free the pointer on exit.
|
||||
*/
|
||||
class OptionalRustObject: Destroyable {
|
||||
open class OptionalRustObject: Destroyable {
|
||||
var raw: OpaquePointer?
|
||||
lazy var uniqueId: ObjectIdentifier = {
|
||||
ObjectIdentifier(self)
|
||||
}()
|
||||
|
||||
init(raw: UnsafeMutableRawPointer) {
|
||||
public init(raw: UnsafeMutableRawPointer) {
|
||||
self.raw = OpaquePointer(raw)
|
||||
}
|
||||
|
||||
init(raw: OpaquePointer?) {
|
||||
public init(raw: OpaquePointer?) {
|
||||
self.raw = raw
|
||||
}
|
||||
|
||||
func intoRaw() -> OpaquePointer? {
|
||||
public func getRaw() -> OpaquePointer? {
|
||||
return self.raw
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ class OptionalRustObject: Destroyable {
|
|||
|
||||
- Returns: the raw `OpaquePointer` wrapped by this class.
|
||||
*/
|
||||
func validPointer() throws -> OpaquePointer {
|
||||
public func validPointer() throws -> OpaquePointer {
|
||||
guard let r = self.raw else {
|
||||
throw PointerError.pointerConsumed
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class OptionalRustObject: Destroyable {
|
|||
return r
|
||||
}
|
||||
|
||||
func cleanup(pointer: OpaquePointer) {
|
||||
open func cleanup(pointer: OpaquePointer) {
|
||||
fatalError("\(cleanup) is not implemented.")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,29 +21,33 @@ protocol Destroyable {
|
|||
that inherit from it will have their `OpaquePointer` destroyed when the Swift wrapper is destroyed.
|
||||
If a class does not override `cleanup` then a `fatalError` is thrown.
|
||||
*/
|
||||
public class RustObject: Destroyable {
|
||||
open class RustObject: Destroyable {
|
||||
var raw: OpaquePointer
|
||||
|
||||
init(raw: OpaquePointer) {
|
||||
public init(raw: OpaquePointer) {
|
||||
self.raw = raw
|
||||
}
|
||||
|
||||
init(raw: UnsafeMutableRawPointer) {
|
||||
public init(raw: UnsafeMutableRawPointer) {
|
||||
self.raw = OpaquePointer(raw)
|
||||
}
|
||||
|
||||
init?(raw: OpaquePointer?) {
|
||||
public init?(raw: OpaquePointer?) {
|
||||
guard let r = raw else {
|
||||
return nil
|
||||
}
|
||||
self.raw = r
|
||||
}
|
||||
|
||||
public func getRaw() -> OpaquePointer {
|
||||
return self.raw
|
||||
}
|
||||
|
||||
deinit {
|
||||
self.cleanup(pointer: self.raw)
|
||||
}
|
||||
|
||||
func cleanup(pointer: OpaquePointer) {
|
||||
open func cleanup(pointer: OpaquePointer) {
|
||||
fatalError("\(cleanup) is not implemented.")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ import MentatStore
|
|||
}
|
||||
```
|
||||
*/
|
||||
class EntityBuilder: OptionalRustObject {
|
||||
open class EntityBuilder: OptionalRustObject {
|
||||
/**
|
||||
Asserts the value of attribute `keyword` to be the provided `value`.
|
||||
|
||||
|
@ -68,7 +68,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/long`.
|
||||
*/
|
||||
func add(keyword: String, long value: Int64) throws {
|
||||
open func add(keyword: String, long value: Int64) throws {
|
||||
try entity_builder_add_long(try self.validPointer(), keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/ref`.
|
||||
*/
|
||||
func add(keyword: String, reference value: Int64) throws {
|
||||
open func add(keyword: String, reference value: Int64) throws {
|
||||
try entity_builder_add_ref(try self.validPointer(), keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/keyword`.
|
||||
*/
|
||||
func add(keyword: String, keyword value: String) throws {
|
||||
open func add(keyword: String, keyword value: String) throws {
|
||||
try entity_builder_add_keyword(try self.validPointer(), keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/boolean`.
|
||||
*/
|
||||
func add(keyword: String, boolean value: Bool) throws {
|
||||
open func add(keyword: String, boolean value: Bool) throws {
|
||||
try entity_builder_add_boolean(try self.validPointer(), keyword, value ? 1 : 0).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/double`.
|
||||
*/
|
||||
func add(keyword: String, double value: Double) throws {
|
||||
open func add(keyword: String, double value: Double) throws {
|
||||
try entity_builder_add_double(try self.validPointer(), keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/instant`.
|
||||
*/
|
||||
func add(keyword: String, date value: Date) throws {
|
||||
open func add(keyword: String, date value: Date) throws {
|
||||
try entity_builder_add_timestamp(try self.validPointer(), keyword, value.toMicroseconds()).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/string`.
|
||||
*/
|
||||
func add(keyword: String, string value: String) throws {
|
||||
open func add(keyword: String, string value: String) throws {
|
||||
try entity_builder_add_string(try self.validPointer(), keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/uuid`.
|
||||
*/
|
||||
func add(keyword: String, uuid value: UUID) throws {
|
||||
open func add(keyword: String, uuid value: UUID) throws {
|
||||
var rawUuid = value.uuid
|
||||
let _ = try withUnsafePointer(to: &rawUuid) { uuidPtr in
|
||||
try entity_builder_add_uuid(try self.validPointer(), keyword, uuidPtr).pointee.tryUnwrap()
|
||||
|
@ -192,7 +192,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/long`.
|
||||
*/
|
||||
func retract(keyword: String, long value: Int64) throws {
|
||||
open func retract(keyword: String, long value: Int64) throws {
|
||||
try entity_builder_retract_long(try self.validPointer(), keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/ref`.
|
||||
*/
|
||||
func retract(keyword: String, reference value: Int64) throws {
|
||||
open func retract(keyword: String, reference value: Int64) throws {
|
||||
try entity_builder_retract_ref(try self.validPointer(), keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/keyword`.
|
||||
*/
|
||||
func retract(keyword: String, keyword value: String) throws {
|
||||
open func retract(keyword: String, keyword value: String) throws {
|
||||
try entity_builder_retract_keyword(try self.validPointer(), keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/boolean`.
|
||||
*/
|
||||
func retract(keyword: String, boolean value: Bool) throws {
|
||||
open func retract(keyword: String, boolean value: Bool) throws {
|
||||
try entity_builder_retract_boolean(try self.validPointer(), keyword, value ? 1 : 0).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -252,7 +252,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/double`.
|
||||
*/
|
||||
func retract(keyword: String, double value: Double) throws {
|
||||
open func retract(keyword: String, double value: Double) throws {
|
||||
try entity_builder_retract_double(try self.validPointer(), keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/instant`.
|
||||
*/
|
||||
func retract(keyword: String, date value: Date) throws {
|
||||
open func retract(keyword: String, date value: Date) throws {
|
||||
try entity_builder_retract_timestamp(try self.validPointer(), keyword, value.toMicroseconds()).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -282,7 +282,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/string`.
|
||||
*/
|
||||
func retract(keyword: String, string value: String) throws {
|
||||
open func retract(keyword: String, string value: String) throws {
|
||||
try entity_builder_retract_string(try self.validPointer(), keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -298,7 +298,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/uuid`.
|
||||
*/
|
||||
func retract(keyword: String, uuid value: UUID) throws {
|
||||
open func retract(keyword: String, uuid value: UUID) throws {
|
||||
var rawUuid = value.uuid
|
||||
let _ = try withUnsafePointer(to: &rawUuid) { uuidPtr in
|
||||
try entity_builder_retract_uuid(try self.validPointer(), keyword, uuidPtr).pointee.tryUnwrap()
|
||||
|
@ -319,7 +319,7 @@ class EntityBuilder: OptionalRustObject {
|
|||
|
||||
- Returns: The current `InProgress` and the `TxReport` generated by the transact.
|
||||
*/
|
||||
func transact() throws -> (InProgress, TxReport?) {
|
||||
open func transact() throws -> (InProgress, TxReport?) {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
|
@ -342,14 +342,14 @@ class EntityBuilder: OptionalRustObject {
|
|||
|
||||
- Returns: The `TxReport` generated by the transact.
|
||||
*/
|
||||
func commit() throws -> TxReport {
|
||||
open func commit() throws -> TxReport {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
return TxReport(raw: try entity_builder_commit(try self.validPointer()).pointee.unwrap())
|
||||
}
|
||||
|
||||
override func cleanup(pointer: OpaquePointer) {
|
||||
override open func cleanup(pointer: OpaquePointer) {
|
||||
entity_builder_destroy(pointer)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ import MentatStore
|
|||
}
|
||||
```
|
||||
*/
|
||||
class InProgress: OptionalRustObject {
|
||||
open class InProgress: OptionalRustObject {
|
||||
|
||||
/**
|
||||
Creates an `InProgressBuilder` using this `InProgress`.
|
||||
|
@ -88,7 +88,7 @@ class InProgress: OptionalRustObject {
|
|||
|
||||
- Returns: an `InProgressBuilder` for this `InProgress`
|
||||
*/
|
||||
func builder() throws -> InProgressBuilder {
|
||||
open func builder() throws -> InProgressBuilder {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ class InProgress: OptionalRustObject {
|
|||
|
||||
- Returns: an `EntityBuilder` for this `InProgress`
|
||||
*/
|
||||
func builder(forEntid entid: Int64) throws -> EntityBuilder {
|
||||
open func builder(forEntid entid: Int64) throws -> EntityBuilder {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ class InProgress: OptionalRustObject {
|
|||
|
||||
- Returns: an `EntityBuilder` for this `InProgress`
|
||||
*/
|
||||
func builder(forTempId tempId: String) throws -> EntityBuilder {
|
||||
open func builder(forTempId tempId: String) throws -> EntityBuilder {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ class InProgress: OptionalRustObject {
|
|||
|
||||
- Returns: The `TxReport` generated by the transact.
|
||||
*/
|
||||
func transact(transaction: String) throws -> TxReport {
|
||||
open func transact(transaction: String) throws -> TxReport {
|
||||
let result = in_progress_transact(try self.validPointer(), transaction).pointee
|
||||
return TxReport(raw: try result.unwrap())
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ class InProgress: OptionalRustObject {
|
|||
has already been transacted or committed.
|
||||
- Throws: `ResultError.error` if the commit failed.
|
||||
*/
|
||||
func commit() throws {
|
||||
open func commit() throws {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
|
@ -171,14 +171,14 @@ class InProgress: OptionalRustObject {
|
|||
has already been transacted or committed.
|
||||
- Throws: `ResultError.error` if the rollback failed.
|
||||
*/
|
||||
func rollback() throws {
|
||||
open func rollback() throws {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
try in_progress_rollback(try self.validPointer()).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
override func cleanup(pointer: OpaquePointer) {
|
||||
override open func cleanup(pointer: OpaquePointer) {
|
||||
in_progress_destroy(pointer)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ import MentatStore
|
|||
}
|
||||
```
|
||||
*/
|
||||
class InProgressBuilder: OptionalRustObject {
|
||||
open class InProgressBuilder: OptionalRustObject {
|
||||
|
||||
/**
|
||||
Asserts the value of attribute `keyword` to be the provided `value` for entity `entid`.
|
||||
|
@ -72,7 +72,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/long`.
|
||||
*/
|
||||
func add(entid: Entid, keyword: String, long value: Int64) throws {
|
||||
open func add(entid: Entid, keyword: String, long value: Int64) throws {
|
||||
try in_progress_builder_add_long(try self.validPointer(), entid, keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/ref`.
|
||||
*/
|
||||
func add(entid: Entid, keyword: String, reference value: Entid) throws {
|
||||
open func add(entid: Entid, keyword: String, reference value: Entid) throws {
|
||||
try in_progress_builder_add_ref(try self.validPointer(), entid, keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/keyword`.
|
||||
*/
|
||||
func add(entid: Entid, keyword: String, keyword value: String) throws {
|
||||
open func add(entid: Entid, keyword: String, keyword value: String) throws {
|
||||
try in_progress_builder_add_keyword(try self.validPointer(), entid, keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/boolean`.
|
||||
*/
|
||||
func add(entid: Entid, keyword: String, boolean value: Bool) throws {
|
||||
open func add(entid: Entid, keyword: String, boolean value: Bool) throws {
|
||||
try in_progress_builder_add_boolean(try self.validPointer(), entid, keyword, value ? 1 : 0).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/double`.
|
||||
*/
|
||||
func add(entid: Entid, keyword: String, double value: Double) throws {
|
||||
open func add(entid: Entid, keyword: String, double value: Double) throws {
|
||||
try in_progress_builder_add_double(try self.validPointer(), entid, keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/instant`.
|
||||
*/
|
||||
func add(entid: Entid, keyword: String, date value: Date) throws {
|
||||
open func add(entid: Entid, keyword: String, date value: Date) throws {
|
||||
try in_progress_builder_add_timestamp(try self.validPointer(), entid, keyword, value.toMicroseconds()).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/string`.
|
||||
*/
|
||||
func add(entid: Entid, keyword: String, string value: String) throws {
|
||||
open func add(entid: Entid, keyword: String, string value: String) throws {
|
||||
try in_progress_builder_add_string(try self.validPointer(), entid, keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/uuid`.
|
||||
*/
|
||||
func add(entid: Entid, keyword: String, uuid value: UUID) throws {
|
||||
open func add(entid: Entid, keyword: String, uuid value: UUID) throws {
|
||||
var rawUuid = value.uuid
|
||||
let _ = try withUnsafePointer(to: &rawUuid) { uuidPtr in
|
||||
try in_progress_builder_add_uuid(try self.validPointer(), entid, keyword, uuidPtr).pointee.tryUnwrap()
|
||||
|
@ -203,7 +203,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/long`.
|
||||
*/
|
||||
func retract(entid: Entid, keyword: String, long value: Int64) throws {
|
||||
open func retract(entid: Entid, keyword: String, long value: Int64) throws {
|
||||
try in_progress_builder_retract_long(try self.validPointer(), entid, keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/ref`.
|
||||
*/
|
||||
func retract(entid: Entid, keyword: String, reference value: Entid) throws {
|
||||
open func retract(entid: Entid, keyword: String, reference value: Entid) throws {
|
||||
try in_progress_builder_retract_ref(try self.validPointer(), entid, keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/keyword`.
|
||||
*/
|
||||
func retract(entid: Entid, keyword: String, keyword value: String) throws {
|
||||
open func retract(entid: Entid, keyword: String, keyword value: String) throws {
|
||||
try in_progress_builder_retract_keyword(try self.validPointer(), entid, keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/boolean`.
|
||||
*/
|
||||
func retract(entid: Entid, keyword: String, boolean value: Bool) throws {
|
||||
open func retract(entid: Entid, keyword: String, boolean value: Bool) throws {
|
||||
try in_progress_builder_retract_boolean(try self.validPointer(), entid, keyword, value ? 1 : 0).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/double`.
|
||||
*/
|
||||
func retract(entid: Entid, keyword: String, double value: Double) throws {
|
||||
open func retract(entid: Entid, keyword: String, double value: Double) throws {
|
||||
try in_progress_builder_retract_double(try self.validPointer(), entid, keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/instant`.
|
||||
*/
|
||||
func retract(entid: Entid, keyword: String, date value: Date) throws {
|
||||
open func retract(entid: Entid, keyword: String, date value: Date) throws {
|
||||
try in_progress_builder_retract_timestamp(try self.validPointer(), entid, keyword, value.toMicroseconds()).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/string`.
|
||||
*/
|
||||
func retract(entid: Entid, keyword: String, string value: String) throws {
|
||||
open func retract(entid: Entid, keyword: String, string value: String) throws {
|
||||
try in_progress_builder_retract_string(try self.validPointer(), entid, keyword, value).pointee.tryUnwrap()
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
- Throws: `ResultError.error` if the attribute is not present in the schema or the attribute value type
|
||||
is not `:db.type/uuid`.
|
||||
*/
|
||||
func retract(entid: Entid, keyword: String, uuid value: UUID) throws {
|
||||
open func retract(entid: Entid, keyword: String, uuid value: UUID) throws {
|
||||
var rawUuid = value.uuid
|
||||
let _ = try withUnsafePointer(to: &rawUuid) { uuidPtr in
|
||||
try in_progress_builder_retract_uuid(try self.validPointer(), entid, keyword, uuidPtr).pointee.tryUnwrap()
|
||||
|
@ -336,7 +336,7 @@ class InProgressBuilder: OptionalRustObject {
|
|||
|
||||
- Returns: The current `InProgress` and the `TxReport` generated by the transact.
|
||||
*/
|
||||
func transact() throws -> (InProgress, TxReport?) {
|
||||
open func transact() throws -> (InProgress, TxReport?) {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
|
@ -359,14 +359,14 @@ class InProgressBuilder: OptionalRustObject {
|
|||
|
||||
- Returns: The `TxReport` generated by the transact.
|
||||
*/
|
||||
func commit() throws -> TxReport {
|
||||
open func commit() throws -> TxReport {
|
||||
defer {
|
||||
self.raw = nil
|
||||
}
|
||||
return TxReport(raw: try in_progress_builder_commit(try self.validPointer()).pointee.unwrap())
|
||||
}
|
||||
|
||||
override func cleanup(pointer: OpaquePointer) {
|
||||
override open func cleanup(pointer: OpaquePointer) {
|
||||
in_progress_builder_destroy(pointer)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,15 +29,15 @@ import MentatStore
|
|||
let aEntid = report.entid(forTempId: "a")
|
||||
```
|
||||
*/
|
||||
class TxReport: RustObject {
|
||||
open class TxReport: RustObject {
|
||||
|
||||
// The identifier for the transaction.
|
||||
public var txId: Entid {
|
||||
open var txId: Entid {
|
||||
return tx_report_get_entid(self.raw)
|
||||
}
|
||||
|
||||
// The time that the transaction occured.
|
||||
public var txInstant: Date {
|
||||
open var txInstant: Date {
|
||||
return Date(timeIntervalSince1970: TimeInterval(tx_report_get_tx_instant(self.raw)))
|
||||
}
|
||||
|
||||
|
@ -48,14 +48,14 @@ class TxReport: RustObject {
|
|||
|
||||
- Returns: The `Entid` for the temporary identifier, if present, otherwise `nil`.
|
||||
*/
|
||||
public func entid(forTempId tempId: String) -> Entid? {
|
||||
open func entid(forTempId tempId: String) -> Entid? {
|
||||
guard let entidPtr = tx_report_entity_for_temp_id(self.raw, tempId) else {
|
||||
return nil
|
||||
}
|
||||
return entidPtr.pointee
|
||||
}
|
||||
|
||||
override func cleanup(pointer: OpaquePointer) {
|
||||
override open func cleanup(pointer: OpaquePointer) {
|
||||
tx_report_destroy(pointer)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue