pub trait RedisRepository {
// Provided methods
fn serialize_entity<T, F>(
&self,
entity: &T,
id_extractor: F,
entity_type: &str,
) -> Result<String, RepositoryError>
where T: Serialize,
F: Fn(&T) -> &str { ... }
fn deserialize_entity<T>(
&self,
json: &str,
entity_id: &str,
entity_type: &str,
) -> Result<T, RepositoryError>
where T: for<'de> Deserialize<'de> { ... }
fn map_redis_error(
&self,
error: RedisError,
context: &str,
) -> RepositoryError { ... }
fn map_pool_error(&self, error: PoolError, context: &str) -> RepositoryError { ... }
async fn get_connection(
&self,
pool: &Arc<Pool>,
context: &str,
) -> Result<Connection, RepositoryError> { ... }
}Expand description
Base trait for Redis repositories providing common functionality
Provided Methods§
fn serialize_entity<T, F>( &self, entity: &T, id_extractor: F, entity_type: &str, ) -> Result<String, RepositoryError>
Sourcefn deserialize_entity<T>(
&self,
json: &str,
entity_id: &str,
entity_type: &str,
) -> Result<T, RepositoryError>where
T: for<'de> Deserialize<'de>,
fn deserialize_entity<T>(
&self,
json: &str,
entity_id: &str,
entity_type: &str,
) -> Result<T, RepositoryError>where
T: for<'de> Deserialize<'de>,
Deserialize entity with detailed error context Default implementation that works for any Deserialize type
Sourcefn map_redis_error(&self, error: RedisError, context: &str) -> RepositoryError
fn map_redis_error(&self, error: RedisError, context: &str) -> RepositoryError
Convert Redis errors to appropriate RepositoryError types
Sourcefn map_pool_error(&self, error: PoolError, context: &str) -> RepositoryError
fn map_pool_error(&self, error: PoolError, context: &str) -> RepositoryError
Convert deadpool Pool errors to appropriate RepositoryError types
Sourceasync fn get_connection(
&self,
pool: &Arc<Pool>,
context: &str,
) -> Result<Connection, RepositoryError>
async fn get_connection( &self, pool: &Arc<Pool>, context: &str, ) -> Result<Connection, RepositoryError>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.