Type Alias polkadot_node_primitives::approval::v2::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.
source§

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
source§

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

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

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.
source§

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

Convert self to an owned vector.
source§

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.
source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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>>,

§

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>