Struct typedb_driver::Session

source ·
pub struct Session { /* private fields */ }
Expand description

A session with a TypeDB database.

Implementations§

source§

impl Session

source

pub async 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

source

pub async 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.

§Arguments
  • database – The database with which the session connects
  • session_type – The type of session to be created (DATA or SCHEMA)
  • optionsTypeDBOptions for the session
§Examples
Session::new_with_options(database, session_type, options).await;
source

pub fn database_name(&self) -> &str

Returns the name of the database of the session.

§Examples
session.database_name();
source

pub fn type_(&self) -> SessionType

The current session’s type (SCHEMA or DATA)

source

pub fn is_open(&self) -> bool

Checks whether this session is open.

§Examples
session.is_open();
source

pub fn force_close(&self) -> Result

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

§Examples
session.force_close();
source

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

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

§Arguments
  • function – The callback function.
§Examples
session.on_close(function);
source

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.

§Arguments
  • function – The callback function.
§Examples
session.on_reopen(function);
source

pub async 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

source

pub async 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.

§Arguments
  • transaction_type – The type of transaction to be created (READ or WRITE)
  • options – Options for the session
§Examples
session.transaction_with_options(transaction_type, options).await;

Trait Implementations§

source§

impl Debug for Session

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Session

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more