Skip to main content

StateSet

Struct StateSet 

Source
pub struct StateSet(BitFlags<State>);
Expand description

The bitflag representation of all states an object may have.

Tuple Fields§

§0: BitFlags<State>

Implementations§

Source§

impl StateSet

Source

pub fn new<B: Into<BitFlags<State>>>(value: B) -> Self

Create a new StateSet.

§Example
let states = State::Focusable | State::Sensitive | State::Active;
let set = StateSet::new(states);

assert!(set.contains(State::Active));
assert!(!set.contains(State::Busy));
Source

pub fn from_bits(bits: u64) -> Result<StateSet, FromBitsError<State>>

Returns the StateSet that corresponds to the provided u64s bit pattern.

§Errors

When the argument encodes an undefined State.

Source

pub fn empty() -> StateSet

Create an empty StateSet

Source

pub fn bits(&self) -> u64

Returns the state as represented by a u64.

Source

pub fn contains<B: Into<BitFlags<State>>>(self, other: B) -> bool

Whether the StateSet contains a State.

Source

pub fn remove<B: Into<BitFlags<State>>>(&mut self, other: B)

Removes a State (optionally) previously contained in the StateSet.

Source

pub fn insert<B: Into<BitFlags<State>>>(&mut self, other: B)

Inserts a State in the StateSet.

Source

pub fn iter(self) -> Iter<State> ⓘ

Returns an iterator that yields each set State.

Source

pub fn is_empty(self) -> bool

Checks if all states are unset.

Source

pub fn intersects<B: Into<BitFlags<State>>>(self, other: B) -> bool

Returns true if at least one flag is shared.

Source

pub fn toggle<B: Into<BitFlags<State>>>(&mut self, other: B)

Toggles the matching bits.

Trait Implementations§

Source§

impl BitAnd for StateSet

Source§

type Output = StateSet

The resulting type after applying the & operator.
Source§

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

Performs the & operation. Read more
Source§

impl BitAndAssign for StateSet

Source§

fn bitand_assign(&mut self, other: Self)

Performs the &= operation. Read more
Source§

impl BitOr for StateSet

Source§

type Output = StateSet

The resulting type after applying the | operator.
Source§

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

Performs the | operation. Read more
Source§

impl BitOrAssign for StateSet

Source§

fn bitor_assign(&mut self, other: Self)

Performs the |= operation. Read more
Source§

impl BitXor for StateSet

Source§

type Output = StateSet

The resulting type after applying the ^ operator.
Source§

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

Performs the ^ operation. Read more
Source§

impl BitXorAssign for StateSet

Source§

fn bitxor_assign(&mut self, other: Self)

Performs the ^= operation. Read more
Source§

impl Clone for StateSet

Source§

fn clone(&self) -> StateSet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for StateSet

Source§

impl Debug for StateSet

Source§

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

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

impl Default for StateSet

Source§

fn default() -> StateSet

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

impl<'de> Deserialize<'de> for StateSet

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for StateSet

Source§

impl From<State> for StateSet

Source§

fn from(value: State) -> Self

Converts to this type from the input type.
Source§

impl<'a> FromIterator<&'a State> for StateSet

Source§

fn from_iter<I: IntoIterator<Item = &'a State>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<State> for StateSet

Source§

fn from_iter<I: IntoIterator<Item = State>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl Hash for StateSet

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 IntoIterator for StateSet

Source§

type IntoIter = Iter<State>

Which kind of iterator are we turning this into?
Source§

type Item = State

The type of the elements being iterated over.
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for &StateSet

Source§

type IntoIter = Iter<State>

Which kind of iterator are we turning this into?
Source§

type Item = State

The type of the elements being iterated over.
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for StateSet

Source§

fn eq(&self, other: &StateSet) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for StateSet

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for StateSet

Source§

impl Type for StateSet

Source§

const SIGNATURE: &'static Signature = <Vec<u32> as Type>::SIGNATURE

The signature for the implementing type, in parsed format. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<'de, T> DynamicDeserialize<'de> for T
where T: Type + Deserialize<'de>,

Source§

type Deserializer = PhantomData<T>

A DeserializeSeed implementation for this type.
Source§

fn deserializer_for_signature( signature: &Signature, ) -> Result<<T as DynamicDeserialize<'de>>::Deserializer, Error>

Get a deserializer compatible with this parsed signature.
Source§

impl<T> DynamicType for T
where T: Type + ?Sized,

Source§

fn signature(&self) -> Signature

The type signature for self. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

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

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more