Trait feattle::Feattles[][src]

pub trait Feattles<P>: FeattlesPrivate<P> {
    fn new(persistence: P) -> Self;
fn persistence(&self) -> &P;
fn keys(&self) -> &'static [&'static str];
fn definition(&self, key: &str) -> Option<FeattleDefinition>; fn last_reload(&self) -> LastReload { ... }
fn current_values(
        &self
    ) -> Option<MappedRwLockReadGuard<'_, RawRwLock, CurrentValues>> { ... }
fn reload<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<(), <P as Persist>::Error>> + Send + 'async_trait, Global>>
    where
        'life0: 'async_trait,
        Self: 'async_trait + Sync,
        P: 'static + Persist + Sync
, { ... }
fn update<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        value: Value,
        modified_by: String
    ) -> Pin<Box<dyn Future<Output = Result<(), UpdateError<<P as Persist>::Error>>> + Send + 'async_trait, Global>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait + Sync,
        P: 'static + Persist + Sync
, { ... }
fn definitions(&self) -> Vec<FeattleDefinition, Global> { ... }
fn history<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<ValueHistory, HistoryError<<P as Persist>::Error>>> + Send + 'async_trait, Global>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait + Sync,
        P: 'static + Persist + Sync
, { ... } }
Expand description

The main trait of this crate.

The struct created with feattles! will implement this trait in addition to a method for each feattle. Read more at the crate documentation.

Required methods

Create a new feattles instance, using the given persistence layer logic.

All feattles will start with their default values. You can force an initial synchronization with Feattles::update.

Return a shared reference to the persistence layer.

The list of all available keys.

Describe one specific feattle, returning None if the feattle with the given name does not exist.

Provided methods

Return details of the last time the data was synchronized by calling Feattles::reload().

Return a reference to the last synchronized data. The reference is behind a read-write lock and will block any update until it is dropped. None is returned if a successful synchronization have never happened.

Reload the current feattles’ data from the persistence layer, propagating any errors produced by it.

If any of the feattle values fail to be parsed from previously persisted values, their updates will be skipped. Other feattles that parsed successfully will still be updated. In this case, a [log::error!] will be generated for each time it occurs.

Update a single feattle, passing the new value (in JSON representation) and the user that is associated with this change. The change will be persisted directly.

While the update is happening, the new value will already be observable from other execution tasks or threads. However, if the update fails, the change will be rolled back.

Consistency

To avoid operating on stale data, before doing an update the caller should usually call Feattles::reload() to ensure data is current.

Return the definition for all the feattles.

Return the history for a single feattle. It can be potentially empty (not entries).

Implementors