Skip to main content

build_backend

Function build_backend 

Source
pub fn build_backend(
    config: &BackendConfig,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn StorageBackend>, StoreError>> + Send + '_>>
Expand description

Config-select factory: build the concrete StorageBackend a BackendConfig names.

This is typed dispatch, not stringly — a new backend kind is a non-exhaustive-match compile error, and the Tiered arm recurses, composing each sub-backend into a TieredBackend. The result is an Arc<dyn StorageBackend> ready for injection into any consumer.

The Redis and Pg arms require their production transports; without the corresponding Cargo feature (redis-client / postgres) they return a typed StoreError::NotImplemented rather than silently falling back to disk.

Returns a boxed future because the Tiered arm is recursive.

§Errors

Propagates any backend construction failure, or StoreError::NotImplemented when a config selects a backend whose feature is not compiled in.