pub trait Loader<K, V>: Send + Sync {
// Required method
fn load(
&self,
key: &K,
) -> impl Future<Output = CacheResult<Option<V>>> + Send;
}Expand description
Single-key data loader abstraction.
Design notes:
- This trait is intentionally async because loader implementations are usually IO-bound (DB/HTTP/RPC).
- Methods return
impl Future + Sendto make the async contract explicit without lint suppression. - Returning
Option<V>allows negative caching semantics:Ok(None)means “query succeeded but row not found”.
Required Methods§
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.