Struct sp_election_providers::Assignment [−][src]
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]
AccountId: IdentifierT,
P: PerThing128,
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]
AccountId: Clone,
P: Clone + PerThing,
pub fn clone(&self) -> Assignment<AccountId, P>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<AccountId, P> Debug for Assignment<AccountId, P> where
AccountId: Debug,
P: PerThing + Debug,
[src]
AccountId: Debug,
P: PerThing + Debug,
impl<AccountId, P> Decode for Assignment<AccountId, P> where
AccountId: Decode,
P: PerThing,
Vec<(AccountId, P), Global>: Decode,
[src]
AccountId: Decode,
P: PerThing,
Vec<(AccountId, P), Global>: Decode,
pub fn decode<__CodecInputEdqy>(
__codec_input_edqy: &mut __CodecInputEdqy
) -> Result<Assignment<AccountId, P>, Error> where
__CodecInputEdqy: Input,
[src]
__codec_input_edqy: &mut __CodecInputEdqy
) -> Result<Assignment<AccountId, P>, Error> where
__CodecInputEdqy: Input,
pub fn skip<I>(input: &mut I) -> Result<(), Error> where
I: Input,
[src]
I: Input,
pub fn encoded_fixed_size() -> Option<usize>
[src]
impl<AccountId, P> Default for Assignment<AccountId, P> where
AccountId: Default,
P: Default + PerThing,
[src]
AccountId: Default,
P: Default + PerThing,
pub fn default() -> Assignment<AccountId, P>
[src]
impl<AccountId, P> Encode for Assignment<AccountId, P> where
AccountId: Encode,
P: PerThing,
Vec<(AccountId, P), Global>: Encode,
[src]
AccountId: Encode,
P: PerThing,
Vec<(AccountId, P), Global>: Encode,
pub fn encode_to<__CodecOutputEdqy>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy
) where
__CodecOutputEdqy: Output + ?Sized,
[src]
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy
) where
__CodecOutputEdqy: Output + ?Sized,
pub fn size_hint(&self) -> usize
[src]
pub fn encode(&self) -> Vec<u8, Global>
[src]
pub fn using_encoded<R, F>(&self, f: F) -> R where
F: FnOnce(&[u8]) -> R,
[src]
F: FnOnce(&[u8]) -> R,
pub fn encoded_size(&self) -> usize
[src]
impl<AccountId, P> EncodeLike<Assignment<AccountId, P>> for Assignment<AccountId, P> where
AccountId: Encode,
P: PerThing,
Vec<(AccountId, P), Global>: Encode,
[src]
AccountId: Encode,
P: PerThing,
Vec<(AccountId, P), Global>: Encode,
impl<AccountId, P> Eq for Assignment<AccountId, P> where
AccountId: Eq,
P: Eq + PerThing,
[src]
AccountId: Eq,
P: Eq + PerThing,
impl<AccountId, P> PartialEq<Assignment<AccountId, P>> for Assignment<AccountId, P> where
AccountId: PartialEq<AccountId>,
P: PartialEq<P> + PerThing,
[src]
AccountId: PartialEq<AccountId>,
P: PartialEq<P> + PerThing,
pub fn eq(&self, other: &Assignment<AccountId, P>) -> bool
[src]
pub fn ne(&self, other: &Assignment<AccountId, P>) -> bool
[src]
impl<AccountId, P> StructuralEq for Assignment<AccountId, P> where
P: PerThing,
[src]
P: PerThing,
impl<AccountId, P> StructuralPartialEq for Assignment<AccountId, P> where
P: PerThing,
[src]
P: PerThing,
Auto Trait Implementations
impl<AccountId, P> RefUnwindSafe for Assignment<AccountId, P> where
AccountId: RefUnwindSafe,
P: RefUnwindSafe,
[src]
AccountId: RefUnwindSafe,
P: RefUnwindSafe,
impl<AccountId, P> Send for Assignment<AccountId, P> where
AccountId: Send,
P: Send,
[src]
AccountId: Send,
P: Send,
impl<AccountId, P> Sync for Assignment<AccountId, P> where
AccountId: Sync,
P: Sync,
[src]
AccountId: Sync,
P: Sync,
impl<AccountId, P> Unpin for Assignment<AccountId, P> where
AccountId: Unpin,
P: Unpin,
[src]
AccountId: Unpin,
P: Unpin,
impl<AccountId, P> UnwindSafe for Assignment<AccountId, P> where
AccountId: UnwindSafe,
P: UnwindSafe,
[src]
AccountId: UnwindSafe,
P: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<S> Codec for S where
S: Encode + Decode,
[src]
S: Encode + Decode,
impl<T> DecodeAll for T where
T: Decode,
[src]
T: Decode,
impl<T> DecodeLimit for T where
T: Decode,
[src]
T: Decode,
pub fn decode_all_with_depth_limit(limit: u32, input: &[u8]) -> Result<T, Error>
[src]
pub fn decode_with_depth_limit(limit: u32, input: &[u8]) -> Result<T, Error>
[src]
impl<T> DynClone for T where
T: Clone,
[src]
T: Clone,
pub fn __clone_box(&self, Private) -> *mut ()
[src]
impl<'_, '_, T> EncodeLike<&'_ &'_ T> for T where
T: Encode,
[src]
T: Encode,
impl<'_, T> EncodeLike<&'_ T> for T where
T: Encode,
[src]
T: Encode,
impl<'_, T> EncodeLike<&'_ mut T> for T where
T: Encode,
[src]
T: Encode,
impl<T> EncodeLike<Arc<T>> for T where
T: Encode,
[src]
T: Encode,
impl<T> EncodeLike<Box<T, Global>> for T where
T: Encode,
[src]
T: Encode,
impl<'a, T> EncodeLike<Cow<'a, T>> for T where
T: Encode + ToOwned,
[src]
T: Encode + ToOwned,
impl<T> EncodeLike<Rc<T>> for T where
T: Encode,
[src]
T: Encode,
impl<T> From<T> for T
[src]
impl<S> FullCodec for S where
S: Decode + FullEncode,
[src]
S: Decode + FullEncode,
impl<S> FullEncode for S where
S: Encode + EncodeLike<S>,
[src]
S: Encode + EncodeLike<S>,
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, Outer> IsWrappedBy<Outer> for T where
T: From<Outer>,
Outer: AsRef<T> + AsMut<T> + From<T>,
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]
T: Codec,
impl<T> MaybeDebug for T where
T: Debug,
T: Debug,
impl<T> MaybeRefUnwindSafe for T where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> SaturatedConversion for T
[src]
pub fn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
[src]
Self: UniqueSaturatedFrom<T>,
pub fn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
[src]
Self: UniqueSaturatedInto<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
T: UncheckedFrom<S>,
pub fn unchecked_into(self) -> T
impl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
[src]
T: Bounded,
S: TryInto<T>,
pub fn unique_saturated_into(self) -> T
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,