pub struct ArcadeScoreboard {
pub scores: Vec<u32>,
}Expand description
Serialized top-5 leaderboard stored in arcade_scores.json.
use limitless_cli::modules::arcade::{ArcadeScoreboard, MAX_SCORES};
let mut board = ArcadeScoreboard::default();
board.record(30);
board.record(50);
assert_eq!(board.top5(), vec![50, 30]);
assert!(board.scores.len() <= MAX_SCORES);Fields§
§scores: Vec<u32>All recorded scores, kept descending and capped at MAX_SCORES.
Implementations§
Source§impl ArcadeScoreboard
impl ArcadeScoreboard
Sourcepub fn load(path: &Path) -> Self
pub fn load(path: &Path) -> Self
Loads the board from path; missing/corrupt files yield an empty board.
Sourcepub fn save(&self, path: &Path) -> Result<()>
pub fn save(&self, path: &Path) -> Result<()>
Persists the board to path, creating parent directories as needed.
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Sorts descending, keeps the top MAX_SCORES.
Trait Implementations§
Source§impl Clone for ArcadeScoreboard
impl Clone for ArcadeScoreboard
Source§impl Debug for ArcadeScoreboard
impl Debug for ArcadeScoreboard
Source§impl Default for ArcadeScoreboard
impl Default for ArcadeScoreboard
Source§impl<'de> Deserialize<'de> for ArcadeScoreboard
impl<'de> Deserialize<'de> for ArcadeScoreboard
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ArcadeScoreboard
Source§impl PartialEq for ArcadeScoreboard
impl PartialEq for ArcadeScoreboard
Source§impl Serialize for ArcadeScoreboard
impl Serialize for ArcadeScoreboard
impl StructuralPartialEq for ArcadeScoreboard
Auto Trait Implementations§
impl Forget for ArcadeScoreboard
impl Freeze for ArcadeScoreboard
impl RefUnwindSafe for ArcadeScoreboard
impl Send for ArcadeScoreboard
impl Sync for ArcadeScoreboard
impl Unpin for ArcadeScoreboard
impl UnsafeUnpin for ArcadeScoreboard
impl UnwindSafe for ArcadeScoreboard
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