pub struct MultiStore {
pub primary: Store,
/* private fields */
}Expand description
Struct representing a MultiStore that manages multiple stores, including
a primary store and mirrors.
Fields§
§primary: StoreImplementations§
Source§impl MultiStore
impl MultiStore
Sourcepub fn new(store: Store) -> Self
pub fn new(store: Store) -> Self
Creates a new MultiStore with the provided primary store.
§Example
use std::{collections::HashMap, path::PathBuf};
use active_storage::{drivers, multi_store::MultiStore, StoreConfig};
#[tokio::main]
async fn main() {
let config = drivers::disk::Config {
location: PathBuf::from("tmp").join("primary-storage"),
};
let disk_driver = StoreConfig::Disk(config).build().await.unwrap();
let inmem_driver = StoreConfig::InMem().build().await.unwrap();
let mut multi_store = MultiStore::new(disk_driver);
multi_store.add_stores(HashMap::from([("secondary", inmem_driver)]));
} Sourcepub fn add_stores(&mut self, stores: HashMap<&str, Store>) -> &mut Self
pub fn add_stores(&mut self, stores: HashMap<&str, Store>) -> &mut Self
Adds a Stores to the MultiStore.
Sourcepub fn set_mirrors_policy(&mut self, policy: Policy) -> &mut Self
pub fn set_mirrors_policy(&mut self, policy: Policy) -> &mut Self
Sets the mirroring policy for the MultiStore.
Sourcepub fn add_mirrors(
&mut self,
name: &str,
stores_names: &[&str],
) -> Result<&mut Self, String>
pub fn add_mirrors( &mut self, name: &str, stores_names: &[&str], ) -> Result<&mut Self, String>
Adds mirrors to the MultiStore with the specified name and store
names.
§Errors
Returns an error if any of the specified stores are not defined in the
MultiStore.
Sourcepub fn mirror_stores_from_primary(&self) -> Mirror<'_>
pub fn mirror_stores_from_primary(&self) -> Mirror<'_>
Creates a Mirror struct for mirroring operations from the primary store.
Trait Implementations§
Source§impl Clone for MultiStore
impl Clone for MultiStore
Source§fn clone(&self) -> MultiStore
fn clone(&self) -> MultiStore
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MultiStore
impl !RefUnwindSafe for MultiStore
impl Send for MultiStore
impl Sync for MultiStore
impl Unpin for MultiStore
impl !UnwindSafe for MultiStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more