Trait InspectWeight

Source
pub trait InspectWeight<Candidate, Weight>
where Candidate: Keyed, Weight: RuntimeType,
{ // Required method fn weight_of(who: &Candidate) -> Result<Weight, DispatchError>; }
Expand description

Trait for inspecting the weight of a candidate for an upcoming election.

  • Different election models may compute or store weights differently.
  • Providing a trait allows generic election managers or plugins to query a candidate’s weight without knowing the underlying structure.

§Type Parameters

  • Candidate: The type representing a candidate.
  • Weight: The type representing the candidate’s vote weight.

Required Methods§

Source

fn weight_of(who: &Candidate) -> Result<Weight, DispatchError>

Return the weight of a candidate if available.

Returns an error if the candidate has no associated weight.

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.

Implementors§