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.
|
/// Provide the result of a previous difficulty or performance calculation.
|
||||||
/// If you already calculated the attributes for the current map-mod combination,
|
/// 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.
|
/// 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()
|
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]
|
#[inline]
|
||||||
pub fn try_from_osu(osu: OsuPP<'map>) -> Option<Self> {
|
pub fn try_from_osu(osu: OsuPP<'map>) -> Option<Self> {
|
||||||
let OsuPP {
|
let OsuPP {
|
||||||
@@ -402,6 +406,33 @@ impl<'map> CatchPP<'map> {
|
|||||||
clock_rate,
|
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 {
|
struct CatchPPInner {
|
||||||
@@ -521,7 +552,6 @@ impl CatchAttributeProvider for CatchPerformanceAttributes {
|
|||||||
impl CatchAttributeProvider for DifficultyAttributes {
|
impl CatchAttributeProvider for DifficultyAttributes {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn attributes(self) -> Option<CatchDifficultyAttributes> {
|
fn attributes(self) -> Option<CatchDifficultyAttributes> {
|
||||||
#[allow(irrefutable_let_patterns)]
|
|
||||||
if let Self::Catch(attributes) = self {
|
if let Self::Catch(attributes) = self {
|
||||||
Some(attributes)
|
Some(attributes)
|
||||||
} else {
|
} else {
|
||||||
@@ -533,7 +563,6 @@ impl CatchAttributeProvider for DifficultyAttributes {
|
|||||||
impl CatchAttributeProvider for PerformanceAttributes {
|
impl CatchAttributeProvider for PerformanceAttributes {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn attributes(self) -> Option<CatchDifficultyAttributes> {
|
fn attributes(self) -> Option<CatchDifficultyAttributes> {
|
||||||
#[allow(irrefutable_let_patterns)]
|
|
||||||
if let Self::Catch(attributes) = self {
|
if let Self::Catch(attributes) = self {
|
||||||
Some(attributes.difficulty)
|
Some(attributes.difficulty)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+38
-1
@@ -741,7 +741,13 @@ impl<'map> ManiaPP<'map> {
|
|||||||
calculator.calculate()
|
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]
|
#[inline]
|
||||||
pub fn try_from_osu(osu: OsuPP<'map>) -> Option<Self> {
|
pub fn try_from_osu(osu: OsuPP<'map>) -> Option<Self> {
|
||||||
let OsuPP {
|
let OsuPP {
|
||||||
@@ -780,6 +786,37 @@ impl<'map> ManiaPP<'map> {
|
|||||||
hitresult_priority,
|
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 {
|
struct ManiaPpInner {
|
||||||
|
|||||||
+31
-2
@@ -74,6 +74,10 @@ impl<'map> OsuPP<'map> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Convert the map into another mode.
|
/// 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]
|
#[inline]
|
||||||
pub fn try_mode(self, mode: GameMode) -> Option<AnyPP<'map>> {
|
pub fn try_mode(self, mode: GameMode) -> Option<AnyPP<'map>> {
|
||||||
match mode {
|
match mode {
|
||||||
@@ -421,6 +425,33 @@ impl<'map> OsuPP<'map> {
|
|||||||
|
|
||||||
calculator.calculate()
|
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 {
|
struct OsuPpInner {
|
||||||
@@ -774,7 +805,6 @@ impl OsuAttributeProvider for OsuPerformanceAttributes {
|
|||||||
impl OsuAttributeProvider for DifficultyAttributes {
|
impl OsuAttributeProvider for DifficultyAttributes {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn attributes(self) -> Option<OsuDifficultyAttributes> {
|
fn attributes(self) -> Option<OsuDifficultyAttributes> {
|
||||||
#[allow(irrefutable_let_patterns)]
|
|
||||||
if let Self::Osu(attributes) = self {
|
if let Self::Osu(attributes) = self {
|
||||||
Some(attributes)
|
Some(attributes)
|
||||||
} else {
|
} else {
|
||||||
@@ -786,7 +816,6 @@ impl OsuAttributeProvider for DifficultyAttributes {
|
|||||||
impl OsuAttributeProvider for PerformanceAttributes {
|
impl OsuAttributeProvider for PerformanceAttributes {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn attributes(self) -> Option<OsuDifficultyAttributes> {
|
fn attributes(self) -> Option<OsuDifficultyAttributes> {
|
||||||
#[allow(irrefutable_let_patterns)]
|
|
||||||
if let Self::Osu(attributes) = self {
|
if let Self::Osu(attributes) = self {
|
||||||
Some(attributes.difficulty)
|
Some(attributes.difficulty)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ impl<'map> AnyPP<'map> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: from_attributes method
|
||||||
|
|
||||||
/// Consume the performance calculator and calculate
|
/// Consume the performance calculator and calculate
|
||||||
/// performance attributes for the given parameters.
|
/// performance attributes for the given parameters.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|||||||
+36
-3
@@ -321,7 +321,13 @@ impl<'map> TaikoPP<'map> {
|
|||||||
calculator.calculate()
|
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]
|
#[inline]
|
||||||
pub fn try_from_osu(osu: OsuPP<'map>) -> Option<Self> {
|
pub fn try_from_osu(osu: OsuPP<'map>) -> Option<Self> {
|
||||||
let OsuPP {
|
let OsuPP {
|
||||||
@@ -358,6 +364,35 @@ impl<'map> TaikoPP<'map> {
|
|||||||
n_misses,
|
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 {
|
struct TaikoPpInner {
|
||||||
@@ -511,7 +546,6 @@ impl TaikoAttributeProvider for TaikoPerformanceAttributes {
|
|||||||
impl TaikoAttributeProvider for DifficultyAttributes {
|
impl TaikoAttributeProvider for DifficultyAttributes {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn attributes(self) -> Option<TaikoDifficultyAttributes> {
|
fn attributes(self) -> Option<TaikoDifficultyAttributes> {
|
||||||
#[allow(irrefutable_let_patterns)]
|
|
||||||
if let Self::Taiko(attributes) = self {
|
if let Self::Taiko(attributes) = self {
|
||||||
Some(attributes)
|
Some(attributes)
|
||||||
} else {
|
} else {
|
||||||
@@ -523,7 +557,6 @@ impl TaikoAttributeProvider for DifficultyAttributes {
|
|||||||
impl TaikoAttributeProvider for PerformanceAttributes {
|
impl TaikoAttributeProvider for PerformanceAttributes {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn attributes(self) -> Option<TaikoDifficultyAttributes> {
|
fn attributes(self) -> Option<TaikoDifficultyAttributes> {
|
||||||
#[allow(irrefutable_let_patterns)]
|
|
||||||
if let Self::Taiko(attributes) = self {
|
if let Self::Taiko(attributes) = self {
|
||||||
Some(attributes.difficulty)
|
Some(attributes.difficulty)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user