doc: added documentation
This commit is contained in:
+34
-5
@@ -71,8 +71,6 @@ impl<'map> CatchPP<'map> {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: new_with_attributes function
|
||||
|
||||
/// Provide the result of a previous difficulty or performance calculation.
|
||||
/// If you already calculated the attributes for the current map-mod combination,
|
||||
/// be sure to put them in here so that they don't have to be recalculated.
|
||||
@@ -367,7 +365,13 @@ impl<'map> CatchPP<'map> {
|
||||
calculator.calculate()
|
||||
}
|
||||
|
||||
/// TODO: docs
|
||||
/// Try to create [`CatchPP`] through [`OsuPP`].
|
||||
///
|
||||
/// Returns `None` if [`OsuPP`] already replaced its internal [`Beatmap`]
|
||||
/// with [`OsuDifficultyAttributes`], i.e. if [`OsuPP::attributes`]
|
||||
/// or [`OsuPP::generate_state`] was called.
|
||||
///
|
||||
/// [`OsuDifficultyAttributes`]: crate::osu::OsuDifficultyAttributes
|
||||
#[inline]
|
||||
pub fn try_from_osu(osu: OsuPP<'map>) -> Option<Self> {
|
||||
let OsuPP {
|
||||
@@ -402,6 +406,33 @@ impl<'map> CatchPP<'map> {
|
||||
clock_rate,
|
||||
})
|
||||
}
|
||||
|
||||
/// Try to create [`CatchPP`] through a [`CatchAttributeProvider`].
|
||||
///
|
||||
/// If you already calculated the attributes for the current map-mod
|
||||
/// combination, the [`Beatmap`] is no longer necessary to calculate
|
||||
/// performance attributes so this method can be used instead of
|
||||
/// [`CatchPP::new`].
|
||||
///
|
||||
/// Returns `None` only if the [`CatchAttributeProvider`] did not contain
|
||||
/// attributes for catch e.g. if it's [`DifficultyAttributes::Taiko`].
|
||||
#[inline]
|
||||
pub fn try_from_attributes(attributes: impl CatchAttributeProvider) -> Option<Self> {
|
||||
attributes.attributes().map(|attrs| Self {
|
||||
map_or_attrs: MapOrElse::Else(attrs),
|
||||
mods: 0,
|
||||
acc: None,
|
||||
combo: None,
|
||||
|
||||
n_fruits: None,
|
||||
n_droplets: None,
|
||||
n_tiny_droplets: None,
|
||||
n_tiny_droplet_misses: None,
|
||||
n_misses: None,
|
||||
passed_objects: None,
|
||||
clock_rate: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
struct CatchPPInner {
|
||||
@@ -521,7 +552,6 @@ impl CatchAttributeProvider for CatchPerformanceAttributes {
|
||||
impl CatchAttributeProvider for DifficultyAttributes {
|
||||
#[inline]
|
||||
fn attributes(self) -> Option<CatchDifficultyAttributes> {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
if let Self::Catch(attributes) = self {
|
||||
Some(attributes)
|
||||
} else {
|
||||
@@ -533,7 +563,6 @@ impl CatchAttributeProvider for DifficultyAttributes {
|
||||
impl CatchAttributeProvider for PerformanceAttributes {
|
||||
#[inline]
|
||||
fn attributes(self) -> Option<CatchDifficultyAttributes> {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
if let Self::Catch(attributes) = self {
|
||||
Some(attributes.difficulty)
|
||||
} else {
|
||||
|
||||
+38
-1
@@ -741,7 +741,13 @@ impl<'map> ManiaPP<'map> {
|
||||
calculator.calculate()
|
||||
}
|
||||
|
||||
/// TODO: docs
|
||||
/// Try to create [`ManiaPP`] through [`OsuPP`].
|
||||
///
|
||||
/// Returns `None` if [`OsuPP`] already replaced its internal [`Beatmap`]
|
||||
/// with [`OsuDifficultyAttributes`], i.e. if [`OsuPP::attributes`]
|
||||
/// or [`OsuPP::generate_state`] was called.
|
||||
///
|
||||
/// [`OsuDifficultyAttributes`]: crate::osu::OsuDifficultyAttributes
|
||||
#[inline]
|
||||
pub fn try_from_osu(osu: OsuPP<'map>) -> Option<Self> {
|
||||
let OsuPP {
|
||||
@@ -780,6 +786,37 @@ impl<'map> ManiaPP<'map> {
|
||||
hitresult_priority,
|
||||
})
|
||||
}
|
||||
|
||||
/// Try to create [`ManiaPP`] through a [`ManiaAttributeProvider`].
|
||||
///
|
||||
/// If you already calculated the attributes for the current map-mod
|
||||
/// combination, the [`Beatmap`] is no longer necessary to calculate
|
||||
/// performance attributes so this method can be used instead of
|
||||
/// [`ManiaPP::new`].
|
||||
///
|
||||
/// Returns `None` only if the [`ManiaAttributeProvider`] did not contain
|
||||
/// attributes for mania e.g. if it's [`DifficultyAttributes::Taiko`].
|
||||
#[inline]
|
||||
pub fn try_from_attributes(
|
||||
attributes: impl ManiaAttributeProvider,
|
||||
is_convert: bool,
|
||||
) -> Option<Self> {
|
||||
attributes.attributes().map(|attrs| Self {
|
||||
is_convert,
|
||||
map_or_attrs: MapOrElse::Else(attrs),
|
||||
mods: 0,
|
||||
passed_objects: None,
|
||||
clock_rate: None,
|
||||
n320: None,
|
||||
n300: None,
|
||||
n200: None,
|
||||
n100: None,
|
||||
n50: None,
|
||||
n_misses: None,
|
||||
acc: None,
|
||||
hitresult_priority: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
struct ManiaPpInner {
|
||||
|
||||
+31
-2
@@ -74,6 +74,10 @@ impl<'map> OsuPP<'map> {
|
||||
}
|
||||
|
||||
/// Convert the map into another mode.
|
||||
///
|
||||
/// Returns `None` if `self` already replaced it's internal [`Beatmap`]
|
||||
/// with [`OsuDifficultyAttributes`], i.e. if [`OsuPP::attributes`]
|
||||
/// or [`OsuPP::generate_state`] was called.
|
||||
#[inline]
|
||||
pub fn try_mode(self, mode: GameMode) -> Option<AnyPP<'map>> {
|
||||
match mode {
|
||||
@@ -421,6 +425,33 @@ impl<'map> OsuPP<'map> {
|
||||
|
||||
calculator.calculate()
|
||||
}
|
||||
|
||||
/// Try to create [`OsuPP`] through a [`OsuAttributeProvider`].
|
||||
///
|
||||
/// If you already calculated the attributes for the current map-mod
|
||||
/// combination, the [`Beatmap`] is no longer necessary to calculate
|
||||
/// performance attributes so this method can be used instead of
|
||||
/// [`OsuPP::new`].
|
||||
///
|
||||
/// Returns `None` only if the [`OsuAttributeProvider`] did not contain
|
||||
/// attributes for catch e.g. if it's [`DifficultyAttributes::Taiko`].
|
||||
#[inline]
|
||||
pub fn try_from_attributes(attributes: impl OsuAttributeProvider) -> Option<Self> {
|
||||
attributes.attributes().map(|attrs| Self {
|
||||
map_or_attrs: MapOrElse::Else(attrs),
|
||||
mods: 0,
|
||||
acc: None,
|
||||
combo: None,
|
||||
|
||||
n300: None,
|
||||
n100: None,
|
||||
n50: None,
|
||||
n_misses: None,
|
||||
passed_objects: None,
|
||||
clock_rate: None,
|
||||
hitresult_priority: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
struct OsuPpInner {
|
||||
@@ -774,7 +805,6 @@ impl OsuAttributeProvider for OsuPerformanceAttributes {
|
||||
impl OsuAttributeProvider for DifficultyAttributes {
|
||||
#[inline]
|
||||
fn attributes(self) -> Option<OsuDifficultyAttributes> {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
if let Self::Osu(attributes) = self {
|
||||
Some(attributes)
|
||||
} else {
|
||||
@@ -786,7 +816,6 @@ impl OsuAttributeProvider for DifficultyAttributes {
|
||||
impl OsuAttributeProvider for PerformanceAttributes {
|
||||
#[inline]
|
||||
fn attributes(self) -> Option<OsuDifficultyAttributes> {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
if let Self::Osu(attributes) = self {
|
||||
Some(attributes.difficulty)
|
||||
} else {
|
||||
|
||||
@@ -60,6 +60,8 @@ impl<'map> AnyPP<'map> {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: from_attributes method
|
||||
|
||||
/// Consume the performance calculator and calculate
|
||||
/// performance attributes for the given parameters.
|
||||
#[inline]
|
||||
|
||||
+36
-3
@@ -321,7 +321,13 @@ impl<'map> TaikoPP<'map> {
|
||||
calculator.calculate()
|
||||
}
|
||||
|
||||
/// TODO: docs
|
||||
/// Try to create [`TaikoPP`] through [`OsuPP`].
|
||||
///
|
||||
/// Returns `None` if [`OsuPP`] already replaced its internal [`Beatmap`]
|
||||
/// with [`OsuDifficultyAttributes`], i.e. if [`OsuPP::attributes`]
|
||||
/// or [`OsuPP::generate_state`] was called.
|
||||
///
|
||||
/// [`OsuDifficultyAttributes`]: crate::osu::OsuDifficultyAttributes
|
||||
#[inline]
|
||||
pub fn try_from_osu(osu: OsuPP<'map>) -> Option<Self> {
|
||||
let OsuPP {
|
||||
@@ -358,6 +364,35 @@ impl<'map> TaikoPP<'map> {
|
||||
n_misses,
|
||||
})
|
||||
}
|
||||
|
||||
/// Try to create [`TaikoPP`] through a [`TaikoAttributeProvider`].
|
||||
///
|
||||
/// If you already calculated the attributes for the current map-mod
|
||||
/// combination, the [`Beatmap`] is no longer necessary to calculate
|
||||
/// performance attributes so this method can be used instead of
|
||||
/// [`TaikoPP::new`].
|
||||
///
|
||||
/// Returns `None` only if the [`TaikoAttributeProvider`] did not contain
|
||||
/// attributes for catch e.g. if it's [`DifficultyAttributes::Mania`].
|
||||
#[inline]
|
||||
pub fn try_from_attributes(
|
||||
attributes: impl TaikoAttributeProvider,
|
||||
is_convert: bool,
|
||||
) -> Option<Self> {
|
||||
attributes.attributes().map(|attrs| Self {
|
||||
is_convert,
|
||||
map_or_attrs: MapOrElse::Else(attrs),
|
||||
mods: 0,
|
||||
combo: None,
|
||||
acc: None,
|
||||
n_misses: None,
|
||||
passed_objects: None,
|
||||
clock_rate: None,
|
||||
n300: None,
|
||||
n100: None,
|
||||
hitresult_priority: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
struct TaikoPpInner {
|
||||
@@ -511,7 +546,6 @@ impl TaikoAttributeProvider for TaikoPerformanceAttributes {
|
||||
impl TaikoAttributeProvider for DifficultyAttributes {
|
||||
#[inline]
|
||||
fn attributes(self) -> Option<TaikoDifficultyAttributes> {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
if let Self::Taiko(attributes) = self {
|
||||
Some(attributes)
|
||||
} else {
|
||||
@@ -523,7 +557,6 @@ impl TaikoAttributeProvider for DifficultyAttributes {
|
||||
impl TaikoAttributeProvider for PerformanceAttributes {
|
||||
#[inline]
|
||||
fn attributes(self) -> Option<TaikoDifficultyAttributes> {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
if let Self::Taiko(attributes) = self {
|
||||
Some(attributes.difficulty)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user