Struct holochain_sqlite::db::DbWrite
source · [−]pub struct DbWrite<Kind: DbKindT>(_);
Expand description
The canonical representation of a (singleton) database. The wrapper contains methods for managing transactions and database connections,
Implementations
sourceimpl<Kind: DbKindT + Send + Sync + 'static> DbWrite<Kind>
impl<Kind: DbKindT + Send + Sync + 'static> DbWrite<Kind>
sourcepub fn open(path_prefix: &Path, kind: Kind) -> DatabaseResult<Self>
pub fn open(path_prefix: &Path, kind: Kind) -> DatabaseResult<Self>
Create or open an existing database reference,
pub async fn conn_write_permit(&self) -> PConnPermit
pub fn open_with_sync_level(
path_prefix: &Path,
kind: Kind,
sync_level: DbSyncLevel
) -> DatabaseResult<Self>
sourcepub fn test(path: &Path, kind: Kind) -> DatabaseResult<Self>
pub fn test(path: &Path, kind: Kind) -> DatabaseResult<Self>
Create a unique db in a temp dir with no static management of the connection pool, useful for testing.
pub fn test_in_mem(kind: Kind) -> DatabaseResult<Self>
sourcepub async fn remove(self) -> DatabaseResult<()>
👎 Deprecated: is this used?
pub async fn remove(self) -> DatabaseResult<()>
is this used?
Remove the db and directory
pub async fn async_commit<E, R, F>(&self, f: F) -> Result<R, E> where
E: From<DatabaseError> + Send + 'static,
F: FnOnce(&mut Transaction<'_>) -> Result<R, E> + Send + 'static,
R: Send + 'static,
pub fn test_commit<R, F>(&self, f: F) -> R where
F: FnOnce(&mut Transaction<'_>) -> R,
sourcepub async fn async_commit_in_place<E, R, F>(&self, f: F) -> Result<R, E> where
E: From<DatabaseError>,
F: FnOnce(&mut Transaction<'_>) -> Result<R, E>,
R: Send,
pub async fn async_commit_in_place<E, R, F>(&self, f: F) -> Result<R, E> where
E: From<DatabaseError>,
F: FnOnce(&mut Transaction<'_>) -> Result<R, E>,
R: Send,
If possible prefer async_commit as this is slower and can starve chained futures.
Methods from Deref<Target = DbRead<Kind>>
pub fn conn(&self) -> DatabaseResult<PConn>
pub async fn conn_permit(&self) -> PConnPermit
pub async fn async_reader<E, R, F>(&self, f: F) -> Result<R, E> where
E: From<DatabaseError> + Send + 'static,
F: FnOnce(Transaction<'_>) -> Result<R, E> + Send + 'static,
R: Send + 'static,
Trait Implementations
sourceimpl<Kind: DbKindT> PermittedConn for DbWrite<Kind>
impl<Kind: DbKindT> PermittedConn for DbWrite<Kind>
fn from_permit(&self, permit: PConnPermit) -> DatabaseResult<PConnGuard>
sourceimpl<Kind: DbKindT> ReadAccess<Kind> for DbWrite<Kind>
impl<Kind: DbKindT> ReadAccess<Kind> for DbWrite<Kind>
sourcefn async_reader<'life0, 'async_trait, E, R, F>(
&'life0 self,
f: F
) -> Pin<Box<dyn Future<Output = Result<R, E>> + Send + 'async_trait>> where
E: From<DatabaseError> + Send + 'static,
F: FnOnce(Transaction<'_>) -> Result<R, E> + Send + 'static,
R: Send + 'static,
E: 'async_trait,
R: 'async_trait,
F: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn async_reader<'life0, 'async_trait, E, R, F>(
&'life0 self,
f: F
) -> Pin<Box<dyn Future<Output = Result<R, E>> + Send + 'async_trait>> where
E: From<DatabaseError> + Send + 'static,
F: FnOnce(Transaction<'_>) -> Result<R, E> + Send + 'static,
R: Send + 'static,
E: 'async_trait,
R: 'async_trait,
F: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Run an async read transaction on a background thread.
sourcefn sync_reader<E, R, F>(&self, f: F) -> Result<R, E> where
E: From<DatabaseError>,
F: FnOnce(Transaction<'_>) -> Result<R, E>,
fn sync_reader<E, R, F>(&self, f: F) -> Result<R, E> where
E: From<DatabaseError>,
F: FnOnce(Transaction<'_>) -> Result<R, E>,
Run an sync read transaction on a the current thread.
Auto Trait Implementations
impl<Kind> !RefUnwindSafe for DbWrite<Kind>
impl<Kind> Send for DbWrite<Kind>
impl<Kind> Sync for DbWrite<Kind>
impl<Kind> Unpin for DbWrite<Kind> where
Kind: Unpin,
impl<Kind> !UnwindSafe for DbWrite<Kind>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> FutureExt for T
impl<T> FutureExt for T
fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more