noosphere_storage/
config.rs

1use crate::storage::Storage;
2use anyhow::Result;
3use async_trait::async_trait;
4use noosphere_common::ConditionalSend;
5use std::path::Path;
6
7/// Generalized configurations for [ConfigurableStorage].
8#[derive(Debug, Clone, Default)]
9pub struct StorageConfig {
10    /// If set, the size limit in bytes of a memory-based cache.
11    pub memory_cache_limit: Option<usize>,
12}
13
14/// [Storage] that can be customized via [StorageConfig].
15///
16/// Configurations are generalized across storage providers,
17/// and may have differing underlying semantics.
18#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
19#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
20pub trait ConfigurableStorage: Storage {
21    async fn open_with_config<P: AsRef<Path> + ConditionalSend>(
22        path: P,
23        config: StorageConfig,
24    ) -> Result<Self>;
25}