Struct amplify::flags::FlagVec

source ·
pub struct FlagVec(/* private fields */);
Expand description

Bit flag vector. Can hold up to 2^16-1 flags and guaranteed to have length up to 255 bytes.

Implementations§

source§

impl FlagVec

source

pub fn new() -> FlagVec

Constructs a features vector of zero feature flag set

source

pub fn with_capacity(upto: FlagNo) -> Self

Constructs a features vector of upto feature flag in unset state

source

pub fn is_empty(&self) -> bool

Detects whether structure contains any flags set

source

pub fn count_flags(&self) -> u16

Counts number of flags set

source

pub fn as_slice(&self) -> &[u8]

Returns byte slice representation of the inner data

source

pub fn to_vec(&self) -> Vec<u8>

Returns inner byte vector containing all flags

source

pub fn into_vec(self) -> Vec<u8>

Returns inner byte vector containing all flags

source

pub fn from_inner(vec: TinyVec<u8>) -> Self

Constructs flags from the inner representation in form of TinyVec.

source

pub fn as_inner(&mut self) -> &TinyVec<u8>

Returns byte slice representation of the inner TinyVec.

Shrinks the inner data.

source

pub fn to_inner(&self) -> TinyVec<u8>

Returns byte slice representation of the inner TinyVec

source

pub fn into_inner(self) -> TinyVec<u8>

Returns byte slice representation of the inner TinyVec

source

pub fn shrunk(&self) -> Self

Returns a shrunk copy of the self

source

pub fn iter(&self) -> AllSet<'_>

Creates an iterator for the current feature flags which have “set” state

source

pub fn known_iter(&self, known: FlagVec) -> FilteredIter<'_>

Creates iterator over known set of the features

source

pub fn unknown_iter(&self, known: FlagVec) -> FilteredIter<'_>

Creates iterator over unknown set of the features, i.e. features that do not match flags set in known parameter

source

pub fn shrink(&mut self) -> bool

Reduces the size of the internal buffer to the smallest capacity required to keep all currently set feature flags. Returns true if resize operation was required, or false otherwise, when the internal buffer already was of the smallest possible size

source

pub fn is_set(&self, flag_no: FlagNo) -> bool

Returns whether a feature flag with flag_no is set (true or false)

source

pub fn set(&mut self, flag_no: FlagNo) -> bool

Sets the feature flag with number flag_no. Returns true if the flag was already set and false otherwise (i.e. previous value of the flag)

source

pub fn unset(&mut self, flag_no: FlagNo) -> bool

Unsets the feature flag with number flag_no. Returns true if the flag was set before and false otherwise (i.e. previous value of the flag)

source

pub fn invert(&mut self, flag_no: FlagNo)

Inverts the feature flag with number flag_no

Trait Implementations§

source§

impl Binary for FlagVec

source§

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

Formats the value using the given formatter.
source§

impl BitAnd for FlagVec

§

type Output = FlagVec

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
source§

impl BitOr for FlagVec

§

type Output = FlagVec

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
source§

impl BitXor for FlagVec

§

type Output = FlagVec

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
source§

impl Clone for FlagVec

source§

fn clone(&self) -> FlagVec

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 Debug for FlagVec

source§

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

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

impl Default for FlagVec

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for FlagVec

source§

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

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

impl FromStr for FlagVec

§

type Err = ParseError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for FlagVec

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 LowerHex for FlagVec

source§

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

Formats the value using the given formatter.
source§

impl Octal for FlagVec

source§

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

Formats the value using the given formatter.
source§

impl Ord for FlagVec

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for FlagVec

source§

fn eq(&self, other: &Self) -> 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 PartialOrd for FlagVec

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl TryFrom<&[u8]> for FlagVec

§

type Error = ParseError

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

fn try_from(value: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Vec<u8>> for FlagVec

§

type Error = ParseError

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

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

Performs the conversion.
source§

impl UpperHex for FlagVec

source§

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

Formats the value using the given formatter.
source§

impl Eq for FlagVec

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToHex for T
where T: LowerHex,

source§

fn to_hex(&self) -> String

Outputs the hash in hexadecimal form

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.