pub struct DbRead<Kind>where
Kind: DbKindT,{ /* private fields */ }
Expand description
A read-only version of DbWrite. This environment can only generate read-only transactions, never read-write.
Implementations§
source§impl<Kind> DbRead<Kind>where
Kind: DbKindT,
impl<Kind> DbRead<Kind>where Kind: DbKindT,
sourcepub async fn read_async<E, R, F>(
&self,
f: F
) -> impl Future<Output = Result<R, E>>where
E: From<DatabaseError> + Send + 'static,
F: FnOnce(Transaction<'_>) -> Result<R, E> + Send + 'static,
R: Send + 'static,
pub async fn read_async<E, R, F>( &self, f: F ) -> impl Future<Output = Result<R, E>>where E: From<DatabaseError> + Send + 'static, F: FnOnce(Transaction<'_>) -> Result<R, E> + Send + 'static, R: Send + 'static,
Execute a read closure on the database by acquiring a connection from the pool, starting a new transaction and running the closure with that transaction.
Note that it is not enforced that your closure runs read-only operations or that it finishes quickly so it is up to the caller to use this function as intended.
sourcepub async fn get_read_txn(
&self
) -> impl Future<Output = Result<PTxnGuard, DatabaseError>>
pub async fn get_read_txn( &self ) -> impl Future<Output = Result<PTxnGuard, DatabaseError>>
Intended to be used for transactions that need to be kept open for a longer period of time than just running a
sequence of reads using read_async
. You should default to read_async
and only call this if you have a good
reason.
A valid reason for this is holding read transactions across multiple databases as part of a cascade query.
pub fn test_read<R, F>(&self, f: F) -> Rwhere F: FnOnce(Transaction<'_>) -> R + Send + 'static, R: Send + 'static,
Trait Implementations§
source§impl<Kind> ReadAccess<Kind> for DbRead<Kind>where
Kind: DbKindT,
impl<Kind> ReadAccess<Kind> for DbRead<Kind>where Kind: DbKindT,
source§fn read_async<'life0, 'async_trait, E, R, F>(
&'life0 self,
f: F
) -> Pin<Box<dyn Future<Output = Result<R, E>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
E: From<DatabaseError> + Send + 'static + 'async_trait,
F: FnOnce(Transaction<'_>) -> Result<R, E> + Send + 'static + 'async_trait,
R: Send + 'static + 'async_trait,
DbRead<Kind>: 'async_trait,
fn read_async<'life0, 'async_trait, E, R, F>( &'life0 self, f: F ) -> Pin<Box<dyn Future<Output = Result<R, E>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, E: From<DatabaseError> + Send + 'static + 'async_trait, F: FnOnce(Transaction<'_>) -> Result<R, E> + Send + 'static + 'async_trait, R: Send + 'static + 'async_trait, DbRead<Kind>: 'async_trait,
Auto Trait Implementations§
impl<Kind> !RefUnwindSafe for DbRead<Kind>
impl<Kind> Send for DbRead<Kind>
impl<Kind> Sync for DbRead<Kind>
impl<Kind> Unpin for DbRead<Kind>where Kind: Unpin,
impl<Kind> !UnwindSafe for DbRead<Kind>
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
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
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>
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> 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> ⓘ
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.