Officially out now: The TypeDB 3.0 Roadmap >>

Rust driver API reference

Connection

Connection

Implements traits:

  • Clone

  • Debug

A connection to a TypeDB server which serves as the starting point for all interaction.

force_close

pub fn force_close(&self) -> Result

Closes this connection.

Returns
Result
Code examples
connection.force_close()

is_cloud

pub fn is_cloud(&self) -> bool

Check if the connection is to an Cloud server.

Returns
bool
Code examples
connection.is_cloud()

is_open

pub fn is_open(&self) -> bool

Checks it this connection is opened.

Returns
bool
Code examples
connection.is_open()

new_cloud

pub fn new_cloud<T: AsRef<str> + Sync>(
    init_addresses: &[T],
    credential: Credential
) -> Result<Self>

Creates a new TypeDB Cloud connection.

Input parameters
Name Description Type

init_addresses

Addresses (host:port) on which TypeDB Cloud nodes are running

&[T]

credential

User credential and TLS encryption setting

Credential

Returns
Result<Self>
Code examples
Connection::new_cloud(
    &["localhost:11729", "localhost:21729", "localhost:31729"],
    Credential::with_tls(
        "admin",
        "password",
        Some(&PathBuf::from(
            std::env::var("ROOT_CA")
                .expect("ROOT_CA environment variable needs to be set for cloud tests to run"),
        )),
    )?,
)

new_cloud_with_translation

pub fn new_cloud_with_translation<T, U>(
    address_translation: HashMap<T, U>,
    credential: Credential
) -> Result<Self>where
    T: AsRef<str> + Sync,
    U: AsRef<str> + Sync,

Creates a new TypeDB Cloud connection.

Input parameters
Name Description Type

address_translation

Translation map from addresses to be used by the driver for connection to addresses received from the TypeDB server(s)

HashMap<T

credential

User credential and TLS encryption setting

Credential

Returns
Result<Self>where
    T: AsRef<str> + Sync,
    U: AsRef<str> + Sync,
Code examples
Connection::new_cloud_with_translation(
    [
        ("typedb-cloud.ext:11729", "localhost:11729"),
        ("typedb-cloud.ext:21729", "localhost:21729"),
        ("typedb-cloud.ext:31729", "localhost:31729"),
    ].into(),
    credential,
)

new_core

pub fn new_core(address: impl AsRef<str>) -> Result<Self>

Creates a new TypeDB Server connection.

Input parameters
Name Description Type

address

The address (host:port) on which the TypeDB Server is running

impl AsRef<str>

Returns
Result<Self>
Code examples
Connection::new_core("127.0.0.1:1729")

Credential

Implements traits:

  • Clone

  • Debug

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

is_tls_enabled

pub fn is_tls_enabled(&self) -> bool

Retrieves whether TLS is enabled for the connection.

Returns
bool

password

pub fn password(&self) -> &str

Retrieves the password used.

Returns
&str

username

pub fn username(&self) -> &str

Retrieves the username used.

Returns
&str

with_tls

pub fn with_tls(
    username: &str,
    password: &str,
    tls_root_ca: Option<&Path>
) -> Result<Self>

Creates a credential with username and password. Specifies the connection must use TLS

Input parameters
Name Description Type

username

The name of the user to connect as

&str

password

The password for the user

&str

tls_root_ca

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

Option<&Path>

Returns
Result<Self>
Code examples
Credential::with_tls(username, password, Some(&path_to_ca));

without_tls

pub fn without_tls(username: &str, password: &str) -> Self

Creates a credential with username and password. The connection will not use TLS

Input parameters
Name Description Type

username

The name of the user to connect as

&str

password

The password for the user

&str

Returns
Self
Code examples
Credential::without_tls(username, password);

DatabaseManager

Implements traits:

  • Clone

  • Debug

Provides access to all database management methods.

all

  • async

  • sync

pub async fn all(&self) -> Result<Vec<Database>>
pub fn all(&self) -> Result<Vec<Database>>

Retrieves all databases present on the TypeDB server

Returns
Result<Vec<Database>>
Code examples
  • async

  • sync

driver.databases().all().await;
driver.databases().all();

contains

  • async

  • sync

pub async fn contains(&self, name: impl Into<String>) -> Result<bool>
pub fn contains(&self, name: impl Into<String>) -> Result<bool>

Checks if a database with the given name exists

Input parameters
Name Description Type

name

The database name to be checked

impl Into<String>

Returns
Result<bool>
Code examples
  • async

  • sync

driver.databases().contains(name).await;
driver.databases().contains(name);

create

  • async

  • sync

pub async fn create(&self, name: impl Into<String>) -> Result
pub fn create(&self, name: impl Into<String>) -> Result

Create a database with the given name

Input parameters
Name Description Type

name

The name of the database to be created

impl Into<String>

Returns
Result
Code examples
  • async

  • sync

driver.databases().create(name).await;
driver.databases().create(name);

get

  • async

  • sync

pub async fn get(&self, name: impl Into<String>) -> Result<Database>
pub fn get(&self, name: impl Into<String>) -> Result<Database>

Retrieve the database with the given name.

Input parameters
Name Description Type

name

The name of the database to retrieve

impl Into<String>

Returns
Result<Database>
Code examples
  • async

  • sync

driver.databases().get(name).await;
driver.databases().get(name);

Database

Implements traits:

  • Debug

A TypeDB database

delete

  • async

  • sync

pub async fn delete(self) -> Result
pub fn delete(self) -> Result

Deletes this database.

Returns
Result
Code examples
  • async

  • sync

database.delete().await;
database.delete();

name

pub fn name(&self) -> &str

Retrieves the database name as a string.

Returns
&str

preferred_replica_info

pub fn preferred_replica_info(&self) -> Option<ReplicaInfo>

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
Option<ReplicaInfo>
Code examples
database.preferred_replica_info();

primary_replica_info

pub fn primary_replica_info(&self) -> Option<ReplicaInfo>

Returns the primary replica for this database. Only works in TypeDB Cloud

Returns
Option<ReplicaInfo>
Code examples
database.primary_replica_info()

replicas_info

pub fn replicas_info(&self) -> Vec<ReplicaInfo>

Returns the Replica instances for this database. Only works in TypeDB Cloud

Returns
Vec<ReplicaInfo>
Code examples
database.replicas_info()

rule_schema

  • async

  • sync

pub async fn rule_schema(&self) -> Result<String>
pub fn rule_schema(&self) -> Result<String>

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

Returns
Result<String>
Code examples
  • async

  • sync

database.rule_schema().await;
database.rule_schema();

schema

  • async

  • sync

pub async fn schema(&self) -> Result<String>
pub fn schema(&self) -> Result<String>

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

Returns
Result<String>
Code examples
  • async

  • sync

database.schema().await;
database.schema();

type_schema

  • async

  • sync

pub async fn type_schema(&self) -> Result<String>
pub fn type_schema(&self) -> Result<String>

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

Returns
Result<String>
Code examples
  • async

  • sync

database.type_schema().await;
database.type_schema();

ReplicaInfo

Implements traits:

  • Debug

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

Fields
Name Type Description

is_preferred

bool

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.

is_primary

bool

Whether this is the primary replica of the raft cluster.

server

Address

The server hosting this replica

term

i64

The raft protocol ‘term’ of this replica.

UserManager

Implements traits:

  • Clone

  • Debug

Provides access to all user management methods.

all

  • async

  • sync

pub async fn all(&self) -> Result<Vec<User>>
pub fn all(&self) -> Result<Vec<User>>

Retrieves all users which exist on the TypeDB server.

Returns
Result<Vec<User>>
Code examples
driver.users.all().await;

contains

  • async

  • sync

pub async fn contains(&self, username: impl Into<String>) -> Result<bool>
pub fn contains(&self, username: impl Into<String>) -> Result<bool>

Checks if a user with the given name exists.

Input parameters
Name Description Type

username

The user name to be checked

impl Into<String>

Returns
Result<bool>
Code examples
driver.users.contains(username).await;

create

  • async

  • sync

pub async fn create(
    &self,
    username: impl Into<String>,
    password: impl Into<String>
) -> Result
pub fn create(
    &self,
    username: impl Into<String>,
    password: impl Into<String>
) -> Result

Create a user with the given name & password.

Input parameters
Name Description Type

username

The name of the user to be created

impl Into<String>

password

The password of the user to be created

impl Into<String>

Returns
Result
Code examples
driver.users.create(username, password).await;

current_user

  • async

  • sync

pub async fn current_user(&self) -> Result<Option<User>>
pub fn current_user(&self) -> Result<Option<User>>

Returns the logged-in user for the connection.

Returns
Result<Option<User>>
Code examples
driver.users.current_user().await;

delete

  • async

  • sync

pub async fn delete(&self, username: impl Into<String>) -> Result
pub fn delete(&self, username: impl Into<String>) -> Result

Deletes a user with the given name.

Input parameters
Name Description Type

username

The name of the user to be deleted

impl Into<String>

Returns
Result
Code examples
driver.users.delete(username).await;

get

  • async

  • sync

pub async fn get(&self, username: impl Into<String>) -> Result<Option<User>>
pub fn get(&self, username: impl Into<String>) -> Result<Option<User>>

Retrieve a user with the given name.

Input parameters
Name Description Type

username

The name of the user to retrieve

impl Into<String>

Returns
Result<Option<User>>
Code examples
driver.users.get(username).await;

set_password

  • async

  • sync

pub async fn set_password(
    &self,
    username: impl Into<String>,
    password: impl Into<String>
) -> Result
pub fn set_password(
    &self,
    username: impl Into<String>,
    password: impl Into<String>
) -> Result

Sets a new password for a user. This operation can only be performed by administrators.

Input parameters
Name Description Type

username

The name of the user to set the password of

impl Into<String>

password

The new password

impl Into<String>

Returns
Result
Code examples
driver.users.password_set(username, password).await;

User

Implements traits:

  • Clone

  • Debug

User information

Fields
Name Type Description

password_expiry_seconds

Option<i64>

Returns the number of seconds remaining till this user’s current password expires.

username

String

Returns the name of this user.

password_update

  • async

  • sync

pub async fn password_update(
    &self,
    connection: &Connection,
    password_old: impl Into<String>,
    password_new: impl Into<String>
) -> Result
pub fn password_update(
    &self,
    connection: &Connection,
    password_old: impl Into<String>,
    password_new: impl Into<String>
) -> Result

Updates user password.

Input parameters
Name Description Type

connection

an opened Connection

&Connection

password_old

an old password

impl Into<String>

password_new

a new password

impl Into<String>

Returns
Result
Code examples
user.password_update(connection, "oldpassword", "nEwp@ssw0rd").await;

Session

Session

Implements traits:

  • Debug

  • Drop

A session with a TypeDB database.

database_name

pub fn database_name(&self) -> &str

Returns the name of the database of the session.

Returns
&str
Code examples
session.database_name();

force_close

pub fn force_close(&self) -> Result

Closes the session. Before opening a new session, the session currently open should first be closed.

Returns
Result
Code examples
session.force_close();

is_open

pub fn is_open(&self) -> bool

Checks whether this session is open.

Returns
bool
Code examples
session.is_open();

new

  • async

  • sync

pub async fn new(database: Database, session_type: SessionType) -> Result<Self>
pub fn new(database: Database, session_type: SessionType) -> Result<Self>

Opens a communication tunnel (session) to the given database with default options. See Session::new_with_options

Returns
Result<Self>

new_with_options

  • async

  • sync

pub async fn new_with_options(
    database: Database,
    session_type: SessionType,
    options: Options
) -> Result<Self>
pub fn new_with_options(
    database: Database,
    session_type: SessionType,
    options: Options
) -> Result<Self>

Opens a communication tunnel (session) to the given database on the running TypeDB server.

Input parameters
Name Description Type

database

The database with which the session connects

Database

session_type

The type of session to be created (DATA or SCHEMA)

SessionType

options

TypeDBOptions for the session

Options

Returns
Result<Self>
Code examples
  • async

  • sync

Session::new_with_options(database, session_type, options).await;
Session::new_with_options(database, session_type, options);

on_close

pub fn on_close(&self, callback: impl FnMut() + Send + 'static)

Registers a callback function which will be executed when this session is closed.

Input parameters
Name Description Type

function

The callback function.

Returns
null
Code examples
session.on_close(function);

on_reopen

pub fn on_reopen(&self, callback: impl FnMut() + Send + 'static)

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

function

The callback function.

Returns
null
Code examples
session.on_reopen(function);

transaction

  • async

  • sync

pub async fn transaction(
    &self,
    transaction_type: TransactionType
) -> Result<Transaction<'_>>
pub fn transaction(
    &self,
    transaction_type: TransactionType
) -> Result<Transaction<'_>>

Opens a transaction to perform read or write queries on the database connected to the session. See Session::transaction_with_options

Returns
Result<Transaction<'_>>

transaction_with_options

  • async

  • sync

pub async fn transaction_with_options(
    &self,
    transaction_type: TransactionType,
    options: Options
) -> Result<Transaction<'_>>
pub fn transaction_with_options(
    &self,
    transaction_type: TransactionType,
    options: Options
) -> Result<Transaction<'_>>

Opens a transaction to perform read or write queries on the database connected to the session.

Input parameters
Name Description Type

transaction_type

The type of transaction to be created (READ or WRITE)

TransactionType

options

Options for the session

Options

Returns
Result<Transaction<'_>>
Code examples
  • async

  • sync

session.transaction_with_options(transaction_type, options).await;
session.transaction_with_options(transaction_type, options);

type_

pub fn type_(&self) -> SessionType

The current session’s type (SCHEMA or DATA)

Returns
SessionType

SessionType

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

Enum variants
Variant

Data

Schema

Options

Implements traits:

  • Clone

  • Copy

  • Debug

  • Default

TypeDB session and transaction options. TypeDBOptions object can be used to override the default server behaviour. Options are specified using properties assignment.

Fields
Name Type Description

explain

Option<bool>

If set to True, enables explanations for queries. Only affects read transactions.

infer

Option<bool>

If set to True, enables inference for queries. Only settable at transaction level and above. Only affects read transactions.

parallel

Option<bool>

If set to True, the server uses parallel instead of single-threaded execution.

prefetch

Option<bool>

If set to True, the first batch of answers is streamed to the driver even without an explicit request for it.

prefetch_size

Option<i32>

If set, specifies a guideline number of answers that the server should send before the driver issues a fresh request.

read_any_replica

Option<bool>

If set to True, enables reading data from any replica, potentially boosting read throughput. Only settable in TypeDB Cloud.

schema_lock_acquire_timeout

Option<Duration>

If set, specifies how long the driver should wait if opening a session or transaction is blocked by a schema write lock.

session_idle_timeout

Option<Duration>

If set, specifies a timeout that allows the server to close sessions if the driver terminates or becomes unresponsive.

trace_inference

Option<bool>

If set to True, reasoning tracing graphs are output in the logging directory. Should be used with parallel = False.

transaction_timeout

Option<Duration>

If set, specifies a timeout for killing transactions automatically, preventing memory leaks in unclosed transactions.

explain

pub fn explain(self, explain: bool) -> Self

If set to True, enables explanations for queries. Only affects read transactions.

Returns
Self

infer

pub fn infer(self, infer: bool) -> Self

If set to True, enables inference for queries. Only settable at transaction level and above. Only affects read transactions.

Returns
Self

parallel

pub fn parallel(self, parallel: bool) -> Self

If set to True, the server uses parallel instead of single-threaded execution.

Returns
Self

prefetch

pub fn prefetch(self, prefetch: bool) -> Self

If set to True, the first batch of answers is streamed to the driver even without an explicit request for it.

Returns
Self

prefetch_size

pub fn prefetch_size(self, prefetch_size: i32) -> Self

If set, specifies a guideline number of answers that the server should send before the driver issues a fresh request.

Returns
Self

read_any_replica

pub fn read_any_replica(self, read_any_replica: bool) -> Self

If set to True, enables reading data from any replica, potentially boosting read throughput. Only settable in TypeDB Cloud.

Returns
Self

schema_lock_acquire_timeout

pub fn schema_lock_acquire_timeout(self, timeout: Duration) -> Self

If set, specifies how long the driver should wait if opening a session or transaction is blocked by a schema write lock.

Returns
Self

session_idle_timeout

pub fn session_idle_timeout(self, timeout: Duration) -> Self

If set, specifies a timeout that allows the server to close sessions if the driver terminates or becomes unresponsive.

Returns
Self

trace_inference

pub fn trace_inference(self, trace_inference: bool) -> Self

If set to True, reasoning tracing graphs are output in the logging directory. Should be used with parallel = False.

Returns
Self

transaction_timeout

pub fn transaction_timeout(self, timeout: Duration) -> Self

If set, specifies a timeout for killing transactions automatically, preventing memory leaks in unclosed transactions.

Returns
Self

Transaction

Transaction

Implements traits:

  • Debug

A transaction with a TypeDB database.

commit

pub fn commit(self) -> impl Promise<'static, Result>

Commits the changes made via this transaction to the TypeDB database. Whether or not the transaction is commited successfully, it gets closed after the commit call.

Returns
impl Promise<'static, Result>
Code examples
  • async

  • sync

transaction.commit().await
transaction.commit()

concept

pub fn concept(&self) -> ConceptManager<'_>

The ConceptManager for this transaction, providing access to all Concept API methods.

Returns
ConceptManager<'_>

force_close

pub fn force_close(&self)

Closes the transaction.

Returns
null
Code examples
transaction.force_close()

is_open

pub fn is_open(&self) -> bool

Closes the transaction.

Returns
bool
Code examples
transaction.close()

logic

pub fn logic(&self) -> LogicManager<'_>

Retrieves the LogicManager for this Transaction, providing access to all Concept API - Logic methods.

Returns
LogicManager<'_>

on_close

pub fn on_close(
    &self,
    callback: impl FnOnce(ConnectionError) + Send + Sync + 'static
)

Registers a callback function which will be executed when this transaction is closed.

Input parameters
Name Description Type

function

The callback function.

Returns
null
Code examples
transaction.on_close(function)

query

pub fn query(&self) -> QueryManager<'_>

Retrieves theQueryManager for this Transaction, from which any TypeQL query can be executed.

Returns
QueryManager<'_>

rollback

pub fn rollback(&self) -> impl Promise<'_, Result>

Rolls back the uncommitted changes made via this transaction.

Returns
impl Promise<'_, Result>
Code examples
  • async

  • sync

transaction.rollback().await
transaction.rollback()

type_

pub fn type_(&self) -> TransactionType

Retrieves the transaction’s type (READ or WRITE).

Returns
TransactionType

TransactionType

This enum is used to specify the type of transaction.

Enum variants
Variant

Read

Write

QueryManager

Implements traits:

  • Debug

Provides methods for executing TypeQL queries in the transaction.

define

pub fn define(&self, query: &str) -> impl Promise<'tx, Result>

Performs a TypeQL Define query with default options. See QueryManager::define_with_options

Returns
impl Promise<'tx, Result>

define_with_options

pub fn define_with_options(
    &self,
    query: &str,
    options: Options
) -> impl Promise<'tx, Result>

Performs a TypeQL Define query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Define query to be executed

&str

options

Specify query options

Options

Returns
impl Promise<'tx, Result>
Code examples
  • async

  • sync

transaction.query().define_with_options(query, options).await
transaction.query().define_with_options(query, options).resolve()

delete

pub fn delete(&self, query: &str) -> impl Promise<'tx, Result>

Performs a TypeQL Delete query with default options. See QueryManager::delete_with_options

Returns
impl Promise<'tx, Result>

delete_with_options

pub fn delete_with_options(
    &self,
    query: &str,
    options: Options
) -> impl Promise<'tx, Result>

Performs a TypeQL Delete query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Delete query to be executed

&str

options

Specify query options

Options

Returns
impl Promise<'tx, Result>
Code examples
  • async

  • sync

transaction.query().delete_with_options(query, options).await
transaction.query().delete_with_options(query, options).resolve()

explain

pub fn explain(
    &self,
    explainable: &Explainable
) -> Result<impl Stream<Item = Result<Explanation>> + 'tx>

Performs a TypeQL Explain query in the transaction. See ``QueryManager::explain_with_options

Returns
Result<impl Stream<Item = Result<Explanation>> + 'tx>

explain_with_options

pub fn explain_with_options(
    &self,
    explainable: &Explainable,
    options: Options
) -> Result<impl Stream<Item = Result<Explanation>> + 'tx>

Performs a TypeQL Explain query in the transaction.

Input parameters
Name Description Type

explainable

The Explainable to be explained

&Explainable

options

Specify query options

Options

Returns
Result<impl Stream<Item = Result<Explanation>> + 'tx>
Code examples
transaction.query().explain_with_options(explainable, options)

fetch

pub fn fetch(
    &self,
    query: &str
) -> Result<impl Stream<Item = Result<JSON>> + 'tx>

Performs a TypeQL Fetch query with default options. See QueryManager::fetch_with_options

Returns
Result<impl Stream<Item = Result<JSON>> + 'tx>

fetch_with_options

pub fn fetch_with_options(
    &self,
    query: &str,
    options: Options
) -> Result<impl Stream<Item = Result<JSON>> + 'tx>

Performs a TypeQL Match Group Aggregate query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Match Group Aggregate query to be executed

&str

options

Specify query options

Options

Returns
Result<impl Stream<Item = Result<JSON>> + 'tx>
Code examples
transaction.query().fetch_with_options(query, options)

get

pub fn get(
    &self,
    query: &str
) -> Result<impl Stream<Item = Result<ConceptMap>> + 'tx>

Performs a TypeQL Match (Get) query with default options. See QueryManager::get_with_options

Returns
Result<impl Stream<Item = Result<ConceptMap>> + 'tx>

get_aggregate

pub fn get_aggregate(
    &self,
    query: &str
) -> impl Promise<'tx, Result<Option<Value>>>

Performs a TypeQL Match Aggregate query with default options. See QueryManager::get_aggregate

Returns
impl Promise<'tx, Result<Option<Value>>>

get_aggregate_with_options

pub fn get_aggregate_with_options(
    &self,
    query: &str,
    options: Options
) -> impl Promise<'tx, Result<Option<Value>>>

Performs a TypeQL Match Aggregate query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Match Aggregate query to be executed

&str

options

Specify query options

Options

Returns
impl Promise<'tx, Result<Option<Value>>>
Code examples
  • async

  • sync

transaction.query().get_aggregate_with_options(query, options).await
transaction.query().get_aggregate_with_options(query, options).resolve()

get_group

pub fn get_group(
    &self,
    query: &str
) -> Result<impl Stream<Item = Result<ConceptMapGroup>> + 'tx>

Performs a TypeQL Match Group query with default options. See QueryManager::get_group

Returns
Result<impl Stream<Item = Result<ConceptMapGroup>> + 'tx>

get_group_aggregate

pub fn get_group_aggregate(
    &self,
    query: &str
) -> Result<impl Stream<Item = Result<ValueGroup>> + 'tx>

Performs a TypeQL Match Group Aggregate query with default options. See QueryManager::get_group_aggregate_with_options

Returns
Result<impl Stream<Item = Result<ValueGroup>> + 'tx>

get_group_aggregate_with_options

pub fn get_group_aggregate_with_options(
    &self,
    query: &str,
    options: Options
) -> Result<impl Stream<Item = Result<ValueGroup>> + 'tx>

Performs a TypeQL Match Group Aggregate query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Match Group Aggregate query to be executed

&str

options

Specify query options

Options

Returns
Result<impl Stream<Item = Result<ValueGroup>> + 'tx>
Code examples
transaction.query().get_group_aggregate_with_options(query, options)

get_group_with_options

pub fn get_group_with_options(
    &self,
    query: &str,
    options: Options
) -> Result<impl Stream<Item = Result<ConceptMapGroup>> + 'tx>

Performs a TypeQL Match Group query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Match Group query to be executed

&str

options

Specify query options

Options

Returns
Result<impl Stream<Item = Result<ConceptMapGroup>> + 'tx>
Code examples
transaction.query().get_group_with_options(query, options)

get_with_options

pub fn get_with_options(
    &self,
    query: &str,
    options: Options
) -> Result<impl Stream<Item = Result<ConceptMap>> + 'tx>

Performs a TypeQL Match (Get) query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Match (Get) query to be executed

&str

options

Specify query options

Options

Returns
Result<impl Stream<Item = Result<ConceptMap>> + 'tx>
Code examples
transaction.query().get_with_options(query, options)

insert

pub fn insert(
    &self,
    query: &str
) -> Result<impl Stream<Item = Result<ConceptMap>> + 'tx>

Performs a TypeQL Insert query with default options. See QueryManager::insert_with_options

Returns
Result<impl Stream<Item = Result<ConceptMap>> + 'tx>

insert_with_options

pub fn insert_with_options(
    &self,
    query: &str,
    options: Options
) -> Result<impl Stream<Item = Result<ConceptMap>> + 'tx>

Performs a TypeQL Insert query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Insert query to be executed

&str

options

Specify query options

Options

Returns
Result<impl Stream<Item = Result<ConceptMap>> + 'tx>
Code examples
transaction.query().insert_with_options(query, options)

undefine

pub fn undefine(&self, query: &str) -> impl Promise<'tx, Result>

Performs a TypeQL Undefine query with default options See QueryManager::undefine_with_options

Returns
impl Promise<'tx, Result>

undefine_with_options

pub fn undefine_with_options(
    &self,
    query: &str,
    options: Options
) -> impl Promise<'tx, Result>

Performs a TypeQL Undefine query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Undefine query to be executed

&str

options

Specify query options

Options

Returns
impl Promise<'tx, Result>
Code examples
  • async

  • sync

transaction.query().undefine_with_options(query, options).await
transaction.query().undefine_with_options(query, options).resolve()

update

pub fn update(
    &self,
    query: &str
) -> Result<impl Stream<Item = Result<ConceptMap>> + 'tx>

Performs a TypeQL Update query with default options. See QueryManager::update_with_options

Returns
Result<impl Stream<Item = Result<ConceptMap>> + 'tx>

update_with_options

pub fn update_with_options(
    &self,
    query: &str,
    options: Options
) -> Result<impl Stream<Item = Result<ConceptMap>> + 'tx>

Performs a TypeQL Update query in the transaction.

Input parameters
Name Description Type

query

The TypeQL Update query to be executed

&str

options

Specify query options

Options

Returns
Result<impl Stream<Item = Result<ConceptMap>> + 'tx>
Code examples
transaction.query().update_with_options(query, options)

Answer

ConceptMapGroup

Implements traits:

  • Clone

  • Debug

  • PartialEq<ConceptMapGroup>

  • StructuralPartialEq

Contains an element of the TypeQL Get Group query result.

Fields
Name Type Description

concept_maps

Vec<ConceptMap>

Retrieves the ConceptMaps of the group.

owner

Concept

Retrieves the concept that is the group owner.

ConceptMap

Implements traits:

  • Clone

  • Debug

  • From<ConceptMap>

  • Index<String>

  • IntoIterator

  • PartialEq<ConceptMap>

  • StructuralPartialEq

Contains a mapping of variables to concepts.

Fields
Name Type Description

explainables

Explainables

The Explainables object for this ConceptMap, that exposes which of the concepts in this ConceptMap are explainable.

map

HashMap<String, Concept>

The HashMap where keys are query variables, and values are concepts.

concepts

pub fn concepts(&self) -> impl Iterator<Item = &Concept>

Produces an iterator over all concepts in this ConceptMap.

Returns
impl Iterator<Item = &Concept>
Code examples
concept_map.concepts()

get

pub fn get(&self, var_name: &str) -> Option<&Concept>

Retrieves a concept for a given variable name.

Input parameters
Name Description Type

var_name

The string representation of a variable

&str

Returns
Option<&Concept>
Code examples
concept_map.get(var_name)

ValueGroup

Implements traits:

  • Clone

  • Debug

  • PartialEq<ValueGroup>

  • StructuralPartialEq

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

Fields
Name Type Description

owner

Concept

The concept that is the group owner.

value

Option<Value>

JSON

Enum variants
Variant

Array(Vec<JSON>)

Boolean(bool)

Null

Number(f64)

Object(HashMap<Cow<'static, str>, JSON>)

String(Cow<'static, str>)

Trait Promise

  • async

  • sync

Async promise, an alias for Rust’s built-in Future. A BoxPromise is an alias for Rust’s built-in BoxFuture.

Examples
promise.await

A resolvable promise that can be resolved at a later time. a BoxPromise is in practical terms a Box<dyn Promise> and resolves with .resolve().

Examples
promise.resolve()

Explainables

Implements traits:

  • Clone

  • Debug

  • Default

  • PartialEq<Explainables>

  • StructuralPartialEq

Contains explainable objects.

Fields
Name Type Description

attributes

HashMap<String, Explainable>

Explainable attributes

ownerships

HashMap<(String, String), Explainable>

Explainable pairs of (owner, attribute)

relations

HashMap<String, Explainable>

Explainable relations

is_empty

pub fn is_empty(&self) -> bool

Checks if this Explainables does not contain any Explainable object.

Returns
bool
Code examples
explainables.is_empty()

Explainable

Implements traits:

  • Clone

  • Debug

  • PartialEq<Explainable>

  • StructuralPartialEq

Contains an explainable object.

Fields
Name Type Description

conjunction

String

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

id

i64

The unique ID that identifies this Explainable.

Explanation

Implements traits:

  • Debug

  • PartialEq<Explanation>

  • StructuralPartialEq

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.

Fields
Name Type Description

conclusion

ConceptMap

The Conclusion for this Explanation.

condition

ConceptMap

The Condition for this Explanation.

rule

Rule

The Rule for this Explanation.

variable_mapping

HashMap<String, Vec<String>>

The mapping from query variables to rule variables for this Explanation.

Concept

ConceptManager

Implements traits:

  • Debug

Provides access for all Concept API methods.

get_attribute

pub fn get_attribute(
    &self,
    iid: IID
) -> impl Promise<'tx, Result<Option<Attribute>>>

Retrieves an Attribute by its iid.

Input parameters
Name Description Type

iid

The iid of the Attribute to retrieve

IID

Returns
impl Promise<'tx, Result<Option<Attribute>>>
Code examples
  • async

  • sync

transaction.concepts().get_attribute(iid).await
transaction.concepts().get_attribute(iid).resolve()

get_attribute_type

pub fn get_attribute_type(
    &self,
    label: String
) -> impl Promise<'tx, Result<Option<AttributeType>>>

Retrieves an AttributeType by its label.

Input parameters
Name Description Type

label

The label of the AttributeType to retrieve

String

Returns
impl Promise<'tx, Result<Option<AttributeType>>>
Code examples
  • async

  • sync

transaction.concepts().get_attribute_type(label).await
transaction.concepts().get_attribute_type(label).resolve()

get_entity

pub fn get_entity(&self, iid: IID) -> impl Promise<'tx, Result<Option<Entity>>>

Retrieves an Entity by its iid.

Input parameters
Name Description Type

iid

The iid of the Entity to retrieve

IID

Returns
impl Promise<'tx, Result<Option<Entity>>>
Code examples
  • async

  • sync

transaction.concepts().get_entity(iid).await
transaction.concepts().get_entity(iid).resolve()

get_entity_type

pub fn get_entity_type(
    &self,
    label: String
) -> impl Promise<'tx, Result<Option<EntityType>>>

Retrieves an EntityType by its label.

Input parameters
Name Description Type

label

The label of the EntityType to retrieve

String

Returns
impl Promise<'tx, Result<Option<EntityType>>>
Code examples
  • async

  • sync

transaction.concepts().get_entity_type(label).await
transaction.concepts().get_entity_type(label).resolve()

get_relation

pub fn get_relation(
    &self,
    iid: IID
) -> impl Promise<'tx, Result<Option<Relation>>>

Retrieves a Relation by its iid.

Input parameters
Name Description Type

iid

The iid of the Relation to retrieve

IID

Returns
impl Promise<'tx, Result<Option<Relation>>>
Code examples
  • async

  • sync

transaction.concepts().get_relation(iid).await
transaction.concepts().get_relation(iid).resolve()

get_relation_type

pub fn get_relation_type(
    &self,
    label: String
) -> impl Promise<'tx, Result<Option<RelationType>>>

Retrieves a RelationType by its label.

Input parameters
Name Description Type

label

The label of the RelationType to retrieve

String

Returns
impl Promise<'tx, Result<Option<RelationType>>>
Code examples
  • async

  • sync

transaction.concepts().get_relation_type(label).await
transaction.concepts().get_relation_type(label).resolve()

get_schema_exceptions

pub fn get_schema_exceptions(
    &self
) -> Result<impl Stream<Item = Result<SchemaException>> + 'tx>

Retrieves a list of all schema exceptions for the current transaction.

Returns
Result<impl Stream<Item = Result<SchemaException>> + 'tx>
Code examples
transaction.concepts().get_schema_exceptions()

put_attribute_type

pub fn put_attribute_type(
    &self,
    label: String,
    value_type: ValueType
) -> impl Promise<'tx, Result<AttributeType>>

Creates a new AttributeType if none exists with the given label, or retrieves the existing one. or retrieve. :return:

Input parameters
Name Description Type

label

The label of the AttributeType to create or retrieve

String

value_type

The value type of the AttributeType to create

ValueType

Returns
impl Promise<'tx, Result<AttributeType>>
Code examples
  • async

  • sync

transaction.concepts().put_attribute_type(label, value_type).await
transaction.concepts().put_attribute_type(label, value_type).resolve()

put_entity_type

pub fn put_entity_type(
    &self,
    label: String
) -> impl Promise<'tx, Result<EntityType>>

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

Input parameters
Name Description Type

label

The label of the EntityType to create or retrieve

String

Returns
impl Promise<'tx, Result<EntityType>>
Code examples
  • async

  • sync

transaction.concepts().put_entity_type(label).await
transaction.concepts().put_entity_type(label).resolve()

put_relation_type

pub fn put_relation_type(
    &self,
    label: String
) -> impl Promise<'tx, Result<RelationType>>

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

Input parameters
Name Description Type

label

The label of the RelationType to create or retrieve

String

Returns
impl Promise<'tx, Result<RelationType>>
Code examples
  • async

  • sync

transaction.concepts().put_relation_type(label).await
transaction.concepts().put_relation_type(label).resolve()

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.

Enum variants
Variant

Attribute(Attribute)

AttributeType(AttributeType)

Entity(Entity)

EntityType(EntityType)

Relation(Relation)

RelationType(RelationType)

RoleType(RoleType)

RootThingType(RootThingType)

Value(Value)

Schema

RootThingType

Implements traits:

  • Clone

  • Debug

  • Eq

  • PartialEq<RootThingType>

  • StructuralEq

  • StructuralPartialEq

  • ThingTypeAPI

delete

fn delete<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

get_owns

fn get_owns<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    value_type: Option<ValueType>,
    transitivity: Transitivity,
    annotations: Vec<Annotation>
) -> Result<BoxStream<'tx, Result<AttributeType>>>
Returns
Result<BoxStream<'tx, Result<AttributeType>>>

get_owns_overridden

fn get_owns_overridden<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    overridden_attribute_type: AttributeType
) -> BoxPromise<'tx, Result<Option<AttributeType>>>
Returns
BoxPromise<'tx, Result<Option<AttributeType>>>

get_plays

fn get_plays<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>>
Returns
Result<BoxStream<'tx, Result<RoleType>>>

get_plays_overridden

fn get_plays_overridden<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    overridden_role_type: RoleType
) -> BoxPromise<'tx, Result<Option<RoleType>>>
Returns
BoxPromise<'tx, Result<Option<RoleType>>>

get_syntax

fn get_syntax<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<String>>
Returns
BoxPromise<'tx, Result<String>>

is_abstract

fn is_abstract(&self) -> bool
Returns
bool

is_deleted

fn is_deleted<'tx>(
    &self,
    _transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
Returns
BoxPromise<'tx, Result<bool>>

is_root

fn is_root(&self) -> bool
Returns
bool

label

fn label(&self) -> &str
Returns
&str

set_abstract

fn set_abstract<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_label

fn set_label<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    new_label: String
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_owns

fn set_owns<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    attribute_type: AttributeType,
    overridden_attribute_type: Option<AttributeType>,
    annotations: Vec<Annotation>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_plays

fn set_plays<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    role_type: RoleType,
    overridden_role_type: Option<RoleType>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_abstract

fn unset_abstract<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_owns

fn unset_owns<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    attribute_type: AttributeType
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_plays

fn unset_plays<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    role_type: RoleType
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

ThingType

Enum variants
Variant

AttributeType(AttributeType)

EntityType(EntityType)

RelationType(RelationType)

RootThingType(RootThingType)

label

pub fn label(&self) -> &str

Retrieves the unique label of the ThingType.

Returns
&str
Code examples
thing_type.label()

Trait ThingTypeAPI

Implementors:

  • AttributeType

  • EntityType

  • RelationType

  • RootThingType

delete

fn delete<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>

Deletes this type from the database.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

thing_type.delete(transaction).await;
thing_type.delete(transaction).resolve();

get_owns

fn get_owns<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    value_type: Option<ValueType>,
    transitivity: Transitivity,
    annotations: Vec<Annotation>
) -> Result<BoxStream<'tx, Result<AttributeType>>>

Retrieves AttributeType that the instances of this ThingType are allowed to own directly or via inheritance.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

value_type

If specified, only attribute types of this ValueType will be retrieved.

Option<ValueType>

transitivity

Transitivity::Transitive for direct and inherited ownership, Transitivity::Explicit for direct ownership only

Transitivity

annotations

Only retrieve attribute types owned with annotations.

Vec<Annotation>

Returns
Result<BoxStream<'tx, Result<AttributeType>>>
Code examples
  • async

  • sync

thing_type.get_owns(transaction, Some(value_type), Transitivity::Explicit, vec![Annotation::Key]).await;
thing_type.get_owns(transaction, Some(value_type), Transitivity::Explicit, vec![Annotation::Key]);

get_owns_overridden

fn get_owns_overridden<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    overridden_attribute_type: AttributeType
) -> BoxPromise<'tx, Result<Option<AttributeType>>>

Retrieves an AttributeType, ownership of which is overridden for this ThingType by a given attribute_type.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

overridden_attribute_type

The AttributeType that overrides requested AttributeType

AttributeType

Returns
BoxPromise<'tx, Result<Option<AttributeType>>>
Code examples
  • async

  • sync

thing_type.get_owns_overridden(transaction, attribute_type).await;
thing_type.get_owns_overridden(transaction, attribute_type).resolve();

get_plays

fn get_plays<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>>

Retrieves all direct and inherited (or direct only) roles that are allowed to be played by the instances of this ThingType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

transitivity

Transitivity::Transitive for direct and indirect playing, Transitivity::Explicit for direct playing only

Transitivity

Returns
Result<BoxStream<'tx, Result<RoleType>>>
Code examples
  • async

  • sync

thing_type.get_plays(transaction, Transitivity::Explicit).await;
thing_type.get_plays(transaction, Transitivity::Explicit).resolve();

get_plays_overridden

fn get_plays_overridden<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    overridden_role_type: RoleType
) -> BoxPromise<'tx, Result<Option<RoleType>>>

Retrieves a RoleType that is overridden by the given role_type for this ThingType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

overridden_role_type

The RoleType that overrides an inherited role

RoleType

Returns
BoxPromise<'tx, Result<Option<RoleType>>>
Code examples
  • async

  • sync

thing_type.get_plays_overridden(transaction, role_type).await;
thing_type.get_plays_overridden(transaction, role_type).resolve();

get_syntax

fn get_syntax<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<String>>

Produces a pattern for creating this ThingType in a define query.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result<String>>
Code examples
  • async

  • sync

thing_type.get_syntax(transaction).await;
thing_type.get_syntax(transaction).resolve();

is_abstract

fn is_abstract(&self) -> bool

Checks if the type is prevented from having data instances (i.e. abstract).

Returns
bool
Code examples
thing_type.is_abstract();

is_deleted

fn is_deleted<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>

Checks if this type is deleted.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result<bool>>
Code examples
  • async

  • sync

thing_type.is_deleted(transaction).await;
thing_type.is_deleted(transaction).resolve();

is_root

fn is_root(&self) -> bool

Checks if the type is a root type.

Returns
bool
Code examples
thing_type.is_root();

label

fn label(&self) -> &str

Retrieves the unique label of the type.

Returns
&str
Code examples
thing_type.label();

set_abstract

fn set_abstract<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>

Set a type to be abstract, meaning it cannot have instances.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

thing_type.set_abstract(transaction).await;
thing_type.set_abstract(transaction).resolve();

set_label

fn set_label<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    new_label: String
) -> BoxPromise<'tx, Result>

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

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

new_label

The new Label to be given to the type.

String

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

thing_type.set_label(transaction, new_label).await;
thing_type.set_label(transaction, new_label).resolve();

set_owns

fn set_owns<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    attribute_type: AttributeType,
    overridden_attribute_type: Option<AttributeType>,
    annotations: Vec<Annotation>
) -> BoxPromise<'tx, Result>

Allows the instances of this ThingType to own the given AttributeType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

attribute_type

The AttributeType to be owned by the instances of this type.

AttributeType

overridden_attribute_type

The AttributeType that this attribute ownership overrides, if applicable.

Option<AttributeType>

annotations

Adds annotations to the ownership.

Vec<Annotation>

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

thing_type.set_owns(transaction, attribute_type, Some(overridden_type), vec![Annotation::Key]).await;
thing_type.set_owns(transaction, attribute_type, Some(overridden_type), vec![Annotation::Key]);

set_plays

fn set_plays<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    role_type: RoleType,
    overridden_role_type: Option<RoleType>
) -> BoxPromise<'tx, Result>

Allows the instances of this ThingType to play the given role.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

role_type

The role to be played by the instances of this type

RoleType

overridden_role_type

The role type that this role overrides, if applicable

Option<RoleType>

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

thing_type.set_plays(transaction, role_type, None).await;
thing_type.set_plays(transaction, role_type, None).resolve();

unset_abstract

fn unset_abstract<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>

Set a type to be non-abstract, meaning it can have instances.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

thing_type.unset_abstract(transaction).await;
thing_type.unset_abstract(transaction).resolve();

unset_owns

fn unset_owns<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    attribute_type: AttributeType
) -> BoxPromise<'tx, Result>

Disallows the instances of this ThingType from owning the given AttributeType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

attribute_type

The AttributeType to not be owned by the type.

AttributeType

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

thing_type.unset_owns(transaction, attribute_type).await;
thing_type.unset_owns(transaction, attribute_type).resolve();

unset_plays

fn unset_plays<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    role_type: RoleType
) -> BoxPromise<'tx, Result>

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

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

role_type

The role to not be played by the instances of this type.

RoleType

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

thing_type.unset_plays(transaction, role_type).await;
thing_type.unset_plays(transaction, role_type).resolve();

EntityType

Implements traits:

  • Clone

  • Debug

  • EntityTypeAPI

  • Eq

  • PartialEq<EntityType>

  • StructuralEq

  • StructuralPartialEq

  • ThingTypeAPI

Entity types represent the classification of independent objects in the data model of the business domain.

Fields
Name Type Description

is_abstract

bool

is_root

bool

label

String

create

fn create<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Entity>>
Returns
BoxPromise<'tx, Result<Entity>>

delete

fn delete<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

get_instances

fn get_instances<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<Entity>>>
Returns
Result<BoxStream<'tx, Result<Entity>>>

get_owns

fn get_owns<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    value_type: Option<ValueType>,
    transitivity: Transitivity,
    annotations: Vec<Annotation>
) -> Result<BoxStream<'tx, Result<AttributeType>>>
Returns
Result<BoxStream<'tx, Result<AttributeType>>>

get_owns_overridden

fn get_owns_overridden<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    overridden_attribute_type: AttributeType
) -> BoxPromise<'tx, Result<Option<AttributeType>>>
Returns
BoxPromise<'tx, Result<Option<AttributeType>>>

get_plays

fn get_plays<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>>
Returns
Result<BoxStream<'tx, Result<RoleType>>>

get_plays_overridden

fn get_plays_overridden<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    overridden_role_type: RoleType
) -> BoxPromise<'tx, Result<Option<RoleType>>>
Returns
BoxPromise<'tx, Result<Option<RoleType>>>

get_subtypes

fn get_subtypes<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<EntityType>>>
Returns
Result<BoxStream<'tx, Result<EntityType>>>

get_supertype

fn get_supertype<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<EntityType>>>
Returns
BoxPromise<'tx, Result<Option<EntityType>>>

get_supertypes

fn get_supertypes<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<EntityType>>>
Returns
Result<BoxStream<'tx, Result<EntityType>>>

get_syntax

fn get_syntax<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<String>>
Returns
BoxPromise<'tx, Result<String>>

is_abstract

fn is_abstract(&self) -> bool
Returns
bool

is_deleted

fn is_deleted<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
Returns
BoxPromise<'tx, Result<bool>>

is_root

fn is_root(&self) -> bool
Returns
bool

label

fn label(&self) -> &str
Returns
&str

root

pub fn root() -> Self

Returns the root EntityType

Returns
Self

set_abstract

fn set_abstract<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_label

fn set_label<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    new_label: String
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_owns

fn set_owns<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    attribute_type: AttributeType,
    overridden_attribute_type: Option<AttributeType>,
    annotations: Vec<Annotation>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_plays

fn set_plays<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    role_type: RoleType,
    overridden_role_type: Option<RoleType>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_supertype

fn set_supertype<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    supertype: EntityType
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_abstract

fn unset_abstract<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_owns

fn unset_owns<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    attribute_type: AttributeType
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_plays

fn unset_plays<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    role_type: RoleType
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

Trait EntityTypeAPI

Implementors:

  • EntityType

create

fn create<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Entity>>

Creates and returns a new instance of this EntityType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result<Entity>>
Code examples
  • async

  • sync

entity_type.create(transaction).await;
entity_type.create(transaction).resolve();

get_instances

fn get_instances<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<Entity>>>

Retrieves all direct and indirect (or direct only) Entity objects that are instances of this EntityType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

transitivity

Transitivity::Transitive for direct and indirect instances, Transitivity::Explicit for direct instances only

Transitivity

Returns
Result<BoxStream<'tx, Result<Entity>>>
Code examples
entity_type.get_instances(transaction, Transitivity::Explicit);

get_subtypes

fn get_subtypes<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<EntityType>>>

Retrieves all direct and indirect (or direct only) subtypes of the EntityType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

transitivity

Transitivity::Transitive for direct and indirect subtypes, Transitivity::Explicit for direct subtypes only

Transitivity

Returns
Result<BoxStream<'tx, Result<EntityType>>>
Code examples
entity_type.get_subtypes(transaction, Transitivity::Transitive);

get_supertype

fn get_supertype<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<EntityType>>>

Retrieves the most immediate supertype of the EntityType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result<Option<EntityType>>>
Code examples
  • async

  • sync

entity_type.get_supertype(transaction).await;
entity_type.get_supertype(transaction).resolve();

get_supertypes

fn get_supertypes<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<EntityType>>>

Retrieves all supertypes of the EntityType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
Result<BoxStream<'tx, Result<EntityType>>>
Code examples
entity_type.get_supertypes(transaction);

set_supertype

fn set_supertype<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    supertype: EntityType
) -> BoxPromise<'tx, Result>

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

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

supertype

The EntityType to set as the supertype of this EntityType

EntityType

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

entity_type.set_supertype(transaction, super_entity_type).await;
entity_type.set_supertype(transaction, super_entity_type).resolve();

RelationType

Implements traits:

  • Clone

  • Debug

  • Eq

  • PartialEq<RelationType>

  • RelationTypeAPI

  • StructuralEq

  • StructuralPartialEq

  • ThingTypeAPI

Relation types (or subtypes of the relation root type) represent relationships between types. Relation types have roles.

Other types can play roles in relations if it’s mentioned in their definition.

A relation type must specify at least one role.

Fields
Name Type Description

is_abstract

bool

is_root

bool

label

String

create

fn create<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Relation>>
Returns
BoxPromise<'tx, Result<Relation>>

delete

fn delete<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

get_instances

fn get_instances<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<Relation>>>
Returns
Result<BoxStream<'tx, Result<Relation>>>

get_owns

fn get_owns<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    value_type: Option<ValueType>,
    transitivity: Transitivity,
    annotations: Vec<Annotation>
) -> Result<BoxStream<'tx, Result<AttributeType>>>
Returns
Result<BoxStream<'tx, Result<AttributeType>>>

get_owns_overridden

fn get_owns_overridden<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    overridden_attribute_type: AttributeType
) -> BoxPromise<'tx, Result<Option<AttributeType>>>
Returns
BoxPromise<'tx, Result<Option<AttributeType>>>

get_plays

fn get_plays<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>>
Returns
Result<BoxStream<'tx, Result<RoleType>>>

get_plays_overridden

fn get_plays_overridden<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    overridden_role_type: RoleType
) -> BoxPromise<'tx, Result<Option<RoleType>>>
Returns
BoxPromise<'tx, Result<Option<RoleType>>>

get_relates

fn get_relates<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>>
Returns
Result<BoxStream<'tx, Result<RoleType>>>

get_relates_for_role_label

fn get_relates_for_role_label<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    role_label: String
) -> BoxPromise<'tx, Result<Option<RoleType>>>
Returns
BoxPromise<'tx, Result<Option<RoleType>>>

get_relates_overridden

fn get_relates_overridden<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    overridden_role_label: String
) -> BoxPromise<'tx, Result<Option<RoleType>>>
Returns
BoxPromise<'tx, Result<Option<RoleType>>>

get_subtypes

fn get_subtypes<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RelationType>>>
Returns
Result<BoxStream<'tx, Result<RelationType>>>

get_supertype

fn get_supertype<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<RelationType>>>
Returns
BoxPromise<'tx, Result<Option<RelationType>>>

get_supertypes

fn get_supertypes<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RelationType>>>
Returns
Result<BoxStream<'tx, Result<RelationType>>>

get_syntax

fn get_syntax<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<String>>
Returns
BoxPromise<'tx, Result<String>>

is_abstract

fn is_abstract(&self) -> bool
Returns
bool

is_deleted

fn is_deleted<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
Returns
BoxPromise<'tx, Result<bool>>

is_root

fn is_root(&self) -> bool
Returns
bool

label

fn label(&self) -> &str
Returns
&str

root

pub fn root() -> Self

Returns the root RelationType

Returns
Self

set_abstract

fn set_abstract<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_label

fn set_label<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    new_label: String
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_owns

fn set_owns<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    attribute_type: AttributeType,
    overridden_attribute_type: Option<AttributeType>,
    annotations: Vec<Annotation>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_plays

fn set_plays<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    role_type: RoleType,
    overridden_role_type: Option<RoleType>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_relates

fn set_relates<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    role_label: String,
    overridden_role_label: Option<String>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_supertype

fn set_supertype<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    supertype: RelationType
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_abstract

fn unset_abstract<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_owns

fn unset_owns<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    attribute_type: AttributeType
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_plays

fn unset_plays<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    role_type: RoleType
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_relates

fn unset_relates<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    role_label: String
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

Trait RelationTypeAPI

Implementors:

  • RelationType

create

fn create<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Relation>>

Creates and returns an instance of this RelationType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result<Relation>>
Code examples
  • async

  • sync

relation_type.create(transaction).await;
relation_type.create(transaction).resolve();

get_instances

fn get_instances<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<Relation>>>

Retrieves all direct and indirect (or direct only) Relations that are instances of this RelationType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

transitivity

Transitivity::Transitive for direct and indirect instances, Transitivity::Explicit for direct relates only

Transitivity

Returns
Result<BoxStream<'tx, Result<Relation>>>
Code examples
relation_type.get_instances(transaction, Transitivity::Explicit);

get_relates

fn get_relates<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>>

Retrieves roles that this RelationType relates to directly or via inheritance.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

transitivity

Transitivity::Transitive for direct and inherited relates, Transitivity::Explicit for direct relates only

Transitivity

Returns
Result<BoxStream<'tx, Result<RoleType>>>
Code examples
relation_type.get_relates(transaction, Transitivity::Transitive);

get_relates_for_role_label

fn get_relates_for_role_label<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    role_label: String
) -> BoxPromise<'tx, Result<Option<RoleType>>>

Retrieves role with a given role_label that this RelationType relates to.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

role_label

Label of the role we wish to retrieve

String

Returns
BoxPromise<'tx, Result<Option<RoleType>>>
Code examples
  • async

  • sync

relation_type.get_relates_for_role_label(transaction, role_label).await;
relation_type.get_relates_for_role_label(transaction, role_label).resolve();

get_relates_overridden

fn get_relates_overridden<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    overridden_role_label: String
) -> BoxPromise<'tx, Result<Option<RoleType>>>

Retrieves a RoleType that is overridden by the role with the overridden_role_label.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

overridden_role_label

Label of the role that overrides an inherited role

String

Returns
BoxPromise<'tx, Result<Option<RoleType>>>
Code examples
  • async

  • sync

relation_type.get_relates_overridden(transaction, overridden_role_label).await;
relation_type.get_relates_overridden(transaction, overridden_role_label).resolve();

get_subtypes

fn get_subtypes<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RelationType>>>

Retrieves all direct and indirect (or direct only) subtypes of the RelationType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

transitivity

Transitivity::Transitive for direct and indirect subtypes, Transitivity::Explicit for direct subtypes only

Transitivity

Returns
Result<BoxStream<'tx, Result<RelationType>>>
Code examples
relation_type.get_subtypes(transaction, Transitivity::Transitive);

get_supertype

fn get_supertype<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<RelationType>>>

Retrieves the most immediate supertype of the RelationType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result<Option<RelationType>>>
Code examples
  • async

  • sync

relation_type.get_supertype(transaction).await;
relation_type.get_supertype(transaction).resolve();

get_supertypes

fn get_supertypes<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RelationType>>>

Retrieves all supertypes of the RelationType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
Result<BoxStream<'tx, Result<RelationType>>>
Code examples
relation_type.get_supertypes(transaction);

set_relates

fn set_relates<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    role_label: String,
    overridden_role_label: Option<String>
) -> BoxPromise<'tx, Result>

Sets the new role that this RelationType relates to. If we are setting an overriding type this way, we have to also pass the overridden type as a second argument.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

role_label

The new role for the RelationType to relate to

String

overridden_role_label

The label being overridden, if applicable

Option<String>

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

relation_type.set_relates(transaction, role_label, None).await;
relation_type.set_relates(transaction, role_label, None).resolve();

set_supertype

fn set_supertype<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    supertype: RelationType
) -> BoxPromise<'tx, Result>

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

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

supertype

The RelationType to set as the supertype of this RelationType

RelationType

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

relation_type.set_supertype(transaction, super_relation_type).await;
relation_type.set_supertype(transaction, super_relation_type).resolve();

unset_relates

fn unset_relates<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    role_label: String
) -> BoxPromise<'tx, Result>

Disallows this RelationType from relating to the given role.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

role_label

The role to not relate to the relation type.

String

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

relation_type.unset_relates(transaction, role_label).await;
relation_type.unset_relates(transaction, role_label).resolve();

RoleType

Implements traits:

  • Clone

  • Debug

  • Eq

  • PartialEq<RoleType>

  • RoleTypeAPI

  • StructuralEq

  • StructuralPartialEq

Roles are special internal types used by relations. We can not create an instance of a role in a database. But we can set an instance of another type (role player) to play a role in a particular instance of a relation type.

Roles allow a schema to enforce logical constraints on types of role players.

Fields
Name Type Description

is_abstract

bool

is_root

bool

label

ScopedLabel

delete

fn delete<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

get_player_instances

fn get_player_instances<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<Thing>>>
Returns
Result<BoxStream<'tx, Result<Thing>>>

get_player_types

fn get_player_types<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<ThingType>>>
Returns
Result<BoxStream<'tx, Result<ThingType>>>

get_relation_instances

fn get_relation_instances<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<Relation>>>
Returns
Result<BoxStream<'tx, Result<Relation>>>

get_relation_type

fn get_relation_type<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<RelationType>>>
Returns
BoxPromise<'tx, Result<Option<RelationType>>>

get_relation_types

fn get_relation_types<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RelationType>>>
Returns
Result<BoxStream<'tx, Result<RelationType>>>

get_subtypes

fn get_subtypes<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>>
Returns
Result<BoxStream<'tx, Result<RoleType>>>

get_supertype

fn get_supertype<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<RoleType>>>
Returns
BoxPromise<'tx, Result<Option<RoleType>>>

get_supertypes

fn get_supertypes<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RoleType>>>
Returns
Result<BoxStream<'tx, Result<RoleType>>>

is_abstract

fn is_abstract(&self) -> bool
Returns
bool

is_deleted

fn is_deleted<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
Returns
BoxPromise<'tx, Result<bool>>

set_label

fn set_label<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    new_label: String
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

Trait RoleTypeAPI

Implementors:

  • RoleType

delete

fn delete<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>

Deletes this type from the database.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

role_type.delete(transaction).await;
role_type.delete(transaction).resolve();

get_player_instances

fn get_player_instances<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<Thing>>>

Retrieves the Thing instances that play this role.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

transitivity

Transitivity::Transitive for direct and indirect playing, Transitivity::Explicit for direct playing only

Transitivity

Returns
Result<BoxStream<'tx, Result<Thing>>>
Code examples
role_type.get_player_instances(transaction, transitivity)

get_player_types

fn get_player_types<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<ThingType>>>

Retrieves the ThingTypes whose instances play this role.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

transitivity

Transitivity::Transitive for direct and indirect playing, Transitivity::Explicit for direct playing only

Transitivity

Returns
Result<BoxStream<'tx, Result<ThingType>>>
Code examples
role_type.get_player_types(transaction, transitivity)

get_relation_instances

fn get_relation_instances<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<Relation>>>

Retrieves the Relation instances that this role is related to.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

transitivity

Transitivity::Transitive for direct and indirect relation, Transitivity::Explicit for direct relation only

Transitivity

Returns
Result<BoxStream<'tx, Result<Relation>>>
Code examples
role_type.get_relation_instances(transaction, transitivity)

get_relation_type

fn get_relation_type<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<RelationType>>>

Retrieves the RelationType that this role is directly related to.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result<Option<RelationType>>>
Code examples
  • async

  • sync

role_type.get_relation_type(transaction).await;
role_type.get_relation_type(transaction).resolve();

get_relation_types

fn get_relation_types<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RelationType>>>

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

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
Result<BoxStream<'tx, Result<RelationType>>>
Code examples
role_type.get_relation_types(transaction)

get_subtypes

fn get_subtypes<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>>

Retrieves all direct and indirect (or direct only) subtypes of the RoleType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

transitivity

Transitivity::Transitive for direct and indirect subtypes, Transitivity::Explicit for direct subtypes only

Transitivity

Returns
Result<BoxStream<'tx, Result<RoleType>>>
Code examples
role_type.get_subtypes(transaction, transitivity)

get_supertype

fn get_supertype<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<RoleType>>>

Retrieves the most immediate supertype of the RoleType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result<Option<RoleType>>>
Code examples
  • async

  • sync

role_type.get_supertype(transaction).await;
role_type.get_supertype(transaction).resolve();

get_supertypes

fn get_supertypes<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RoleType>>>

Retrieves all supertypes of the RoleType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
Result<BoxStream<'tx, Result<RoleType>>>
Code examples
role_type.get_supertypes(transaction)

is_abstract

fn is_abstract(&self) -> bool

Checks if the type is prevented from having data instances (i.e., abstract).

Returns
bool
Code examples
role_type.is_abstract()

is_deleted

fn is_deleted<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>

Checks if this type is deleted.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result<bool>>
Code examples
  • async

  • sync

role_type.is_deleted(transaction).await;
role_type.is_deleted(transaction).resolve();

set_label

fn set_label<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    new_label: String
) -> BoxPromise<'tx, Result>

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

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

new_label

The new Label to be given to the type.

String

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

role_type.set_label(transaction, new_label).await;
role_type.set_label(transaction, new_label).resolve();

AttributeType

Implements traits:

  • AttributeTypeAPI

  • Clone

  • Debug

  • PartialEq<AttributeType>

  • StructuralPartialEq

  • ThingTypeAPI

Attribute types represent properties that other types can own.

Attribute types have a value type. This value type is fixed and unique for every given instance of the attribute type.

Other types can own an attribute type. That means that instances of these other types can own an instance of this attribute type. This usually means that an object in our domain has a property with the matching value.

Multiple types can own the same attribute type, and different instances of the same type or different types can share ownership of the same attribute instance.

Fields
Name Type Description

is_abstract

bool

is_root

bool

label

String

value_type

ValueType

delete

fn delete<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

get

fn get<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    value: Value
) -> BoxPromise<'tx, Result<Option<Attribute>>>
Returns
BoxPromise<'tx, Result<Option<Attribute>>>

get_instances

fn get_instances<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<Attribute>>>
Returns
Result<BoxStream<'tx, Result<Attribute>>>

get_owners

fn get_owners<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity,
    annotations: Vec<Annotation>
) -> Result<BoxStream<'tx, Result<ThingType>>>
Returns
Result<BoxStream<'tx, Result<ThingType>>>

get_owns

fn get_owns<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    value_type: Option<ValueType>,
    transitivity: Transitivity,
    annotations: Vec<Annotation>
) -> Result<BoxStream<'tx, Result<AttributeType>>>
Returns
Result<BoxStream<'tx, Result<AttributeType>>>

get_owns_overridden

fn get_owns_overridden<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    overridden_attribute_type: AttributeType
) -> BoxPromise<'tx, Result<Option<AttributeType>>>
Returns
BoxPromise<'tx, Result<Option<AttributeType>>>

get_plays

fn get_plays<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>>
Returns
Result<BoxStream<'tx, Result<RoleType>>>

get_plays_overridden

fn get_plays_overridden<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    overridden_role_type: RoleType
) -> BoxPromise<'tx, Result<Option<RoleType>>>
Returns
BoxPromise<'tx, Result<Option<RoleType>>>

get_regex

fn get_regex<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<String>>>
Returns
BoxPromise<'tx, Result<Option<String>>>

get_subtypes

fn get_subtypes<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<AttributeType>>>
Returns
Result<BoxStream<'tx, Result<AttributeType>>>

get_subtypes_with_value_type

fn get_subtypes_with_value_type<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    value_type: ValueType,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<AttributeType>>>
Returns
Result<BoxStream<'tx, Result<AttributeType>>>

get_supertype

fn get_supertype<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<AttributeType>>>
Returns
BoxPromise<'tx, Result<Option<AttributeType>>>

get_supertypes

fn get_supertypes<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<AttributeType>>>
Returns
Result<BoxStream<'tx, Result<AttributeType>>>

get_syntax

fn get_syntax<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<String>>
Returns
BoxPromise<'tx, Result<String>>

is_abstract

fn is_abstract(&self) -> bool
Returns
bool

is_deleted

fn is_deleted<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
Returns
BoxPromise<'tx, Result<bool>>

is_root

fn is_root(&self) -> bool
Returns
bool

label

fn label(&self) -> &str
Returns
&str

put

fn put<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    value: Value
) -> BoxPromise<'tx, Result<Attribute>>
Returns
BoxPromise<'tx, Result<Attribute>>

root

pub fn root() -> Self

Returns the root AttributeType

Returns
Self

set_abstract

fn set_abstract<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_label

fn set_label<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    new_label: String
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_owns

fn set_owns<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    attribute_type: AttributeType,
    overridden_attribute_type: Option<AttributeType>,
    annotations: Vec<Annotation>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_plays

fn set_plays<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    role_type: RoleType,
    overridden_role_type: Option<RoleType>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_regex

fn set_regex<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    regex: String
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_supertype

fn set_supertype<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    supertype: AttributeType
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_abstract

fn unset_abstract<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_owns

fn unset_owns<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    attribute_type: AttributeType
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_plays

fn unset_plays<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    role_type: RoleType
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_regex

fn unset_regex<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

value_type

fn value_type(&self) -> ValueType
Returns
ValueType

Trait AttributeTypeAPI

Implementors:

  • AttributeType

get

fn get<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    value: Value
) -> BoxPromise<'tx, Result<Option<Attribute>>>

Retrieves an Attribute of this AttributeType with the given value if such Attribute exists. Otherwise, returns None.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

value

Attribute’s value

Value

Returns
BoxPromise<'tx, Result<Option<Attribute>>>
Code examples
  • async

  • sync

attribute = attribute_type.get(transaction, value).await;
attribute = attribute_type.get(transaction, value).resolve();

get_instances

fn get_instances<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<Attribute>>>

Retrieves all direct and indirect (or direct only) Attributes that are instances of this AttributeType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

transitivity

Transitivity::Transitive for direct and indirect subtypes, Transitivity::Explicit for direct subtypes only

Transitivity

Returns
Result<BoxStream<'tx, Result<Attribute>>>
Code examples
attribute_type.get_instances(transaction, transitivity)

get_owners

fn get_owners<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity,
    annotations: Vec<Annotation>
) -> Result<BoxStream<'tx, Result<ThingType>>>

Retrieve all Things that own an attribute of this AttributeType and have all given Annotations.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

transitivity

Transitivity::Transitive for direct and inherited ownership, Transitivity::Explicit for direct ownership only

Transitivity

annotations

Only retrieve ThingTypes that have an attribute of this AttributeType with all given Annotations

Vec<Annotation>

Returns
Result<BoxStream<'tx, Result<ThingType>>>
Code examples
attribute_type.get_owners(transaction, transitivity, annotations)

get_regex

fn get_regex<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<String>>>

Retrieves the regular expression that is defined for this AttributeType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result<Option<String>>>
Code examples
  • async

  • sync

attribute_type.get_regex(transaction).await;
attribute_type.get_regex(transaction).resolve();

get_subtypes

fn get_subtypes<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<AttributeType>>>

Retrieves all direct and indirect (or direct only) subtypes of this AttributeType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

transitivity

Transitivity::Transitive for direct and indirect subtypes, Transitivity::Explicit for direct subtypes only

Transitivity

Returns
Result<BoxStream<'tx, Result<AttributeType>>>
Code examples
attribute_type.get_subtypes(transaction, transitivity)

get_subtypes_with_value_type

fn get_subtypes_with_value_type<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    value_type: ValueType,
    transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<AttributeType>>>

Retrieves all direct and indirect (or direct only) subtypes of this AttributeType with given ValueType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

value_type

ValueType for retrieving subtypes

ValueType

transitivity

Transitivity::Transitive for direct and indirect subtypes, Transitivity::Explicit for direct subtypes only

Transitivity

Returns
Result<BoxStream<'tx, Result<AttributeType>>>
Code examples
attribute_type.get_subtypes_with_value_type(transaction, value_type, transitivity)

get_supertype

fn get_supertype<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<AttributeType>>>

Retrieves the most immediate supertype of this AttributeType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result<Option<AttributeType>>>
Code examples
  • async

  • sync

attribute_type.get_supertype(transaction).await;
attribute_type.get_supertype(transaction).resolve();

get_supertypes

fn get_supertypes<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<AttributeType>>>

Retrieves all supertypes of this AttributeType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
Result<BoxStream<'tx, Result<AttributeType>>>
Code examples
attribute_type.get_supertypes(transaction)

put

fn put<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    value: Value
) -> BoxPromise<'tx, Result<Attribute>>

Adds and returns an Attribute of this AttributeType with the given value.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

value

New Attribute’s value

Value

Returns
BoxPromise<'tx, Result<Attribute>>
Code examples
  • async

  • sync

attribute = attribute_type.put(transaction, value).await;
attribute = attribute_type.put(transaction, value).resolve();

set_regex

fn set_regex<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    regex: String
) -> BoxPromise<'tx, Result>

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.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

regex

Regular expression

String

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

attribute_type.set_regex(transaction, regex).await;
attribute_type.set_regex(transaction, regex).resolve();

set_supertype

fn set_supertype<'tx>(
    &mut self,
    transaction: &'tx Transaction<'_>,
    supertype: AttributeType
) -> BoxPromise<'tx, Result>

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

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

supertype

The AttributeType to set as the supertype of this AttributeType

AttributeType

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

attribute_type.set_supertype(transaction, supertype).await;
attribute_type.set_supertype(transaction, supertype).resolve();

unset_regex

fn unset_regex<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>

Removes the regular expression that is defined for this AttributeType.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

attribute_type.unset_regex(transaction).await;
attribute_type.unset_regex(transaction).resolve();

value_type

fn value_type(&self) -> ValueType

Retrieves the ValueType of this AttributeType.

Returns
ValueType
Code examples
attribute_type.value_type()

Annotation

Annotations are used to specify extra schema constraints.

Enum variants
Variant

Key

Unique

Transitivity

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

Enum variants
Variant

Explicit

Transitive

ValueType

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

Enum variants
Variant

Boolean

DateTime

Double

Long

Object

String

ScopedLabel

Implements traits:

  • Clone

  • Debug

  • Display

  • Eq

  • PartialEq<ScopedLabel>

  • StructuralEq

  • StructuralPartialEq

Fields
Name Type Description

name

String

scope

String

Data

Thing

Enum variants
Variant

Attribute(Attribute)

Entity(Entity)

Relation(Relation)

Trait ThingAPI

Implementors:

  • Attribute

  • Entity

  • Relation

delete

fn delete<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>

Deletes this Thing.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

thing.delete(transaction).await;
thing.delete(transaction).resolve();

get_has

fn get_has<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    attribute_types: Vec<AttributeType>,
    annotations: Vec<Annotation>
) -> Result<BoxStream<'tx, Result<Attribute>>>

Retrieves the Attributes that this Thing owns. Optionally, filtered by an AttributeType or a list of AttributeTypes. Optionally, filtered by Annotations.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

attribute_type

The AttributeType to filter the attributes by

attribute_types

The AttributeTypes to filter the attributes by

Vec<AttributeType>

annotations

Only retrieve attributes with all given Annotations

Vec<Annotation>

Returns
Result<BoxStream<'tx, Result<Attribute>>>
Code examples
thing.get_has(transaction, attribute_type, annotations=vec![Annotation::Key]);

get_playing

fn get_playing<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RoleType>>>

Retrieves the roles that this Thing is currently playing.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
Result<BoxStream<'tx, Result<RoleType>>>
Code examples
thing.get_playing(transaction);

get_relations

fn get_relations<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    role_types: Vec<RoleType>
) -> Result<BoxStream<'tx, Result<Relation>>>

Retrieves all the Relations which this Thing plays a role in, optionally filtered by one or more given roles.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

role_types

The list of roles to filter the relations by.

Vec<RoleType>

Returns
Result<BoxStream<'tx, Result<Relation>>>
Code examples
thing.get_relations(transaction, role_types);

iid

fn iid(&self) -> &IID

Retrieves the unique id of the Thing.

Returns
&IID
Code examples
thing.iid();

is_deleted

fn is_deleted<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>

Checks if this Thing is deleted.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

Returns
BoxPromise<'tx, Result<bool>>
Code examples
  • async

  • sync

thing.is_deleted(transaction).await;
thing.is_deleted(transaction).resolve();

is_inferred

fn is_inferred(&self) -> bool

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

Returns
bool
Code examples
thing.is_inferred();

set_has

fn set_has<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    attribute: Attribute
) -> BoxPromise<'tx, Result>

Assigns an Attribute to be owned by this Thing.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

attribute

The Attribute to be owned by this Thing.

Attribute

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

thing.set_has(transaction, attribute).await;
thing.set_has(transaction, attribute).resolve();

unset_has

fn unset_has<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    attribute: Attribute
) -> BoxPromise<'tx, Result>

Unassigns an Attribute from this Thing.

Input parameters
Name Description Type

transaction

The current transaction

&'tx Transaction<'_>

attribute

The Attribute to be disowned from this Thing.

Attribute

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

thing.unset_has(transaction, attribute).await;
thing.unset_has(transaction, attribute).resolve();

Entity

Implements traits:

  • Clone

  • Debug

  • EntityAPI

  • Eq

  • PartialEq<Entity>

  • StructuralEq

  • StructuralPartialEq

  • ThingAPI

Instance of data of an entity type, representing a standalone object that exists in the data model independently. Entity does not have a value. It is usually addressed by its ownership over attribute instances and/or roles played in relation instances.

Fields
Name Type Description

iid

IID

The unique id of this Entity

is_inferred

bool

If this Thing is inferred by a [Reasoning Rule] or not

type_

EntityType

The type which this Entity belongs to

delete

fn delete<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

get_has

fn get_has<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    attribute_types: Vec<AttributeType>,
    annotations: Vec<Annotation>
) -> Result<BoxStream<'tx, Result<Attribute>>>
Returns
Result<BoxStream<'tx, Result<Attribute>>>

get_playing

fn get_playing<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RoleType>>>
Returns
Result<BoxStream<'tx, Result<RoleType>>>

get_relations

fn get_relations<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    role_types: Vec<RoleType>
) -> Result<BoxStream<'tx, Result<Relation>>>
Returns
Result<BoxStream<'tx, Result<Relation>>>

iid

fn iid(&self) -> &IID
Returns
&IID

is_deleted

fn is_deleted<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
Returns
BoxPromise<'tx, Result<bool>>

is_inferred

fn is_inferred(&self) -> bool
Returns
bool

set_has

fn set_has<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    attribute: Attribute
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_has

fn unset_has<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    attribute: Attribute
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

Relation

Implements traits:

  • Clone

  • Debug

  • Eq

  • PartialEq<Relation>

  • RelationAPI

  • StructuralEq

  • StructuralPartialEq

  • ThingAPI

Relation is an instance of a relation type and can be uniquely addressed by a combination of its type, owned attributes and role players.

Fields
Name Type Description

iid

IID

The unique id of this Relation

is_inferred

bool

If this Relation is inferred by a [Reasoning Rule] or not

type_

RelationType

The type which this Relation belongs to

add_role_player

fn add_role_player<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    role_type: RoleType,
    player: Thing
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

delete

fn delete<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

get_has

fn get_has<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    attribute_types: Vec<AttributeType>,
    annotations: Vec<Annotation>
) -> Result<BoxStream<'tx, Result<Attribute>>>
Returns
Result<BoxStream<'tx, Result<Attribute>>>

get_players_by_role_type

fn get_players_by_role_type<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    role_types: Vec<RoleType>
) -> Result<BoxStream<'tx, Result<Thing>>>
Returns
Result<BoxStream<'tx, Result<Thing>>>

get_playing

fn get_playing<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RoleType>>>
Returns
Result<BoxStream<'tx, Result<RoleType>>>

get_relating

fn get_relating<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RoleType>>>
Returns
Result<BoxStream<'tx, Result<RoleType>>>

get_relations

fn get_relations<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    role_types: Vec<RoleType>
) -> Result<BoxStream<'tx, Result<Relation>>>
Returns
Result<BoxStream<'tx, Result<Relation>>>

get_role_players

fn get_role_players<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<(RoleType, Thing)>>>
Returns
Result<BoxStream<'tx, Result<(RoleType, Thing)>>>

iid

fn iid(&self) -> &IID
Returns
&IID

is_deleted

fn is_deleted<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
Returns
BoxPromise<'tx, Result<bool>>

is_inferred

fn is_inferred(&self) -> bool
Returns
bool

remove_role_player

fn remove_role_player<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    role_type: RoleType,
    player: Thing
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

set_has

fn set_has<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    attribute: Attribute
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_has

fn unset_has<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    attribute: Attribute
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

Attribute

Implements traits:

  • AttributeAPI

  • Clone

  • Debug

  • PartialEq<Attribute>

  • StructuralPartialEq

  • ThingAPI

Attribute is an instance of the attribute type and has a value. This value is fixed and unique for every given instance of the attribute type. Attributes can be uniquely addressed by their type and value.

Fields
Name Type Description

iid

IID

The unique id of this Attribute

is_inferred

bool

If this Attribute is inferred by a [Reasoning Rule] or not

type_

AttributeType

The type which this Attribute belongs to

value

Value

The value which this Attribute instance holds.

delete

fn delete<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

get_has

fn get_has<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    attribute_types: Vec<AttributeType>,
    annotations: Vec<Annotation>
) -> Result<BoxStream<'tx, Result<Attribute>>>
Returns
Result<BoxStream<'tx, Result<Attribute>>>

get_owners

fn get_owners<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    thing_type: Option<ThingType>
) -> Result<BoxStream<'tx, Result<Thing>>>
Returns
Result<BoxStream<'tx, Result<Thing>>>

get_playing

fn get_playing<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RoleType>>>
Returns
Result<BoxStream<'tx, Result<RoleType>>>

get_relations

fn get_relations<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    role_types: Vec<RoleType>
) -> Result<BoxStream<'tx, Result<Relation>>>
Returns
Result<BoxStream<'tx, Result<Relation>>>

iid

fn iid(&self) -> &IID
Returns
&IID

is_deleted

fn is_deleted<'tx>(
    &self,
    transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
Returns
BoxPromise<'tx, Result<bool>>

is_inferred

fn is_inferred(&self) -> bool
Returns
bool

set_has

fn set_has<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    attribute: Attribute
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

unset_has

fn unset_has<'tx>(
    &self,
    transaction: &'tx Transaction<'_>,
    attribute: Attribute
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

Value

Enum variants
Variant

Boolean(bool)

DateTime(NaiveDateTime)

Double(f64)

Long(i64)

String(String)

get_type

pub fn get_type(&self) -> ValueType

Retrieves the ValueType of this value concept.

Returns
ValueType
Code examples
value.get_value_type();

Logic

LogicManager

Implements traits:

  • Clone

  • Debug

Provides methods for manipulating rules in the database.

get_rule

pub fn get_rule(&self, label: String) -> impl Promise<'tx, Result<Option<Rule>>>

Retrieves the Rule that has the given label.

Input parameters
Name Description Type

label

The label of the Rule to create or retrieve

String

Returns
impl Promise<'tx, Result<Option<Rule>>>
Code examples
  • async

  • sync

transaction.logic().get_rule(label).await
transaction.logic().get_rule(label).resolve()

get_rules

pub fn get_rules(&self) -> Result<impl Stream<Item = Result<Rule>> + 'tx>

Retrieves all rules.

Returns
Result<impl Stream<Item = Result<Rule>> + 'tx>
Code examples
transaction.logic.get_rules()

put_rule

pub fn put_rule(
    &self,
    label: String,
    when: Conjunction,
    then: Statement
) -> impl Promise<'tx, Result<Rule>>

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

String

when

The when body of the rule to create

Conjunction

then

The then body of the rule to create

Statement

Returns
impl Promise<'tx, Result<Rule>>
Code examples
  • async

  • sync

transaction.logic().put_rule(label, when, then).await
transaction.logic().put_rule(label, when, then).resolve()

Rule

Implements traits:

  • Clone

  • Debug

  • PartialEq<Rule>

  • RuleAPI

  • StructuralPartialEq

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.

Fields
Name Type Description

label

String

The unique label of the rule.

then

ThingStatement

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

when

Conjunction

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

delete

fn delete<'tx>(
    &mut self,
    transaction: &'tx Transaction<'tx>
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

is_deleted

fn is_deleted<'tx>(
    &self,
    transaction: &'tx Transaction<'tx>
) -> BoxPromise<'tx, Result<bool>>
Returns
BoxPromise<'tx, Result<bool>>

label

fn label(&self) -> &String
Returns
&String

set_label

fn set_label<'tx>(
    &mut self,
    transaction: &'tx Transaction<'tx>,
    new_label: String
) -> BoxPromise<'tx, Result>
Returns
BoxPromise<'tx, Result>

Trait RuleAPI

Implementors:

  • Rule

delete

fn delete<'tx>(
    &mut self,
    transaction: &'tx Transaction<'tx>
) -> BoxPromise<'tx, Result>

Deletes this rule.

Input parameters
Name Description Type

transaction

The current Transaction

&'tx Transaction<'tx>

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

rule.delete(transaction).await
rule.delete(transaction).resolve()

is_deleted

fn is_deleted<'tx>(
    &self,
    transaction: &'tx Transaction<'tx>
) -> BoxPromise<'tx, Result<bool>>

Check if this rule has been deleted.

Input parameters
Name Description Type

transaction

The current Transaction

&'tx Transaction<'tx>

Returns
BoxPromise<'tx, Result<bool>>
Code examples
  • async

  • sync

rule.is_deleted(transaction).await
rule.is_deleted(transaction).resolve()

label

fn label(&self) -> &String

Retrieves the unique label of the rule.

Returns
&String

set_label

fn set_label<'tx>(
    &mut self,
    transaction: &'tx Transaction<'tx>,
    new_label: String
) -> BoxPromise<'tx, Result>

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

Input parameters
Name Description Type

transaction

The current Transaction

&'tx Transaction<'tx>

new_label

The new label to be given to the rule

String

Returns
BoxPromise<'tx, Result>
Code examples
  • async

  • sync

rule.set_label(transaction, new_label).await
rule.set_label(transaction, new_label).resolve()

Errors

SchemaException

Implements traits:

  • Clone

  • Debug

Represents invalid schema constructs discovered during schema validation.

Fields
Name Type Description

code

String

message

String

Error

Represents errors encountered during operation.

Enum variants
Variant

Connection(ConnectionError)

Internal(InternalError)

Other(String)

TypeQL(Error)

ConnectionError

Enum variants
Variant

AddressTranslationMismatch

BrokenPipe

CloudAllNodesFailed

CloudEncryptionSettingsMismatch

CloudReplicaNotPrimary

CloudSSLCertificateNotValidated

CloudTokenCredentialInvalid

ConnectionFailed

ConnectionIsClosed

DatabaseDoesNotExist

InvalidResponseField

MissingPort

MissingResponseField

RPCMethodUnavailable

ServerConnectionFailed

ServerConnectionFailedStatusError

ServerConnectionFailedWithError

SessionCloseFailed

SessionIsClosed

TransactionIsClosed

TransactionIsClosedWithErrors

UnexpectedResponse

UnknownRequestId

UserManagementCloudOnly

InternalError

Enum variants
Variant

EnumOutOfBounds

RecvError

SendError

UnexpectedRequestType

UnexpectedResponseType

UnknownServer