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 = ()>)
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: ConfigGroupData>(
&self,
path: Vec<CompactString>
) -> Result<Group<T>, ConfigError>
pub async fn create_group_ex<T: ConfigGroupData>(
&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 = &str>
) -> Result<Group<T>, ConfigError>where
T: ConfigGroupData,
pub async fn create_group_block<T>(
&self,
path: impl IntoIterator<Item = &str>
) -> Result<Group<T>, ConfigError>where
T: ConfigGroupData,
sourcepub async fn export(
&self,
no_merge: Option<bool>,
no_update: Option<bool>
) -> Result<Archive, Error>
pub async fn export(
&self,
no_merge: Option<bool>,
no_update: Option<bool>
) -> 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,
merge: Option<bool>
) -> Result<(), Error>
pub async fn import(
&self,
archive: Archive,
merge: Option<bool>
) -> 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": {}
}