pub struct Modifiers { /* private fields */ }
Expand description
Pressed modifier keys.
Specification: https://w3c.github.io/uievents-key/#keys-modifier
Implementations§
§impl Modifiers
impl Modifiers
pub const ALT: Modifiers = Self{ bits: 1,}
pub const ALT_GRAPH: Modifiers = Self{ bits: 2,}
pub const CAPS_LOCK: Modifiers = Self{ bits: 4,}
pub const CONTROL: Modifiers = Self{ bits: 8,}
pub const FN: Modifiers = Self{ bits: 16,}
pub const FN_LOCK: Modifiers = Self{ bits: 32,}
pub const META: Modifiers = Self{ bits: 64,}
pub const NUM_LOCK: Modifiers = Self{ bits: 128,}
pub const SCROLL_LOCK: Modifiers = Self{ bits: 256,}
pub const SHIFT: Modifiers = Self{ bits: 512,}
pub const SYMBOL: Modifiers = Self{ bits: 1024,}
pub const SYMBOL_LOCK: Modifiers = Self{ bits: 2048,}
pub const HYPER: Modifiers = Self{ bits: 4096,}
pub const SUPER: Modifiers = Self{ bits: 8192,}
pub const fn from_bits(bits: u32) -> Option<Modifiers>
pub const fn from_bits(bits: u32) -> Option<Modifiers>
Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.
pub const fn from_bits_truncate(bits: u32) -> Modifiers
pub const fn from_bits_truncate(bits: u32) -> Modifiers
Convert from underlying bit representation, dropping any bits that do not correspond to flags.
pub const unsafe fn from_bits_unchecked(bits: u32) -> Modifiers
pub const unsafe fn from_bits_unchecked(bits: u32) -> Modifiers
Convert from underlying bit representation, preserving all bits (even those not corresponding to a defined flag).
Safety
The caller of the bitflags!
macro can chose to allow or
disallow extra bits for their bitflags type.
The caller of from_bits_unchecked()
has to ensure that
all bits correspond to a defined flag or that extra bits
are valid for this bitflags type.
pub const fn intersects(&self, other: Modifiers) -> bool
pub const fn intersects(&self, other: Modifiers) -> bool
Returns true
if there are flags common to both self
and other
.
pub const fn contains(&self, other: Modifiers) -> bool
pub const fn contains(&self, other: Modifiers) -> bool
Returns true
if all of the flags in other
are contained within self
.
pub fn set(&mut self, other: Modifiers, value: bool)
pub fn set(&mut self, other: Modifiers, value: bool)
Inserts or removes the specified flags depending on the passed value.
pub const fn intersection(self, other: Modifiers) -> Modifiers
pub const fn intersection(self, other: Modifiers) -> Modifiers
Returns the intersection between the flags in self
and
other
.
Specifically, the returned set contains only the flags which are
present in both self
and other
.
This is equivalent to using the &
operator (e.g.
ops::BitAnd
), as in flags & other
.
pub const fn union(self, other: Modifiers) -> Modifiers
pub const fn union(self, other: Modifiers) -> Modifiers
Returns the union of between the flags in self
and other
.
Specifically, the returned set contains all flags which are
present in either self
or other
, including any which are
present in both (see Self::symmetric_difference
if that
is undesirable).
This is equivalent to using the |
operator (e.g.
ops::BitOr
), as in flags | other
.
pub const fn difference(self, other: Modifiers) -> Modifiers
pub const fn difference(self, other: Modifiers) -> Modifiers
Returns the difference between the flags in self
and other
.
Specifically, the returned set contains all flags present in
self
, except for the ones present in other
.
It is also conceptually equivalent to the “bit-clear” operation:
flags & !other
(and this syntax is also supported).
This is equivalent to using the -
operator (e.g.
ops::Sub
), as in flags - other
.
pub const fn symmetric_difference(self, other: Modifiers) -> Modifiers
pub const fn symmetric_difference(self, other: Modifiers) -> Modifiers
Returns the symmetric difference between the flags
in self
and other
.
Specifically, the returned set contains the flags present which
are present in self
or other
, but that are not present in
both. Equivalently, it contains the flags present in exactly
one of the sets self
and other
.
This is equivalent to using the ^
operator (e.g.
ops::BitXor
), as in flags ^ other
.
pub const fn complement(self) -> Modifiers
pub const fn complement(self) -> Modifiers
Returns the complement of this set of flags.
Specifically, the returned set contains all the flags which are
not set in self
, but which are allowed for this type.
Alternatively, it can be thought of as the set difference
between Self::all()
and self
(e.g. Self::all() - self
)
This is equivalent to using the !
operator (e.g.
ops::Not
), as in !flags
.
Trait Implementations§
§impl BitAndAssign<Modifiers> for Modifiers
impl BitAndAssign<Modifiers> for Modifiers
§fn bitand_assign(&mut self, other: Modifiers)
fn bitand_assign(&mut self, other: Modifiers)
Disables all flags disabled in the set.
§impl BitOrAssign<Modifiers> for Modifiers
impl BitOrAssign<Modifiers> for Modifiers
§fn bitor_assign(&mut self, other: Modifiers)
fn bitor_assign(&mut self, other: Modifiers)
Adds the set of flags.
§impl BitXorAssign<Modifiers> for Modifiers
impl BitXorAssign<Modifiers> for Modifiers
§fn bitxor_assign(&mut self, other: Modifiers)
fn bitxor_assign(&mut self, other: Modifiers)
Toggles the set of flags.
§impl<'de> Deserialize<'de> for Modifiers
impl<'de> Deserialize<'de> for Modifiers
§fn deserialize<__D>(
__deserializer: __D
) -> Result<Modifiers, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>( __deserializer: __D ) -> Result<Modifiers, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,
§impl Extend<Modifiers> for Modifiers
impl Extend<Modifiers> for Modifiers
§fn extend<T>(&mut self, iterator: T)where
T: IntoIterator<Item = Modifiers>,
fn extend<T>(&mut self, iterator: T)where T: IntoIterator<Item = Modifiers>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)§impl FromIterator<Modifiers> for Modifiers
impl FromIterator<Modifiers> for Modifiers
§impl Ord for Modifiers
impl Ord for Modifiers
§impl PartialOrd<Modifiers> for Modifiers
impl PartialOrd<Modifiers> for Modifiers
§fn partial_cmp(&self, other: &Modifiers) -> Option<Ordering>
fn partial_cmp(&self, other: &Modifiers) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more§impl Serialize for Modifiers
impl Serialize for Modifiers
§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where __S: Serializer,
§impl SubAssign<Modifiers> for Modifiers
impl SubAssign<Modifiers> for Modifiers
§fn sub_assign(&mut self, other: Modifiers)
fn sub_assign(&mut self, other: Modifiers)
Disables all flags enabled in the set.
impl Copy for Modifiers
impl Eq for Modifiers
impl StructuralEq for Modifiers
impl StructuralPartialEq for Modifiers
Auto Trait Implementations§
impl RefUnwindSafe for Modifiers
impl Send for Modifiers
impl Sync for Modifiers
impl Unpin for Modifiers
impl UnwindSafe for Modifiers
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.