[][src]Struct fre::stats::ItemStats

pub struct ItemStats {
    pub item: String,
    // some fields omitted
}

A representation of statistics for a single item

Fields

item: String

Methods

impl ItemStats
[src]

pub fn new(item: &str, ref_time: f64, half_life: f32) -> ItemStats
[src]

Create a new item

pub fn cmp_score(&self, other: &ItemStats, method: &SortMethod) -> Ordering
[src]

Compare the score of two items given a sort method

pub fn set_half_life(&mut self, half_life: f32)
[src]

Change the half life of the item, maintaining the same frecency

pub fn get_frecency(&self) -> f32
[src]

Calculate the frecency of the item

pub fn set_frecency(&mut self, new: f32)
[src]

pub fn update_frecency(&mut self, weight: f32)
[src]

update the frecency of the item by the given weight

pub fn update_num_accesses(&mut self, weight: i32)
[src]

Update the number of accesses of the item by the given weight

pub fn update_last_access(&mut self, time: f64)
[src]

Update the time the item was last accessed

pub fn reset_ref_time(&mut self, new_time: f64)
[src]

Reset the reference time and recalculate the last_accessed time

pub fn secs_since_access(&self) -> f32
[src]

Return the number of seconds since the item was last accessed

pub fn to_string(&self, method: &SortMethod, show_stats: bool) -> String
[src]

sort method if show_stats is true

Trait Implementations

impl From<ItemStats> for ItemStatsSerializer
[src]

impl Clone for ItemStats
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for ItemStats

impl Sync for ItemStats

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]