pub enum Error {
SerializationError(String),
DeserializationError(String),
ValidationError(String),
CacheMiss,
BackendError(String),
RepositoryError(String),
Timeout(String),
ConfigError(String),
NotImplemented(String),
InvalidCacheEntry(String),
VersionMismatch {
expected: u32,
found: u32,
},
Other(String),
}Expand description
Error types for cache framework.
All cache operations return Result<T> where Result is defined as std::result::Result<T, Error>.
Different error variants represent different failure modes:
Variants§
SerializationError(String)
Serialization failed when converting entity to cache bytes.
This occurs when the entity’s Serde implementation fails.
Common causes:
- Entity contains non-serializable types
- Serde serialization panic/error
- Postcard codec error
DeserializationError(String)
Deserialization failed when converting cache bytes to entity.
This indicates corrupted or malformed data in cache. Common causes:
- Cache was corrupted during transport or storage
- Invalid Postcard encoding
- Incomplete data read from backend
Recovery: Cache entry should be evicted and recomputed.
ValidationError(String)
Validation failed in feeder or entity.
This is raised when:
CacheFeed::validate()returns an errorCacheEntity::validate()returns an error after deserialization
Implement these methods to add custom validation logic.
CacheMiss
Cache miss: key not found in cache.
Not necessarily an error condition, but indicates cache entry was absent.
Only returned with CacheStrategy::Fresh when cache lookup fails.
BackendError(String)
Backend storage error (Redis, Memcached, etc).
This indicates the cache backend is unavailable or returned an error. Common causes:
- Redis/Memcached connection lost
- Network timeout
- Backend storage full
- Backend protocol error
Recovery: Retry the operation or fallback to database.
RepositoryError(String)
Data repository error (database, etc).
This indicates the source repository (database) failed to fetch data. Common causes:
- Database connection lost
- Query syntax error
- Database server error
- Row/record not found
Recovery: Retry after connection recovery.
Timeout(String)
Operation exceeded configured timeout threshold.
This occurs when cache or repository operations take too long. Common causes:
- Network latency
- Slow database query
- Backend overload
Recovery: Retry with exponential backoff.
ConfigError(String)
Configuration error during crate initialization.
This occurs when creating backends or policies with invalid config. Common causes:
- Invalid connection string
- Missing required configuration
- Invalid TTL policy
Recovery: Fix configuration and restart.
NotImplemented(String)
Feature not implemented or not enabled.
This indicates a requested feature is not available. Common causes:
- Cargo feature not enabled (e.g., “redis” for RedisBackend)
- Backend-specific operation called on wrong backend type
Recovery: Enable the required Cargo feature.
InvalidCacheEntry(String)
Invalid cache entry: corrupted envelope or bad magic.
This indicates the cache entry header is invalid. Returned when:
- Magic header is not
b"CKIT" - Envelope deserialization fails
- Non-cache-kit data in cache key
Recovery: Evict the cache entry and recompute.
VersionMismatch
Schema version mismatch between code and cached data.
This indicates the cache entry was created with a different schema version. Raised when:
CURRENT_SCHEMA_VERSIONchanged- Struct fields were added/removed/reordered
- Enum variants changed
Recovery: Cache entry is automatically evicted and recomputed on next access. No action needed - this is expected during deployments.
Fields
Other(String)
Generic error with custom message.
Used for errors that don’t fit into other variants.