pub struct ItemStats {
pub item: String,
pub num_accesses: i32,
/* private fields */
}
Expand description
A representation of statistics for a single item
Fields§
§item: String
§num_accesses: i32
Implementations§
source§impl ItemStats
impl ItemStats
sourcepub fn cmp_score(&self, other: &ItemStats, method: SortMethod) -> Ordering
pub fn cmp_score(&self, other: &ItemStats, method: SortMethod) -> Ordering
Compare the score of two items given a sort method
sourcepub fn set_half_life(&mut self, half_life: f64)
pub fn set_half_life(&mut self, half_life: f64)
Change the half life of the item, maintaining the same frecency
sourcepub fn get_frecency(&self, current_time_secs: f64) -> f64
pub fn get_frecency(&self, current_time_secs: f64) -> f64
Calculate the frecency of the item
pub fn set_frecency(&mut self, new: f64)
sourcepub fn update_frecency(&mut self, weight: f64)
pub fn update_frecency(&mut self, weight: f64)
update the frecency of the item by the given weight
sourcepub fn update_num_accesses(&mut self, weight: i32)
pub fn update_num_accesses(&mut self, weight: i32)
Update the number of accesses of the item by the given weight
sourcepub fn update_last_access(&mut self, time: f64)
pub fn update_last_access(&mut self, time: f64)
Update the time the item was last accessed
sourcepub fn reset_ref_time(&mut self, new_time: f64)
pub fn reset_ref_time(&mut self, new_time: f64)
Reset the reference time and recalculate the last_accessed time
sourcepub fn last_access(&self) -> f64
pub fn last_access(&self) -> f64
Timestamp (in nanoseconds since epoch) of the last access
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for ItemStats
impl Send for ItemStats
impl Sync for ItemStats
impl Unpin for ItemStats
impl UnwindSafe for ItemStats
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