pub trait Influence<RawFrom>where
RawFrom: Elastic,{
type Influence: Delimited;
type InfluenceModel: PurePluginModel<RawFrom, <Self::InfluenceContext as ModelContext>::Context, Self::Influence> + Default;
type InfluenceContext: ModelContext;
// Provided method
fn influence(input: RawFrom) -> Self::Influence { ... }
}Expand description
A trait for computing influence, a normalized and comparable metric representing the relative power or importance of an entity.
Influence is intended to capture non-transferable system weight, derived from various inputs such as votes, stake, participation, or other domain-specific factors.
§Key Properties
- Non-transferable: Influence is a derived metric and must not be directly traded or transferred.
- Model-dependent: Different systems may define influence differently based on their weighting rules or algorithms.
- Deterministic: Given the same input and context, the computed influence should be consistent.
- Comparable: Influence values must be bounded and comparable across entities.
§Design
This trait follows a plugin-based architecture:
- The computation logic is delegated to pluggable models.
- Different influence strategies can coexist without changing the trait.
- Runtime configuration is supported via context.
§Type Parameters
-
RawFrom: The raw input type used to derive influence.This allows flexibility in supporting various input formats, such as:
- Numeric values (e.g., stake or balance)
- Account identifiers
- Structured or aggregated data
Required Associated Types§
Sourcetype InfluenceModel: PurePluginModel<RawFrom, <Self::InfluenceContext as ModelContext>::Context, Self::Influence> + Default
type InfluenceModel: PurePluginModel<RawFrom, <Self::InfluenceContext as ModelContext>::Context, Self::Influence> + Default
The plugin responsible for computing influence.
This model defines how raw input is transformed into a bounded influence value.
Different models may implement:
- Linear scaling
- Weighted aggregation
- Non-linear transformations (e.g., logarithmic influence)
Sourcetype InfluenceContext: ModelContext
type InfluenceContext: ModelContext
Provides runtime configuration for Self::InfluenceModel.
This context supplies dynamic parameters such as:
- Scaling factors
- Thresholds
- External weights or modifiers
This enables flexible and adaptive influence computation without hardcoding logic.
Provided Methods§
Sourcefn influence(input: RawFrom) -> Self::Influence
fn influence(input: RawFrom) -> Self::Influence
Computes influence from a raw input using the configured plugin.
This function:
- Delegates computation to
Self::InfluenceModel - Uses
Self::InfluenceContextfor parameterization
§Returns
A bounded influence value derived from the given input.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.