Trait feattle::Feattles[][src]

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

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

pub fn new(persistence: P) -> Self[src]

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.

pub fn persistence(&self) -> &P[src]

Return a shared reference to the persistence layer.

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

The list of all available keys.

pub fn definition(&self, key: &str) -> Option<FeattleDefinition>[src]

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

Loading content...

Provided methods

pub fn last_reload(&self) -> Option<DateTime<Utc>>[src]

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

pub fn current_values(
    &self
) -> Option<MappedRwLockReadGuard<'_, RawRwLock, CurrentValues>>
[src]

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]pub fn reload<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = Result<(), <P as Persist>::Error>> + 'async_trait + Send, Global>> where
    'life0: 'async_trait,
    Self: Sync + 'async_trait,
    P: Persist + Sync + 'static, 
[src]

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]pub 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>>> + 'async_trait + Send, Global>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: Sync + 'async_trait,
    P: Persist + Sync + 'static, 
[src]

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.

pub fn definitions(&self) -> Vec<FeattleDefinition, Global>[src]

Return the definition for all the feattles.

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

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

Loading content...

Implementors

Loading content...