Trait AppView

Source
pub trait AppView: Send + Sync {
    // Required methods
    fn name(&self) -> String;
    fn init_chain<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        dbtx: &'life1 mut PgTransaction<'_>,
        app_state: &'life2 Value,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn index_batch<'life0, 'life1, 'async_trait>(
        &'life0 self,
        dbtx: &'life1 mut PgTransaction<'_>,
        batch: EventBatch,
        context: EventBatchContext,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn version(&self) -> Version { ... }
    fn reset<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _dbtx: &'life1 mut PgTransaction<'_>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn on_startup<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _dbtx: &'life1 mut PgTransaction<'_>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Represents a specific index of raw event data.

Required Methods§

Source

fn name(&self) -> String

Return the name of this index.

This should be unique across all of the indices.

Source

fn init_chain<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, dbtx: &'life1 mut PgTransaction<'_>, app_state: &'life2 Value, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

This will be called once when processing the genesis before the first block.

Source

fn index_batch<'life0, 'life1, 'async_trait>( &'life0 self, dbtx: &'life1 mut PgTransaction<'_>, batch: EventBatch, context: EventBatchContext, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

This allows processing a batch of events, over many blocks.

Provided Methods§

Source

fn version(&self) -> Version

Return the version of this index.

As code evolves, versions should increase, only. If one version is greater than another, that indicates that the view needs to be reindexed.

Source

fn reset<'life0, 'life1, 'async_trait>( &'life0 self, _dbtx: &'life1 mut PgTransaction<'_>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reset this app view to an empty state.

This should delete all tables, across all versions, resetting the app view to a blank state.

Source

fn on_startup<'life0, 'life1, 'async_trait>( &'life0 self, _dbtx: &'life1 mut PgTransaction<'_>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§