pub struct Database { /* private fields */ }Expand description
The process-wide managed database capability.
Implementations§
Source§impl Database
impl Database
Sourcepub async fn connect(config: DatabaseConfig, observer: Observer) -> Result<Self>
pub async fn connect(config: DatabaseConfig, observer: Observer) -> Result<Self>
Creates the single managed pool and verifies that it can connect.
pub async fn query_all( &self, parent: &CallContext, statement: Statement, ) -> Result<Vec<DbRow>>
pub async fn query_optional( &self, parent: &CallContext, statement: Statement, ) -> Result<Option<DbRow>>
pub async fn write( &self, parent: &CallContext, statement: Statement, ) -> Result<WriteResult>
Sourcepub async fn transaction<T, F>(
&self,
parent: &CallContext,
operation: impl Into<OperationId>,
work: F,
) -> Result<T>
pub async fn transaction<T, F>( &self, parent: &CallContext, operation: impl Into<OperationId>, work: F, ) -> Result<T>
Runs one explicit, single-level transaction.
The callback returns a boxed async block because that is the minimal Rust API that safely ties all operations to the borrowed transaction.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Database
impl !UnwindSafe for Database
impl Freeze for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl UnsafeUnpin for Database
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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