Officially out now: The TypeDB 3.0 Roadmap

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.

Returns

void

connection_force_close

void connection_force_close(struct Connection* connection)

Forcibly closes the driver. To be used in exceptional cases.

Returns

void

connection_is_open

bool connection_is_open(const struct Connection* connection)

Checks whether this connection is presently open.

Returns

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.

Input parameters
Name Description Type

addresses

a null-terminated array holding the address(es) of the TypeDB server(s)

const char*const*

credential

The Credential to connect with

const struct Credential*

Returns

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.

Input parameters
Name Description Type

public_addresses

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 advertised_addresses

const char*const*

private_addresses

A null-terminated array holding the address(es) the TypeDB server(s) are configured to advertise

const char*const*

credential

The Credential to connect with

const struct Credential*

Returns

struct Connection*

connection_open_core

struct Connection* connection_open_core(const char* address)

Open a TypeDB Driver to a TypeDB Core server available at the provided address.

Input parameters
Name Description Type

address

The address of the TypeDB server

const char*

Returns

struct Connection*

init_logging

void init_logging(void)

Enables logging in the TypeDB driver.

Returns

void

credential

Struct Credential

User credentials and TLS encryption settings for connecting to TypeDB Cloud.

credential_drop

void credential_drop(struct Credential* credential)

Frees the native rust Credential object

Returns

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.

Input parameters
Name Description Type

username

The name of the user to connect as

const char*

password

The password for the user

const char*

tls_root_ca

Path to the CA certificate to use for authenticating server certificates.

const char*

with_tls

Specify whether the connection to TypeDB Cloud must be done over TLS

bool

Returns

struct Credential*

database

Struct Database

A TypeDB database

Struct DatabaseIterator

An Iterator over databases present on the TypeDB server

Struct DatabaseManager

Provides access to all database management methods.

database_close

void database_close(struct Database* database)

Frees the native rust Database object

Returns

void

database_delete

void database_delete(struct Database* database)

Deletes this database.

Returns

void

database_get_name

char* database_get_name(const struct Database* database)

The database name as a string.

Returns

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

Returns

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

Returns

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

Returns

struct ReplicaInfoIterator*

database_iterator_drop

void database_iterator_drop(struct DatabaseIterator* it)

Frees the native rust DatabaseIterator object

Returns

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.

Returns

struct Database*

database_manager_drop

void database_manager_drop(struct DatabaseManager* databases)

Frees the native rust DatabaseManager object

Returns

void

database_manager_new

struct DatabaseManager* database_manager_new(const struct Connection* connection)

Creates and returns a native DatabaseManager for the connection

Returns

struct DatabaseManager*

database_rule_schema

char* database_rule_schema(struct Database* database)

The rules in the schema as a valid TypeQL define query string.

Returns

char*

database_schema

char* database_schema(struct Database* database)

A full schema text as a valid TypeQL define query string.

Returns

char*

database_type_schema

char* database_type_schema(struct Database* database)

The types in the schema as a valid TypeQL define query string.

Returns

char*

databases_all

struct DatabaseIterator* databases_all(struct DatabaseManager* databases)

Returns a DatabaseIterator over all databases present on the TypeDB server

Returns

struct DatabaseIterator*

databases_contains

bool databases_contains(struct DatabaseManager* databases, const char* name)

Checks if a database with the given name exists

Returns

bool

databases_create

void databases_create(struct DatabaseManager* databases, const char* name)

Create a database with the given name

Returns

void

databases_get

struct Database* databases_get(struct DatabaseManager* databases, const char* name)

Retrieve the database with the given name.

Returns

struct Database*

replica

Struct ReplicaInfo

The metadata and state of an individual raft replica of a database.

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

Returns

void

replica_info_get_server

char* replica_info_get_server(const struct ReplicaInfo* replica_info)

The server hosting this replica

Returns

char*

replica_info_get_term

int64_t replica_info_get_term(const struct ReplicaInfo* replica_info)

The raft protocol ‘term’ of this replica.

Returns

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.

Returns

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.

Returns

bool

replica_info_iterator_drop

void replica_info_iterator_drop(struct ReplicaInfoIterator* it)

Frees the native rust ReplicaInfoIterator object

Returns

void

replica_info_iterator_next

struct ReplicaInfo* replica_info_iterator_next(struct ReplicaInfoIterator* it)

Forwards the ReplicaInfoIterator and returns the next ReplicaInfo if it exists, or null if there are no more elements.

Returns

struct ReplicaInfo*

user

Struct User

User information

Struct UserIterator

Iterator over a set of Users

Struct UserManager

Provides access to all user management methods.

user_drop

void user_drop(struct User* user)

Frees the native rust User object.

Returns

void

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.

Returns

int64_t

user_get_username

char* user_get_username(struct User* user)

Returns the name of this user.

Returns

char*

user_iterator_drop

void user_iterator_drop(struct UserIterator* it)

Frees the native rust UserIterator object

Returns

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.

Returns

struct User*

user_manager_drop

void user_manager_drop(struct UserManager* user_manager)

Frees the native rust UserManager object

Returns

void

user_manager_new

struct UserManager* user_manager_new(const struct Connection* connection)

Creates a UserManager on the specified connection

Returns

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.

Input parameters
Name Description Type

user

The user to update the password of - must be the current user.

struct User*

user_manager

The UserManager object on this connection.

const struct UserManager*

password_old

The current password of this user

const char*

password_new

The new password

const char*

Returns

void

users_all

struct UserIterator* users_all(const struct UserManager* user_manager)

Retrieves all users which exist on the TypeDB server.

Returns

struct UserIterator*

users_contains

bool users_contains(const struct UserManager* user_manager, const char* username)

Checks if a user with the given name exists.

Returns

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.

Returns

void

users_current_user

struct User* users_current_user(const struct UserManager* user_manager)

Retrieves the user who opened this connection

Returns

struct User*

users_delete

void users_delete(const struct UserManager* user_manager, const char* username)

Deletes the user with the given username.

Returns

void

users_get

struct User* users_get(const struct UserManager* user_manager, const char* username)

Retrieves a user with the given name.

Returns

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.

Input parameters
Name Description Type

user_manager

The UserManager object to be used. This must be on a connection opened by an administrator.

const struct UserManager*

username

The name of the user to set the password of

const char*

password

The new password

const char*

Returns

void

Session

session

Struct Session

A session with a TypeDB database.

Struct SessionType

This enum is used to specify the type of the session.

Enum SessionType

This enum is used to specify the type of the session.

Enum constants
Name

Data = 0

Schema = 1

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.

Returns

void

session_force_close

void session_force_close(struct Session* session)

Forcibly closes the session. To be used in exceptional cases.

Returns

void

session_get_database_name

char* session_get_database_name(const struct Session* session)

Returns the name of the database of the session.

Returns

char*

session_is_open

bool session_is_open(const struct Session* session)

Checks whether this session is open.

Returns

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.

Input parameters
Name Description Type

databases

The DatabaseManager object on this connection.

struct DatabaseManager*

database_name

The name of the database with which the session connects

const char*

session_type

The type of session to be created (Schema or Data)

enum SessionType

options

Options for this session

const struct Options*

Returns

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.

Input parameters
Name Description Type

session

The session on which to register the callback

const struct Session*

data

The argument to be passed to the callback function when it is executed

void*

callback

The function to be called

finished

A function which will be executed when the session is destroyed, allowing cleanup

Returns

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.

Input parameters
Name Description Type

session

The session on which to register the callback

const struct Session*

data

The argument to be passed to the callback function when it is executed

void*

callback

The function to be called

finished

A function which will be executed when the session is destroyed, allowing cleanup

Returns

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.

Returns

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.

Returns

bool

options_get_infer

bool options_get_infer(const struct Options* options)

Returns the value set for the inference in this TypeDBOptions object.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

bool

options_new

struct Options* options_new(void)

Produces a new TypeDBOptions object.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Input parameters
Name Description Type

prefetchSize

Number of answers that the server should send before the driver issues a fresh request

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

void

Transaction

transaction

Struct Transaction

A transaction with a TypeDB database.

Struct TransactionType

This enum is used to specify the type of transaction.

Enum TransactionType

This enum is used to specify the type of transaction.

Enum constants
Name

Read = 0

Write = 1

transaction_close

void transaction_close(struct Transaction* txn)

Closes the transaction and frees the native rust object.

Returns

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.

Returns

struct VoidPromise*

transaction_force_close

void transaction_force_close(struct Transaction* txn)

Forcibly closes this transaction. To be used in exceptional cases.

Returns

void

transaction_is_open

bool transaction_is_open(const struct Transaction* txn)

Checks whether this transaction is open.

Returns

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.

Input parameters
Name Description Type

type_

The type of transaction to be created (Write or Read).

enum TransactionType

options

Options for the transaction

const struct Options*

Returns

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.

Input parameters
Name Description Type

txn

The transaction on which to register the callback

const struct Transaction*

callback_id

The argument to be passed to the callback function when it is executed.

uintptr_t

callback

The function to be called

Returns

void

transaction_rollback

struct VoidPromise* transaction_rollback(const struct Transaction* txn)

Rolls back the uncommitted changes made via this transaction.

Returns

struct VoidPromise*

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.

Returns

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.

Returns

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.

Input parameters
Name Description Type

explainable

The Explainable to be explained

const struct Explainable*

options

Specify query options

const struct Options*

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

struct ConceptMapIterator*

query_undefine

struct VoidPromise* query_undefine(struct Transaction* transaction, const char* query, const struct Options* options)

Performs a TypeQL Undefine query in the transaction.

Returns

struct VoidPromise*

query_update

struct ConceptMapIterator* query_update(struct Transaction* transaction, const char* query, const struct Options* options)

Performs a TypeQL Update query in the transaction.

Returns

struct ConceptMapIterator*

Answer

conceptmap

Struct ConceptMap

Contains a mapping of variables to concepts.

Struct ConceptMapGroup

Contains an element of the TypeQL Get Group query result.

Struct ConceptMapGroupIterator

Iterator over the ConceptMapGroups in the result of the TypeQL Get Group query.

Struct ConceptMapIterator

Iterator over the ConceptMaps in the result of a TypeQL Get query.

concept_map_drop

void concept_map_drop(struct ConceptMap* concept_map)

Frees the native rust ConceptMap object

Returns

void

concept_map_equals

bool concept_map_equals(const struct ConceptMap* lhs, const struct ConceptMap* rhs)

Checks whether the provided ConceptMap objects are equal

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

struct StringIterator*

concept_map_group_drop

void concept_map_group_drop(struct ConceptMapGroup* concept_map_group)

Frees the native rust ConceptMapGroup object

Returns

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

Returns

bool

concept_map_group_get_concept_maps

struct ConceptMapIterator* concept_map_group_get_concept_maps(const struct ConceptMapGroup* concept_map_group)

Retrieves the ConceptMaps of the group.

Returns

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.

Returns

struct Concept*

concept_map_group_iterator_drop

void concept_map_group_iterator_drop(struct ConceptMapGroupIterator* it)

Frees the native rust ConceptMapGroupIterator object

Returns

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.

Returns

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

Returns

char*

concept_map_iterator_drop

void concept_map_iterator_drop(struct ConceptMapIterator* it)

Frees the native rust ConceptMapIterator object

Returns

void

concept_map_iterator_next

struct ConceptMap* concept_map_iterator_next(struct ConceptMapIterator* it)

Forwards the ConceptMapIterator and returns the next ConceptMap if it exists, or null if there are no more elements.

Returns

struct ConceptMap*

concept_map_to_string

char* concept_map_to_string(const struct ConceptMap* concept_map)

A string representation of this ConceptMap.

Returns

char*

valuegroup

Struct ValueGroup

Contains an element of a TypeQL Get Group Aggregate query result.

Struct ValueGroupIterator

Iterator over the ValueGroups 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

Returns

void

value_group_equals

bool value_group_equals(const struct ValueGroup* lhs, const struct ValueGroup* rhs)

Checks whether the provided ValueGroup objects are equal

Returns

bool

value_group_get_owner

struct Concept* value_group_get_owner(struct ValueGroup* value_group)

Retrieves the concept that is the group owner.

Returns

struct Concept*

value_group_get_value

struct Concept* value_group_get_value(struct ValueGroup* value_group)

Retrieves the Value answer of the group.

Returns

struct Concept*

value_group_iterator_drop

void value_group_iterator_drop(struct ValueGroupIterator* it)

Frees the native rust ValueGroupIterator object

Returns

void

value_group_iterator_next

struct ValueGroup* value_group_iterator_next(struct ValueGroupIterator* it)

Forwards the ValueGroupIterator and returns the next ValueGroup if it exists, or null if there are no more elements.

Returns

struct ValueGroup*

value_group_to_string

char* value_group_to_string(const struct ValueGroup* value_group)

A string representation of this ValueGroup object

Returns

char*

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 StringIterator

Iterator over the strings in the result of a request or a TypeQL Fetch query.

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 StringPairs 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.

Returns

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.

Returns

void

string_iterator_drop

void string_iterator_drop(struct StringIterator* it)

Frees the native rust StringIterator object

Returns

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.

Returns

char*

string_pair_drop

void string_pair_drop(struct StringPair* string_pair)

Frees the native rust StringPair object

Returns

void

string_pair_iterator_drop

void string_pair_iterator_drop(struct StringPairIterator* it)

Frees the native rust StringPairIterator object

Returns

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.

Returns

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.

Returns

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.

Returns

void

explanation

Struct Explainable

Contains an explainable object.

Struct Explainables

Contains explainable objects.

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.

Struct ExplanationIterator

Iterator over the Explanations in the result of the explain query.

explainable_drop

void explainable_drop(struct Explainable* explainable)

Frees the native rust Explainable object

Returns

void

explainable_get_conjunction

char* explainable_get_conjunction(const struct Explainable* explainable)

Retrieves the subquery of the original query that is actually being explained.

Returns

char*

explainable_get_id

int64_t explainable_get_id(const struct Explainable* explainable)

Retrieves the unique ID that identifies this Explainable.

Returns

int64_t

explainables_drop

void explainables_drop(struct Explainables* explainables)

Frees the native rust Explainables object

Returns

void

explainables_equals

bool explainables_equals(const struct Explainables* lhs, const struct Explainables* rhs)

Checks whether the provided Explainables objects are equal

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

struct StringIterator*

explainables_to_string

char* explainables_to_string(const struct Explainables* explainables)

A string representation of this Explainables object

Returns

char*

explanation_drop

void explanation_drop(struct Explanation* explanation)

Frees the native rust Explanation object

Returns

void

explanation_equals

bool explanation_equals(const struct Explanation* lhs, const struct Explanation* rhs)

Checks whether the provided Explanation objects are equal

Returns

bool

explanation_get_conclusion

struct ConceptMap* explanation_get_conclusion(const struct Explanation* explanation)

Retrieves the Conclusion for this Explanation.

Returns

struct ConceptMap*

explanation_get_condition

struct ConceptMap* explanation_get_condition(const struct Explanation* explanation)

Retrieves the Condition for this Explanation.

Returns

struct ConceptMap*

explanation_get_mapped_variables

struct StringIterator* explanation_get_mapped_variables(const struct Explanation* explanation)

Retrieves the query variables for this Explanation.

Returns

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.

Returns

struct StringIterator*

explanation_get_rule

struct Rule* explanation_get_rule(const struct Explanation* explanation)

Retrieves the Rule for this Explanation.

Returns

struct Rule*

explanation_iterator_drop

void explanation_iterator_drop(struct ExplanationIterator* it)

Frees the native rust ExplanationIterator object

Returns

void

explanation_iterator_next

struct Explanation* explanation_iterator_next(struct ExplanationIterator* it)

Forwards the Explanation and returns the next Explanation if it exists, or null if there are no more elements.

Returns

struct Explanation*

explanation_to_string

char* explanation_to_string(const struct Explanation* explanation)

A string representation of this Explanation object

Returns

char*

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 ConceptIterator

Iterator over the Conceptss returned by an API method or query.

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

Returns

void

concept_equals

bool concept_equals(const struct Concept* lhs, const struct Concept* rhs)

Checks whether the provided Concept objects are equal

Returns

bool

concept_is_attribute

bool concept_is_attribute(const struct Concept* concept)

Checks if the concept is an Attribute.

Returns

bool

concept_is_attribute_type

bool concept_is_attribute_type(const struct Concept* concept)

Checks if the concept is an AttributeType.

Returns

bool

concept_is_entity

bool concept_is_entity(const struct Concept* concept)

Checks if the concept is an Entity.

Returns

bool

concept_is_entity_type

bool concept_is_entity_type(const struct Concept* concept)

Checks if the concept is an EntityType.

Returns

bool

concept_is_relation

bool concept_is_relation(const struct Concept* concept)

Checks if the concept is a Relation.

Returns

bool

concept_is_relation_type

bool concept_is_relation_type(const struct Concept* concept)

Checks if the concept is a RelationType.

Returns

bool

concept_is_role_type

bool concept_is_role_type(const struct Concept* concept)

Checks if the concept is a RoleType.

Returns

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.

Returns

bool

concept_is_value

bool concept_is_value(const struct Concept* concept)

Checks if the concept is a Value.

Returns

bool

concept_iterator_drop

void concept_iterator_drop(struct ConceptIterator* it)

Frees the native rust ConceptIterator object

Returns

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.

Returns

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.

Returns

struct Concept*

concept_to_string

char* concept_to_string(const struct Concept* concept)

A string representation of this Concept object

Returns

char*

concepts_get_attribute

struct ConceptPromise* concepts_get_attribute(const struct Transaction* transaction, const char* iid)

Retrieves an Attribute instance by its iid.

Returns

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.

Returns

struct ConceptPromise*

concepts_get_entity

struct ConceptPromise* concepts_get_entity(const struct Transaction* transaction, const char* iid)

Retrieves an Entity instance by its iid.

Returns

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.

Returns

struct ConceptPromise*

concepts_get_relation

struct ConceptPromise* concepts_get_relation(const struct Transaction* transaction, const char* iid)

Retrieves a relation instance by its iid.

Returns

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.

Returns

struct ConceptPromise*

concepts_get_root_attribute_type

struct Concept* concepts_get_root_attribute_type(void)

Retrieves the root AttributeType, “attribute”.

Returns

struct Concept*

concepts_get_root_entity_type

struct Concept* concepts_get_root_entity_type(void)

Retrieves the root EntityType, “entity”.

Returns

struct Concept*

concepts_get_root_relation_type

struct Concept* concepts_get_root_relation_type(void)

Retrieves the root RelationType, “relation”.

Returns

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.

Returns

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.

Returns

struct ConceptPromise*

concepts_put_entity_type

struct ConceptPromise* concepts_put_entity_type(const struct Transaction* transaction, const char* label)

Creates a new EntityType if none exists with the given label, otherwise retrieves the existing one.

Returns

struct ConceptPromise*

concepts_put_relation_type

struct ConceptPromise* concepts_put_relation_type(const struct Transaction* transaction, const char* label)

Creates a new RelationType if none exists with the given label, otherwise retrieves the existing one.

Returns

struct ConceptPromise*

thing

thing_delete

struct VoidPromise* thing_delete(struct Transaction* transaction, struct Concept* thing)

Deletes this Thing.

Returns

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 Attributes that this Thing owns, optionally filtered by AttributeTypes.

Input parameters
Name Description Type

transaction

The current transaction

struct Transaction*

thing

The thing to get owned attributes of

const struct Concept*

attribute_types

a null-terminated array holding the attribute-types to include

const struct Concept*const*

annotations

a null-terminated array of annotations - If non-empty, Only retrieves attributes with all given Annotations

const struct Annotation*const*

Returns

struct ConceptIterator*

thing_get_iid

char* thing_get_iid(struct Concept* thing)

Retrieves the unique id of the Thing.

Returns

char*

thing_get_is_inferred

bool thing_get_is_inferred(struct Concept* thing)

Checks if this Thing is inferred by a [Reasoning Rule].

Returns

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.

Returns

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.

Input parameters
Name Description Type

role_types

a null-terminated array of RoleTypes to include.

const struct Concept*const*

Returns

struct ConceptIterator*

thing_is_deleted

struct BoolPromise* thing_is_deleted(struct Transaction* transaction, const struct Concept* thing)

Checks if this Thing is deleted.

Returns

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.

Returns

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.

Returns

struct VoidPromise*

thing_type_get_label

char* thing_type_get_label(const struct Concept* thing_type)

Retrieves the unique label of the thing type.

Returns

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

Input parameters
Name Description Type

annotations

a null-terminated array of Annotations - If non-empty, Only retrieves attribute types owned with all specified annotations.

const struct Annotation*const*

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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).

Returns

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

Returns

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"")

Returns

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.

Returns

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.

Returns

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.

Input parameters
Name Description Type

transaction

The current transaction

const struct Transaction*

thing_type

The thing type which is to own the specified attribute

struct Concept*

attribute_type

The attribute type which is to be owned by the specified thing type

const struct Concept*

overridden_attribute_type

Optional, The attribute whose ownership must be overridden

const struct Concept*

annotations

A null-terminated array of Annotations to be added to the ownership

const struct Annotation*const*

Returns

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.

Returns

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.

Returns

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.

Returns

struct VoidPromise*

thing_type_unset_plays

struct VoidPromise* thing_type_unset_plays(const struct Transaction* transaction, struct Concept* thing_type, const struct Concept* role_type)

Disallows the instances of this ThingType from playing the given role.

Returns

struct VoidPromise*

thing_unset_has

struct VoidPromise* thing_unset_has(struct Transaction* transaction, struct Concept* thing, const struct Concept* attribute)

Unassigns an Attribute from this Thing.

Returns

struct VoidPromise*

entity

entity_get_type

struct Concept* entity_get_type(const struct Concept* entity)

Retrieves the type which this Entity belongs to.

Returns

struct Concept*

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.

Returns

struct ConceptIterator*

attribute_get_type

struct Concept* attribute_get_type(const struct Concept* attribute)

Retrieves the type which this Attribute belongs to.

Returns

struct Concept*

attribute_get_value

struct Concept* attribute_get_value(const struct Concept* attribute)

Retrieves the type which this Relation belongs to.

Returns

struct Concept*

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.

Returns

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.

Input parameters
Name Description Type

role_types

a null-terminated array of RoleTypes to include.

const struct Concept*const*

Returns

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.

Returns

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.

Returns

struct RolePlayerIterator*

relation_get_type

struct Concept* relation_get_type(const struct Concept* relation)

Retrieves the type which this Relation belongs to.

Returns

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.

Returns

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

Returns

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

Returns

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

Returns

struct Concept*

role_player_iterator_drop

void role_player_iterator_drop(struct RolePlayerIterator* it)

Frees the native rust RolePlayerIterator object

Returns

void

role_player_iterator_next

struct RolePlayer* role_player_iterator_next(struct RolePlayerIterator* it)

Forwards the RolePlayerIterator and returns the next RolePlayer if it exists, or null if there are no more elements.

Returns

struct RolePlayer*

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

bool

value_new_boolean

struct Concept* value_new_boolean(bool bool_)

Creates a new Value object of the specified boolean value.

Returns

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.

Returns

struct Concept*

value_new_double

struct Concept* value_new_double(double double_)

Creates a new Value object of the specified double value.

Returns

struct Concept*

value_new_long

struct Concept* value_new_long(int64_t long_)

Creates a new Value object of the specified long value.

Returns

struct Concept*

value_new_string

struct Concept* value_new_string(const char* string)

Creates a new Value object of the specified string value.

Returns

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.

Returns

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

Returns

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.

Returns

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.

Returns

struct ConceptPromise*

entity_type_get_supertypes

struct ConceptIterator* entity_type_get_supertypes(struct Transaction* transaction, const struct Concept* entity_type)

Retrieves all supertypes of the given EntityType.

Returns

struct ConceptIterator*

entity_type_set_supertype

struct VoidPromise* entity_type_set_supertype(struct Transaction* transaction, struct Concept* entity_type, const struct Concept* supertype)

Sets the supplied EntityType as the supertype of the current EntityType.

Returns

struct VoidPromise*

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.

Returns

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

Returns

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

Input parameters
Name Description Type

annotations

a null-terminated array of Annotations - If non-empty, Only retrieves thing types of ownerships with all specified annotations.

const struct Annotation*const*

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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. Values of all Attributes of this type (inserted earlier or later) should match this regex.

Can only be applied for AttributeTypes with a string value type.

Returns

struct VoidPromise*

attribute_type_set_supertype

struct VoidPromise* attribute_type_set_supertype(struct Transaction* transaction, struct Concept* attribute_type, const struct Concept* supertype)

Sets the supplied AttributeType as the supertype of the current AttributeType.

Returns

struct VoidPromise*

attribute_type_unset_regex

struct VoidPromise* attribute_type_unset_regex(struct Transaction* transaction, const struct Concept* attribute_type)

Removes the regular expression that is defined for this AttributeType.

Returns

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.

Returns

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

Returns

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

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

struct VoidPromise*

relation_type_set_supertype

struct VoidPromise* relation_type_set_supertype(struct Transaction* transaction, struct Concept* relation_type, const struct Concept* supertype)

Sets the supplied RelationType as the supertype of the current RelationType.

Returns

struct VoidPromise*

relation_type_unset_relates

struct VoidPromise* relation_type_unset_relates(struct Transaction* transaction, struct Concept* relation_type, const char* role_label)

Disallows this RelationType from relating to the given role.

Returns

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.

Returns

struct VoidPromise*

role_type_get_name

char* role_type_get_name(const struct Concept* role_type)

Gets the name of this role type.

Returns

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

Returns

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 ThingTypes whose instances play this role. Specify Transitive for direct and indirect playing, or Explicit for direct playing only

Returns

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

Returns

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.

Returns

struct ConceptPromise*

role_type_get_relation_types

struct ConceptIterator* role_type_get_relation_types(struct Transaction* transaction, const struct Concept* role_type)

Retrieves RelationTypes that this role is related to (directly or indirectly).

Returns

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.

Returns

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.

Returns

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.

Returns

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.

Returns

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).

Returns

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

Returns

struct BoolPromise*

role_type_is_root

bool role_type_is_root(const struct Concept* role_type)

Checks if the role type is the root role type, ""relation:role""

Returns

bool

role_type_set_label

struct VoidPromise* role_type_set_label(struct Transaction* transaction, const struct Concept* role_type, const char* new_label)

Renames the label of the type. The new label must remain unique in the hierarchy of a relation type.

Returns

struct VoidPromise*

annotation

Struct Annotation

Annotations are used to specify extra schema constraints.

annotation_drop

void annotation_drop(struct Annotation* annotation)

Frees the native rust Annotation object

Returns

void

annotation_equals

bool annotation_equals(const struct Annotation* lhs, const struct Annotation* rhs)

Checks whether the provided Annotation objects are equal

Returns

bool

annotation_is_key

bool annotation_is_key(const struct Annotation* annotation)

Checks whether the provided Annotation is @key

Returns

bool

annotation_is_unique

bool annotation_is_unique(const struct Annotation* annotation)

Checks whether the provided Annotation is @unique

Returns

bool

annotation_new_key

struct Annotation* annotation_new_key(void)

Produces a @key annotation.

Returns

struct Annotation*

annotation_new_unique

struct Annotation* annotation_new_unique(void)

Produces a @unique annotation.

Returns

struct Annotation*

annotation_to_string

char* annotation_to_string(const struct Annotation* annotation)

A string representation of this Annotation object

Returns

char*

transitivity

Struct Transitivity

Used for specifying whether we need explicit or transitive subtyping, instances, etc.

Enum Transitivity

Used for specifying whether we need explicit or transitive subtyping, instances, etc.

Enum constants
Name

Explicit

Transitive

valuetype

Struct ValueType

Represents the type of primitive value is held by a Value or Attribute.

Enum ValueType

Represents the type of primitive value is held by a Value or Attribute.

Enum constants
Name

Boolean

DateTime

Double

Long

Object

String

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.

Returns

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.

Returns

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.

Input parameters
Name Description Type

label

The label of the Rule to create or replace

const char*

when

The when body of the rule to create

const char*

then

The then body of the rule to create

const char*

Returns

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 RuleIterator

An iterator over Rules in the database

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.

Returns

struct VoidPromise*

rule_drop

void rule_drop(struct Rule* rule)

Frees the native rust ReplicaInfoIterator object.

Returns

void

rule_get_label

char* rule_get_label(const struct Rule* rule)

Retrieves the unique label of the rule.

Returns

char*

rule_get_then

char* rule_get_then(const struct Rule* rule)

The single statement that constitutes the ‘then’ of the rule.

Returns

char*

rule_get_when

char* rule_get_when(const struct Rule* rule)

The statements that constitute the ‘when’ of the rule.

Returns

char*

rule_is_deleted

struct BoolPromise* rule_is_deleted(const struct Transaction* transaction, struct Rule* rule)

Check if this rule has been deleted.

Returns

struct BoolPromise*

rule_iterator_drop

void rule_iterator_drop(struct RuleIterator* it)

Frees the native rust RuleIterator object.

Returns

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.

Returns

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.

Returns

struct Rule*

rule_set_label

struct VoidPromise* rule_set_label(const struct Transaction* transaction, struct Rule* rule, const char* new_label)

Renames the label of the rule. The new label must remain unique.

Returns

struct VoidPromise*

rule_to_string

char* rule_to_string(const struct Rule* rule)

A string representation of this Rule object

Returns

char*

Errors

error

Struct Error

Represents errors encountered during operation.

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)

Returns

bool

error_code

char* error_code(const struct Error* error)

Returns the error code of the Error object

Returns

char*

error_drop

void error_drop(struct Error* error)

Frees the native rust Error object

Returns

void

error_message

char* error_message(const struct Error* error)

Returns the error message of the Error object

Returns

char*

get_last_error

struct Error* get_last_error(void)

Returns the error which set the error flag.

Returns

struct Error*

schemaexception

Struct SchemaException

Represents invalid schema constructs discovered during schema validation.

Struct SchemaExceptionIterator

Iterator over the SchemaExceptions 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

Returns

char*

schema_exception_drop

void schema_exception_drop(struct SchemaException* schema_exception)

Frees the native rust SchemaException object

Returns

void

schema_exception_iterator_drop

void schema_exception_iterator_drop(struct SchemaExceptionIterator* it)

Frees the native rust SchemaExceptionIterator object

Returns

void

schema_exception_iterator_next

struct SchemaException* schema_exception_iterator_next(struct SchemaExceptionIterator* it)

Forwards the SchemaExceptionIterator and returns the next SchemaException if it exists, or null if there are no more elements.

Returns

struct SchemaException*

schema_exception_message

char* schema_exception_message(const struct SchemaException* schema_exception)

Returns the error message of the SchemaException object

Returns

char*