Skip to main content

Database

Struct Database 

Source
pub struct Database<S: Schema = Unbound> { /* private fields */ }
Expand description

Primary database session handle type-branded by schema S.

Implementations§

Source§

impl<S: Schema> Database<S>

Source

pub fn query(&self) -> Result<QuerySession<'_, S>>

Start one owner-branded query authoring session over this schema-bound database.

Source

pub fn query_with_resources( &self, resources: QueryExecutionResourceLimits, cancellation: AnswerCancellation, ) -> Result<QuerySession<'_, S>>

Start one owner-branded query authoring session with one common tighten-only resource policy and caller-owned cancellation signal.

Source§

impl Database<Unbound>

Source

pub async fn connect( options: impl Into<ConnectionOptions>, ) -> Result<Database<Unbound>>

Connect to a TypeDB server returning an unbound database handle.

Source

pub fn with_schema<S: Schema>( self, schema: SchemaPackage<S>, ) -> Result<Database<S>>

Bind and verify a generated schema package, transitioning to Database<S>.

Source§

impl<S: Schema> Database<S>

Source

pub fn entities<M>(&self) -> EntityManager<'_, S, M>
where M: EntityModel<Schema = S>,

Create a lightweight client-owned exact entity manager.

Source

pub fn relations<M>(&self) -> RelationManager<'_, S, M>
where M: RelationModel<Schema = S>,

Create a lightweight client-owned exact relation manager.

Source

pub async fn write(&self) -> Result<WriteTransaction<'_, S>>

Open one client-owned write transaction over this schema-bound database. Operations on its borrowed managers never auto-commit; the caller terminally commits or rolls back, and dropping the open transaction releases the context without commit.

Source

pub async fn read(&self) -> Result<ReadTransaction<'_, S>>

Open one reusable client-owned read transaction. Query terminals borrow and reuse its retained context until explicit close or drop.

Source

pub fn database_name(&self) -> &str

Return the target database name.

Source

pub async fn database_exists(&self) -> Result<bool>

Return whether the one configured database exists.

Source

pub async fn database_exists_controlled( &self, control: &MigrationExecutionControl, ) -> Result<bool>

Return whether the managed database exists, honoring execution controls.

Source

pub async fn create_database(&self) -> Result<DatabaseCreateOutcome>

Create the one configured database and return its normalized outcome.

Source

pub async fn create_database_controlled( &self, control: &MigrationExecutionControl, ) -> Result<DatabaseCreateOutcome>

Create the configured database with cancellation and deadline control.

Source

pub async fn delete_database(&self) -> Result<DatabaseDeleteOutcome>

Delete the one configured database and return its normalized outcome.

Source

pub async fn inspect_database_pair(&self) -> Result<ManagedDatabasePairState>

Inspect the exact managed database and reserved journal pair.

Source

pub async fn inspect_database_pair_controlled( &self, control: &MigrationExecutionControl, ) -> Result<ManagedDatabasePairState>

Inspect the managed pair while honoring cancellation and a deadline.

Source

pub async fn plan_database_delete(&self) -> Result<ManagedDatabaseDeletionPlan>

Inspect and retain an explicit pair-aware destructive deletion plan.

Source

pub async fn plan_database_delete_controlled( &self, control: &MigrationExecutionControl, ) -> Result<ManagedDatabaseDeletionPlan>

Inspect and retain a deletion plan while honoring execution controls.

Source

pub fn close(&self) -> Result<()>

Explicitly close this database’s provider connection.

Closing is idempotent. Once closed, the database cannot admit new provider work, while repeated calls remain harmless.

Source

pub fn is_schema_bound(&self) -> bool

Return whether this database handle is bound to a verified schema.

Auto Trait Implementations§

§

impl<S = Unbound> !RefUnwindSafe for Database<S>

§

impl<S = Unbound> !UnwindSafe for Database<S>

§

impl<S> Freeze for Database<S>
where PhantomData<fn() -> S>: Freeze,

§

impl<S> Send for Database<S>
where PhantomData<fn() -> S>: Send,

§

impl<S> Sync for Database<S>
where PhantomData<fn() -> S>: Sync,

§

impl<S> Unpin for Database<S>
where PhantomData<fn() -> S>: Unpin,

§

impl<S> UnsafeUnpin for Database<S>
where PhantomData<fn() -> S>: UnsafeUnpin,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
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.
Source§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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