[][src]Trait feattle_core::Feattles

pub trait Feattles<P: Persist>: FeattlesPrivate<P> + Send + Sync + 'static {
    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) -> Option<DateTime<Utc>> { ... }
fn current_values(&self) -> Option<MappedRwLockReadGuard<'_, CurrentValues>> { ... }
#[must_use] fn reload<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<(), P::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
, { ... }
#[must_use] fn update<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        value: Value,
        modified_by: String
    ) -> Pin<Box<dyn Future<Output = Result<(), UpdateError<P::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... }
fn definitions(&self) -> Vec<FeattleDefinition> { ... }
#[must_use] fn history<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<ValueHistory, HistoryError<P::Error>>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... } }

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

fn new(persistence: P) -> Self

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.

fn persistence(&self) -> &P

Return a shared reference to the persistence layer.

fn keys(&self) -> &'static [&'static str]

The list of all available keys.

fn definition(&self, key: &str) -> Option<FeattleDefinition>

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

Loading content...

Provided methods

fn last_reload(&self) -> Option<DateTime<Utc>>

The date when the feattle values were last updated from the persistence layer, if ever.

fn current_values(&self) -> Option<MappedRwLockReadGuard<'_, CurrentValues>>

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.

#[must_use]fn reload<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), P::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 

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.

#[must_use]fn update<'life0, 'life1, 'async_trait>(
    &'life0 self,
    key: &'life1 str,
    value: Value,
    modified_by: String
) -> Pin<Box<dyn Future<Output = Result<(), UpdateError<P::Error>>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

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.

fn definitions(&self) -> Vec<FeattleDefinition>

Return the definition for all the feattles.

#[must_use]fn history<'life0, 'life1, 'async_trait>(
    &'life0 self,
    key: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<ValueHistory, HistoryError<P::Error>>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

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

Loading content...

Implementors

Loading content...