Struct sp_election_providers::Assignment[][src]

pub struct Assignment<AccountId, P> where
    P: PerThing
{ pub who: AccountId, pub distribution: Vec<(AccountId, P), Global>, }

A voter's stake assignment among a set of targets, represented as ratios.

Fields

who: AccountId

Voter's identifier.

distribution: Vec<(AccountId, P), Global>

The distribution of the voter's stake.

Implementations

impl<AccountId, P> Assignment<AccountId, P> where
    AccountId: IdentifierT,
    P: PerThing128
[src]

pub fn into_staked(self, stake: u128) -> StakedAssignment<AccountId>[src]

Convert from a ratio assignment into one with absolute values aka. StakedAssignment.

It needs stake which is the total budget of the voter.

Note that this might create un-normalized assignments, due to accuracy loss of P. Call site might compensate by calling try_normalize() on the returned StakedAssignment as a post-precessing.

If an edge ratio is Bounded::min_value(), it is dropped. This edge can never mean anything useful.

pub fn try_normalize(&mut self) -> Result<(), &'static str>[src]

Try and normalize this assignment.

If Ok(()) is returned, then the assignment MUST have been successfully normalized to 100%.

Errors

This will return only if the internal normalize fails. This can happen if sum of self.distribution.map(|p| p.deconstruct()) fails to fit inside UpperOf<P>. A user of this crate may statically assert that this can never happen and safely expect this to return Ok.

Trait Implementations

impl<AccountId, P> Clone for Assignment<AccountId, P> where
    AccountId: Clone,
    P: Clone + PerThing
[src]

impl<AccountId, P> Debug for Assignment<AccountId, P> where
    AccountId: Debug,
    P: PerThing + Debug
[src]

impl<AccountId, P> Decode for Assignment<AccountId, P> where
    AccountId: Decode,
    P: PerThing,
    Vec<(AccountId, P), Global>: Decode
[src]

impl<AccountId, P> Default for Assignment<AccountId, P> where
    AccountId: Default,
    P: Default + PerThing
[src]

impl<AccountId, P> Encode for Assignment<AccountId, P> where
    AccountId: Encode,
    P: PerThing,
    Vec<(AccountId, P), Global>: Encode
[src]

impl<AccountId, P> EncodeLike<Assignment<AccountId, P>> for Assignment<AccountId, P> where
    AccountId: Encode,
    P: PerThing,
    Vec<(AccountId, P), Global>: Encode
[src]

impl<AccountId, P> Eq for Assignment<AccountId, P> where
    AccountId: Eq,
    P: Eq + PerThing
[src]

impl<AccountId, P> PartialEq<Assignment<AccountId, P>> for Assignment<AccountId, P> where
    AccountId: PartialEq<AccountId>,
    P: PartialEq<P> + PerThing
[src]

impl<AccountId, P> StructuralEq for Assignment<AccountId, P> where
    P: PerThing
[src]

impl<AccountId, P> StructuralPartialEq for Assignment<AccountId, P> where
    P: PerThing
[src]

Auto Trait Implementations

impl<AccountId, P> RefUnwindSafe for Assignment<AccountId, P> where
    AccountId: RefUnwindSafe,
    P: RefUnwindSafe
[src]

impl<AccountId, P> Send for Assignment<AccountId, P> where
    AccountId: Send,
    P: Send
[src]

impl<AccountId, P> Sync for Assignment<AccountId, P> where
    AccountId: Sync,
    P: Sync
[src]

impl<AccountId, P> Unpin for Assignment<AccountId, P> where
    AccountId: Unpin,
    P: Unpin
[src]

impl<AccountId, P> UnwindSafe for Assignment<AccountId, P> where
    AccountId: UnwindSafe,
    P: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<S> Codec for S where
    S: Encode + Decode
[src]

impl<T> DecodeAll for T where
    T: Decode
[src]

impl<T> DecodeLimit for T where
    T: Decode
[src]

impl<T> DynClone for T where
    T: Clone
[src]

impl<'_, '_, T> EncodeLike<&'_ &'_ T> for T where
    T: Encode
[src]

impl<'_, T> EncodeLike<&'_ T> for T where
    T: Encode
[src]

impl<'_, T> EncodeLike<&'_ mut T> for T where
    T: Encode
[src]

impl<T> EncodeLike<Arc<T>> for T where
    T: Encode
[src]

impl<T> EncodeLike<Box<T, Global>> for T where
    T: Encode
[src]

impl<'a, T> EncodeLike<Cow<'a, T>> for T where
    T: Encode + ToOwned
[src]

impl<T> EncodeLike<Rc<T>> for T where
    T: Encode
[src]

impl<T> From<T> for T[src]

impl<S> FullCodec for S where
    S: Decode + FullEncode
[src]

impl<S> FullEncode for S where
    S: Encode + EncodeLike<S>, 
[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, Outer> IsWrappedBy<Outer> for T where
    T: From<Outer>,
    Outer: AsRef<T> + AsMut<T> + From<T>, 

pub fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

pub fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

impl<T> KeyedVec for T where
    T: Codec
[src]

impl<T> MaybeDebug for T where
    T: Debug

impl<T> MaybeRefUnwindSafe for T where
    T: RefUnwindSafe

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> SaturatedConversion for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<S, T> UncheckedInto<T> for S where
    T: UncheckedFrom<S>, 

impl<T, S> UniqueSaturatedInto<T> for S where
    T: Bounded,
    S: TryInto<T>, 
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,