Rust driver API reference
Connection
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/connection/Connection.adoc[]
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/connection/Credential.adoc[]
DatabaseManager
Implements traits:
-
Debug
Provides access to all database management methods.
all
-
async
-
sync
pub async fn all(&self) -> Result<Vec<Arc<Database>>>
pub fn all(&self) -> Result<Vec<Arc<Database>>>
Retrieves all databases present on the TypeDB server
Result<Vec<Arc<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 AsRef<str>) -> Result<Arc<Database>>
pub fn get(&self, name: impl AsRef<str>) -> Result<Arc<Database>>
Retrieve the database with the given name.
Name | Description | Type |
---|---|---|
|
— The name of the database to retrieve |
|
Result<Arc<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: Arc<Self>) -> Result
pub fn delete(self: Arc<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 / Enterprise
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 / Enterprise
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 / Enterprise
Vec<ReplicaInfo>
database.replicas_info()
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:
-
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;
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;
User
Implements traits:
-
Clone
-
Debug
Name | Type | Description |
---|---|---|
|
|
|
|
|
|
|
|
delete
-
async
-
sync
pub async fn delete(self) -> Result
pub fn delete(self) -> Result
Deletes this user
Name | Description | Type |
---|---|---|
|
— The name of the user to be deleted |
Result
-
async
-
sync
user.delete().await;
user.delete(username).await;
user.delete();
user.delete(username).await;
update_password
-
async
-
sync
pub async fn update_password(&self, password: impl Into<String>) -> Result<()>
pub fn update_password(&self, password: impl Into<String>) -> Result<()>
Update the user’s password.
Name | Description | Type |
---|---|---|
|
— The name of the user |
|
|
— The new password |
|
Result<()>
-
async
-
sync
user.update_password(username, password).await;
user.update_password(username, password).await;
user.update_password(username, password);
user.update_password(username, password).await;
Session
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/session/Session.adoc[]
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/session/SessionType.adoc[]
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/session/Options.adoc[]
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()
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()
on_close
pub fn on_close(
&self,
callback: impl FnOnce(Option<Error>) + 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,
query: impl AsRef<str>,
) -> impl Promise<'static, Result<QueryAnswer>>
Performs a TypeQL query with default options. See Transaction::query_with_options
impl Promise<'static, Result<QueryAnswer>>
query_with_options
pub fn query_with_options(
&self,
query: impl AsRef<str>,
options: Options,
) -> impl Promise<'static, Result<QueryAnswer>>
Performs a TypeQL query in this transaction.
Name | Description | Type |
---|---|---|
|
— The TypeQL query to be executed |
|
|
— Query options |
|
impl Promise<'static, Result<QueryAnswer>>
transaction.query_with_options(query, options)
Answer
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/answer/ConceptMapGroup.adoc[]
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/answer/ConceptMap.adoc[]
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/answer/ValueGroup.adoc[]
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()
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/answer/Explainables.adoc[]
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/answer/Explainable.adoc[]
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/answer/Explanation.adoc[]
Concept
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/concept/ConceptManager.adoc[]
Concept
The fundamental TypeQL object.
Variant |
---|
|
|
|
|
|
|
|
|
get_category
pub fn get_category(&self) -> ConceptCategory
Retrieves the category of this Concept.
ConceptCategory
get_label
pub fn get_label(&self) -> &str
Retrieves the label of this Concept. If this is an Instance, returns the label of the type of this instance (“unknown” if type fetching is disabled). If this is a Value, returns the label of the value type of the value. If this is a Type, returns the label of the type.
&str
is_attribute
pub fn is_attribute(&self) -> bool
Check if this Concept represents an Attribute instance from the database
bool
is_attribute_type
pub fn is_attribute_type(&self) -> bool
Check if this Concept represents an Attribute Type from the schema of the database
bool
is_boolean
pub fn is_boolean(&self) -> bool
Check if this Concept holds a boolean as an AttributeType, an Attribute, or a Value
bool
is_date
pub fn is_date(&self) -> bool
Check if this Concept holds a date as an AttributeType, an Attribute, or a Value
bool
is_datetime
pub fn is_datetime(&self) -> bool
Check if this Concept holds a datetime as an AttributeType, an Attribute, or a Value
bool
is_datetime_tz
pub fn is_datetime_tz(&self) -> bool
Check if this Concept holds a timezoned-datetime as an AttributeType, an Attribute, or a Value
bool
is_decimal
pub fn is_decimal(&self) -> bool
Check if this Concept holds a fixed-decimal as an AttributeType, an Attribute, or a Value
bool
is_double
pub fn is_double(&self) -> bool
Check if this Concept holds a double as an AttributeType, an Attribute, or a Value
bool
is_duration
pub fn is_duration(&self) -> bool
Check if this Concept holds a duration as an AttributeType, an Attribute, or a Value
bool
is_entity
pub fn is_entity(&self) -> bool
Check if this Concept represents an Entity instance from the database
bool
is_entity_type
pub fn is_entity_type(&self) -> bool
Check if this Concept represents an Entity Type from the schema of the database
bool
is_instance
pub fn is_instance(&self) -> bool
Check if this Concept represents a stored database instance from the database. These are exactly: Entity, Relation, and Attribute
Equivalent to:
bool
concept.is_entity() || concept.is_relation() || concept.is_attribute()
is_integer
pub fn is_integer(&self) -> bool
Check if this Concept holds an integer as an AttributeType, an Attribute, or a Value
bool
is_relation
pub fn is_relation(&self) -> bool
Check if this Concept represents an Relation instance from the database
bool
is_relation_type
pub fn is_relation_type(&self) -> bool
Check if this Concept represents a Relation Type from the schema of the database
bool
is_role_type
pub fn is_role_type(&self) -> bool
Check if this Concept represents a Role Type from the schema of the database
bool
is_string
pub fn is_string(&self) -> bool
Check if this Concept holds a string as an AttributeType, an Attribute, or a Value
bool
is_struct
pub fn is_struct(&self) -> bool
Check if this Concept holds a struct as an AttributeType, an Attribute, or a Value
bool
is_type
pub fn is_type(&self) -> bool
Check if this Concept represents a Type from the schema of the database. These are exactly: Entity Types, Relation Types, Role Types, and Attribute Types
Equivalent to:
bool
concept.is_entity_type() || concept.is_relation_type() || concept.is_role_type() || concept.is_attribute_type()
is_value
pub fn is_value(&self) -> bool
Check if this Concept represents a Value returned by the database
bool
try_get_boolean
pub fn try_get_boolean(&self) -> Option<bool>
Retrieves the boolean value of this Concept, if it exists. If this is a boolean-valued Attribute Instance, returns the boolean value of this instance. If this a boolean-valued Value, returns the boolean value. Otherwise, returns None.
Option<bool>
try_get_date
pub fn try_get_date(&self) -> Option<NaiveDate>
Retrieves the date value of this Concept, if it exists. If this is a date-valued Attribute Instance, returns the date value of this instance. If this a date-valued Value, returns the date value. Otherwise, returns None.
Option<NaiveDate>
try_get_datetime
pub fn try_get_datetime(&self) -> Option<NaiveDateTime>
Retrieves the datetime value of this Concept, if it exists. If this is a datetime-valued Attribute Instance, returns the datetime value of this instance. If this a datetime-valued Value, returns the datetime value. Otherwise, returns None.
Option<NaiveDateTime>
try_get_datetime_tz
pub fn try_get_datetime_tz(&self) -> Option<DateTime<TimeZone>>
Retrieves the timezoned-datetime value of this Concept, if it exists. If this is a timezoned-datetime valued Attribute Instance, returns the timezoned-datetime value of this instance. If this a timezoned-datetime valued Value, returns the timezoned-datetime value. Otherwise, returns None.
Option<DateTime<TimeZone>>
try_get_decimal
pub fn try_get_decimal(&self) -> Option<Decimal>
Retrieves the fixed-decimal value of this Concept, if it exists. If this is a fixed-decimal valued Attribute Instance, returns the fixed-decimal value of this instance. If this a fixed-decimal valued Value, returns the fixed-decimal value. Otherwise, returns None.
Option<Decimal>
try_get_double
pub fn try_get_double(&self) -> Option<f64>
Retrieves the double value of this Concept, if it exists. If this is a double-valued Attribute Instance, returns the double value of this instance. If this a double-valued Value, returns the double value. Otherwise, returns None.
Option<f64>
try_get_duration
pub fn try_get_duration(&self) -> Option<Duration>
Retrieves the duration value of this Concept, if it exists. If this is a duration-valued Attribute Instance, returns the duration value of this instance. If this a duration-valued Value, returns the duration value. Otherwise, returns None.
Option<Duration>
try_get_iid
pub fn try_get_iid(&self) -> Option<&IID>
Retrieves the unique id (IID) of this Concept. If this is an Entity or Relation Instance, returns the IID of the instance. Otherwise, returns None.
Option<&IID>
try_get_integer
pub fn try_get_integer(&self) -> Option<i64>
Retrieves the integer value of this Concept, if it exists. If this is an integer-valued Attribute Instance, returns the integer value of this instance. If this an integer-valued Value, returns the integer value. Otherwise, returns None.
Option<i64>
try_get_label
pub fn try_get_label(&self) -> Option<&str>
Retrieves the optional label of the concept. If this is an Instance, returns the label of the type of this instance (None if type fetching is disabled). If this is a Value, returns the label of the value type of the value. If this is a Type, returns the label of the type.
Option<&str>
try_get_string
pub fn try_get_string(&self) -> Option<&str>
Retrieves the string value of this Concept, if it exists. If this is a string-valued Attribute Instance, returns the string value of this instance. If this a string-valued Value, returns the string value. Otherwise, returns None.
Option<&str>
try_get_struct
pub fn try_get_struct(&self) -> Option<&Struct>
Retrieves the struct value of this Concept, if it exists. If this is a struct-valued Attribute Instance, returns the struct value of this instance. If this a struct-valued Value, returns the struct value. Otherwise, returns None.
Option<&Struct>
try_get_value
pub fn try_get_value(&self) -> Option<&Value>
Retrieves the value of this Concept, if it exists. If this is an Attribute Instance, returns the value of this instance. If this a Value, returns the value. Otherwise, returns empty.
Option<&Value>
try_get_value_label
pub fn try_get_value_label(&self) -> Option<&str>
Retrieves the label of the value type of the concept, if it exists. If this is an Attribute Instance, returns the label of the value of this instance. If this is a Value, returns the label of the value. If this is an Attribute Type, returns the label of the value type that the schema permits for the attribute type, if one is defined. Otherwise, returns None.
Option<&str>
try_get_value_type
pub fn try_get_value_type(&self) -> Option<ValueType>
Retrieves the value type enum of the concept, if it exists. If this is an Attribute Instance, returns the value type of the value of this instance. If this is a Value, returns the value type of the value. If this is an Attribute Type, returns value type that the schema permits for the attribute type, if one is defined. Otherwise, returns None.
Option<ValueType>
Schema
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/schema/RootThingType.adoc[]
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/schema/ThingType.adoc[]
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/schema/Trait_ThingTypeAPI.adoc[]
EntityType
Implements traits:
-
Clone
-
Debug
-
Display
-
Eq
-
PartialEq
-
StructuralPartialEq
Entity types represent the classification of independent objects in the data model of the business domain.
Name | Type | Description |
---|---|---|
|
|
RelationType
Implements traits:
-
Clone
-
Debug
-
Display
-
Eq
-
PartialEq
-
StructuralPartialEq
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 |
---|---|---|
|
|
RoleType
Implements traits:
-
Clone
-
Debug
-
Display
-
Eq
-
PartialEq
-
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 |
---|---|---|
|
|
AttributeType
Implements traits:
-
Clone
-
Debug
-
Display
-
PartialEq
-
StructuralPartialEq
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 |
---|---|---|
|
|
|
|
|
label
pub fn label(&self) -> &str
Retrieves the unique label of the AttributeType
.
&str
attribute_type.label()
value_type
pub fn value_type(&self) -> Option<&ValueType>
Retrieves the ValueType
of the AttributeType
.
Option<&ValueType>
attribute_type.value_type()
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/schema/Trait_AttributeTypeAPI.adoc[]
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/schema/Annotation.adoc[]
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/schema/Transitivity.adoc[]
ValueType
Represents the type of primitive value is held by a Value or Attribute.
Variant |
---|
|
|
|
|
|
|
|
|
|
|
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/schema/ScopedLabel.adoc[]
Data
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/data/Thing.adoc[]
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/data/Trait_ThingAPI.adoc[]
Entity
Implements traits:
-
Clone
-
Debug
-
Eq
-
PartialEq
-
StructuralPartialEq
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 |
|
|
The type which this Entity belongs to |
Relation
Implements traits:
-
Clone
-
Debug
-
Eq
-
PartialEq
-
StructuralPartialEq
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 |
|
|
The type which this Relation belongs to |
Attribute
Implements traits:
-
Clone
-
Debug
-
PartialEq
-
StructuralPartialEq
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 (internal use only) |
|
|
The type which this Attribute belongs to |
|
|
The (dataful) value of this attribute |
Value
Variant |
---|
|
|
|
|
|
|
|
|
|
|
Logic
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/logic/LogicManager.adoc[]
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/logic/Rule.adoc[]
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/logic/Trait_RuleAPI.adoc[]
Errors
Unresolved include directive in modules/ROOT/partials/rust/api-reference.adoc - include::api-ref::partial$rust/errors/SchemaException.adoc[]
Error
Represents errors encountered during operation.
Variant |
---|
|
|
|
|
|
ConnectionError
Variant |
---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|