pub struct PreparedDbQuery<T, C = PostcardCodec>where
C: CacheCodec,{ /* private fields */ }Expand description
A prepared database query descriptor.
PreparedDbQuery keeps adapter state and stable query-cache metadata close
together. It can cheaply create ordinary DbQuery values for each call,
or execute loaders directly through load_id/fetch_with_id.
Implementations§
Source§impl<T, C> PreparedDbQuery<T, C>where
C: CacheCodec,
impl<T, C> PreparedDbQuery<T, C>where
C: CacheCodec,
Sourcepub fn cache(&self) -> &HydraCache<C>
pub fn cache(&self) -> &HydraCache<C>
Return the underlying local cache.
Sourcepub fn prepared_policy(&self) -> &PreparedQueryPolicy
pub fn prepared_policy(&self) -> &PreparedQueryPolicy
Return the prepared policy backing this descriptor.
Sourcepub fn requires_id(&self) -> bool
pub fn requires_id(&self) -> bool
Return whether this descriptor needs an id binding before execution.
Sourcepub fn static_key_value(&self) -> Option<&str>
pub fn static_key_value(&self) -> Option<&str>
Return the static logical key, if this descriptor has one.
Sourcepub fn entity_key_prefix(&self) -> Option<&str>
pub fn entity_key_prefix(&self) -> Option<&str>
Return the precomputed entity key prefix, if this is an entity policy.
Return the precomputed tags.
Sourcepub fn to_query(&self) -> DbQuery<T, C>
pub fn to_query(&self) -> DbQuery<T, C>
Create a runtime query from a static prepared policy.
Entity-id policies should usually use PreparedDbQuery::for_id so the
dynamic id becomes part of the key and entity invalidation tag.
Sourcepub fn for_id(&self, id: impl ToString) -> DbQuery<T, C>
pub fn for_id(&self, id: impl ToString) -> DbQuery<T, C>
Bind an id and create a runtime query.
Sourcepub async fn load<E, F, Fut>(&self, loader: F) -> Result<T, DbCacheError>
pub async fn load<E, F, Fut>(&self, loader: F) -> Result<T, DbCacheError>
Fetch a cached value from a static prepared policy or run the loader.
Sourcepub async fn load_id<E, F, Fut>(
&self,
id: impl ToString,
loader: F,
) -> Result<T, DbCacheError>
pub async fn load_id<E, F, Fut>( &self, id: impl ToString, loader: F, ) -> Result<T, DbCacheError>
Bind an id, fetch a cached value, or run the loader.
Sourcepub async fn fetch_value_with<U, E, F, Fut>(
&self,
loader: F,
) -> Result<U, DbCacheError>
pub async fn fetch_value_with<U, E, F, Fut>( &self, loader: F, ) -> Result<U, DbCacheError>
Fetch a static prepared value with an output type chosen by an adapter.
Sourcepub async fn fetch_value_with_id<U, E, F, Fut>(
&self,
id: impl ToString,
loader: F,
) -> Result<U, DbCacheError>
pub async fn fetch_value_with_id<U, E, F, Fut>( &self, id: impl ToString, loader: F, ) -> Result<U, DbCacheError>
Bind an id and fetch a value with an output type chosen by an adapter.
Trait Implementations§
Source§impl<T, C> Clone for PreparedDbQuery<T, C>where
C: CacheCodec,
impl<T, C> Clone for PreparedDbQuery<T, C>where
C: CacheCodec,
Source§fn clone(&self) -> PreparedDbQuery<T, C>
fn clone(&self) -> PreparedDbQuery<T, C>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<T, C = PostcardCodec> !RefUnwindSafe for PreparedDbQuery<T, C>
impl<T, C = PostcardCodec> !UnwindSafe for PreparedDbQuery<T, C>
impl<T, C> Freeze for PreparedDbQuery<T, C>
impl<T, C> Send for PreparedDbQuery<T, C>
impl<T, C> Sync for PreparedDbQuery<T, C>
impl<T, C> Unpin for PreparedDbQuery<T, C>
impl<T, C> UnsafeUnpin for PreparedDbQuery<T, C>
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> 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>
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 more