pub struct GameMods { /* private fields */ }Expand description
Combination of GameMods.
Implementations§
Source§impl GameMods
impl GameMods
Sourcepub fn bits(&self) -> u32
pub fn bits(&self) -> u32
Return the accumulated bit values of all contained mods.
Mods that don’t have bit values will be ignored. See https://github.com/ppy/osu-api/wiki#mods
§Example
let hdhrdtwu = mods!(Osu: HD HR DT WU);
assert_eq!(hdhrdtwu.bits(), 8 + 16 + 64);Sourcepub fn checked_bits(&self) -> Option<u32>
pub fn checked_bits(&self) -> Option<u32>
Return the accumulated bit values of all contained mods.
If any contained mod has no bit value None is returned.
See https://github.com/ppy/osu-api/wiki#mods
§Example
let hdhrdt = mods!(Osu: HD HR DT);
assert_eq!(hdhrdt.checked_bits(), Some(8 + 16 + 64));
let hdhrdtwu = mods!(Osu: HD HR DT WU);
assert_eq!(hdhrdtwu.checked_bits(), None);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if no mods are contained.
§Example
use rosu_mods::{GameMod, GameMods};
let mut mods = GameMods::new();
assert!(mods.is_empty());
mods.insert(GameMod::HiddenOsu(Default::default()));
assert!(!mods.is_empty());Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the amount of contained mods.
§Example
use rosu_mods::{GameMod, GameMods};
let hdhrdt = mods!(Catch: HD HR DT);
assert_eq!(hdhrdt.len(), 3);
let mut nm = GameMods::new();
assert_eq!(nm.len(), 0);
assert_eq!(nm.to_string(), "NM");Sourcepub fn insert(&mut self, gamemod: GameMod)
pub fn insert(&mut self, gamemod: GameMod)
Add a GameMod
§Example
use rosu_mods::{GameMod, GameMods};
let mut mods = GameMods::new();
assert_eq!(mods.to_string(), "NM");
mods.insert(GameMod::TraceableOsu(Default::default()));
assert_eq!(mods.to_string(), "TC");
mods.insert(GameMod::HardRockOsu(Default::default()));
assert_eq!(mods.to_string(), "HRTC");Sourcepub fn contains_intermode<M>(&self, gamemod: M) -> boolwhere
GameModIntermode: From<M>,
pub fn contains_intermode<M>(&self, gamemod: M) -> boolwhere
GameModIntermode: From<M>,
Check whether a given GameModIntermode is contained.
§Example
use rosu_mods::GameModIntermode;
let hd = mods!(Taiko: HD);
assert!(hd.contains_intermode(GameModIntermode::Hidden));
assert!(!hd.contains_intermode(GameModIntermode::HardRock));Sourcepub fn contains_any<I, M>(&self, mods: I) -> bool
pub fn contains_any<I, M>(&self, mods: I) -> bool
Check whether any of the given mods are contained.
Note that this method does not consider the mods’ modes so it could
return true even if it’s a different mode.
§Example
use rosu_mods::mods;
let hd = mods!(Taiko: HD);
assert!(hd.contains_any(mods!(HD HR)));
assert!(!hd.contains_any(mods!(HR DT)));
// Careful: It returns `true` even if it's a different mode
assert!(hd.contains_any(mods!(Osu: HD)));Sourcepub fn contains_acronym(&self, acronym: Acronym) -> bool
pub fn contains_acronym(&self, acronym: Acronym) -> bool
Sourcepub fn remove(&mut self, gamemod: &GameMod) -> bool
pub fn remove(&mut self, gamemod: &GameMod) -> bool
Remove a GameMod and return whether it was contained.
§Example
use rosu_mods::{GameMod, GameMods};
let mut mods: GameMods = mods!(Mania: DT MR);
#*/
assert!(mods.remove(&GameMod::MirrorMania(Default::default())));
assert_eq!(mods.to_string(), "DT");
assert!(!mods.remove(&GameMod::DoubleTimeCatch(Default::default())));Sourcepub fn remove_intermode<M>(&mut self, gamemod: M) -> boolwhere
GameModIntermode: From<M>,
pub fn remove_intermode<M>(&mut self, gamemod: M) -> boolwhere
GameModIntermode: From<M>,
Remove a gamemod and return whether it was contained.
If the same gamemod is contained for multiple modes, only one of them will be removed.
§Example
use rosu_mods::{mods, GameModIntermode, GameMod, GameMods};
let mut mods: GameMods = [
GameMod::HiddenOsu(Default::default()),
GameMod::HiddenTaiko(Default::default()),
GameMod::HardRockOsu(Default::default()),
].into_iter().collect();
assert_eq!(mods.to_string(), "HDHRHD");
assert!(mods.remove_intermode(GameModIntermode::Hidden));
assert_eq!(mods.to_string(), "HRHD");
assert!(!mods.remove_intermode(GameModIntermode::DoubleTime));Sourcepub fn remove_all<'m, I>(&mut self, mods: I)
pub fn remove_all<'m, I>(&mut self, mods: I)
Remove all mods contained in the iterator.
§Example
use rosu_mods::{mods, GameMod, GameMods};
let mut mods: GameMods = mods!(Osu: HD HR WG DT BR);
mods.remove_all([
GameMod::HiddenOsu(Default::default()),
GameMod::EasyOsu(Default::default())
].iter());
assert_eq!(mods.to_string(), "DTHRBRWG");
mods.remove_all(mods!(Osu: NF WG).iter());
assert_eq!(mods.to_string(), "DTHRBR")Sourcepub fn remove_all_intermode<I, M>(&mut self, mods: I)
pub fn remove_all_intermode<I, M>(&mut self, mods: I)
Remove all mods contained in the iterator.
If the same gamemod is contained for multiple modes, each occurence of the gamemod in the iterator will remove only one of the contained gamemods.
§Example
use rosu_mods::{mods, GameMod, GameMods};
let mut mods: GameMods = [
GameMod::HiddenOsu(Default::default()),
GameMod::HardRockOsu(Default::default()),
GameMod::HardRockCatch(Default::default()),
GameMod::WiggleOsu(Default::default()),
GameMod::DoubleTimeOsu(Default::default()),
GameMod::BarrelRollOsu(Default::default()),
].into_iter().collect();
assert_eq!(mods.to_string(), "DTHDHRBRWGHR");
mods.remove_all_intermode(mods!(HD HR WG));
assert_eq!(mods.to_string(), "DTBRHR");Sourcepub fn intersection<'m>(
&'m self,
other: &'m GameMods,
) -> GameModsIntersection<'m> ⓘ
pub fn intersection<'m>( &'m self, other: &'m GameMods, ) -> GameModsIntersection<'m> ⓘ
Returns an iterator over all mods that appear in both GameMods.
§Example
use rosu_mods::GameMods;
let hd = mods!(Catch: HD);
let hdhr = mods!(Catch: HD HR);
let mut intersection = hd.intersection(&hdhr);
assert_eq!(intersection.next(), Some(&GameMod::HiddenCatch(Default::default())));
assert_eq!(intersection.next(), None);Sourcepub fn intersects(&self, other: &Self) -> bool
pub fn intersects(&self, other: &Self) -> bool
Sourcepub fn clock_rate(&self) -> Option<f64>
pub fn clock_rate(&self) -> Option<f64>
The clock rate of the GameMods.
Returns None if any contained GameMod has no single clock rate.
§Example
use rosu_mods::GameMod;
let hd = mods!(Osu: HD);
assert_eq!(hd.clock_rate(), Some(1.0));
let mut hddt = hd;
hddt.insert(GameMod::DoubleTimeOsu(Default::default()));
assert_eq!(hddt.clock_rate(), Some(1.5));
let mut hddtwu = hddt;
hddtwu.insert(GameMod::WindUpOsu(Default::default()));
assert_eq!(hddtwu.clock_rate(), None);Sourcepub fn try_from_intermode(
mods: &GameModsIntermode,
mode: GameMode,
) -> Option<Self>
pub fn try_from_intermode( mods: &GameModsIntermode, mode: GameMode, ) -> Option<Self>
Tries to create GameMods from a GameModsIntermode.
Returns None if any contained GameModIntermode is unknown for the
given GameMode.
§Example
use rosu_mods::{mods, GameMods, GameModsIntermode, GameMode};
let intermode: GameModsIntermode = mods!(DT FI);
let mods = GameMods::try_from_intermode(&intermode, GameMode::Mania).unwrap();
// The FadeIn mod doesn't exist in Taiko
assert!(GameMods::try_from_intermode(&intermode, GameMode::Taiko).is_none());Sourcepub fn from_intermode(mods: &GameModsIntermode, mode: GameMode) -> Self
pub fn from_intermode(mods: &GameModsIntermode, mode: GameMode) -> Self
Create GameMods from a GameModsIntermode.
Any contained GameModIntermode that’s unknown for the given
GameMode will be replaced with GameModIntermode::Unknown.
§Example
use rosu_mods::{mods, GameMods, GameModsIntermode, GameMode};
let intermode: GameModsIntermode = mods!(DT FI);
let mods = GameMods::from_intermode(&intermode, GameMode::Mania);
// The FadeIn mod doesn't exist in Taiko
let dt = GameMods::from_intermode(&intermode, GameMode::Taiko);Sourcepub fn iter(&self) -> GameModsIter<'_> ⓘ
pub fn iter(&self) -> GameModsIter<'_> ⓘ
Returns an iterator over all contained mods.
Note that the iterator will immediately yield None in case of “NoMod”.
Sourcepub fn iter_mut(&mut self) -> GameModsIterMut<'_> ⓘ
pub fn iter_mut(&mut self) -> GameModsIterMut<'_> ⓘ
Returns an iterator that allows modifying each contained mod.
Note that the iterator will immediately yield None in case of “NoMod”.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Checks whether some contained mods exclude other contained mods.
§Example
use rosu_mods::GameMod;
let mut mods = mods!(Osu: EZ);
assert!(mods.is_valid());
mods.insert(GameMod::HardRockOsu(Default::default()));
assert!(!mods.is_valid());Sourcepub fn sanitize(&mut self)
pub fn sanitize(&mut self)
Remove all mods that are excluded by other contained mods.
§Example
let mut mods = mods!(Osu: EZ HR);
assert_eq!(mods.to_string(), "EZHR");
mods.sanitize();
assert_eq!(mods.to_string(), "EZ");Sourcepub fn as_legacy(&self) -> GameModsLegacy
pub fn as_legacy(&self) -> GameModsLegacy
Turns GameMods into GameModsLegacy.
Sourcepub fn try_as_legacy(&self) -> Option<GameModsLegacy>
pub fn try_as_legacy(&self) -> Option<GameModsLegacy>
Attempts to turns GameMods into GameModsLegacy.
Returns None if any contained GameMod does not have a bit value.
Trait Implementations§
Source§impl Archive for GameMods
Available on crate feature rkyv only.
impl Archive for GameMods
rkyv only.Source§type Archived = <Vec<GameMod> as Archive>::Archived
type Archived = <Vec<GameMod> as Archive>::Archived
Source§type Resolver = VecResolver
type Resolver = VecResolver
Source§fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
Source§const COPY_OPTIMIZATION: CopyOptimization<Self> = _
const COPY_OPTIMIZATION: CopyOptimization<Self> = _
serialize. Read moreSource§impl<D: Fallible + ?Sized> Deserialize<GameMods, D> for ArchivedVec<Archived<GameMod>>
Available on crate feature rkyv only.
impl<D: Fallible + ?Sized> Deserialize<GameMods, D> for ArchivedVec<Archived<GameMod>>
rkyv only.Source§impl Extend<GameMod> for GameMods
impl Extend<GameMod> for GameMods
Source§fn extend<T: IntoIterator<Item = GameMod>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = GameMod>>(&mut self, iter: T)
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<GameMods> for GameModsIntermode
impl From<GameMods> for GameModsIntermode
Source§impl FromIterator<GameMod> for GameMods
impl FromIterator<GameMod> for GameMods
Source§impl<'a> IntoIterator for &'a GameMods
impl<'a> IntoIterator for &'a GameMods
Source§impl<'a> IntoIterator for &'a mut GameMods
impl<'a> IntoIterator for &'a mut GameMods
Source§impl IntoIterator for GameMods
impl IntoIterator for GameMods
Source§impl<S: Fallible<Error: Source> + Allocator + Writer + ?Sized> Serialize<S> for GameMods
Available on crate feature rkyv only.
impl<S: Fallible<Error: Source> + Allocator + Writer + ?Sized> Serialize<S> for GameMods
rkyv only.impl StructuralPartialEq for GameMods
Auto Trait Implementations§
impl Freeze for GameMods
impl RefUnwindSafe for GameMods
impl Send for GameMods
impl Sync for GameMods
impl Unpin for GameMods
impl UnwindSafe for GameMods
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§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,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.