C driver API reference
Connection
connection
Struct Connection
A connection to a TypeDB server which serves as the starting point for all interaction.
connection_close
void connection_close(struct Connection* connection)
Closes the driver. Before instantiating a new driver, the driver that’s currently open should first be closed. Closing a connction frees the underlying rust object.
void
connection_force_close
void connection_force_close(struct Connection* connection)
Forcibly closes the driver. To be used in exceptional cases.
void
connection_is_open
bool connection_is_open(const struct Connection* connection)
Checks whether this connection is presently open.
bool
connection_open_cloud
struct Connection* connection_open_cloud(const char*const* addresses, const struct Credential* credential)
Open a TypeDB Driver to TypeDB Cloud server(s) available at the provided addresses, using the provided credential.
Name | Description | Type |
---|---|---|
|
a null-terminated array holding the address(es) of the TypeDB server(s) |
|
|
The |
|
struct Connection*
connection_open_cloud_translated
struct Connection* connection_open_cloud_translated(const char*const* public_addresses, const char*const* private_addresses, const struct Credential* credential)
Open a TypeDB Driver to TypeDB Cloud server(s), using provided address translation, with the provided credential.
Name | Description | Type |
---|---|---|
|
A null-terminated array holding the address(es) of the TypeDB server(s) the driver will connect to. This array must have the same length as |
|
|
A null-terminated array holding the address(es) the TypeDB server(s) are configured to advertise |
|
|
The |
|
struct Connection*
credential
credential_drop
void credential_drop(struct Credential* credential)
Frees the native rust Credential
object
void
credential_new
struct Credential* credential_new(const char* username, const char* password, const char* tls_root_ca, bool with_tls)
Creates a new Credential
for connecting to TypeDB Cloud.
Name | Description | Type |
---|---|---|
|
The name of the user to connect as |
|
|
The password for the user |
|
|
Path to the CA certificate to use for authenticating server certificates. |
|
|
Specify whether the connection to TypeDB Cloud must be done over TLS |
|
struct Credential*
database
database_close
void database_close(struct Database* database)
Frees the native rust Database
object
void
database_get_name
char* database_get_name(const struct Database* database)
The database name as a string.
char*
database_get_preferred_replica_info
struct ReplicaInfo* database_get_preferred_replica_info(const struct Database* database)
Returns the preferred replica for this database. Operations which can be run on any replica will prefer to use this replica. Only works in TypeDB Cloud
struct ReplicaInfo*
database_get_primary_replica_info
struct ReplicaInfo* database_get_primary_replica_info(const struct Database* database)
Returns the primary replica for this database. Only works in TypeDB Cloud
struct ReplicaInfo*
database_get_replicas_info
struct ReplicaInfoIterator* database_get_replicas_info(const struct Database* database)
Set of Replica
instances for this database. Only works in TypeDB Cloud
struct ReplicaInfoIterator*
database_iterator_drop
void database_iterator_drop(struct DatabaseIterator* it)
Frees the native rust DatabaseIterator
object
void
database_iterator_next
struct Database* database_iterator_next(struct DatabaseIterator* it)
Forwards the DatabaseIterator
and returns the next Database
if it exists, or null if there are no more elements.
struct Database*
database_manager_drop
void database_manager_drop(struct DatabaseManager* databases)
Frees the native rust DatabaseManager
object
void
database_manager_new
struct DatabaseManager* database_manager_new(const struct Connection* connection)
Creates and returns a native DatabaseManager
for the connection
struct DatabaseManager*
database_rule_schema
char* database_rule_schema(struct Database* database)
The rules in the schema as a valid TypeQL define query string.
char*
database_schema
char* database_schema(struct Database* database)
A full schema text as a valid TypeQL define query string.
char*
database_type_schema
char* database_type_schema(struct Database* database)
The types in the schema as a valid TypeQL define query string.
char*
databases_all
struct DatabaseIterator* databases_all(struct DatabaseManager* databases)
Returns a DatabaseIterator
over all databases present on the TypeDB server
struct DatabaseIterator*
databases_contains
bool databases_contains(struct DatabaseManager* databases, const char* name)
Checks if a database with the given name exists
bool
replica
Struct ReplicaInfoIterator
Iterator over the ReplicaInfo
corresponding to each replica of a TypeDB cloud database.
replica_info_drop
void replica_info_drop(struct ReplicaInfo* replica_info)
Frees the native rust ReplicaInfo
object
void
replica_info_get_server
char* replica_info_get_server(const struct ReplicaInfo* replica_info)
The server hosting this replica
char*
replica_info_get_term
int64_t replica_info_get_term(const struct ReplicaInfo* replica_info)
The raft protocol ‘term’ of this replica.
int64_t
replica_info_is_preferred
bool replica_info_is_preferred(const struct ReplicaInfo* replica_info)
Checks whether this is the preferred replica of the raft cluster. If true, Operations which can be run on any replica will prefer to use this replica.
bool
replica_info_is_primary
bool replica_info_is_primary(const struct ReplicaInfo* replica_info)
Checks whether this is the primary replica of the raft cluster.
bool
user
user_get_password_expiry_seconds
int64_t user_get_password_expiry_seconds(struct User* user)
Returns the number of seconds remaining till this user’s current password expires.
int64_t
user_get_username
char* user_get_username(struct User* user)
Returns the name of this user.
char*
user_iterator_drop
void user_iterator_drop(struct UserIterator* it)
Frees the native rust UserIterator
object
void
user_iterator_next
struct User* user_iterator_next(struct UserIterator* it)
Forwards the UserIterator
and returns the next User
if it exists, or null if there are no more elements.
struct User*
user_manager_drop
void user_manager_drop(struct UserManager* user_manager)
Frees the native rust UserManager
object
void
user_manager_new
struct UserManager* user_manager_new(const struct Connection* connection)
Creates a UserManager
on the specified connection
struct UserManager*
user_password_update
void user_password_update(struct User* user, const struct UserManager* user_manager, const char* password_old, const char* password_new)
Updates the password for the current authenticated user.
Name | Description | Type |
---|---|---|
|
The user to update the password of - must be the current user. |
|
|
The |
|
|
The current password of this user |
|
|
The new password |
|
void
users_all
struct UserIterator* users_all(const struct UserManager* user_manager)
Retrieves all users which exist on the TypeDB server.
struct UserIterator*
users_contains
bool users_contains(const struct UserManager* user_manager, const char* username)
Checks if a user with the given name exists.
bool
users_create
void users_create(const struct UserManager* user_manager, const char* username, const char* password)
Creates a user with the given name & password.
void
users_current_user
struct User* users_current_user(const struct UserManager* user_manager)
Retrieves the user who opened this connection
struct User*
users_delete
void users_delete(const struct UserManager* user_manager, const char* username)
Deletes the user with the given username.
void
users_get
struct User* users_get(const struct UserManager* user_manager, const char* username)
Retrieves a user with the given name.
struct User*
users_set_password
void users_set_password(const struct UserManager* user_manager, const char* username, const char* password)
Sets a new password for a user. This operation can only be performed by administrators.
Name | Description | Type |
---|---|---|
|
The UserManager object to be used. This must be on a connection opened by an administrator. |
|
|
The name of the user to set the password of |
|
|
The new password |
|
void
Session
session
Enum SessionType
This enum is used to specify the type of the session.
Name |
---|
|
|
session_close
void session_close(struct Session* session)
Closes the session. Before opening a new session, the session currently open should first be closed. The native rust object is freed on close.
void
session_force_close
void session_force_close(struct Session* session)
Forcibly closes the session. To be used in exceptional cases.
void
session_get_database_name
char* session_get_database_name(const struct Session* session)
Returns the name of the database of the session.
char*
session_is_open
bool session_is_open(const struct Session* session)
Checks whether this session is open.
bool
session_new
struct Session* session_new(struct DatabaseManager* databases, const char* database_name, enum SessionType session_type, const struct Options* options)
Opens a session to the given database.
Name | Description | Type |
---|---|---|
|
The |
|
|
The name of the database with which the session connects |
|
|
The type of session to be created (Schema or Data) |
|
|
|
|
struct Session*
session_on_close
void session_on_close(const struct Session* session, void* data, void(*)(void*) callback, void(*)(void*) finished)
Registers a callback function which will be executed when this session is closed.
Name | Description | Type |
---|---|---|
|
The session on which to register the callback |
|
|
The argument to be passed to the callback function when it is executed |
|
|
The function to be called |
|
|
A function which will be executed when the session is destroyed, allowing cleanup |
void
session_on_reopen
void session_on_reopen(const struct Session* session, void* data, void(*)(void*) callback, void(*)(void*) finished)
Registers a callback function which will be executed when this session is reopened. A session may be closed if it times out, or loses the connection to the database. In such situations, the session is reopened automatically when opening a new transaction.
Name | Description | Type |
---|---|---|
|
The session on which to register the callback |
|
|
The argument to be passed to the callback function when it is executed |
|
|
The function to be called |
|
|
A function which will be executed when the session is destroyed, allowing cleanup |
void
options
Struct Options
TypeDB session and transaction options. TypeDBOptions
object can be used to override the default server behaviour. Options are specified using properties assignment.
options_drop
void options_drop(struct Options* options)
Frees the native rust Options
object.
void
options_get_explain
bool options_get_explain(const struct Options* options)
Returns the value set for the explanation in this TypeDBOptions
object. If set to true
, explanations for queries are enabled.
bool
options_get_infer
bool options_get_infer(const struct Options* options)
Returns the value set for the inference in this TypeDBOptions
object.
bool
options_get_parallel
bool options_get_parallel(const struct Options* options)
Returns the value set for the parallel execution in this TypeDBOptions
object. If set to true
, the server uses parallel instead of single-threaded execution.
bool
options_get_prefetch
bool options_get_prefetch(const struct Options* options)
Returns the value set for the prefetching in this TypeDBOptions
object. If set to true
, the first batch of answers is streamed to the driver even without an explicit request for it.
bool
options_get_prefetch_size
int32_t options_get_prefetch_size(const struct Options* options)
Returns the value set for the prefetch size in this TypeDBOptions
object. If set, specifies a guideline number of answers that the server should send before the driver issues a fresh request.
int32_t
options_get_read_any_replica
bool options_get_read_any_replica(const struct Options* options)
Returns the value set for reading data from any replica in this TypeDBOptions
object. If set to True
, enables reading data from any replica, potentially boosting read throughput.
bool
options_get_schema_lock_acquire_timeout_millis
int64_t options_get_schema_lock_acquire_timeout_millis(const struct Options* options)
Returns the value set for the schema lock acquire timeout in this TypeDBOptions
object. If set, specifies how long the driver should wait if opening a session or transaction is blocked by a schema write lock.
int64_t
options_get_session_idle_timeout_millis
int64_t options_get_session_idle_timeout_millis(const struct Options* options)
Returns the value set for the session idle timeout in this TypeDBOptions
object. If set, specifies a timeout that allows the server to close sessions if the driver terminates or becomes unresponsive.
int64_t
options_get_trace_inference
bool options_get_trace_inference(const struct Options* options)
Returns the value set for reasoning tracing in this TypeDBOptions
object. If set to true
, reasoning tracing graphs are output in the logging directory.
bool
options_get_transaction_timeout_millis
int64_t options_get_transaction_timeout_millis(const struct Options* options)
Returns the value set for the transaction timeout in this TypeDBOptions
object. If set, specifies a timeout for killing transactions automatically, preventing memory leaks in unclosed transactions.
int64_t
options_has_explain
bool options_has_explain(const struct Options* options)
Checks whether the option for explanation was explicitly set for this TypeDBOptions
object.
bool
options_has_infer
bool options_has_infer(const struct Options* options)
Checks whether the option for inference was explicitly set for this TypeDBOptions
object.
bool
options_has_parallel
bool options_has_parallel(const struct Options* options)
Checks whether the option for parallel execution was explicitly set for this TypeDBOptions
object.
bool
options_has_prefetch
bool options_has_prefetch(const struct Options* options)
Checks whether the option for prefetching was explicitly set for this TypeDBOptions
object.
bool
options_has_prefetch_size
bool options_has_prefetch_size(const struct Options* options)
Checks whether the option for prefetch size was explicitly set for this TypeDBOptions
object.
bool
options_has_read_any_replica
bool options_has_read_any_replica(const struct Options* options)
Checks whether the option for reading data from any replica was explicitly set for this TypeDBOptions
object.
bool
options_has_schema_lock_acquire_timeout_millis
bool options_has_schema_lock_acquire_timeout_millis(const struct Options* options)
Checks whether the option for schema lock acquire timeout was explicitly set for this TypeDBOptions
object.
bool
options_has_session_idle_timeout_millis
bool options_has_session_idle_timeout_millis(const struct Options* options)
Checks whether the option for the session idle timeout was explicitly set for this TypeDBOptions
object.
bool
options_has_trace_inference
bool options_has_trace_inference(const struct Options* options)
Checks whether the option for reasoning tracing was explicitly set for this TypeDBOptions
object.
bool
options_has_transaction_timeout_millis
bool options_has_transaction_timeout_millis(const struct Options* options)
Checks whether the option for transaction timeout was explicitly set for this TypeDBOptions
object.
bool
options_new
struct Options* options_new(void)
Produces a new TypeDBOptions
object.
struct Options*
options_set_explain
void options_set_explain(struct Options* options, bool explain)
Explicitly enables or disables explanations. If set to true
, enables explanations for queries. Only affects read transactions.
void
options_set_infer
void options_set_infer(struct Options* options, bool infer)
Explicitly enables or disables inference. Only settable at transaction level and above. Only affects read transactions.
void
options_set_parallel
void options_set_parallel(struct Options* options, bool parallel)
Explicitly enables or disables parallel execution. If set to true
, the server uses parallel instead of single-threaded execution.
void
options_set_prefetch
void options_set_prefetch(struct Options* options, bool prefetch)
Explicitly enables or disables prefetching. If set to true
, the first batch of answers is streamed to the driver even without an explicit request for it.
void
options_set_prefetch_size
void options_set_prefetch_size(struct Options* options, int32_t prefetch_size)
Explicitly sets a prefetch size. If set, specifies a guideline number of answers that the server should send before the driver issues a fresh request.
Name | Description | Type |
---|---|---|
|
Number of answers that the server should send before the driver issues a fresh request |
void
options_set_read_any_replica
void options_set_read_any_replica(struct Options* options, bool read_any_replica)
Explicitly enables or disables reading data from any replica. If set to True
, enables reading data from any replica, potentially boosting read throughput. Only settable in TypeDB Cloud.
void
options_set_schema_lock_acquire_timeout_millis
void options_set_schema_lock_acquire_timeout_millis(struct Options* options, int64_t timeout_millis)
Explicitly sets schema lock acquire timeout. If set, specifies how long the driver should wait if opening a session or transaction is blocked by a schema write lock.
void
options_set_session_idle_timeout_millis
void options_set_session_idle_timeout_millis(struct Options* options, int64_t timeout_millis)
Explicitly sets a session idle timeout. If set, specifies a timeout that allows the server to close sessions if the driver terminates or becomes unresponsive.
void
options_set_trace_inference
void options_set_trace_inference(struct Options* options, bool trace_inference)
Explicitly enables or disables reasoning tracing. If set to true
, reasoning tracing graphs are output in the logging directory. Should be used with parallel = False
.
void
options_set_transaction_timeout_millis
void options_set_transaction_timeout_millis(struct Options* options, int64_t timeout_millis)
Explicitly set a transaction timeout. If set, specifies a timeout for killing transactions automatically, preventing memory leaks in unclosed transactions.
void
Transaction
transaction
Enum TransactionType
This enum is used to specify the type of transaction.
Name |
---|
|
|
transaction_close
void transaction_close(struct Transaction* txn)
Closes the transaction and frees the native rust object.
void
transaction_commit
struct VoidPromise* transaction_commit(struct Transaction* txn)
Commits the changes made via this transaction to the TypeDB database. Whether or not the transaction is commited successfully, the transaction is closed after the commit call and the native rust object is freed.
struct VoidPromise*
transaction_force_close
void transaction_force_close(struct Transaction* txn)
Forcibly closes this transaction. To be used in exceptional cases.
void
transaction_is_open
bool transaction_is_open(const struct Transaction* txn)
Checks whether this transaction is open.
bool
transaction_new
struct Transaction* transaction_new(const struct Session* session, enum TransactionType type_, const struct Options* options)
Opens a transaction to perform read or write queries on the database connected to the session.
Name | Description | Type |
---|---|---|
|
The type of transaction to be created (Write or Read). |
|
|
Options for the transaction |
|
struct Transaction*
transaction_on_close
void transaction_on_close(const struct Transaction* txn, uintptr_t callback_id, void(*)(uintptr_t, struct Error*) callback)
Registers a callback function which will be executed when this transaction is closed.
Name | Description | Type |
---|---|---|
|
The transaction on which to register the callback |
|
|
The argument to be passed to the callback function when it is executed. |
|
|
The function to be called |
void
query
query_define
struct VoidPromise* query_define(struct Transaction* transaction, const char* query, const struct Options* options)
Performs a TypeQL Define query in the transaction.
struct VoidPromise*
query_delete
struct VoidPromise* query_delete(struct Transaction* transaction, const char* query, const struct Options* options)
Performs a TypeQL Delete query in the transaction.
struct VoidPromise*
query_explain
struct ExplanationIterator* query_explain(struct Transaction* transaction, const struct Explainable* explainable, const struct Options* options)
Performs a TypeQL Explain query in the transaction.
Name | Description | Type |
---|---|---|
|
The Explainable to be explained |
|
|
Specify query options |
|
struct ExplanationIterator*
query_fetch
struct StringIterator* query_fetch(struct Transaction* transaction, const char* query, const struct Options* options)
Performs a TypeQL Fetch query in the transaction.
struct StringIterator*
query_get
struct ConceptMapIterator* query_get(struct Transaction* transaction, const char* query, const struct Options* options)
Performs a TypeQL Get (Get) query in the transaction.
struct ConceptMapIterator*
query_get_aggregate
struct ConceptPromise* query_get_aggregate(struct Transaction* transaction, const char* query, const struct Options* options)
Performs a TypeQL Get Aggregate query in the transaction.
struct ConceptPromise*
query_get_group
struct ConceptMapGroupIterator* query_get_group(struct Transaction* transaction, const char* query, const struct Options* options)
Performs a TypeQL Get Group query in the transaction.
struct ConceptMapGroupIterator*
query_get_group_aggregate
struct ValueGroupIterator* query_get_group_aggregate(struct Transaction* transaction, const char* query, const struct Options* options)
Performs a TypeQL Get Group Aggregate query in the transaction.
struct ValueGroupIterator*
query_insert
struct ConceptMapIterator* query_insert(struct Transaction* transaction, const char* query, const struct Options* options)
Performs a TypeQL Insert query in the transaction.
struct ConceptMapIterator*
Answer
conceptmap
Struct ConceptMapGroupIterator
Iterator over the ConceptMapGroup
s in the result of the TypeQL Get Group query.
concept_map_drop
void concept_map_drop(struct ConceptMap* concept_map)
Frees the native rust ConceptMap
object
void
concept_map_equals
bool concept_map_equals(const struct ConceptMap* lhs, const struct ConceptMap* rhs)
Checks whether the provided ConceptMap
objects are equal
bool
concept_map_get
struct Concept* concept_map_get(const struct ConceptMap* concept_map, const char* var)
Retrieves a concept for a given variable name.
struct Concept*
concept_map_get_explainables
struct Explainables* concept_map_get_explainables(const struct ConceptMap* concept_map)
Gets the Explainables
object for this ConceptMap
, exposing which of the concepts in this ConceptMap
are explainable.
struct Explainables*
concept_map_get_values
struct ConceptIterator* concept_map_get_values(const struct ConceptMap* concept_map)
Produces an Iterator
over all Concepts
in this ConceptMap
.
struct ConceptIterator*
concept_map_get_variables
struct StringIterator* concept_map_get_variables(const struct ConceptMap* concept_map)
Produces an Iterator
over all variables in this ConceptMap
.
struct StringIterator*
concept_map_group_drop
void concept_map_group_drop(struct ConceptMapGroup* concept_map_group)
Frees the native rust ConceptMapGroup
object
void
concept_map_group_equals
bool concept_map_group_equals(const struct ConceptMapGroup* lhs, const struct ConceptMapGroup* rhs)
Checks whether the provided ConceptMapGroup
objects are equal
bool
concept_map_group_get_concept_maps
struct ConceptMapIterator* concept_map_group_get_concept_maps(const struct ConceptMapGroup* concept_map_group)
Retrieves the ConceptMap
s of the group.
struct ConceptMapIterator*
concept_map_group_get_owner
struct Concept* concept_map_group_get_owner(const struct ConceptMapGroup* concept_map_group)
Retrieves the concept that is the group owner.
struct Concept*
concept_map_group_iterator_drop
void concept_map_group_iterator_drop(struct ConceptMapGroupIterator* it)
Frees the native rust ConceptMapGroupIterator
object
void
concept_map_group_iterator_next
struct ConceptMapGroup* concept_map_group_iterator_next(struct ConceptMapGroupIterator* it)
Forwards the ConceptMapGroupIterator
and returns the next ConceptMapGroup
if it exists, or null if there are no more elements.
struct ConceptMapGroup*
concept_map_group_to_string
char* concept_map_group_to_string(const struct ConceptMapGroup* concept_map_group)
A string representation of this ConceptMapGroup
object
char*
concept_map_iterator_drop
void concept_map_iterator_drop(struct ConceptMapIterator* it)
Frees the native rust ConceptMapIterator
object
void
valuegroup
Struct ValueGroupIterator
Iterator over the ValueGroup
s in the result of the Get Group Aggregate query.
value_group_drop
void value_group_drop(struct ValueGroup* value_group)
Frees the native rust ValueGroup
object
void
value_group_equals
bool value_group_equals(const struct ValueGroup* lhs, const struct ValueGroup* rhs)
Checks whether the provided ValueGroup
objects are equal
bool
value_group_get_owner
struct Concept* value_group_get_owner(struct ValueGroup* value_group)
Retrieves the concept that is the group owner.
struct Concept*
value_group_get_value
struct Concept* value_group_get_value(struct ValueGroup* value_group)
Retrieves the Value
answer of the group.
struct Concept*
value_group_iterator_drop
void value_group_iterator_drop(struct ValueGroupIterator* it)
Frees the native rust ValueGroupIterator
object
void
primitives
Struct BoolPromise
Promise object representing the result of an asynchronous operation. Use bool_promise_resolve(BoolPromise*) to wait for and retrieve the resulting boolean value.
Struct StringPair
A StringPair
used to represent the pair of variables involved in an ownership. _0
and _1
are the owner and attribute variables respectively.
Struct StringPairIterator
Iterator over the StringPair
s representing explainable owner-attribute variable pairs
Struct StringPromise
Promise object representing the result of an asynchronous operation. Use string_promise_resolve(StringPromise*) to wait for and retrieve the resulting string.
Struct VoidPromise
Promise object representing the result of an asynchronous operation. A VoidPromise does not return a value, but must be resolved using void_promise_resolve(VoidPromise*) to ensure the operation has completed, or for a failed operation to set the error.
bool_promise_resolve
bool bool_promise_resolve(struct BoolPromise* promise)
Waits for and returns the result of the operation represented by the BoolPromise
object. In case the operation failed, the error flag will only be set when the promise is resolved. The native promise object is freed when it is resolved.
bool
string_free
void string_free(char* str)
Frees a native rust string. WARNING: Always use this function to free strings returned by the driver. Using the standard C free function will create a dangling reference on the rust side.
void
string_iterator_drop
void string_iterator_drop(struct StringIterator* it)
Frees the native rust StringIterator
object
void
string_iterator_next
char* string_iterator_next(struct StringIterator* it)
Forwards the StringIterator
and returns the next string if it exists, or null if there are no more elements.
char*
string_pair_drop
void string_pair_drop(struct StringPair* string_pair)
Frees the native rust StringPair
object
void
string_pair_iterator_drop
void string_pair_iterator_drop(struct StringPairIterator* it)
Frees the native rust StringPairIterator
object
void
string_pair_iterator_next
struct StringPair* string_pair_iterator_next(struct StringPairIterator* it)
Forwards the StringIterator
and returns the next StringPair
if it exists, or null if there are no more elements.
struct StringPair*
string_promise_resolve
char* string_promise_resolve(struct StringPromise* promise)
Waits for and returns the result of the operation represented by the BoolPromise
object. In case the operation failed, the error flag will only be set when the promise is resolved. The native promise object is freed when it is resolved.
char*
void_promise_resolve
void void_promise_resolve(struct VoidPromise* promise)
Waits for the operation represented by the VoidPromise
to complete. In case the operation failed, the error flag will only be set when the promise is resolved. The native promise object is freed when it is resolved.
void
explanation
Struct Explanation
An explanation of which rule was used for inferring the explained concept, the condition of the rule, the conclusion of the rule, and the mapping of variables between the query and the rule’s conclusion.
explainable_drop
void explainable_drop(struct Explainable* explainable)
Frees the native rust Explainable
object
void
explainable_get_conjunction
char* explainable_get_conjunction(const struct Explainable* explainable)
Retrieves the subquery of the original query that is actually being explained.
char*
explainable_get_id
int64_t explainable_get_id(const struct Explainable* explainable)
Retrieves the unique ID that identifies this Explainable
.
int64_t
explainables_drop
void explainables_drop(struct Explainables* explainables)
Frees the native rust Explainables
object
void
explainables_equals
bool explainables_equals(const struct Explainables* lhs, const struct Explainables* rhs)
Checks whether the provided Explainables
objects are equal
bool
explainables_get_attribute
struct Explainable* explainables_get_attribute(const struct Explainables* explainables, const char* var)
Retrieves the explainable attribute with the given variable name.
struct Explainable*
explainables_get_attributes_keys
struct StringIterator* explainables_get_attributes_keys(const struct Explainables* explainables)
Retrieves all variables corresponding to this ConceptMap
’s explainable attributes.
struct StringIterator*
explainables_get_ownership
struct Explainable* explainables_get_ownership(const struct Explainables* explainables, const char* owner, const char* attribute)
Retrieves the explainable attribute ownership with the pair of (owner, attribute) variable names.
struct Explainable*
explainables_get_ownerships_keys
struct StringPairIterator* explainables_get_ownerships_keys(const struct Explainables* explainables)
Retrieves all variables corresponding to this ConceptMap
’s explainable ownerships.
struct StringPairIterator*
explainables_get_relation
struct Explainable* explainables_get_relation(const struct Explainables* explainables, const char* var)
Retrieves the explainable relation with the given variable name.
struct Explainable*
explainables_get_relations_keys
struct StringIterator* explainables_get_relations_keys(const struct Explainables* explainables)
Retrieves all variables corresponding to this ConceptMap
’s explainable relations.
struct StringIterator*
explainables_to_string
char* explainables_to_string(const struct Explainables* explainables)
A string representation of this Explainables
object
char*
explanation_drop
void explanation_drop(struct Explanation* explanation)
Frees the native rust Explanation
object
void
explanation_equals
bool explanation_equals(const struct Explanation* lhs, const struct Explanation* rhs)
Checks whether the provided Explanation
objects are equal
bool
explanation_get_conclusion
struct ConceptMap* explanation_get_conclusion(const struct Explanation* explanation)
Retrieves the Conclusion for this Explanation.
struct ConceptMap*
explanation_get_condition
struct ConceptMap* explanation_get_condition(const struct Explanation* explanation)
Retrieves the Condition for this Explanation.
struct ConceptMap*
explanation_get_mapped_variables
struct StringIterator* explanation_get_mapped_variables(const struct Explanation* explanation)
Retrieves the query variables for this Explanation
.
struct StringIterator*
explanation_get_mapping
struct StringIterator* explanation_get_mapping(const struct Explanation* explanation, const char* var)
Retrieves the rule variables corresponding to the query variable var for this Explanation
.
struct StringIterator*
explanation_get_rule
struct Rule* explanation_get_rule(const struct Explanation* explanation)
Retrieves the Rule for this Explanation.
struct Rule*
explanation_iterator_drop
void explanation_iterator_drop(struct ExplanationIterator* it)
Frees the native rust ExplanationIterator
object
void
Concept
concept
Struct Concept
The fundamental TypeQL object. A Concept is either a Type, Thing, or Value. To use subtype specific methods, the Concept must be of the expected subtype.
Struct ConceptPromise
Promise object representing the result of an asynchronous operation. Use concept_promise_resolve(ConceptPromise*) to wait for and retrieve the resulting boolean value.
concept_drop
void concept_drop(struct Concept* concept)
Frees the native rust Concept
object
void
concept_equals
bool concept_equals(const struct Concept* lhs, const struct Concept* rhs)
Checks whether the provided Concept
objects are equal
bool
concept_is_attribute
bool concept_is_attribute(const struct Concept* concept)
Checks if the concept is an Attribute
.
bool
concept_is_attribute_type
bool concept_is_attribute_type(const struct Concept* concept)
Checks if the concept is an AttributeType
.
bool
concept_is_entity
bool concept_is_entity(const struct Concept* concept)
Checks if the concept is an Entity
.
bool
concept_is_entity_type
bool concept_is_entity_type(const struct Concept* concept)
Checks if the concept is an EntityType
.
bool
concept_is_relation
bool concept_is_relation(const struct Concept* concept)
Checks if the concept is a Relation
.
bool
concept_is_relation_type
bool concept_is_relation_type(const struct Concept* concept)
Checks if the concept is a RelationType
.
bool
concept_is_role_type
bool concept_is_role_type(const struct Concept* concept)
Checks if the concept is a RoleType
.
bool
concept_is_root_thing_type
bool concept_is_root_thing_type(const struct Concept* concept)
Checks if the concept is the root thing
type.
bool
concept_is_value
bool concept_is_value(const struct Concept* concept)
Checks if the concept is a Value
.
bool
concept_iterator_drop
void concept_iterator_drop(struct ConceptIterator* it)
Frees the native rust ConceptIterator
object
void
concept_iterator_next
struct Concept* concept_iterator_next(struct ConceptIterator* it)
Forwards the ConceptIterator
and returns the next Concept
if it exists, or null if there are no more elements.
struct Concept*
concept_promise_resolve
struct Concept* concept_promise_resolve(struct ConceptPromise* promise)
Waits for and returns the result of the operation represented by the ConceptPromise
object. In case the operation failed, the error flag will only be set when the promise is resolved. The native promise object is freed when it is resolved.
struct Concept*
concept_to_string
char* concept_to_string(const struct Concept* concept)
A string representation of this Concept
object
char*
concepts_get_attribute
struct ConceptPromise* concepts_get_attribute(const struct Transaction* transaction, const char* iid)
Retrieves an Attribute
instance by its iid.
struct ConceptPromise*
concepts_get_attribute_type
struct ConceptPromise* concepts_get_attribute_type(const struct Transaction* transaction, const char* label)
Retrieves an AttributeType
by its label.
struct ConceptPromise*
concepts_get_entity
struct ConceptPromise* concepts_get_entity(const struct Transaction* transaction, const char* iid)
Retrieves an Entity
instance by its iid.
struct ConceptPromise*
concepts_get_entity_type
struct ConceptPromise* concepts_get_entity_type(const struct Transaction* transaction, const char* label)
Retrieves an EntityType
by its label.
struct ConceptPromise*
concepts_get_relation
struct ConceptPromise* concepts_get_relation(const struct Transaction* transaction, const char* iid)
Retrieves a relation
instance by its iid.
struct ConceptPromise*
concepts_get_relation_type
struct ConceptPromise* concepts_get_relation_type(const struct Transaction* transaction, const char* label)
Retrieves a RelationType
by its label.
struct ConceptPromise*
concepts_get_root_attribute_type
struct Concept* concepts_get_root_attribute_type(void)
Retrieves the root AttributeType
, “attribute”.
struct Concept*
concepts_get_root_entity_type
struct Concept* concepts_get_root_entity_type(void)
Retrieves the root EntityType
, “entity”.
struct Concept*
concepts_get_root_relation_type
struct Concept* concepts_get_root_relation_type(void)
Retrieves the root RelationType
, “relation”.
struct Concept*
concepts_get_schema_exceptions
struct SchemaExceptionIterator* concepts_get_schema_exceptions(const struct Transaction* transaction)
Retrieves a list of all schema exceptions for the current transaction.
struct SchemaExceptionIterator*
concepts_put_attribute_type
struct ConceptPromise* concepts_put_attribute_type(const struct Transaction* transaction, const char* label, enum ValueType value_type)
Creates a new AttributeType
if none exists with the given label, otherwise retrieves the existing one.
struct ConceptPromise*
thing
thing_delete
struct VoidPromise* thing_delete(struct Transaction* transaction, struct Concept* thing)
Deletes this Thing
.
struct VoidPromise*
thing_get_has
struct ConceptIterator* thing_get_has(struct Transaction* transaction, const struct Concept* thing, const struct Concept*const* attribute_types, const struct Annotation*const* annotations)
Retrieves the Attribute
s that this Thing
owns, optionally filtered by AttributeType
s.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The thing to get owned attributes of |
|
|
a null-terminated array holding the attribute-types to include |
|
|
a null-terminated array of annotations - If non-empty, Only retrieves attributes with all given |
|
struct ConceptIterator*
thing_get_iid
char* thing_get_iid(struct Concept* thing)
Retrieves the unique id of the Thing
.
char*
thing_get_is_inferred
bool thing_get_is_inferred(struct Concept* thing)
Checks if this Thing
is inferred by a [Reasoning Rule].
bool
thing_get_playing
struct ConceptIterator* thing_get_playing(struct Transaction* transaction, const struct Concept* thing)
Retrieves the roles that this Thing
is currently playing.
struct ConceptIterator*
thing_get_relations
struct ConceptIterator* thing_get_relations(struct Transaction* transaction, const struct Concept* thing, const struct Concept*const* role_types)
Retrieves all the Relations
which this Thing
plays a role in, optionally filtered by one or more given roles.
Name | Description | Type |
---|---|---|
|
a null-terminated array of |
|
struct ConceptIterator*
thing_is_deleted
struct BoolPromise* thing_is_deleted(struct Transaction* transaction, const struct Concept* thing)
Checks if this Thing
is deleted.
struct BoolPromise*
thing_set_has
struct VoidPromise* thing_set_has(struct Transaction* transaction, struct Concept* thing, const struct Concept* attribute)
Assigns an Attribute
to be owned by this Thing
.
struct VoidPromise*
thing_type_delete
struct VoidPromise* thing_type_delete(const struct Transaction* transaction, struct Concept* thing_type)
Deletes this thing type from the database.
struct VoidPromise*
thing_type_get_label
char* thing_type_get_label(const struct Concept* thing_type)
Retrieves the unique label of the thing type.
char*
thing_type_get_owns
struct ConceptIterator* thing_type_get_owns(const struct Transaction* transaction, const struct Concept* thing_type, const enum ValueType* value_type, enum Transitivity transitivity, const struct Annotation*const* annotations)
Retrieves AttributeType
that the instances of this ThingType
are allowed to own directly or via inheritance. Specify Explicit
to only include directly owned types, or Transitive
to include inherited
Name | Description | Type |
---|---|---|
|
a null-terminated array of |
|
struct ConceptIterator*
thing_type_get_owns_overridden
struct ConceptPromise* thing_type_get_owns_overridden(const struct Transaction* transaction, const struct Concept* thing_type, const struct Concept* overridden_attribute_type)
Retrieves the AttributeType
, ownership of which is overridden for this ThingType
by the specified AttributeType
.
struct ConceptPromise*
thing_type_get_plays
struct ConceptIterator* thing_type_get_plays(const struct Transaction* transaction, const struct Concept* thing_type, enum Transitivity transitivity)
Retrieves all direct and inherited (or direct only) roles that are allowed to be played by the instances of this ThingType
. Specify Transitive
for direct and inherited roles, Or Explicit
for directly played roles only.
struct ConceptIterator*
thing_type_get_plays_overridden
struct ConceptPromise* thing_type_get_plays_overridden(const struct Transaction* transaction, const struct Concept* thing_type, const struct Concept* overridden_role_type)
Retrieves the RoleType
that is overridden by the given RoleType
for this ThingType
.
struct ConceptPromise*
thing_type_get_syntax
struct StringPromise* thing_type_get_syntax(const struct Transaction* transaction, const struct Concept* thing_type)
Produces a TypeQL pattern for creating this ThingType
in a define
query.
struct StringPromise*
thing_type_is_abstract
bool thing_type_is_abstract(const struct Concept* thing_type)
Checks if this thing type is prevented from having data instances (i.e., abstract).
bool
thing_type_is_deleted
struct BoolPromise* thing_type_is_deleted(const struct Transaction* transaction, const struct Concept* thing_type)
Checks if the thing type has been deleted
struct BoolPromise*
thing_type_is_root
bool thing_type_is_root(const struct Concept* thing_type)
Checks if this type is a root type (""entity"", ""relation"", ""attribute"")
bool
thing_type_set_abstract
struct VoidPromise* thing_type_set_abstract(const struct Transaction* transaction, struct Concept* thing_type)
Set a ThingType
to be abstract, meaning it cannot have instances.
struct VoidPromise*
thing_type_set_label
struct VoidPromise* thing_type_set_label(const struct Transaction* transaction, struct Concept* thing_type, const char* new_label)
Renames the label of the type. The new label must remain unique.
struct VoidPromise*
thing_type_set_owns
struct VoidPromise* thing_type_set_owns(const struct Transaction* transaction, struct Concept* thing_type, const struct Concept* attribute_type, const struct Concept* overridden_attribute_type, const struct Annotation*const* annotations)
Allows the instances of this ThingType
to own the given AttributeType
. Optionally, overriding a previously declared ownership. With the specified annotations to the ownership.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The thing type which is to own the specified attribute |
|
|
The attribute type which is to be owned by the specified thing type |
|
|
Optional, The attribute whose ownership must be overridden |
|
|
A null-terminated array of |
|
struct VoidPromise*
thing_type_set_plays
struct VoidPromise* thing_type_set_plays(struct Transaction* transaction, struct Concept* thing_type, const struct Concept* role_type, const struct Concept* overridden_role_type)
Allows the instances of this ThingType
to play the given role. Optionally, overriding the existing ability to play a role.
struct VoidPromise*
thing_type_unset_abstract
struct VoidPromise* thing_type_unset_abstract(const struct Transaction* transaction, struct Concept* thing_type)
Set a ThingType
to be non-abstract, meaning it can have instances.
struct VoidPromise*
thing_type_unset_owns
struct VoidPromise* thing_type_unset_owns(const struct Transaction* transaction, struct Concept* thing_type, const struct Concept* attribute_type)
Disallows the instances of this ThingType
from owning the given AttributeType
.
struct VoidPromise*
attribute
attribute_get_owners
struct ConceptIterator* attribute_get_owners(struct Transaction* transaction, const struct Concept* attribute, const struct Concept* thing_type)
Retrieves the instances that own this Attribute
.
struct ConceptIterator*
relation
relation_add_role_player
struct VoidPromise* relation_add_role_player(struct Transaction* transaction, struct Concept* relation, const struct Concept* role_type, const struct Concept* player)
Adds a new role player to play the given role in this Relation
.
struct VoidPromise*
relation_get_players_by_role_type
struct ConceptIterator* relation_get_players_by_role_type(struct Transaction* transaction, const struct Concept* relation, const struct Concept*const* role_types)
Retrieves all role players of this Relation
, optionally filtered by given role types.
Name | Description | Type |
---|---|---|
|
a null-terminated array of |
|
struct ConceptIterator*
relation_get_relating
struct ConceptIterator* relation_get_relating(struct Transaction* transaction, const struct Concept* relation)
Retrieves all role types currently played in this Relation
.
struct ConceptIterator*
relation_get_role_players
struct RolePlayerIterator* relation_get_role_players(struct Transaction* transaction, const struct Concept* relation)
Retrieves all instance involved in the Relation
, each paired with the role it plays.
struct RolePlayerIterator*
relation_get_type
struct Concept* relation_get_type(const struct Concept* relation)
Retrieves the type which this Relation
belongs to.
struct Concept*
relation_remove_role_player
struct VoidPromise* relation_remove_role_player(struct Transaction* transaction, struct Concept* relation, const struct Concept* role_type, const struct Concept* player)
Removes the association of the given instance that plays the given role in this Relation
.
struct VoidPromise*
roleplayer
Struct RolePlayer
A pair representing the concept and the role it plays in a relation. The result of relation_get_role_players(Transaction*, Concept*)
Struct RolePlayerIterator
An iterator over RolePlayer
pairs returned by relation_get_role_players(Transaction*, Concept*)
role_player_drop
void role_player_drop(struct RolePlayer* role_player)
Frees the native rust RolePlayer
object
void
role_player_get_player
struct Concept* role_player_get_player(const struct RolePlayer* role_player)
Returns the Concept
which plays the role in the RolePlayer
struct Concept*
role_player_get_role_type
struct Concept* role_player_get_role_type(const struct RolePlayer* role_player)
Returns the role-type played by the RolePlayer
struct Concept*
value
value_get_boolean
bool value_get_boolean(const struct Concept* value)
Returns a boolean
value of this value concept. If the value has another type, the error is set.
bool
value_get_date_time_as_millis
int64_t value_get_date_time_as_millis(const struct Concept* value)
Returns the value of this datetime value concept as milliseconds since the start of the UNIX epoch. If the value has another type, the error is set.
int64_t
value_get_double
double value_get_double(const struct Concept* value)
Returns the double
value of this value concept. If the value has another type, the error is set.
double
value_get_long
int64_t value_get_long(const struct Concept* value)
Returns the long
value of this value concept. If the value has another type, the error is set.
int64_t
value_get_string
char* value_get_string(const struct Concept* value)
Returns the string
value of this value concept. If the value has another type, the error is set.
char*
value_is_boolean
bool value_is_boolean(const struct Concept* value)
Returns true
if the value which this Value
concept holds is of type boolean
. Otherwise, returns false
.
bool
value_is_date_time
bool value_is_date_time(const struct Concept* value)
Returns true
if the value which this Value
concept holds is of type datetime
. Otherwise, returns false
.
bool
value_is_double
bool value_is_double(const struct Concept* value)
Returns true
if the value which this Value
concept holds is of type double
. Otherwise, returns false
.
bool
value_is_long
bool value_is_long(const struct Concept* value)
Returns true
if the value which this Value
concept holds is of type long
. Otherwise, returns false
.
bool
value_is_string
bool value_is_string(const struct Concept* value)
Returns true
if the value which this Value
concept holds is of type string
. Otherwise, returns false
.
bool
value_new_boolean
struct Concept* value_new_boolean(bool bool_)
Creates a new Value
object of the specified boolean value.
struct Concept*
value_new_date_time_from_millis
struct Concept* value_new_date_time_from_millis(int64_t millis)
Creates a new Value
object of the specified datetime value.
struct Concept*
value_new_double
struct Concept* value_new_double(double double_)
Creates a new Value
object of the specified double value.
struct Concept*
Schema
entitytype
entity_type_create
struct ConceptPromise* entity_type_create(struct Transaction* transaction, const struct Concept* entity_type)
Creates and returns a new instance of this EntityType
.
struct ConceptPromise*
entity_type_get_instances
struct ConceptIterator* entity_type_get_instances(struct Transaction* transaction, const struct Concept* entity_type, enum Transitivity transitivity)
Retrieves all Entity
objects that are instances of this EntityType
or its subtypes. Specify Transitive
for instances of this EntityType and subtypes, Or Explicit
of this EntityType only
struct ConceptIterator*
entity_type_get_subtypes
struct ConceptIterator* entity_type_get_subtypes(struct Transaction* transaction, const struct Concept* entity_type, enum Transitivity transitivity)
Retrieves all direct and indirect (or direct only) subtypes of the given EntityType. Specify Transitive
for direct and indirect subtypes, Or Explicit
for directly subtypes only.
struct ConceptIterator*
entity_type_get_supertype
struct ConceptPromise* entity_type_get_supertype(struct Transaction* transaction, const struct Concept* entity_type)
Retrieves the most immediate supertype of the given EntityType
.
struct ConceptPromise*
attributetype
attribute_type_get
struct ConceptPromise* attribute_type_get(struct Transaction* transaction, const struct Concept* attribute_type, const struct Concept* value)
Retrieves an Attribute
of this AttributeType
with the given Value
if such Attribute
exists. Otherwise, returns null
.
struct ConceptPromise*
attribute_type_get_instances
struct ConceptIterator* attribute_type_get_instances(struct Transaction* transaction, const struct Concept* attribute_type, enum Transitivity transitivity)
Retrieves all Attribute
objects that are instances of this AttributeType
or its subtypes. Specify Transitive
for instances of this AttributeType and subtypes, Or Explicit
of this AttributeType only
struct ConceptIterator*
attribute_type_get_owners
struct ConceptIterator* attribute_type_get_owners(struct Transaction* transaction, const struct Concept* attribute_type, enum Transitivity transitivity, const struct Annotation*const* annotations)
Retrieve all Things
that own an attribute of this AttributeType
directly or through inheritance. Specify Transitive
for direct and inherited ownership, or Explicit
for direct ownership only
Name | Description | Type |
---|---|---|
|
a null-terminated array of |
|
struct ConceptIterator*
attribute_type_get_regex
struct StringPromise* attribute_type_get_regex(struct Transaction* transaction, const struct Concept* attribute_type)
Retrieves the regular expression that is defined for this AttributeType
.
struct StringPromise*
attribute_type_get_subtypes
struct ConceptIterator* attribute_type_get_subtypes(struct Transaction* transaction, const struct Concept* attribute_type, enum Transitivity transitivity)
Retrieves all direct and indirect (or direct only) subtypes of the given AttributeType
. Specify Transitive
for direct and indirect subtypes, Or Explicit
for directly subtypes only.
struct ConceptIterator*
attribute_type_get_subtypes_with_value_type
struct ConceptIterator* attribute_type_get_subtypes_with_value_type(struct Transaction* transaction, const struct Concept* attribute_type, enum ValueType value_type, enum Transitivity transitivity)
Retrieves subtypes of this AttributeType
with given ValueType
. Specify Transitive
for direct and indirect subtypes, Or Explicit
for directly subtypes only.
struct ConceptIterator*
attribute_type_get_supertype
struct ConceptPromise* attribute_type_get_supertype(struct Transaction* transaction, const struct Concept* attribute_type)
Retrieves the most immediate supertype of the given AttributeType
.
struct ConceptPromise*
attribute_type_get_supertypes
struct ConceptIterator* attribute_type_get_supertypes(struct Transaction* transaction, const struct Concept* attribute_type)
Retrieves all supertypes of the given AttributeType
.
struct ConceptIterator*
attribute_type_get_value_type
enum ValueType attribute_type_get_value_type(const struct Concept* attribute_type)
Retrieves the ValueType
of this AttributeType
.
enum ValueType
attribute_type_put
struct ConceptPromise* attribute_type_put(struct Transaction* transaction, const struct Concept* attribute_type, const struct Concept* value)
Creates and returns a new instance of this AttributeType
, with the specified Value
.
struct ConceptPromise*
attribute_type_set_regex
struct VoidPromise* attribute_type_set_regex(struct Transaction* transaction, const struct Concept* attribute_type, const char* regex)
Sets a regular expression as a constraint for this AttributeType
. Value
s of all Attribute
s of this type (inserted earlier or later) should match this regex.
Can only be applied for AttributeType
s with a string
value type.
struct VoidPromise*
relationtype
relation_type_create
struct ConceptPromise* relation_type_create(struct Transaction* transaction, const struct Concept* relation_type)
Creates and returns a new instance of this RelationType
.
struct ConceptPromise*
relation_type_get_instances
struct ConceptIterator* relation_type_get_instances(struct Transaction* transaction, const struct Concept* relation_type, enum Transitivity transitivity)
Retrieves all Relation
objects that are instances of this RelationType
or its subtypes. Specify Transitive
for instances of this RelationType and subtypes, Or Explicit
of this RelationType only
struct ConceptIterator*
relation_type_get_relates
struct ConceptIterator* relation_type_get_relates(struct Transaction* transaction, const struct Concept* relation_type, enum Transitivity transitivity)
Retrieves roles that this RelationType
relates to directly or via inheritance. Specify Transitive
for direct and inherited relates Or Explicit
for direct relates only
struct ConceptIterator*
relation_type_get_relates_for_role_label
struct ConceptPromise* relation_type_get_relates_for_role_label(struct Transaction* transaction, const struct Concept* relation_type, const char* role_label)
Retrieves the role with the specified label that this RelationType
relates to, directly or via inheritance.
struct ConceptPromise*
relation_type_get_relates_overridden
struct ConceptPromise* relation_type_get_relates_overridden(struct Transaction* transaction, const struct Concept* relation_type, const char* overridden_role_label)
Retrieves the RoleType
that is overridden by the role with the role_label
.
struct ConceptPromise*
relation_type_get_subtypes
struct ConceptIterator* relation_type_get_subtypes(struct Transaction* transaction, const struct Concept* relation_type, enum Transitivity transitivity)
Retrieves all direct and indirect (or direct only) subtypes of the given RelationType. Specify Transitive
for direct and indirect subtypes, Or Explicit
for directly subtypes only.
struct ConceptIterator*
relation_type_get_supertype
struct ConceptPromise* relation_type_get_supertype(struct Transaction* transaction, const struct Concept* relation_type)
Retrieves the most immediate supertype of the given RelationType
.
struct ConceptPromise*
relation_type_get_supertypes
struct ConceptIterator* relation_type_get_supertypes(struct Transaction* transaction, const struct Concept* relation_type)
Retrieves all supertypes of the given RelationType.
struct ConceptIterator*
relation_type_set_relates
struct VoidPromise* relation_type_set_relates(struct Transaction* transaction, struct Concept* relation_type, const char* role_label, const char* overridden_role_label)
Sets the new role that this RelationType
relates to. If we are setting an overriding type this way, we have to also pass overridden_role_label.
struct VoidPromise*
roletype
role_type_delete
struct VoidPromise* role_type_delete(struct Transaction* transaction, const struct Concept* role_type)
Deletes this role type from the database.
struct VoidPromise*
role_type_get_name
char* role_type_get_name(const struct Concept* role_type)
Gets the name of this role type.
char*
role_type_get_player_instances
struct ConceptIterator* role_type_get_player_instances(struct Transaction* transaction, const struct Concept* role_type, enum Transitivity transitivity)
Retrieves the Thing
instances that play this role. Specify Transitive
for direct and indirect playing, or Explicit
for direct playing only
struct ConceptIterator*
role_type_get_player_types
struct ConceptIterator* role_type_get_player_types(struct Transaction* transaction, const struct Concept* role_type, enum Transitivity transitivity)
Retrieves the ThingType
s whose instances play this role. Specify Transitive
for direct and indirect playing, or Explicit
for direct playing only
struct ConceptIterator*
role_type_get_relation_instances
struct ConceptIterator* role_type_get_relation_instances(struct Transaction* transaction, const struct Concept* role_type, enum Transitivity transitivity)
Retrieves the Relation
instances that this role is related to. Specify Transitive
for direct and indirect relation, or Explicit
for direct relation only
struct ConceptIterator*
role_type_get_relation_type
struct ConceptPromise* role_type_get_relation_type(struct Transaction* transaction, const struct Concept* role_type)
Retrieves the RelationType
that this role is directly related to.
struct ConceptPromise*
role_type_get_relation_types
struct ConceptIterator* role_type_get_relation_types(struct Transaction* transaction, const struct Concept* role_type)
Retrieves RelationType
s that this role is related to (directly or indirectly).
struct ConceptIterator*
role_type_get_scope
char* role_type_get_scope(const struct Concept* role_type)
Gets the 'scope' of this role type. This corresponds to the label of the RelationType
it is directly related to.
char*
role_type_get_subtypes
struct ConceptIterator* role_type_get_subtypes(struct Transaction* transaction, const struct Concept* role_type, enum Transitivity transitivity)
Retrieves all direct and indirect (or direct only) subtypes of the given RoleType
. Specify Transitive
for direct and indirect subtypes, Or Explicit
for directly subtypes only.
struct ConceptIterator*
role_type_get_supertype
struct ConceptPromise* role_type_get_supertype(struct Transaction* transaction, const struct Concept* role_type)
Retrieves the most immediate supertype of the given RoleType
.
struct ConceptPromise*
role_type_get_supertypes
struct ConceptIterator* role_type_get_supertypes(struct Transaction* transaction, const struct Concept* role_type)
Retrieves all supertypes of the given RoleType
.
struct ConceptIterator*
role_type_is_abstract
bool role_type_is_abstract(const struct Concept* role_type)
Checks if the role type is prevented from having data instances (i.e., abstract
).
bool
role_type_is_deleted
struct BoolPromise* role_type_is_deleted(const struct Transaction* transaction, const struct Concept* role_type)
Check if the role type has been deleted
struct BoolPromise*
annotation
annotation_drop
void annotation_drop(struct Annotation* annotation)
Frees the native rust Annotation
object
void
annotation_equals
bool annotation_equals(const struct Annotation* lhs, const struct Annotation* rhs)
Checks whether the provided Annotation
objects are equal
bool
annotation_is_key
bool annotation_is_key(const struct Annotation* annotation)
Checks whether the provided Annotation
is @key
bool
annotation_is_unique
bool annotation_is_unique(const struct Annotation* annotation)
Checks whether the provided Annotation
is @unique
bool
annotation_new_key
struct Annotation* annotation_new_key(void)
Produces a @key
annotation.
struct Annotation*
Logic
logic
logic_manager_get_rule
struct RulePromise* logic_manager_get_rule(struct Transaction* transaction, const char* label)
Retrieves the Rule that has the given label.
struct RulePromise*
logic_manager_get_rules
struct RuleIterator* logic_manager_get_rules(struct Transaction* transaction)
Returns a RuleIterator
over all rules in the database for the transaction.
struct RuleIterator*
logic_manager_put_rule
struct RulePromise* logic_manager_put_rule(struct Transaction* transaction, const char* label, const char* when, const char* then)
Creates a new Rule if none exists with the given label, or replaces the existing one.
Name | Description | Type |
---|---|---|
|
The label of the Rule to create or replace |
|
|
The when body of the rule to create |
|
|
The then body of the rule to create |
|
struct RulePromise*
rule
Struct Rule
Rules are a part of schema and define embedded logic. The reasoning engine uses rules as a set of logic to infer new data. A rule consists of a condition and a conclusion, and is uniquely identified by a label.
Struct RulePromise
Promise object representing the result of an asynchronous operation. Use rule_promise_resolve(RulePromise*) to wait for and retrieve the resulting Rule
.
rule_delete
struct VoidPromise* rule_delete(const struct Transaction* transaction, struct Rule* rule)
Deletes this rule.
struct VoidPromise*
rule_drop
void rule_drop(struct Rule* rule)
Frees the native rust ReplicaInfoIterator
object.
void
rule_get_label
char* rule_get_label(const struct Rule* rule)
Retrieves the unique label of the rule.
char*
rule_get_then
char* rule_get_then(const struct Rule* rule)
The single statement that constitutes the ‘then’ of the rule.
char*
rule_get_when
char* rule_get_when(const struct Rule* rule)
The statements that constitute the ‘when’ of the rule.
char*
rule_is_deleted
struct BoolPromise* rule_is_deleted(const struct Transaction* transaction, struct Rule* rule)
Check if this rule has been deleted.
struct BoolPromise*
rule_iterator_drop
void rule_iterator_drop(struct RuleIterator* it)
Frees the native rust RuleIterator
object.
void
rule_iterator_next
struct Rule* rule_iterator_next(struct RuleIterator* it)
Forwards the RuleIterator
and returns the next Rule
if it exists, or null if there are no more elements.
struct Rule*
rule_promise_resolve
struct Rule* rule_promise_resolve(struct RulePromise* promise)
Waits for and returns the result of the operation represented by the RulePromise
object. In case the operation failed, the error flag will only be set when the promise is resolved. The native promise object is freed when it is resolved.
struct Rule*
Errors
error
check_error
bool check_error(void)
Checks if the error flag was set by the last operation. If true, the error can be retrieved using get_last_error(void)
bool
error_code
char* error_code(const struct Error* error)
Returns the error code of the Error
object
char*
schemaexception
Struct SchemaExceptionIterator
Iterator over the SchemaException
s in the result of concepts_get_schema_exceptions(Transaction*).
schema_exception_code
char* schema_exception_code(const struct SchemaException* schema_exception)
Returns the error code of the SchemaException
object
char*
schema_exception_drop
void schema_exception_drop(struct SchemaException* schema_exception)
Frees the native rust SchemaException
object
void
schema_exception_iterator_drop
void schema_exception_iterator_drop(struct SchemaExceptionIterator* it)
Frees the native rust SchemaExceptionIterator
object
void