pub struct Leaderboard {
pub name: String,
/* private fields */
}Expand description
Local top-N leaderboard for a level/mode.
Fields§
§name: StringImplementations§
Source§impl Leaderboard
impl Leaderboard
pub fn new(name: impl Into<String>, max_entries: usize) -> Self
Sourcepub fn submit(
&mut self,
score: u64,
player_name: impl Into<String>,
metadata: HashMap<String, String>,
)
pub fn submit( &mut self, score: u64, player_name: impl Into<String>, metadata: HashMap<String, String>, )
Submit a score. The leaderboard stays sorted (highest first) and
truncated to max_entries.
pub fn get_top(&self, n: usize) -> &[LeaderboardEntry]
Sourcepub fn rank_of(&self, score: u64) -> usize
pub fn rank_of(&self, score: u64) -> usize
1-based rank of the given score; returns entries.len() + 1 if not on board.
Sourcepub fn percentile_of(&self, score: u64) -> f32
pub fn percentile_of(&self, score: u64) -> f32
Fraction (0.0–1.0) of entries the given score beats.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Auto Trait Implementations§
impl Freeze for Leaderboard
impl RefUnwindSafe for Leaderboard
impl Send for Leaderboard
impl Sync for Leaderboard
impl Unpin for Leaderboard
impl UnsafeUnpin for Leaderboard
impl UnwindSafe for Leaderboard
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.