rspack_storage/
lib.rs

1mod error;
2mod fs;
3mod pack;
4
5use std::sync::Arc;
6
7pub use error::Result;
8pub use fs::{BridgeFileSystem, FSError, FSOperation, FSResult, FileSystem, Reader, Writer};
9pub use pack::{PackStorage, PackStorageOptions};
10use tokio::sync::oneshot::Receiver;
11
12type ItemKey = Vec<u8>;
13type ItemValue = Vec<u8>;
14type ItemPairs = Vec<(Arc<ItemKey>, Arc<ItemValue>)>;
15
16#[async_trait::async_trait]
17pub trait Storage: std::fmt::Debug + Sync + Send {
18  async fn load(&self, scope: &'static str) -> Result<Vec<(Arc<Vec<u8>>, Arc<Vec<u8>>)>>;
19  fn set(&self, scope: &'static str, key: Vec<u8>, value: Vec<u8>);
20  fn remove(&self, scope: &'static str, key: &[u8]);
21  fn trigger_save(&self) -> Result<Receiver<Result<()>>>;
22  async fn reset(&self);
23  /// Get list of all available scopes in the storage
24  async fn scopes(&self) -> Result<Vec<String>>;
25}
26
27pub type ArcStorage = Arc<dyn Storage>;