pub struct TypeDBDriver { /* private fields */ }Expand description
A connection to a TypeDB server which serves as the starting point for all interaction.
Implementations§
Source§impl TypeDBDriver
impl TypeDBDriver
pub const DEFAULT_ADDRESS: &'static str = "127.0.0.1:1729"
Sourcepub async fn new(
addresses: Addresses,
credentials: Credentials,
driver_options: DriverOptions,
) -> Result<Self>
pub async fn new( addresses: Addresses, credentials: Credentials, driver_options: DriverOptions, ) -> Result<Self>
Creates a new TypeDB Server connection.
§Arguments
addresses— The address(es) of the TypeDB Server(s), provided in a unified formatcredentials— The Credentials to connect withdriver_options— The DriverOptions to connect with
§Examples
TypeDBDriver::new(Addresses::try_from_address_str("127.0.0.1:1729").unwrap(), Credentials::new("username", "password"), DriverOptions::new(true, None)).awaitSourcepub async fn new_with_description(
addresses: Addresses,
credentials: Credentials,
driver_options: DriverOptions,
driver_lang: impl AsRef<str>,
) -> Result<Self>
pub async fn new_with_description( addresses: Addresses, credentials: Credentials, driver_options: DriverOptions, driver_lang: impl AsRef<str>, ) -> Result<Self>
Creates a new TypeDB Server connection with a description.
This method is generally used by TypeDB drivers built on top of the Rust driver.
In other cases, use Self::new instead.
§Arguments
addresses— The address(es) of the TypeDB Server(s), provided in a unified formatcredentials— The Credentials to connect withdriver_options— The DriverOptions to connect withdriver_lang— The language of the driver connecting to the server
§Examples
TypeDBDriver::new_with_description(Addresses::try_from_address_str("127.0.0.1:1729").unwrap(), Credentials::new("username", "password"), DriverOptions::new(true, None), "rust").awaitSourcepub fn databases(&self) -> &DatabaseManager
pub fn databases(&self) -> &DatabaseManager
The DatabaseManager for this connection, providing access to database management methods.
§Examples
driver.databases()Sourcepub fn users(&self) -> &UserManager
pub fn users(&self) -> &UserManager
The UserManager for this connection, providing access to user management methods.
§Examples
driver.databases()Sourcepub async fn server_version(&self) -> Result<ServerVersion>
pub async fn server_version(&self) -> Result<ServerVersion>
Retrieves the server’s version, using default automatic server routing.
See Self::server_version_with_routing for more details and options.
§Examples
driver.server_version().awaitSourcepub async fn server_version_with_routing(
&self,
server_routing: ServerRouting,
) -> Result<ServerVersion>
pub async fn server_version_with_routing( &self, server_routing: ServerRouting, ) -> Result<ServerVersion>
Sourcepub async fn servers(&self) -> Result<HashSet<Server>>
pub async fn servers(&self) -> Result<HashSet<Server>>
Retrieves the servers, using default automatic server routing.
See Self::servers_with_routing for more details and options.
§Examples
driver.servers().await;Sourcepub async fn servers_with_routing(
&self,
server_routing: ServerRouting,
) -> Result<HashSet<Server>>
pub async fn servers_with_routing( &self, server_routing: ServerRouting, ) -> Result<HashSet<Server>>
Sourcepub async fn primary_server(&self) -> Result<Option<AvailableServer>>
pub async fn primary_server(&self) -> Result<Option<AvailableServer>>
Retrieves the primary server, if exists, using default automatic server routing.
See Self::primary_server_with_routing for more details and options.
§Examples
driver.primary_server().await;Sourcepub async fn primary_server_with_routing(
&self,
server_routing: ServerRouting,
) -> Result<Option<AvailableServer>>
pub async fn primary_server_with_routing( &self, server_routing: ServerRouting, ) -> Result<Option<AvailableServer>>
Sourcepub fn options(&self) -> &DriverOptions
pub fn options(&self) -> &DriverOptions
Updates address translation of the driver. This lets you actualize new translation information without recreating the driver from scratch. Useful after registering new replicas requiring address translation. This operation will update existing connections using the provided addresses.
The DriverOptions for this connection.
§Examples
driver.options()Sourcepub fn configured_addresses(&self) -> &Addresses
pub fn configured_addresses(&self) -> &Addresses
Sourcepub async fn transaction(
&self,
database_name: impl AsRef<str>,
transaction_type: TransactionType,
) -> Result<Transaction>
pub async fn transaction( &self, database_name: impl AsRef<str>, transaction_type: TransactionType, ) -> Result<Transaction>
Opens a transaction with default options.
See TypeDBDriver::transaction_with_options for more details.
§Examples
driver.transaction(database_name, TransactionType::Read).await;Sourcepub async fn transaction_with_options(
&self,
database_name: impl AsRef<str>,
transaction_type: TransactionType,
options: TransactionOptions,
) -> Result<Transaction>
pub async fn transaction_with_options( &self, database_name: impl AsRef<str>, transaction_type: TransactionType, options: TransactionOptions, ) -> Result<Transaction>
Opens a new transaction with custom transaction options.
§Arguments
database_name— The name of the database to connect totransaction_type— The TransactionType to open the transaction withoptions— The TransactionOptions to open the transaction with
§Examples
transaction.transaction_with_options(database_name, transaction_type, options).awaitSourcepub fn force_close(&self) -> Result
pub fn force_close(&self) -> Result
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TypeDBDriver
impl !UnwindSafe for TypeDBDriver
impl Freeze for TypeDBDriver
impl Send for TypeDBDriver
impl Sync for TypeDBDriver
impl Unpin for TypeDBDriver
impl UnsafeUnpin for TypeDBDriver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request