Struct config_it::storage::Storage

source ·
pub struct Storage { /* private fields */ }
Expand description

Storage manages multiple sets registered by preset key.

Implementations§

source§

impl Storage

source

pub fn new() -> (Self, impl Future<Output = ()>)

👎Deprecated: Use global function ‘create’ instead

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

source

pub fn close(&self) -> Result<(), Error>

source

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

source

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

source

pub async fn create<T>( &self, path: impl IntoIterator<Item = impl ToCompactString> ) -> Result<Group<T>, ConfigError>where T: Template,

source

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
source

pub async fn import( &self, archive: Archive, option: ImportOptions ) -> Result<(), Error>

Deserializes data

Arguments
  • de - Deserializer
  • merge - 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": {}
}
source

pub async fn fence(&self)

Wait synchronization after calling ‘import’

source

pub async fn monitor_open_replication_channel( &self ) -> Result<ReplicationChannel, Error>

Create replication channel

source

pub async fn monitor_send_event(&self, evt: MonitorEvent) -> Result<(), Error>

Send monitor event to storage driver.

Trait Implementations§

source§

impl Clone for Storage

source§

fn clone(&self) -> Storage

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for Twhere T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.