pub struct Storage { /* private fields */ }Expand description
Storage manages multiple sets registered by preset key.
Implementations§
source§impl Storage
impl Storage
sourcepub fn new() -> (Self, impl Future<Output = ()>)
👎Deprecated: Use global function ‘create’ instead
pub fn new() -> (Self, impl Future<Output = ()>)
Creates new storage and its driver.
The second tuple parameter is asynchronous loop which handles all storage events, which must be spawned or blocked by runtime to make storage work. All storage
pub fn close(&self) -> Result<(), Error>
sourcepub async fn find_or_create<T>(
&self,
path: impl IntoIterator<Item = impl ToCompactString>
) -> Result<Group<T>, ConfigError>where
T: Template,
pub async fn find_or_create<T>( &self, path: impl IntoIterator<Item = impl ToCompactString> ) -> Result<Group<T>, ConfigError>where T: Template,
Tries to find existing group from path name, and if it doesn’t exist, tries to create new
sourcepub async fn find<'a, T: Template>(
&self,
path: impl IntoIterator<Item = &'a impl AsRef<str> + ?Sized + 'a>
) -> Result<Group<T>, GroupFindError>
pub async fn find<'a, T: Template>( &self, path: impl IntoIterator<Item = &'a impl AsRef<str> + ?Sized + 'a> ) -> Result<Group<T>, GroupFindError>
A shortcut for find_group_ex
pub async fn create<T>( &self, path: impl IntoIterator<Item = impl ToCompactString> ) -> Result<Group<T>, ConfigError>where T: Template,
sourcepub async fn export(&self, option: ExportOptions) -> Result<Archive, Error>
pub async fn export(&self, option: ExportOptions) -> Result<Archive, Error>
Dump all configs from storage.
Arguments
no_merge- If true, only active archive contents will be collected. Otherwise, result will contain merge result of previously loaded archive.no_update- If true, existing archive won’t
sourcepub async fn import(
&self,
archive: Archive,
option: ImportOptions
) -> Result<(), Error>
pub async fn import( &self, archive: Archive, option: ImportOptions ) -> Result<(), Error>
Deserializes data
Arguments
de- Deserializermerge- True if loaded archive should merge onto existing one. Otherwise, it’ll replace currently loaded archive data.
Data serialization rule:
- The first path component is root component, which is written as-is.
- Any path component after the first must be prefixed with
~(tilde)character.- Otherwise, they are treated as field element of enclosing path component.
- Any ‘~’ prefixed key inside of existing field
{
"root_path": {
"~path_component": {
"field_name": "value",
"other_field": {
"~this_is_not_treated_as_path"
}
},
"~another_path_component": {},
"field_name_of_root_path": "yay"
},
"another_root_path": {}
}
sourcepub async fn monitor_open_replication_channel(
&self
) -> Result<ReplicationChannel, Error>
pub async fn monitor_open_replication_channel( &self ) -> Result<ReplicationChannel, Error>
Create replication channel
sourcepub async fn monitor_send_event(&self, evt: MonitorEvent) -> Result<(), Error>
pub async fn monitor_send_event(&self, evt: MonitorEvent) -> Result<(), Error>
Send monitor event to storage driver.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Storage
impl Send for Storage
impl Sync for Storage
impl Unpin for Storage
impl UnwindSafe for Storage
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