Trait bitflags::BitFlags

source ·
pub trait BitFlags: ImplementedByBitFlagsMacro {
    type Bits: Bits;
    type Iter: Iterator<Item = Self>;
    type IterNames: Iterator<Item = (&'static str, Self)>;

Show 17 methods // Required methods fn empty() -> Self; fn all() -> Self; fn bits(&self) -> Self::Bits; fn from_bits(bits: Self::Bits) -> Option<Self> where Self: Sized; fn from_bits_truncate(bits: Self::Bits) -> Self; fn from_bits_retain(bits: Self::Bits) -> Self; fn from_name(name: &str) -> Option<Self> where Self: Sized; fn iter(&self) -> Self::Iter; fn iter_names(&self) -> Self::IterNames; fn is_empty(&self) -> bool; fn is_all(&self) -> bool; fn intersects(&self, other: Self) -> bool; fn contains(&self, other: Self) -> bool; fn insert(&mut self, other: Self); fn remove(&mut self, other: Self); fn toggle(&mut self, other: Self); fn set(&mut self, other: Self, value: bool);
}
Expand description

A trait that is automatically implemented for all bitflags.

It should not be implemented manually.

Required Associated Types§

source

type Bits: Bits

The underlying integer type.

source

type Iter: Iterator<Item = Self>

An iterator over enabled flags in an instance of the type.

source

type IterNames: Iterator<Item = (&'static str, Self)>

An iterator over the raw names and bits for enabled flags in an instance of the type.

Required Methods§

source

fn empty() -> Self

Returns an empty set of flags.

source

fn all() -> Self

Returns the set containing all flags.

source

fn bits(&self) -> Self::Bits

Returns the raw value of the flags currently stored.

source

fn from_bits(bits: Self::Bits) -> Option<Self>where Self: Sized,

Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.

source

fn from_bits_truncate(bits: Self::Bits) -> Self

Convert from underlying bit representation, dropping any bits that do not correspond to flags.

source

fn from_bits_retain(bits: Self::Bits) -> Self

Convert from underlying bit representation, preserving all bits (even those not corresponding to a defined flag).

source

fn from_name(name: &str) -> Option<Self>where Self: Sized,

Get the flag for a particular name.

source

fn iter(&self) -> Self::Iter

Iterate over enabled flag values.

source

fn iter_names(&self) -> Self::IterNames

Iterate over the raw names and bits for enabled flag values.

source

fn is_empty(&self) -> bool

Returns true if no flags are currently stored.

source

fn is_all(&self) -> bool

Returns true if all flags are currently set.

source

fn intersects(&self, other: Self) -> bool

Returns true if there are flags common to both self and other.

source

fn contains(&self, other: Self) -> bool

Returns true if all of the flags in other are contained within self.

source

fn insert(&mut self, other: Self)

Inserts the specified flags in-place.

source

fn remove(&mut self, other: Self)

Removes the specified flags in-place.

source

fn toggle(&mut self, other: Self)

Toggles the specified flags in-place.

source

fn set(&mut self, other: Self, value: bool)

Inserts or removes the specified flags depending on the passed value.

Implementors§