pub enum StatementCacheKey<DB: Backend> {
Type(TypeId),
Sql {
sql: String,
bind_types: Vec<DB::TypeMetadata>,
},
}
i-implement-a-third-party-backend-and-opt-into-breaking-changes
only.Expand description
The lookup key used by StatementCache
internally
This can contain either a at compile time known type id (representing a statically known query) or a at runtime calculated query string + parameter types (for queries that may change depending on their parameters)
Variants§
Type(TypeId)
Represents a at compile time known query
Calculated via QueryId::QueryId
Sql
Represents a dynamically constructed query
This variant is used if QueryId::HAS_STATIC_QUERY_ID
is false
and AstPass::unsafe_to_cache_prepared
is not
called for a given query.
Fields
bind_types: Vec<DB::TypeMetadata>
contains the types of any bind parameter passed to the query
Implementations§
Source§impl<DB> StatementCacheKey<DB>
impl<DB> StatementCacheKey<DB>
Sourcepub fn for_source(
maybe_type_id: Option<TypeId>,
source: &dyn QueryFragmentForCachedStatement<DB>,
bind_types: &[DB::TypeMetadata],
backend: &DB,
) -> QueryResult<Self>
pub fn for_source( maybe_type_id: Option<TypeId>, source: &dyn QueryFragmentForCachedStatement<DB>, bind_types: &[DB::TypeMetadata], backend: &DB, ) -> QueryResult<Self>
Create a new statement cache key for the given query source
Sourcepub fn sql(
&self,
source: &dyn QueryFragmentForCachedStatement<DB>,
backend: &DB,
) -> QueryResult<Cow<'_, str>>
pub fn sql( &self, source: &dyn QueryFragmentForCachedStatement<DB>, backend: &DB, ) -> QueryResult<Cow<'_, str>>
Get the sql for a given query source based
This is an optimization that may skip constructing the query string twice if it’s already part of the current cache key
Trait Implementations§
Source§impl<DB: Hash + Backend> Hash for StatementCacheKey<DB>where
DB::TypeMetadata: Hash,
impl<DB: Hash + Backend> Hash for StatementCacheKey<DB>where
DB::TypeMetadata: Hash,
Source§impl<DB: PartialEq + Backend> PartialEq for StatementCacheKey<DB>where
DB::TypeMetadata: PartialEq,
impl<DB: PartialEq + Backend> PartialEq for StatementCacheKey<DB>where
DB::TypeMetadata: PartialEq,
impl<DB: Eq + Backend> Eq for StatementCacheKey<DB>where
DB::TypeMetadata: Eq,
impl<DB: Backend> StructuralPartialEq for StatementCacheKey<DB>
Auto Trait Implementations§
impl<DB> Freeze for StatementCacheKey<DB>
impl<DB> RefUnwindSafe for StatementCacheKey<DB>
impl<DB> Send for StatementCacheKey<DB>
impl<DB> Sync for StatementCacheKey<DB>
impl<DB> Unpin for StatementCacheKey<DB>
impl<DB> UnwindSafe for StatementCacheKey<DB>
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.