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.
Result
connection.force_close()
is_cloud
pub fn is_cloud(&self) -> bool
Check if the connection is to an Cloud server.
bool
connection.is_cloud()
is_open
pub fn is_open(&self) -> bool
Checks it this connection is opened.
bool
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.
Name | Description | Type |
---|---|---|
|
Addresses (host:port) on which TypeDB Cloud nodes are running |
|
|
User credential and TLS encryption setting |
|
Result<Self>
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.
Name | Description | Type |
---|---|---|
|
Translation map from addresses to be used by the driver for connection to addresses received from the TypeDB server(s) |
|
|
User credential and TLS encryption setting |
|
Result<Self>where
T: AsRef<str> + Sync,
U: AsRef<str> + Sync,
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.
Name | Description | Type |
---|---|---|
|
The address (host:port) on which the TypeDB Server is running |
|
Result<Self>
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.
bool
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
Name | Description | Type |
---|---|---|
|
The name of the user to connect as |
|
|
The password for the user |
|
|
Path to the CA certificate to use for authenticating server certificates. |
|
Result<Self>
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
Name | Description | Type |
---|---|---|
|
The name of the user to connect as |
|
|
The password for the user |
|
Self
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
Result<Vec<Database>>
-
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
Name | Description | Type |
---|---|---|
|
The database name to be checked |
|
Result<bool>
-
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
Name | Description | Type |
---|---|---|
|
The name of the database to be created |
|
Result
-
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.
Name | Description | Type |
---|---|---|
|
The name of the database to retrieve |
|
Result<Database>
-
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.
Result
-
async
-
sync
database.delete().await;
database.delete();
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
Option<ReplicaInfo>
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
Option<ReplicaInfo>
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
Vec<ReplicaInfo>
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.
Result<String>
-
async
-
sync
database.rule_schema().await;
database.rule_schema();
ReplicaInfo
Implements traits:
-
Debug
The metadata and state of an individual raft replica of a database.
Name | Type | Description |
---|---|---|
|
|
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. |
|
|
Whether this is the primary replica of the raft cluster. |
|
|
The server hosting this replica |
|
|
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.
Result<Vec<User>>
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.
Name | Description | Type |
---|---|---|
|
The user name to be checked |
|
Result<bool>
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.
Name | Description | Type |
---|---|---|
|
The name of the user to be created |
|
|
The password of the user to be created |
|
Result
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.
Result<Option<User>>
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.
Name | Description | Type |
---|---|---|
|
The name of the user to be deleted |
|
Result
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.
Name | Description | Type |
---|---|---|
|
The name of the user to retrieve |
|
Result<Option<User>>
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.
Name | Description | Type |
---|---|---|
|
The name of the user to set the password of |
|
|
The new password |
|
Result
driver.users.password_set(username, password).await;
User
Implements traits:
-
Clone
-
Debug
User information
Name | Type | Description |
---|---|---|
|
|
Returns the number of seconds remaining till this user’s current password expires. |
|
|
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.
Name | Description | Type |
---|---|---|
|
an opened |
|
|
an old password |
|
|
a new password |
|
Result
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.
&str
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.
Result
session.force_close();
is_open
pub fn is_open(&self) -> bool
Checks whether this session is open.
bool
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
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.
Name | Description | Type |
---|---|---|
|
The database with which the session connects |
|
|
The type of session to be created (DATA or SCHEMA) |
|
|
|
|
Result<Self>
-
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.
Name | Description | Type |
---|---|---|
|
The callback function. |
null
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.
Name | Description | Type |
---|---|---|
|
The callback function. |
null
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
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.
Name | Description | Type |
---|---|---|
|
The type of transaction to be created (READ or WRITE) |
|
|
Options for the session |
|
Result<Transaction<'_>>
-
async
-
sync
session.transaction_with_options(transaction_type, options).await;
session.transaction_with_options(transaction_type, options);
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.
Name | Type | Description |
---|---|---|
|
|
If set to |
|
|
If set to |
|
|
If set to |
|
|
If set to |
|
|
If set, specifies a guideline number of answers that the server should send before the driver issues a fresh request. |
|
|
If set to |
|
|
If set, specifies how long the driver should wait if opening a session or transaction is blocked by a schema write lock. |
|
|
If set, specifies a timeout that allows the server to close sessions if the driver terminates or becomes unresponsive. |
|
|
If set to |
|
|
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.
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.
Self
parallel
pub fn parallel(self, parallel: bool) -> Self
If set to True
, the server uses parallel instead of single-threaded execution.
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.
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.
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.
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.
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.
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.
impl Promise<'static, Result>
-
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.
ConceptManager<'_>
force_close
pub fn force_close(&self)
Closes the transaction.
null
transaction.force_close()
is_open
pub fn is_open(&self) -> bool
Closes the transaction.
bool
transaction.close()
logic
pub fn logic(&self) -> LogicManager<'_>
Retrieves the LogicManager
for this Transaction, providing access to all Concept API - Logic methods.
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.
Name | Description | Type |
---|---|---|
|
The callback function. |
null
transaction.on_close(function)
query
pub fn query(&self) -> QueryManager<'_>
Retrieves theQueryManager
for this Transaction, from which any TypeQL query can be executed.
QueryManager<'_>
TransactionType
This enum is used to specify the type of transaction.
Variant |
---|
|
|
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
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.
Name | Description | Type |
---|---|---|
|
The TypeQL Define query to be executed |
|
|
Specify query options |
|
impl Promise<'tx, Result>
-
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
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.
Name | Description | Type |
---|---|---|
|
The TypeQL Delete query to be executed |
|
|
Specify query options |
|
impl Promise<'tx, Result>
-
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
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.
Name | Description | Type |
---|---|---|
|
The Explainable to be explained |
|
|
Specify query options |
|
Result<impl Stream<Item = Result<Explanation>> + 'tx>
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
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.
Name | Description | Type |
---|---|---|
|
The TypeQL Match Group Aggregate query to be executed |
|
|
Specify query options |
|
Result<impl Stream<Item = Result<JSON>> + 'tx>
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
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
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.
Name | Description | Type |
---|---|---|
|
The TypeQL Match Aggregate query to be executed |
|
|
Specify query options |
|
impl Promise<'tx, Result<Option<Value>>>
-
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
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
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.
Name | Description | Type |
---|---|---|
|
The TypeQL Match Group Aggregate query to be executed |
|
|
Specify query options |
|
Result<impl Stream<Item = Result<ValueGroup>> + 'tx>
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.
Name | Description | Type |
---|---|---|
|
The TypeQL Match Group query to be executed |
|
|
Specify query options |
|
Result<impl Stream<Item = Result<ConceptMapGroup>> + 'tx>
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.
Name | Description | Type |
---|---|---|
|
The TypeQL Match (Get) query to be executed |
|
|
Specify query options |
|
Result<impl Stream<Item = Result<ConceptMap>> + 'tx>
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
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.
Name | Description | Type |
---|---|---|
|
The TypeQL Insert query to be executed |
|
|
Specify query options |
|
Result<impl Stream<Item = Result<ConceptMap>> + 'tx>
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
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.
Name | Description | Type |
---|---|---|
|
The TypeQL Undefine query to be executed |
|
|
Specify query options |
|
impl Promise<'tx, Result>
-
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
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.
Name | Description | Type |
---|---|---|
|
The TypeQL Update query to be executed |
|
|
Specify query options |
|
Result<impl Stream<Item = Result<ConceptMap>> + 'tx>
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.
Name | Type | Description |
---|---|---|
|
|
Retrieves the ConceptMaps of the group. |
|
|
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.
Name | Type | Description |
---|---|---|
|
|
The |
|
|
The |
ValueGroup
Implements traits:
-
Clone
-
Debug
-
PartialEq<ValueGroup>
-
StructuralPartialEq
Contains an element of a TypeQL Get Group Aggregate query result.
Name | Type | Description |
---|---|---|
|
|
The concept that is the group owner. |
|
|
JSON
Variant |
---|
|
|
|
|
|
|
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.
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()
.
promise.resolve()
Explainables
Implements traits:
-
Clone
-
Debug
-
Default
-
PartialEq<Explainables>
-
StructuralPartialEq
Contains explainable objects.
Name | Type | Description |
---|---|---|
|
|
Explainable attributes |
|
|
Explainable pairs of (owner, attribute) |
|
|
Explainable relations |
Explainable
Implements traits:
-
Clone
-
Debug
-
PartialEq<Explainable>
-
StructuralPartialEq
Contains an explainable object.
Name | Type | Description |
---|---|---|
|
|
The subquery of the original query that is actually being explained. |
|
|
The unique ID that identifies this |
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.
Name | Type | Description |
---|---|---|
|
|
The Conclusion for this Explanation. |
|
|
The Condition for this Explanation. |
|
|
The Rule for this Explanation. |
|
|
The mapping from query variables to rule variables for this |
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.
Name | Description | Type |
---|---|---|
|
The iid of the |
|
impl Promise<'tx, Result<Option<Attribute>>>
-
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.
Name | Description | Type |
---|---|---|
|
The label of the |
|
impl Promise<'tx, Result<Option<AttributeType>>>
-
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.
Name | Description | Type |
---|---|---|
|
The iid of the |
|
impl Promise<'tx, Result<Option<Entity>>>
-
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.
Name | Description | Type |
---|---|---|
|
The label of the |
|
impl Promise<'tx, Result<Option<EntityType>>>
-
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.
Name | Description | Type |
---|---|---|
|
The iid of the |
|
impl Promise<'tx, Result<Option<Relation>>>
-
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.
Name | Description | Type |
---|---|---|
|
The label of the |
|
impl Promise<'tx, Result<Option<RelationType>>>
-
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.
Result<impl Stream<Item = Result<SchemaException>> + 'tx>
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:
Name | Description | Type |
---|---|---|
|
The label of the |
|
|
The value type of the |
|
impl Promise<'tx, Result<AttributeType>>
-
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.
Name | Description | Type |
---|---|---|
|
The label of the |
|
impl Promise<'tx, Result<EntityType>>
-
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.
Name | Description | Type |
---|---|---|
|
The label of the |
|
impl Promise<'tx, Result<RelationType>>
-
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.
Variant |
---|
|
|
|
|
|
|
|
|
|
Schema
RootThingType
Implements traits:
-
Clone
-
Debug
-
Eq
-
PartialEq<RootThingType>
-
StructuralEq
-
StructuralPartialEq
-
ThingTypeAPI
delete
fn delete<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
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>>>
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>>>
BoxPromise<'tx, Result<Option<AttributeType>>>
get_plays
fn get_plays<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>>
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>>>
BoxPromise<'tx, Result<Option<RoleType>>>
get_syntax
fn get_syntax<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<String>>
BoxPromise<'tx, Result<String>>
is_deleted
fn is_deleted<'tx>(
&self,
_transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
BoxPromise<'tx, Result<bool>>
set_abstract
fn set_abstract<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
set_label
fn set_label<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
new_label: String
) -> BoxPromise<'tx, Result>
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>
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>
BoxPromise<'tx, Result>
unset_abstract
fn unset_abstract<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
unset_owns
fn unset_owns<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
attribute_type: AttributeType
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
ThingType
Variant |
---|
|
|
|
|
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result>
-
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
If specified, only attribute types of this |
|
|
|
|
|
Only retrieve attribute types owned with annotations. |
|
Result<BoxStream<'tx, Result<AttributeType>>>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The |
|
BoxPromise<'tx, Result<Option<AttributeType>>>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
|
|
Result<BoxStream<'tx, Result<RoleType>>>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The |
|
BoxPromise<'tx, Result<Option<RoleType>>>
-
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result<String>>
-
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
).
bool
thing_type.is_abstract();
is_deleted
fn is_deleted<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
Checks if this type is deleted.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result<bool>>
-
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.
bool
thing_type.is_root();
label
fn label(&self) -> &str
Retrieves the unique label of the type.
&str
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result>
-
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The new |
|
BoxPromise<'tx, Result>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The |
|
|
The |
|
|
Adds annotations to the ownership. |
|
BoxPromise<'tx, Result>
-
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The role to be played by the instances of this type |
|
|
The role type that this role overrides, if applicable |
|
BoxPromise<'tx, Result>
-
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The |
|
BoxPromise<'tx, Result>
-
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The role to not be played by the instances of this type. |
|
BoxPromise<'tx, Result>
-
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.
Name | Type | Description |
---|---|---|
|
|
|
|
|
|
|
|
create
fn create<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Entity>>
BoxPromise<'tx, Result<Entity>>
delete
fn delete<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
get_instances
fn get_instances<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<Entity>>>
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>>>
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>>>
BoxPromise<'tx, Result<Option<AttributeType>>>
get_plays
fn get_plays<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>>
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>>>
BoxPromise<'tx, Result<Option<RoleType>>>
get_subtypes
fn get_subtypes<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<EntityType>>>
Result<BoxStream<'tx, Result<EntityType>>>
get_supertype
fn get_supertype<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<EntityType>>>
BoxPromise<'tx, Result<Option<EntityType>>>
get_supertypes
fn get_supertypes<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<EntityType>>>
Result<BoxStream<'tx, Result<EntityType>>>
get_syntax
fn get_syntax<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<String>>
BoxPromise<'tx, Result<String>>
is_deleted
fn is_deleted<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
BoxPromise<'tx, Result<bool>>
set_abstract
fn set_abstract<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
set_label
fn set_label<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
new_label: String
) -> BoxPromise<'tx, Result>
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>
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>
BoxPromise<'tx, Result>
set_supertype
fn set_supertype<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
supertype: EntityType
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
unset_abstract
fn unset_abstract<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
unset_owns
fn unset_owns<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
attribute_type: AttributeType
) -> BoxPromise<'tx, Result>
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result<Entity>>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
|
|
Result<BoxStream<'tx, Result<Entity>>>
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
|
|
Result<BoxStream<'tx, Result<EntityType>>>
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result<Option<EntityType>>>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
Result<BoxStream<'tx, Result<EntityType>>>
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The |
|
BoxPromise<'tx, Result>
-
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.
Name | Type | Description |
---|---|---|
|
|
|
|
|
|
|
|
create
fn create<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Relation>>
BoxPromise<'tx, Result<Relation>>
delete
fn delete<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
get_instances
fn get_instances<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<Relation>>>
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>>>
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>>>
BoxPromise<'tx, Result<Option<AttributeType>>>
get_plays
fn get_plays<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>>
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>>>
BoxPromise<'tx, Result<Option<RoleType>>>
get_relates
fn get_relates<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>>
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>>>
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>>>
BoxPromise<'tx, Result<Option<RoleType>>>
get_subtypes
fn get_subtypes<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RelationType>>>
Result<BoxStream<'tx, Result<RelationType>>>
get_supertype
fn get_supertype<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<RelationType>>>
BoxPromise<'tx, Result<Option<RelationType>>>
get_supertypes
fn get_supertypes<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RelationType>>>
Result<BoxStream<'tx, Result<RelationType>>>
get_syntax
fn get_syntax<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<String>>
BoxPromise<'tx, Result<String>>
is_deleted
fn is_deleted<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
BoxPromise<'tx, Result<bool>>
set_abstract
fn set_abstract<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
set_label
fn set_label<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
new_label: String
) -> BoxPromise<'tx, Result>
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>
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>
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>
BoxPromise<'tx, Result>
set_supertype
fn set_supertype<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
supertype: RelationType
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
unset_abstract
fn unset_abstract<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
unset_owns
fn unset_owns<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
attribute_type: AttributeType
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
unset_plays
fn unset_plays<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
role_type: RoleType
) -> BoxPromise<'tx, Result>
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result<Relation>>
-
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) Relation
s that are instances of this RelationType
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
|
|
Result<BoxStream<'tx, Result<Relation>>>
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
|
|
Result<BoxStream<'tx, Result<RoleType>>>
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
Label of the role we wish to retrieve |
|
BoxPromise<'tx, Result<Option<RoleType>>>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
Label of the role that overrides an inherited role |
|
BoxPromise<'tx, Result<Option<RoleType>>>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
|
|
Result<BoxStream<'tx, Result<RelationType>>>
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result<Option<RelationType>>>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
Result<BoxStream<'tx, Result<RelationType>>>
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The new role for the |
|
|
The label being overridden, if applicable |
|
BoxPromise<'tx, Result>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The |
|
BoxPromise<'tx, Result>
-
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The role to not relate to the relation type. |
|
BoxPromise<'tx, Result>
-
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.
Name | Type | Description |
---|---|---|
|
|
|
|
|
|
|
|
delete
fn delete<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
get_player_instances
fn get_player_instances<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<Thing>>>
Result<BoxStream<'tx, Result<Thing>>>
get_player_types
fn get_player_types<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<ThingType>>>
Result<BoxStream<'tx, Result<ThingType>>>
get_relation_instances
fn get_relation_instances<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<Relation>>>
Result<BoxStream<'tx, Result<Relation>>>
get_relation_type
fn get_relation_type<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<RelationType>>>
BoxPromise<'tx, Result<Option<RelationType>>>
get_relation_types
fn get_relation_types<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RelationType>>>
Result<BoxStream<'tx, Result<RelationType>>>
get_subtypes
fn get_subtypes<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>>
Result<BoxStream<'tx, Result<RoleType>>>
get_supertype
fn get_supertype<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<RoleType>>>
BoxPromise<'tx, Result<Option<RoleType>>>
get_supertypes
fn get_supertypes<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RoleType>>>
Result<BoxStream<'tx, Result<RoleType>>>
is_deleted
fn is_deleted<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
BoxPromise<'tx, Result<bool>>
Trait RoleTypeAPI
Implementors:
-
RoleType
delete
fn delete<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Deletes this type from the database.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result>
-
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
|
|
Result<BoxStream<'tx, Result<Thing>>>
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 ThingType
s whose instances play this role.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
|
|
Result<BoxStream<'tx, Result<ThingType>>>
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
|
|
Result<BoxStream<'tx, Result<Relation>>>
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result<Option<RelationType>>>
-
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 RelationType
s that this role is related to (directly or indirectly).
Name | Description | Type |
---|---|---|
|
The current transaction |
|
Result<BoxStream<'tx, Result<RelationType>>>
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
|
|
Result<BoxStream<'tx, Result<RoleType>>>
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result<Option<RoleType>>>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
Result<BoxStream<'tx, Result<RoleType>>>
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
).
bool
role_type.is_abstract()
is_deleted
fn is_deleted<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
Checks if this type is deleted.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result<bool>>
-
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The new |
|
BoxPromise<'tx, Result>
-
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.
Name | Type | Description |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
delete
fn delete<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
get
fn get<'tx>(
&self,
transaction: &'tx Transaction<'_>,
value: Value
) -> BoxPromise<'tx, Result<Option<Attribute>>>
BoxPromise<'tx, Result<Option<Attribute>>>
get_instances
fn get_instances<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<Attribute>>>
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>>>
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>>>
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>>>
BoxPromise<'tx, Result<Option<AttributeType>>>
get_plays
fn get_plays<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<RoleType>>>
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>>>
BoxPromise<'tx, Result<Option<RoleType>>>
get_regex
fn get_regex<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<String>>>
BoxPromise<'tx, Result<Option<String>>>
get_subtypes
fn get_subtypes<'tx>(
&self,
transaction: &'tx Transaction<'_>,
transitivity: Transitivity
) -> Result<BoxStream<'tx, Result<AttributeType>>>
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>>>
Result<BoxStream<'tx, Result<AttributeType>>>
get_supertype
fn get_supertype<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<Option<AttributeType>>>
BoxPromise<'tx, Result<Option<AttributeType>>>
get_supertypes
fn get_supertypes<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<AttributeType>>>
Result<BoxStream<'tx, Result<AttributeType>>>
get_syntax
fn get_syntax<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<String>>
BoxPromise<'tx, Result<String>>
is_deleted
fn is_deleted<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
BoxPromise<'tx, Result<bool>>
put
fn put<'tx>(
&self,
transaction: &'tx Transaction<'_>,
value: Value
) -> BoxPromise<'tx, Result<Attribute>>
BoxPromise<'tx, Result<Attribute>>
set_abstract
fn set_abstract<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
set_label
fn set_label<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
new_label: String
) -> BoxPromise<'tx, Result>
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>
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>
BoxPromise<'tx, Result>
set_regex
fn set_regex<'tx>(
&self,
transaction: &'tx Transaction<'_>,
regex: String
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
set_supertype
fn set_supertype<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
supertype: AttributeType
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
unset_abstract
fn unset_abstract<'tx>(
&mut self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
unset_owns
fn unset_owns<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
attribute_type: AttributeType
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
unset_plays
fn unset_plays<'tx>(
&mut self,
transaction: &'tx Transaction<'_>,
role_type: RoleType
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
|
|
BoxPromise<'tx, Result<Option<Attribute>>>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
|
|
Result<BoxStream<'tx, Result<Attribute>>>
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 Annotation
s.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
|
|
|
Only retrieve |
|
Result<BoxStream<'tx, Result<ThingType>>>
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result<Option<String>>>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
|
|
Result<BoxStream<'tx, Result<AttributeType>>>
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
|
|
|
|
|
Result<BoxStream<'tx, Result<AttributeType>>>
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result<Option<AttributeType>>>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
Result<BoxStream<'tx, Result<AttributeType>>>
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
New |
|
BoxPromise<'tx, Result<Attribute>>
-
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 Attribute
s of this type (inserted earlier or later) should match this regex.
Can only be applied for AttributeType
s with a string
value type.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
Regular expression |
|
BoxPromise<'tx, Result>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The |
|
BoxPromise<'tx, Result>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result>
-
async
-
sync
attribute_type.unset_regex(transaction).await;
attribute_type.unset_regex(transaction).resolve();
Annotation
Annotations are used to specify extra schema constraints.
Variant |
---|
|
|
Transitivity
Used for specifying whether we need explicit or transitive subtyping, instances, etc.
Variant |
---|
|
|
Data
Trait ThingAPI
Implementors:
-
Attribute
-
Entity
-
Relation
delete
fn delete<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
Deletes this Thing
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result>
-
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 Attribute
s that this Thing
owns. Optionally, filtered by an AttributeType
or a list of AttributeType
s. Optionally, filtered by Annotation
s.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The |
|
|
The |
|
|
Only retrieve attributes with all given |
|
Result<BoxStream<'tx, Result<Attribute>>>
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
Result<BoxStream<'tx, Result<RoleType>>>
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.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The list of roles to filter the relations by. |
|
Result<BoxStream<'tx, Result<Relation>>>
thing.get_relations(transaction, role_types);
iid
fn iid(&self) -> &IID
Retrieves the unique id of the Thing
.
&IID
thing.iid();
is_deleted
fn is_deleted<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
Checks if this Thing
is deleted.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
BoxPromise<'tx, Result<bool>>
-
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].
bool
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The |
|
BoxPromise<'tx, Result>
-
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
.
Name | Description | Type |
---|---|---|
|
The current transaction |
|
|
The |
|
BoxPromise<'tx, Result>
-
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.
Name | Type | Description |
---|---|---|
|
|
The unique id of this Entity |
|
|
If this Thing is inferred by a [Reasoning Rule] or not |
|
|
The type which this Entity belongs to |
delete
fn delete<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
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>>>
Result<BoxStream<'tx, Result<Attribute>>>
get_playing
fn get_playing<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RoleType>>>
Result<BoxStream<'tx, Result<RoleType>>>
get_relations
fn get_relations<'tx>(
&self,
transaction: &'tx Transaction<'_>,
role_types: Vec<RoleType>
) -> Result<BoxStream<'tx, Result<Relation>>>
Result<BoxStream<'tx, Result<Relation>>>
is_deleted
fn is_deleted<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
BoxPromise<'tx, Result<bool>>
set_has
fn set_has<'tx>(
&self,
transaction: &'tx Transaction<'_>,
attribute: Attribute
) -> BoxPromise<'tx, Result>
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.
Name | Type | Description |
---|---|---|
|
|
The unique id of this Relation |
|
|
If this Relation is inferred by a [Reasoning Rule] or not |
|
|
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>
BoxPromise<'tx, Result>
delete
fn delete<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
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>>>
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>>>
Result<BoxStream<'tx, Result<Thing>>>
get_playing
fn get_playing<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RoleType>>>
Result<BoxStream<'tx, Result<RoleType>>>
get_relating
fn get_relating<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RoleType>>>
Result<BoxStream<'tx, Result<RoleType>>>
get_relations
fn get_relations<'tx>(
&self,
transaction: &'tx Transaction<'_>,
role_types: Vec<RoleType>
) -> Result<BoxStream<'tx, Result<Relation>>>
Result<BoxStream<'tx, Result<Relation>>>
get_role_players
fn get_role_players<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<(RoleType, Thing)>>>
Result<BoxStream<'tx, Result<(RoleType, Thing)>>>
is_deleted
fn is_deleted<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
BoxPromise<'tx, Result<bool>>
remove_role_player
fn remove_role_player<'tx>(
&self,
transaction: &'tx Transaction<'_>,
role_type: RoleType,
player: Thing
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
set_has
fn set_has<'tx>(
&self,
transaction: &'tx Transaction<'_>,
attribute: Attribute
) -> BoxPromise<'tx, Result>
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.
Name | Type | Description |
---|---|---|
|
|
The unique id of this Attribute |
|
|
If this Attribute is inferred by a [Reasoning Rule] or not |
|
|
The type which this Attribute belongs to |
|
|
The value which this Attribute instance holds. |
delete
fn delete<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result>
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>>>
Result<BoxStream<'tx, Result<Attribute>>>
get_owners
fn get_owners<'tx>(
&self,
transaction: &'tx Transaction<'_>,
thing_type: Option<ThingType>
) -> Result<BoxStream<'tx, Result<Thing>>>
Result<BoxStream<'tx, Result<Thing>>>
get_playing
fn get_playing<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> Result<BoxStream<'tx, Result<RoleType>>>
Result<BoxStream<'tx, Result<RoleType>>>
get_relations
fn get_relations<'tx>(
&self,
transaction: &'tx Transaction<'_>,
role_types: Vec<RoleType>
) -> Result<BoxStream<'tx, Result<Relation>>>
Result<BoxStream<'tx, Result<Relation>>>
is_deleted
fn is_deleted<'tx>(
&self,
transaction: &'tx Transaction<'_>
) -> BoxPromise<'tx, Result<bool>>
BoxPromise<'tx, Result<bool>>
set_has
fn set_has<'tx>(
&self,
transaction: &'tx Transaction<'_>,
attribute: Attribute
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
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.
Name | Description | Type |
---|---|---|
|
The label of the Rule to create or retrieve |
|
impl Promise<'tx, Result<Option<Rule>>>
-
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.
Result<impl Stream<Item = Result<Rule>> + 'tx>
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.
Name | Description | Type |
---|---|---|
|
The label of the Rule to create or replace |
|
|
The when body of the rule to create |
|
|
The then body of the rule to create |
|
impl Promise<'tx, Result<Rule>>
-
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.
Name | Type | Description |
---|---|---|
|
|
The unique label of the rule. |
|
|
The single statement that constitutes the ‘then’ of the rule. |
|
|
The statements that constitute the ‘when’ of the rule. |
delete
fn delete<'tx>(
&mut self,
transaction: &'tx Transaction<'tx>
) -> BoxPromise<'tx, Result>
BoxPromise<'tx, Result>
is_deleted
fn is_deleted<'tx>(
&self,
transaction: &'tx Transaction<'tx>
) -> BoxPromise<'tx, Result<bool>>
BoxPromise<'tx, Result<bool>>
Trait RuleAPI
Implementors:
-
Rule
delete
fn delete<'tx>(
&mut self,
transaction: &'tx Transaction<'tx>
) -> BoxPromise<'tx, Result>
Deletes this rule.
Name | Description | Type |
---|---|---|
|
The current |
|
BoxPromise<'tx, Result>
-
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.
Name | Description | Type |
---|---|---|
|
The current |
|
BoxPromise<'tx, Result<bool>>
-
async
-
sync
rule.is_deleted(transaction).await
rule.is_deleted(transaction).resolve()
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.
Name | Description | Type |
---|---|---|
|
The current |
|
|
The new label to be given to the rule |
|
BoxPromise<'tx, Result>
-
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.
Name | Type | Description |
---|---|---|
|
|
|
|
|
Error
Represents errors encountered during operation.
Variant |
---|
|
|
|
|
ConnectionError
Variant |
---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|