[][src]Struct gf::support::bitvec::BitVec

pub struct BitVec { /* fields omitted */ }

A growable bit vector.

Methods

impl BitVec[src]

pub fn new() -> Self[src]

Create an empty bit vector.

pub fn with_capacity(bit_capacity: usize) -> Self[src]

Create an empty bit vector with pre-allocated capacity.

pub fn from_byte_slice(slice: &[u8], endianness: Endianness) -> Self[src]

Create a bit vector from data with given endianness.

pub fn from_byte_slice_be(slice: &[u8]) -> Self[src]

Create a bit vector from a byte slice with reversed byte order.

pub fn from_byte_slice_le(slice: &[u8]) -> Self[src]

Create a bit vector from a byte slice.

pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseBitVecError>[src]

Convert a string slice in a given base to a bit vector.

The resulting bit vector will have no leading zero bits, meaning that it can be empty if the input is zero.

Errors

  • Panics if radix is not in the range from 2 to 36.

Example

assert_eq!(BitVec::from_str_radix("C001a1D3", 16), Ok(BitVec::from(0xC001_A1D3u32)));
assert_eq!(BitVec::from_str_radix("011010001", 2), Ok(BitVec::from(0xD1u8)));
assert_eq!(BitVec::from_str_radix("0", 10), Ok(BitVec::new()));

pub fn is_empty(&self) -> bool[src]

Return whether the bit vector is empty.

pub fn len(&self) -> usize[src]

Return the bit length of the vector.

pub fn get(&self, bit_index: usize) -> bool[src]

Return bit value at bit_index.

Errors

  • Panics on out-of-bound indexing.

pub fn set(&mut self, bit_index: usize, value: bool)[src]

Set bit value at bit_index.

Errors

  • Panics on out-of-bound indexing.

pub fn is_false(&self) -> bool[src]

Return whether tht bit vector is a single zero bit.

pub fn is_true(&self) -> bool[src]

Return whether the bit vector is a single one bit.

pub fn as_bit_slice(&self) -> BitSlice[src]

Borrow the bit vector as an immutable bit slice.

pub fn as_byte_slice(&self) -> &[u8][src]

Borrow the bit vector as an immutable byte slice.

The slice may have extra zero bits at the end, padding it up to a whole byte.

pub fn resize(&mut self, new_bit_len: usize, signedness: Signedness)[src]

Truncate or extend the bit vector in place using either zero or sign extension.

pub fn resize_sx(&mut self, new_bit_len: usize)[src]

Truncate or extend the bit vector in place. New bits are filled with copies of the most significant bit.

pub fn resize_zx(&mut self, new_bit_len: usize)[src]

Truncate or extend the bit vector in place. New bits are filled with 0.

pub fn truncate_leading_zeros(&mut self) -> usize[src]

Remove leading zero bits in place, returning the number of removed bits.

If the original vector had only zero bits, the result is an empty vector.

pub fn push(&mut self, value: bool)[src]

Push a bit at the end of the vector.

pub fn push_bit_vec(&mut self, bit_vec: &Self)[src]

Push a bit vector at the end of this one.

Trait Implementations

impl BitSeq for BitVec[src]

impl BitSeqMut for BitVec[src]

impl From<bool> for BitVec[src]

impl From<i8> for BitVec[src]

impl From<i16> for BitVec[src]

impl From<i32> for BitVec[src]

impl From<i64> for BitVec[src]

impl From<u8> for BitVec[src]

impl From<u16> for BitVec[src]

impl From<u32> for BitVec[src]

impl From<u64> for BitVec[src]

impl From<u128> for BitVec[src]

impl Clone for BitVec[src]

impl Default for BitVec[src]

impl Eq for BitVec[src]

impl PartialEq<BitVec> for BitVec[src]

impl Display for BitVec[src]

impl Debug for BitVec[src]

impl<'_> TryFrom<&'_ BitVec> for bool[src]

type Error = TryFromBitVecError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ BitVec> for i8[src]

type Error = TryFromBitVecError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ BitVec> for i16[src]

type Error = TryFromBitVecError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ BitVec> for i32[src]

type Error = TryFromBitVecError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ BitVec> for i64[src]

type Error = TryFromBitVecError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ BitVec> for u8[src]

type Error = TryFromBitVecError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ BitVec> for u16[src]

type Error = TryFromBitVecError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ BitVec> for u32[src]

type Error = TryFromBitVecError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ BitVec> for u64[src]

type Error = TryFromBitVecError

The type returned in the event of a conversion error.

impl Index<usize> for BitVec[src]

type Output = bool

The returned type after indexing.

impl Hash for BitVec[src]

impl StructuralPartialEq for BitVec[src]

impl StructuralEq for BitVec[src]

impl FromIterator<bool> for BitVec[src]

impl FromIterator<u8> for BitVec[src]

impl FromIterator<u16> for BitVec[src]

impl FromIterator<u32> for BitVec[src]

impl FromIterator<u64> for BitVec[src]

impl FromIterator<u128> for BitVec[src]

impl Binary for BitVec[src]

Auto Trait Implementations

impl Send for BitVec

impl Sync for BitVec

impl Unpin for BitVec

impl UnwindSafe for BitVec

impl RefUnwindSafe for BitVec

Blanket Implementations

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

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

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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<T> Borrow<T> for T where
    T: ?Sized
[src]

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

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

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]