TypeDB 3.0 is live! Get started for free.

Rust driver API reference

Connection

TypeDBDriver

Implements traits:

  • 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 if it is open.

Returns
Result
Code examples
connection.force_close()

is_cloud

pub fn is_cloud(&self) -> bool

Check if the connection is to an Cloud server.

Returns
bool
Code examples
connection.is_cloud()

is_open

pub fn is_open(&self) -> bool

Checks it this connection is opened.

Returns
bool
Code examples
connection.is_open()

new_cloud

  • async

  • sync

pub async fn new_cloud<T: AsRef<str> + Sync>(
    init_addresses: &Vec<T>,
    credentials: Credentials,
    driver_options: DriverOptions,
) -> Result<Self>
pub fn new_cloud<T: AsRef<str> + Sync>(
    init_addresses: &Vec<T>,
    credentials: Credentials,
    driver_options: DriverOptions,
) -> Result<Self>

Creates a new TypeDB Cloud connection.

Input parameters
Name Description Type

init_addresses

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

&Vec<T>

credentials

— The Credentials to connect with

Credentials

driver_options

— The DriverOptions to connect with

DriverOptions

Returns
Result<Self>
Code examples

new_cloud_with_description

  • async

  • sync

pub async fn new_cloud_with_description<T: AsRef<str> + Sync>(
    init_addresses: &Vec<T>,
    credentials: Credentials,
    driver_options: DriverOptions,
    driver_lang: impl AsRef<str>,
) -> Result<Self>
pub fn new_cloud_with_description<T: AsRef<str> + Sync>(
    init_addresses: &Vec<T>,
    credentials: Credentials,
    driver_options: DriverOptions,
    driver_lang: impl AsRef<str>,
) -> Result<Self>

Creates a new TypeDB Cloud connection.

Input parameters
Name Description Type

init_addresses

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

&Vec<T>

credentials

— The Credentials to connect with

Credentials

driver_options

— The DriverOptions to connect with

DriverOptions

driver_lang

— The language of the driver connecting to the server

impl AsRef<str>

Returns
Result<Self>
Code examples

new_cloud_with_translation

  • async

  • sync

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

Creates a new TypeDB Cloud connection.

Input parameters
Name Description Type

address_translation

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

HashMap<T

credential

— The Credentials to connect with

Credentials

driver_options

— The DriverOptions to connect with

DriverOptions

Returns
Result<Self>where
    T: AsRef<str> + Sync,
    U: AsRef<str> + Sync,
Code examples

new_cloud_with_translation_with_description

  • async

  • sync

pub async fn new_cloud_with_translation_with_description<T, U>(
    address_translation: HashMap<T, U>,
    credentials: Credentials,
    driver_options: DriverOptions,
    driver_lang: impl AsRef<str>,
) -> Result<Self>where
    T: AsRef<str> + Sync,
    U: AsRef<str> + Sync,
pub fn new_cloud_with_translation_with_description<T, U>(
    address_translation: HashMap<T, U>,
    credentials: Credentials,
    driver_options: DriverOptions,
    driver_lang: impl AsRef<str>,
) -> Result<Self>where
    T: AsRef<str> + Sync,
    U: AsRef<str> + Sync,

Creates a new TypeDB Cloud connection.

Input parameters
Name Description Type

address_translation

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

HashMap<T

credentials

— The Credentials to connect with

Credentials

driver_options

— The DriverOptions to connect with

DriverOptions

driver_lang

— The language of the driver connecting to the server

impl AsRef<str>

Returns
Result<Self>where
    T: AsRef<str> + Sync,
    U: AsRef<str> + Sync,
Code examples

new_core

  • async

  • sync

pub async fn new_core(
    address: impl AsRef<str>,
    credentials: Credentials,
    driver_options: DriverOptions,
) -> Result<Self>
pub fn new_core(
    address: impl AsRef<str>,
    credentials: Credentials,
    driver_options: DriverOptions,
) -> Result<Self>

Creates a new TypeDB Server connection.

Input parameters
Name Description Type

address

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

impl AsRef<str>

Credentials

— The Credentials to connect with

driver_options

— The DriverOptions to connect with

DriverOptions

Returns
Result<Self>
Code examples
  • async

  • sync

Connection::new_core("127.0.0.1:1729").await
Connection::new_core("127.0.0.1:1729")

new_core_with_description

  • async

  • sync

pub async fn new_core_with_description(
    address: impl AsRef<str>,
    credentials: Credentials,
    driver_options: DriverOptions,
    driver_lang: impl AsRef<str>,
) -> Result<Self>
pub fn new_core_with_description(
    address: impl AsRef<str>,
    credentials: Credentials,
    driver_options: DriverOptions,
    driver_lang: impl AsRef<str>,
) -> Result<Self>

Creates a new TypeDB Server connection with a description.

Input parameters
Name Description Type

address

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

impl AsRef<str>

Credentials

— The Credentials to connect with

driver_options

— The DriverOptions to connect with

DriverOptions

driver_lang

— The language of the driver connecting to the server

impl AsRef<str>

Returns
Result<Self>
Code examples
  • async

  • sync

Connection::new_core("127.0.0.1:1729", "rust").await
Connection::new_core("127.0.0.1:1729", "rust")

Credentials

Implements traits:

  • Clone

  • Debug

User credentials for connecting to TypeDB

new

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

Creates a credentials with username and password.

Input parameters
Name Description Type

username

— The name of the user to connect as

&str

password

— The password for the user

&str

Returns
Self
Code examples
Credentials::new(username, password);

password

pub fn password(&self) -> &str

Retrieves the password used.

Returns
&str

username

pub fn username(&self) -> &str

Retrieves the username used.

Returns
&str

DriverOptions

Implements traits:

  • Clone

  • Debug

User connection settings for connecting to TypeDB.

is_tls_enabled

pub fn is_tls_enabled(&self) -> bool

Retrieves whether TLS is enabled for the connection.

Returns
bool

new

pub fn new(is_tls_enabled: bool, tls_root_ca: Option<&Path>) -> Result<Self>

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

Input parameters
Name Description Type

is_tls_enabled

— Specify whether the connection to TypeDB Server must be done over TLS.

bool

tls_root_ca

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

Option<&Path>

Returns
Result<Self>
Code examples
DriverOptions::new(true, Some(&path_to_ca));

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

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

  • sync

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

contains

  • async

  • sync

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

Checks if a database with the given name exists

Input parameters
Name Description Type

name

— The database name to be checked

impl Into<String>

Returns
Result<bool>
Code examples
  • async

  • sync

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

create

  • async

  • sync

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

Create a database with the given name

Input parameters
Name Description Type

name

— The name of the database to be created

impl Into<String>

Returns
Result
Code examples
  • async

  • sync

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

get

  • async

  • sync

pub async fn get(&self, name: impl AsRef<str>) -> Result<Arc<Database>>
pub fn get(&self, name: impl AsRef<str>) -> Result<Arc<Database>>

Retrieve the database with the given name.

Input parameters
Name Description Type

name

— The name of the database to retrieve

impl AsRef<str>

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

  • sync

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

Database

Implements traits:

  • Debug

A TypeDB database

delete

  • async

  • sync

pub async fn delete(self: Arc<Self>) -> Result
pub fn delete(self: Arc<Self>) -> Result

Deletes this database.

Returns
Result
Code examples
  • async

  • sync

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

name

pub fn name(&self) -> &str

Retrieves the database name as a string.

Returns
&str

preferred_replica_info

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

Returns the preferred replica for this database. Operations which can be run on any replica will prefer to use this replica. Only works in TypeDB Cloud

Returns
Option<ReplicaInfo>
Code examples
database.preferred_replica_info();

primary_replica_info

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

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

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

replicas_info

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

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

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

schema

  • async

  • sync

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

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

Returns
Result<String>
Code examples
  • async

  • sync

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

type_schema

  • async

  • sync

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

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

Returns
Result<String>
Code examples
  • async

  • sync

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

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.

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

contains

  • async

  • sync

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

Checks if a user with the given name exists.

Input parameters
Name Description Type

username

— The user name to be checked

impl Into<String>

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

create

  • async

  • sync

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

Create a user with the given name & password.

Input parameters
Name Description Type

username

— The name of the user to be created

impl Into<String>

password

— The password of the user to be created

impl Into<String>

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

get

  • async

  • sync

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

Retrieve a user with the given name.

Input parameters
Name Description Type

username

— The name of the user to retrieve

impl Into<String>

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

User

Implements traits:

  • Clone

  • Debug

Fields
Name Type Description

name

String

password

Option<String>

server_connections

HashMap<Address, ServerConnection>

delete

  • async

  • sync

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

Deletes this user

Input parameters
Name Description Type

username

— The name of the user to be deleted

Returns
Result
Code examples
  • 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.

Input parameters
Name Description Type

username

— The name of the user

password

— The new password

impl Into<String>) → Result<(

Returns
Result<()>
Code examples
  • 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;

Transaction

Transaction

Implements traits:

  • Debug

A transaction with a TypeDB database.

commit

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

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

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

  • sync

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

force_close

pub fn force_close(&self)

Closes the transaction.

Returns
null
Code examples
transaction.force_close()

is_open

pub fn is_open(&self) -> bool

Closes the transaction.

Returns
bool
Code examples
transaction.close()

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.

Input parameters
Name Description Type

function

— The callback function.

Returns
null
Code examples
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

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

Input parameters
Name Description Type

query

— The TypeQL query to be executed

impl AsRef<str>

options

— Query options

Options

Returns
impl Promise<'static, Result<QueryAnswer>>
Code examples
transaction.query_with_options(query, options)

rollback

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

Rolls back the uncommitted changes made via this transaction.

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

  • sync

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

type_

pub fn type_(&self) -> TransactionType

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

Returns
TransactionType

TransactionType

This enum is used to specify the type of transaction.

Enum variants
Variant

Read = 0

Schema = 2

Write = 1

Answer

QueryAnswer

Enum variants
Variant

ConceptDocumentStream(Arc<ConceptDocumentHeader>, BoxStream<'static, Result<ConceptDocument>>)

ConceptRowStream(Arc<ConceptRowHeader>, BoxStream<'static, Result<ConceptRow>>)

Ok(QueryType)

get_query_type

pub fn get_query_type(&self) -> QueryType

Retrieve the executed query’s type (shared by all elements in this stream).

Returns
QueryType
Code examples
query_answer.get_query_type()

into_documents

pub fn into_documents(self) -> BoxStream<'static, Result<ConceptDocument>>

Unwraps the QueryAnswer into a ConceptDocumentStream. Panics if it is not a ConceptDocumentStream.

Returns
BoxStream<'static, Result<ConceptDocument>>
Code examples
query_answer.into_documents()

into_rows

pub fn into_rows(self) -> BoxStream<'static, Result<ConceptRow>>

Unwraps the QueryAnswer into a ConceptRowStream. Panics if it is not a ConceptRowStream.

Returns
BoxStream<'static, Result<ConceptRow>>
Code examples
query_answer.into_rows()

is_document_stream

pub fn is_document_stream(&self) -> bool

Check if the QueryAnswer is a ConceptDocumentStream.

Returns
bool
Code examples
query_answer.is_document_stream()

is_ok

pub fn is_ok(&self) -> bool

Check if the QueryAnswer is an Ok response.

Returns
bool
Code examples
query_answer.is_ok()

is_row_stream

pub fn is_row_stream(&self) -> bool

Check if the QueryAnswer is a ConceptRowStream.

Returns
bool
Code examples
query_answer.is_row_stream()

ConceptRow

Implements traits:

  • Clone

  • Debug

  • Display

  • PartialEq

  • StructuralPartialEq

A single row of concepts representing substitutions for variables in the query. Contains a Header (column names and query type), and the row of optional concepts. An empty concept in a column means the variable does not have a substitution in this answer.

Fields
Name Type Description

row

Vec<Option<Concept>>

get

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

Retrieves a concept for a given variable. Returns an empty optional if the variable name has an empty answer. Returns an error if the variable name is not present.

Input parameters
Name Description Type

var_name

— The variable name in the row to retrieve

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

get_column_names

pub fn get_column_names(&self) -> &[String]

Retrieve the row column names (shared by all elements in this stream).

Returns
&[String]
Code examples
concept_row.get_column_names()

get_concepts

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

Produces an iterator over all concepts in this ConceptRow, skipping empty results

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

get_index

pub fn get_index(&self, column_index: usize) -> Result<Option<&Concept>>

Retrieves a concept for a given column index. Returns an empty optional if the index points to an empty answer. Returns an error if the index is not in the row’s range.

Input parameters
Name Description Type

column_index

— The position in the row to retrieve

usize

Returns
Result<Option<&Concept>>
Code examples
concept_row.get_position(column_index)

get_query_type

pub fn get_query_type(&self) -> QueryType

Retrieve the executed query’s type (shared by all elements in this stream).

Returns
QueryType
Code examples
concept_row.get_query_type()

ConceptRowHeader

Implements traits:

  • Debug

  • PartialEq

  • StructuralPartialEq

Fields
Name Type Description

column_names

Vec<String>

query_type

QueryType

ConceptDocument

Implements traits:

  • Clone

  • Debug

  • PartialEq

  • StructuralPartialEq

A single document of concepts representing substitutions for variables in the query. Contains a Header (query type), and the document of concepts.

Fields
Name Type Description

root

Option<Node>

get_query_type

pub fn get_query_type(&self) -> QueryType

Retrieve the executed query’s type (shared by all elements in this stream).

Returns
QueryType
Code examples
concept_document.get_query_type()

ConceptDocumentHeader

Implements traits:

  • Debug

  • PartialEq

  • StructuralPartialEq

Fields
Name Type Description

query_type

QueryType

JSON

Enum variants
Variant

Array(Vec<JSON>)

Boolean(bool)

Null

Number(f64)

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

String(Cow<'static, str>)

Node

Enum variants
Variant

Leaf(Option<Leaf>)

List(Vec<Node>)

Map(HashMap<String, Node>)

Leaf

Enum variants
Variant

Concept(Concept)

Empty

Kind(Kind)

ValueType(ValueType)

QueryType

This enum is used to specify the type of the query resulted in this answer.

Enum variants
Variant

ReadQuery = 0

SchemaQuery = 2

WriteQuery = 1

Trait Promise

  • async

  • sync

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

Examples
promise.await

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

Examples
promise.resolve()

Concept

Concept

The fundamental TypeQL object.

Enum variants
Variant

Attribute(Attribute)

AttributeType(AttributeType)

Entity(Entity)

EntityType(EntityType)

Relation(Relation)

RelationType(RelationType)

RoleType(RoleType)

Value(Value)

get_category

pub fn get_category(&self) -> ConceptCategory

Retrieves the category of this Concept.

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

Returns
&str

is_attribute

pub fn is_attribute(&self) -> bool

Check if this Concept represents an Attribute instance from the database

Returns
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

Returns
bool

is_boolean

pub fn is_boolean(&self) -> bool

Check if this Concept holds a boolean as an AttributeType, an Attribute, or a Value

Returns
bool

is_date

pub fn is_date(&self) -> bool

Check if this Concept holds a date as an AttributeType, an Attribute, or a Value

Returns
bool

is_datetime

pub fn is_datetime(&self) -> bool

Check if this Concept holds a datetime as an AttributeType, an Attribute, or a Value

Returns
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

Returns
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

Returns
bool

is_double

pub fn is_double(&self) -> bool

Check if this Concept holds a double as an AttributeType, an Attribute, or a Value

Returns
bool

is_duration

pub fn is_duration(&self) -> bool

Check if this Concept holds a duration as an AttributeType, an Attribute, or a Value

Returns
bool

is_entity

pub fn is_entity(&self) -> bool

Check if this Concept represents an Entity instance from the database

Returns
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

Returns
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:

Returns
bool
Code examples
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

Returns
bool

is_relation

pub fn is_relation(&self) -> bool

Check if this Concept represents an Relation instance from the database

Returns
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

Returns
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

Returns
bool

is_string

pub fn is_string(&self) -> bool

Check if this Concept holds a string as an AttributeType, an Attribute, or a Value

Returns
bool

is_struct

pub fn is_struct(&self) -> bool

Check if this Concept holds a struct as an AttributeType, an Attribute, or a Value

Returns
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:

Returns
bool
Code examples
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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Returns
Option<ValueType>

ConceptCategory

Enum variants
Variant

Attribute

AttributeType

Entity

EntityType

Relation

RelationType

RoleType

Value

Kind

Kind represents the base of a defined type to describe its capabilities. For example, “define entity person;” defines a type “person” of a kind “entity”.

Enum variants
Variant

Attribute

Entity

Relation

Role

Schema

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.

Fields
Name Type Description

label

String

label

pub fn label(&self) -> &str

Retrieves the unique label of the EntityType.

Returns
&str
Code examples
entity_type.label()

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.

Fields
Name Type Description

label

String

label

pub fn label(&self) -> &str

Retrieves the unique label of the RelationType.

Returns
&str
Code examples
relation_type.label()

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.

Fields
Name Type Description

label

String

label

pub fn label(&self) -> &str

Retrieves the unique label of the RoleType.

Returns
&str
Code examples
role_type.label()

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.

Fields
Name Type Description

label

String

value_type

Option<ValueType>

label

pub fn label(&self) -> &str

Retrieves the unique label of the AttributeType.

Returns
&str
Code examples
attribute_type.label()

value_type

pub fn value_type(&self) -> Option<&ValueType>

Retrieves the ValueType of the AttributeType.

Returns
Option<&ValueType>
Code examples
attribute_type.value_type()

ValueType

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

Enum variants
Variant

Boolean

Date

Datetime

DatetimeTZ

Decimal

Double

Duration

Integer

String

Struct(String)

Data

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.

Fields
Name Type Description

iid

IID

The unique id of this Entity

type_

Option<EntityType>

The type which this Entity belongs to

iid

pub fn iid(&self) -> &IID

Retrieves the unique id of the Entity.

Returns
&IID
Code examples
entity.iid();

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.

Fields
Name Type Description

iid

IID

The unique id of this Relation

type_

Option<RelationType>

The type which this Relation belongs to

iid

pub fn iid(&self) -> &IID

Retrieves the unique id of the Relation.

Returns
&IID
Code examples
relation.iid();

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.

Fields
Name Type Description

iid

IID

The unique id of this Attribute (internal use only)

type_

Option<AttributeType>

The type which this Attribute belongs to

value

Value

The (dataful) value of this attribute

Value

Enum variants
Variant

Boolean(bool)

Date(NaiveDate)

Datetime(NaiveDateTime)

DatetimeTZ(DateTime<TimeZone>)

Decimal(Decimal)

Double(f64)

Duration(Duration)

Integer(i64)

String(String)

Struct(Struct, String)

get_type

pub fn get_type(&self) -> ValueType

Retrieves the ValueType of this value concept.

Returns
ValueType
Code examples
value.get_type();

get_type_name

pub fn get_type_name(&self) -> &str

Retrieves the name of the ValueType of this value concept.

Returns
&str
Code examples
value.get_type_name();

Value

Decimal

Implements traits:

  • Add

  • Clone

  • Copy

  • Debug

  • Default

  • Display

  • Eq

  • Hash

  • Neg

  • Ord

  • PartialEq

  • PartialOrd

  • StructuralPartialEq

  • Sub

A fixed-point decimal number. Holds exactly 19 digits after the decimal point and a 64-bit value before the decimal point.

fractional_part

pub fn fractional_part(&self) -> u64

Get the fractional part of the decimal, in multiples of 10^-19 (Decimal::FRACTIONAL_PART_DENOMINATOR) This means, the smallest decimal representable is 10^-19, and up to 19 decimal places are supported.

Returns
u64

integer_part

pub fn integer_part(&self) -> i64

Get the integer part of the decimal as normal signed 64 bit number

Returns
i64

Duration

Implements traits:

  • Clone

  • Copy

  • Debug

  • Display

  • Eq

  • FromStr

  • Hash

  • PartialEq

  • StructuralPartialEq

  • TryFrom<Duration>

A relative duration, which contains months, days, and nanoseconds. Can be used for calendar-relative durations (eg 7 days forward), or for absolute durations using the nanosecond component When used as an absolute duration, convertible to chrono::Duration

Fields
Name Type Description

days

u32

months

u32

nanos

u64

Offset

Offset for datetime-tz. Can be retrieved from an IANA Tz or a FixedOffset.

Enum variants
Variant

Fixed(FixedOffset)

IANA(<Tz as TimeZone>::Offset)

TimeZone

TimeZone for datetime-tz. Can be represented as an IANA Tz or as a FixedOffset.

Enum variants
Variant

Fixed(FixedOffset)

IANA(Tz)

Errors

Error

Represents errors encountered during operation.

Enum variants
Variant

Concept(ConceptError)

Connection(ConnectionError)

Internal(InternalError)

Other(String)

Server(ServerError)

ConnectionError

Enum variants
Variant

AddressTranslationMismatch

BrokenPipe

CloudAllNodesFailed

CloudEncryptionSettingsMismatch

CloudReplicaNotPrimary

CloudSSLCertificateNotValidated

CloudTokenCredentialInvalid

ConnectionFailed

DatabaseNotFound

InvalidResponseField

ListsNotImplemented

MissingPort

MissingResponseField

QueryStreamNoResponse

RPCMethodUnavailable

ServerConnectionFailed

ServerConnectionFailedStatusError

ServerConnectionFailedWithError

ServerConnectionIsClosed

TransactionIsClosed

TransactionIsClosedWithErrors

UnexpectedConnectionClose

UnexpectedKind

UnexpectedQueryType

UnexpectedResponse

UnknownRequestId

UserManagementCloudOnly

ValueStructNotImplemented

ValueTimeZoneNameNotRecognised

ValueTimeZoneOffsetNotRecognised

ServerError

Implements traits:

  • Clone

  • Debug

  • Display

  • Eq

  • From<ServerError>

  • PartialEq

  • StructuralPartialEq

DurationParseError

Implements traits:

  • Debug

InternalError

Enum variants
Variant

EnumOutOfBounds

RecvError

SendError

UnexpectedRequestType

UnexpectedResponseType

UnknownServer