pub struct StorageInstance;Expand description
Module-level constructor surface for the supported backends.
Originally a 3-variant enum (Memory | Redis | Postgres) with a
350-line hand-written match-based dispatch implementing every
Storage trait method. With the trait split into sub-traits and a
blanket impl<T> Storage for T where T: ..., the enum + dispatch
became pure boilerplate. Replaced with a unit struct whose
associated functions return Arc<dyn Storage> directly — every
backend type already satisfies Storage via the blanket impl, so
no per-backend dispatch is needed.
Existing call sites (StorageInstance::memory(),
StorageInstance::redis(cfg).await, etc.) keep their syntax; what
changes is that those constructors now return Arc<dyn Storage>
rather than an enum value the caller has to wrap in Arc::new.
Implementations§
Source§impl StorageInstance
impl StorageInstance
Sourcepub async fn from_config(
config: StorageConfig,
) -> Result<Arc<dyn Storage>, StorageError>
pub async fn from_config( config: StorageConfig, ) -> Result<Arc<dyn Storage>, StorageError>
Create a storage instance from configuration.
§Examples
use qml_rs::storage::{StorageInstance, StorageConfig, MemoryConfig};
let config = StorageConfig::Memory(MemoryConfig::default());
let storage = StorageInstance::from_config(config).await.unwrap();Sourcepub fn memory() -> Arc<dyn Storage> ⓘ
pub fn memory() -> Arc<dyn Storage> ⓘ
Create a memory storage instance with default configuration.
§Examples
use qml_rs::storage::StorageInstance;
let storage = StorageInstance::memory();Sourcepub fn memory_with_config(config: MemoryConfig) -> Arc<dyn Storage> ⓘ
pub fn memory_with_config(config: MemoryConfig) -> Arc<dyn Storage> ⓘ
Create a memory storage instance with custom configuration.