pub struct Frecency { /* private fields */ }Expand description
What was chosen how often and when, by an id the caller picks (a package id, an action id). Time is passed in as seconds since the epoch, so the ranking is testable without a clock.
Implementations§
Source§impl Frecency
impl Frecency
Sourcepub fn record(&mut self, id: &str, now: u64)
pub fn record(&mut self, id: &str, now: u64)
Note that id was chosen at now (seconds since the epoch).
Sourcepub fn boost(&self, id: &str, now: u64, max: i32) -> i32
pub fn boost(&self, id: &str, now: u64, max: i32) -> i32
0..=max: how strongly id is preferred among equal matches.
0.0..=1.0: how strongly id is preferred, at full resolution: the
share of Self::boost’s scale before it is rounded to steps.
Sourcepub fn most_recent(&self, limit: usize) -> Vec<&str>
pub fn most_recent(&self, limit: usize) -> Vec<&str>
The ids chosen most recently, newest first, at most limit of them.
Sourcepub fn last_used(&self, id: &str) -> Option<u64>
pub fn last_used(&self, id: &str) -> Option<u64>
When id was last chosen (seconds since the epoch), if ever.
Sourcepub fn parse(text: &str) -> Self
pub fn parse(text: &str) -> Self
Read Self::serialize’s text, skipping anything malformed.
Trait Implementations§
impl Eq for Frecency
impl StructuralPartialEq for Frecency
Auto Trait Implementations§
impl Forget for Frecency
impl Freeze for Frecency
impl Move for Frecency
impl RefUnwindSafe for Frecency
impl Send for Frecency
impl Sync for Frecency
impl Unpin for Frecency
impl UnsafeUnpin for Frecency
impl UnwindSafe for Frecency
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