Trait RedisRepository

Source
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 { ... }
}
Expand description

Base trait for Redis repositories providing common functionality

Provided Methods§

Source

fn serialize_entity<T, F>( &self, entity: &T, id_extractor: F, entity_type: &str, ) -> Result<String, RepositoryError>
where T: Serialize, F: Fn(&T) -> &str,

Source

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

Source

fn map_redis_error(&self, error: RedisError, context: &str) -> RepositoryError

Convert Redis errors to appropriate RepositoryError types

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.

Implementors§