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
sourcepub async fn create_group_ex<T: Template>(
&self,
path: Vec<CompactString>
) -> Result<Group<T>, ConfigError>
pub async fn create_group_ex<T: Template>( &self, path: Vec<CompactString> ) -> Result<Group<T>, ConfigError>
Creates and register new config set.
If path is duplicated for existing config set, the program will panic.
pub async fn create_group<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.