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>
impl<S: Schema> Database<S>
Sourcepub fn query(&self) -> Result<QuerySession<'_, S>>
pub fn query(&self) -> Result<QuerySession<'_, S>>
Start one owner-branded query authoring session over this schema-bound database.
Sourcepub fn query_with_resources(
&self,
resources: QueryExecutionResourceLimits,
cancellation: AnswerCancellation,
) -> Result<QuerySession<'_, S>>
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>
impl Database<Unbound>
Sourcepub async fn connect(
options: impl Into<ConnectionOptions>,
) -> Result<Database<Unbound>>
pub async fn connect( options: impl Into<ConnectionOptions>, ) -> Result<Database<Unbound>>
Connect to a TypeDB server returning an unbound database handle.
Sourcepub fn with_schema<S: Schema>(
self,
schema: SchemaPackage<S>,
) -> Result<Database<S>>
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>
impl<S: Schema> Database<S>
Sourcepub fn entities<M>(&self) -> EntityManager<'_, S, M>where
M: EntityModel<Schema = S>,
pub fn entities<M>(&self) -> EntityManager<'_, S, M>where
M: EntityModel<Schema = S>,
Create a lightweight client-owned exact entity manager.
Sourcepub fn relations<M>(&self) -> RelationManager<'_, S, M>where
M: RelationModel<Schema = S>,
pub fn relations<M>(&self) -> RelationManager<'_, S, M>where
M: RelationModel<Schema = S>,
Create a lightweight client-owned exact relation manager.
Sourcepub async fn write(&self) -> Result<WriteTransaction<'_, S>>
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.
Sourcepub async fn read(&self) -> Result<ReadTransaction<'_, S>>
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.
Sourcepub fn database_name(&self) -> &str
pub fn database_name(&self) -> &str
Return the target database name.
Sourcepub async fn database_exists(&self) -> Result<bool>
pub async fn database_exists(&self) -> Result<bool>
Return whether the one configured database exists.
Sourcepub async fn database_exists_controlled(
&self,
control: &MigrationExecutionControl,
) -> Result<bool>
pub async fn database_exists_controlled( &self, control: &MigrationExecutionControl, ) -> Result<bool>
Return whether the managed database exists, honoring execution controls.
Sourcepub async fn create_database(&self) -> Result<DatabaseCreateOutcome>
pub async fn create_database(&self) -> Result<DatabaseCreateOutcome>
Create the one configured database and return its normalized outcome.
Sourcepub async fn create_database_controlled(
&self,
control: &MigrationExecutionControl,
) -> Result<DatabaseCreateOutcome>
pub async fn create_database_controlled( &self, control: &MigrationExecutionControl, ) -> Result<DatabaseCreateOutcome>
Create the configured database with cancellation and deadline control.
Sourcepub async fn delete_database(&self) -> Result<DatabaseDeleteOutcome>
pub async fn delete_database(&self) -> Result<DatabaseDeleteOutcome>
Delete the one configured database and return its normalized outcome.
Sourcepub async fn inspect_database_pair(&self) -> Result<ManagedDatabasePairState>
pub async fn inspect_database_pair(&self) -> Result<ManagedDatabasePairState>
Inspect the exact managed database and reserved journal pair.
Sourcepub async fn inspect_database_pair_controlled(
&self,
control: &MigrationExecutionControl,
) -> Result<ManagedDatabasePairState>
pub async fn inspect_database_pair_controlled( &self, control: &MigrationExecutionControl, ) -> Result<ManagedDatabasePairState>
Inspect the managed pair while honoring cancellation and a deadline.
Sourcepub async fn plan_database_delete(&self) -> Result<ManagedDatabaseDeletionPlan>
pub async fn plan_database_delete(&self) -> Result<ManagedDatabaseDeletionPlan>
Inspect and retain an explicit pair-aware destructive deletion plan.
Sourcepub async fn plan_database_delete_controlled(
&self,
control: &MigrationExecutionControl,
) -> Result<ManagedDatabaseDeletionPlan>
pub async fn plan_database_delete_controlled( &self, control: &MigrationExecutionControl, ) -> Result<ManagedDatabaseDeletionPlan>
Inspect and retain a deletion plan while honoring execution controls.
Sourcepub fn close(&self) -> Result<()>
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.
Sourcepub fn is_schema_bound(&self) -> bool
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>
impl<S> Send for Database<S>
impl<S> Sync for Database<S>
impl<S> Unpin for Database<S>
impl<S> UnsafeUnpin for Database<S>
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
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