Struct holochain_sqlite::db::DbRead
source · pub struct DbRead<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: DbKindT> DbRead<Kind>
impl<Kind: DbKindT> DbRead<Kind>
sourcepub async fn read_async<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,
pub async fn read_async<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,
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) -> DatabaseResult<PTxnGuard>
pub async fn get_read_txn(&self) -> DatabaseResult<PTxnGuard>
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) -> R
Trait Implementations§
source§impl AsP2pStateReadExt for DbRead<DbKindP2pAgents>
impl AsP2pStateReadExt for DbRead<DbKindP2pAgents>
source§fn p2p_get_agent<'life0, 'life1, 'async_trait>(
&'life0 self,
agent: &'life1 KitsuneAgent
) -> Pin<Box<dyn Future<Output = DatabaseResult<Option<AgentInfoSigned>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn p2p_get_agent<'life0, 'life1, 'async_trait>(
&'life0 self,
agent: &'life1 KitsuneAgent
) -> Pin<Box<dyn Future<Output = DatabaseResult<Option<AgentInfoSigned>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§fn p2p_list_agents<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = DatabaseResult<Vec<AgentInfoSigned>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn p2p_list_agents<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = DatabaseResult<Vec<AgentInfoSigned>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§fn p2p_count_agents<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = DatabaseResult<u32>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn p2p_count_agents<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = DatabaseResult<u32>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§fn p2p_gossip_query_agents<'life0, 'async_trait>(
&'life0 self,
since_ms: u64,
until_ms: u64,
arcset: DhtArcSet
) -> Pin<Box<dyn Future<Output = DatabaseResult<Vec<AgentInfoSigned>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn p2p_gossip_query_agents<'life0, 'async_trait>(
&'life0 self,
since_ms: u64,
until_ms: u64,
arcset: DhtArcSet
) -> Pin<Box<dyn Future<Output = DatabaseResult<Vec<AgentInfoSigned>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§fn p2p_query_near_basis<'life0, 'async_trait>(
&'life0 self,
basis: u32,
limit: u32
) -> Pin<Box<dyn Future<Output = DatabaseResult<Vec<AgentInfoSigned>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn p2p_query_near_basis<'life0, 'async_trait>(
&'life0 self,
basis: u32,
limit: u32
) -> Pin<Box<dyn Future<Output = DatabaseResult<Vec<AgentInfoSigned>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§impl<Kind: DbKindT> ReadAccess<Kind> for DbRead<Kind>
impl<Kind: DbKindT> ReadAccess<Kind> for DbRead<Kind>
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>>where
E: From<DatabaseError> + Send + 'static + 'async_trait,
F: FnOnce(Transaction<'_>) -> Result<R, E> + Send + 'static + 'async_trait,
R: Send + 'static + 'async_trait,
Self: 'async_trait,
'life0: '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>>where
E: From<DatabaseError> + Send + 'static + 'async_trait,
F: FnOnce(Transaction<'_>) -> Result<R, E> + Send + 'static + 'async_trait,
R: Send + 'static + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl<Kind> Freeze for DbRead<Kind>where
Kind: Freeze,
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§
source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
source§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
source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<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>
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> LayoutRaw for T
impl<T> LayoutRaw for T
source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moresource§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).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.