Struct rosu_mods::GameModsLegacy
source · pub struct GameModsLegacy(/* private fields */);Expand description
Lightweight bitflag type for legacy mods.
§Example
use rosu_mods::GameModsLegacy;
let nomod = GameModsLegacy::default();
assert_eq!(nomod, GameModsLegacy::NoMod);
// Created via bit operations or from a u32
let hdhr_1 = GameModsLegacy::Hidden | GameModsLegacy::HardRock;
let hdhr_2 = GameModsLegacy::from_bits(8 + 16);
assert_eq!(hdhr_1, hdhr_2);
// Various methods for convenience like `contains` and `intersects`.
let ezhdpf = GameModsLegacy::Easy | GameModsLegacy::Hidden | GameModsLegacy::Perfect;
assert!(!ezhdpf.contains(GameModsLegacy::HardRock));
let hdpf = GameModsLegacy::Hidden | GameModsLegacy::Perfect;
assert!(ezhdpf.intersects(hdpf));
// Parsing a `&str`
let hdhrdt = "dthdhr".parse::<GameModsLegacy>().unwrap();
assert_eq!(hdhrdt.bits(), 8 + 16 + 64);
// The Display implementation combines all acronyms
assert_eq!(hdhrdt.to_string(), "HDHRDT".to_string());
// Has an iterator type
let mut iter = GameModsLegacy::from_bits(536871512).iter();
assert_eq!(iter.next(), Some(GameModsLegacy::Hidden));
assert_eq!(iter.next(), Some(GameModsLegacy::HardRock));
assert_eq!(iter.next(), Some(GameModsLegacy::Nightcore));
assert_eq!(iter.next(), Some(GameModsLegacy::ScoreV2));
assert_eq!(iter.next(), None);Implementations§
source§impl GameModsLegacy
impl GameModsLegacy
pub const NoMod: Self = _
pub const NoFail: Self = _
pub const Easy: Self = _
pub const TouchDevice: Self = _
pub const Hidden: Self = _
pub const HardRock: Self = _
pub const SuddenDeath: Self = _
pub const DoubleTime: Self = _
pub const Relax: Self = _
pub const HalfTime: Self = _
pub const Nightcore: Self = _
pub const Flashlight: Self = _
pub const Autoplay: Self = _
pub const SpunOut: Self = _
pub const Autopilot: Self = _
pub const Perfect: Self = _
pub const Key4: Self = _
pub const Key5: Self = _
pub const Key6: Self = _
pub const Key7: Self = _
pub const Key8: Self = _
pub const FadeIn: Self = _
pub const Random: Self = _
pub const Cinema: Self = _
pub const Target: Self = _
pub const Key9: Self = _
pub const KeyCoop: Self = _
pub const Key1: Self = _
pub const Key3: Self = _
pub const Key2: Self = _
pub const ScoreV2: Self = _
pub const Mirror: Self = _
source§impl GameModsLegacy
impl GameModsLegacy
sourcepub const fn clock_rate(self) -> f32
pub const fn clock_rate(self) -> f32
Returns the clock rate for the mods i.e. 1.5 for DT, 0.75 for HT, and 1.0 otherwise.
sourcepub const fn len(self) -> usize
pub const fn len(self) -> usize
Returns the amount of contained mods.
§Example
use rosu_mods::GameModsLegacy;
assert_eq!(GameModsLegacy::NoMod.len(), 0);
let mods = GameModsLegacy::from_bits(8 + 16 + 64 + 128);
assert_eq!(mods.len(), 4);sourcepub fn iter(self) -> GameModsLegacyIter ⓘ
pub fn iter(self) -> GameModsLegacyIter ⓘ
Returns an iterator over GameModsLegacy.
§Example
use rosu_mods::GameModsLegacy;
let mut iter = GameModsLegacy::from_bits(8 + 16 + 64 + 128).iter();
assert_eq!(iter.next(), Some(GameModsLegacy::Hidden));
assert_eq!(iter.next(), Some(GameModsLegacy::HardRock));
assert_eq!(iter.next(), Some(GameModsLegacy::DoubleTime));
assert_eq!(iter.next(), Some(GameModsLegacy::Relax));
assert_eq!(iter.next(), None);
let mut iter = GameModsLegacy::NoMod.iter();
assert_eq!(iter.next(), Some(GameModsLegacy::NoMod));
assert_eq!(iter.next(), None);sourcepub fn to_intermode(self) -> GameModsIntermode
pub fn to_intermode(self) -> GameModsIntermode
Convert GameModsLegacy to GameModsIntermode.
source§impl GameModsLegacy
impl GameModsLegacy
sourcepub const fn bits(self) -> u32
pub const fn bits(self) -> u32
Get the underlying bits value.
The returned value is exactly the bits set in this flags value.
sourcepub const fn try_from_bits(bits: u32) -> Option<Self>
pub const fn try_from_bits(bits: u32) -> Option<Self>
Convert from a bits value.
This method will return None if any unknown bits are set.
sourcepub const fn from_bits(bits: u32) -> Self
pub const fn from_bits(bits: u32) -> Self
Convert from a bits value, unsetting any unknown bits.
sourcepub const fn from_bits_retain(bits: u32) -> Self
pub const fn from_bits_retain(bits: u32) -> Self
Convert from a bits value exactly.
Unknown bits are retained.
sourcepub const fn intersects(self, other: Self) -> bool
pub const fn intersects(self, other: Self) -> bool
Whether any set bits in a source flags value are also set in a target flags value.
sourcepub const fn contains(self, other: Self) -> bool
pub const fn contains(self, other: Self) -> bool
Whether all set bits in a source flags value are also set in a target flags value.
sourcepub fn remove(&mut self, other: Self)
pub fn remove(&mut self, other: Self)
The intersection of a source flags value with the complement of a target flags value (&!).
This method is not equivalent to self & !other when other has unknown bits set.
remove won’t truncate other, but the ! operator will.
sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
The bitwise and (&) of the bits in two flags values.
sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
The bitwise or (|) of the bits in two flags values.
sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
The intersection of a source flags value with the complement of a target flags value (&!).
This method is not equivalent to self & !other when other has unknown bits set.
difference won’t truncate other, but the ! operator will.
sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
The bitwise exclusive-or (^) of the bits in two flags values.
Trait Implementations§
source§impl Archive for GameModsLegacy
Available on crate feature rkyv only.
impl Archive for GameModsLegacy
rkyv only.source§impl Binary for GameModsLegacy
impl Binary for GameModsLegacy
source§impl BitAnd for GameModsLegacy
impl BitAnd for GameModsLegacy
source§impl BitAndAssign for GameModsLegacy
impl BitAndAssign for GameModsLegacy
source§fn bitand_assign(&mut self, other: Self)
fn bitand_assign(&mut self, other: Self)
The bitwise and (&) of the bits in two flags values.
source§impl BitOr for GameModsLegacy
impl BitOr for GameModsLegacy
source§fn bitor(self, other: GameModsLegacy) -> Self
fn bitor(self, other: GameModsLegacy) -> Self
The bitwise or (|) of the bits in two flags values.
§type Output = GameModsLegacy
type Output = GameModsLegacy
| operator.source§impl BitOrAssign for GameModsLegacy
impl BitOrAssign for GameModsLegacy
source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
The bitwise or (|) of the bits in two flags values.
source§impl BitXor for GameModsLegacy
impl BitXor for GameModsLegacy
source§impl<C: ?Sized> CheckBytes<C> for GameModsLegacy
Available on crate feature rkyv only.
impl<C: ?Sized> CheckBytes<C> for GameModsLegacy
rkyv only.§type Error = TupleStructCheckError
type Error = TupleStructCheckError
source§unsafe fn check_bytes<'a>(
value: *const Self,
ctx: &mut C,
) -> Result<&'a Self, TupleStructCheckError>
unsafe fn check_bytes<'a>( value: *const Self, ctx: &mut C, ) -> Result<&'a Self, TupleStructCheckError>
source§impl Clone for GameModsLegacy
impl Clone for GameModsLegacy
source§fn clone(&self) -> GameModsLegacy
fn clone(&self) -> GameModsLegacy
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for GameModsLegacy
impl Debug for GameModsLegacy
source§impl Default for GameModsLegacy
impl Default for GameModsLegacy
source§fn default() -> GameModsLegacy
fn default() -> GameModsLegacy
source§impl<'de> Deserialize<'de> for GameModsLegacy
Available on crate feature serde only.
impl<'de> Deserialize<'de> for GameModsLegacy
serde only.source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
source§impl<D: Fallible + ?Sized> Deserialize<GameModsLegacy, D> for GameModsLegacy
Available on crate feature rkyv only.
impl<D: Fallible + ?Sized> Deserialize<GameModsLegacy, D> for GameModsLegacy
rkyv only.source§impl Display for GameModsLegacy
impl Display for GameModsLegacy
source§impl Extend<GameModsLegacy> for GameModsLegacy
impl Extend<GameModsLegacy> for GameModsLegacy
source§fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)
The bitwise or (|) of the bits in each flags value.
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)source§impl From<GameModsLegacy> for GameModsIntermode
impl From<GameModsLegacy> for GameModsIntermode
source§fn from(mods: GameModsLegacy) -> Self
fn from(mods: GameModsLegacy) -> Self
source§impl From<GameModsLegacy> for u32
impl From<GameModsLegacy> for u32
source§fn from(mods: GameModsLegacy) -> Self
fn from(mods: GameModsLegacy) -> Self
source§impl FromIterator<GameModsLegacy> for GameModsLegacy
impl FromIterator<GameModsLegacy> for GameModsLegacy
source§fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self
The bitwise or (|) of the bits in each flags value.
source§impl FromStr for GameModsLegacy
impl FromStr for GameModsLegacy
source§impl Hash for GameModsLegacy
impl Hash for GameModsLegacy
source§impl IntoIterator for GameModsLegacy
impl IntoIterator for GameModsLegacy
source§impl Ord for GameModsLegacy
impl Ord for GameModsLegacy
source§fn cmp(&self, other: &GameModsLegacy) -> Ordering
fn cmp(&self, other: &GameModsLegacy) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for GameModsLegacy
impl PartialEq for GameModsLegacy
source§fn eq(&self, other: &GameModsLegacy) -> bool
fn eq(&self, other: &GameModsLegacy) -> bool
self and other values to be equal, and is used
by ==.source§impl PartialOrd for GameModsLegacy
impl PartialOrd for GameModsLegacy
source§fn partial_cmp(&self, other: &GameModsLegacy) -> Option<Ordering>
fn partial_cmp(&self, other: &GameModsLegacy) -> 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 moresource§impl<S: Fallible + ?Sized> Serialize<S> for GameModsLegacy
Available on crate feature rkyv only.
impl<S: Fallible + ?Sized> Serialize<S> for GameModsLegacy
rkyv only.source§impl Serialize for GameModsLegacy
Available on crate feature serde only.
impl Serialize for GameModsLegacy
serde only.source§impl Sub for GameModsLegacy
impl Sub for GameModsLegacy
source§fn sub(self, other: Self) -> Self
fn sub(self, other: Self) -> Self
The intersection of a source flags value with the complement of a target flags value (&!).
This method is not equivalent to self & !other when other has unknown bits set.
difference won’t truncate other, but the ! operator will.
§type Output = GameModsLegacy
type Output = GameModsLegacy
- operator.source§impl SubAssign for GameModsLegacy
impl SubAssign for GameModsLegacy
source§fn sub_assign(&mut self, other: Self)
fn sub_assign(&mut self, other: Self)
The intersection of a source flags value with the complement of a target flags value (&!).
This method is not equivalent to self & !other when other has unknown bits set.
difference won’t truncate other, but the ! operator will.
source§impl TryFrom<Acronym> for GameModsLegacy
impl TryFrom<Acronym> for GameModsLegacy
impl Copy for GameModsLegacy
impl Eq for GameModsLegacy
impl StructuralPartialEq for GameModsLegacy
Auto Trait Implementations§
impl Freeze for GameModsLegacy
impl RefUnwindSafe for GameModsLegacy
impl Send for GameModsLegacy
impl Sync for GameModsLegacy
impl Unpin for GameModsLegacy
impl UnwindSafe for GameModsLegacy
Blanket Implementations§
source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be unsized. Read more§type MetadataResolver = ()
type MetadataResolver = ()
source§unsafe fn resolve_metadata(
&self,
_: usize,
_: <T as ArchiveUnsized>::MetadataResolver,
_: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata,
)
unsafe fn resolve_metadata( &self, _: usize, _: <T as ArchiveUnsized>::MetadataResolver, _: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata, )
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CallHasher for T
impl<T> CallHasher for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)