referrerpolicy=no-referrer-when-downgrade
polkadot_node_primitives::approval::v2

Type Alias CandidateBitfield

Source
pub type CandidateBitfield = Bitfield<CandidateIndex>;
Expand description

A read-only, non-zero bitfield. Each 1 bit identifies a candidate by the bitfield bit index.

Aliased Type§

struct CandidateBitfield(/* private fields */);

Implementations

Source§

impl<T> Bitfield<T>

Source

pub fn bit_at(&self, index: BitIndex) -> bool

Returns the bit value at specified index. If index is greater than bitfield size, returns false.

Source

pub fn len(&self) -> usize

Returns number of bits.

Source

pub fn count_ones(&self) -> usize

Returns the number of 1 bits.

Source

pub fn first_one(&self) -> Option<usize>

Returns the index of the first 1 bit.

Source

pub fn iter_ones(&self) -> IterOnes<'_, u8, Lsb0>

Returns an iterator over inner bits.

Source

pub fn into_inner(self) -> BitVec<u8, Lsb0>

Returns the inner bitfield and consumes self.

Trait Implementations

Source§

impl<T: Clone> Clone for Bitfield<T>

Source§

fn clone(&self) -> Bitfield<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Bitfield<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Decode for Bitfield<T>
where PhantomData<T>: Decode,

Source§

fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy, ) -> Result<Self, Error>

Attempt to deserialise the value from input.
§

fn decode_into<I>( input: &mut I, dst: &mut MaybeUninit<Self>, ) -> Result<DecodeFinished, Error>
where I: Input,

Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
§

fn skip<I>(input: &mut I) -> Result<(), Error>
where I: Input,

Attempt to skip the encoded value from input. Read more
§

fn encoded_fixed_size() -> Option<usize>

Returns the fixed encoded size of the type. Read more
Source§

impl<T> Encode for Bitfield<T>
where PhantomData<T>: Encode,

Source§

fn size_hint(&self) -> usize

If possible give a hint of expected size of the encoding. Read more
Source§

fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )

Convert self to a slice and append it to the destination.
§

fn encode(&self) -> Vec<u8>

Convert self to an owned vector.
§

fn using_encoded<R, F>(&self, f: F) -> R
where F: FnOnce(&[u8]) -> R,

Convert self to a slice and then invoke the given closure with it.
§

fn encoded_size(&self) -> usize

Calculates the encoded size. Read more
Source§

impl<T> From<T> for Bitfield<T>
where T: AsBitIndex,

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash> Hash for Bitfield<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: PartialEq> PartialEq for Bitfield<T>

Source§

fn eq(&self, other: &Bitfield<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> TryFrom<Vec<T>> for Bitfield<T>
where T: Into<Bitfield<T>>,

Source§

type Error = BitfieldError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Vec<T>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T> EncodeLike for Bitfield<T>
where PhantomData<T>: Encode,

Source§

impl<T: Eq> Eq for Bitfield<T>

Source§

impl<T> StructuralPartialEq for Bitfield<T>