pub struct UsageInformation { /* private fields */ }
Expand description
A struct that keeps the records for all tracked objects.
Implementations§
Source§impl UsageInformation
impl UsageInformation
Sourcepub fn list_verbose(&self) -> &BTreeMap<String, Usages>
pub fn list_verbose(&self) -> &BTreeMap<String, Usages>
Provides read access to all stored data.
Sourcepub fn load_usage_information_from_ron_file<R>(
rdr: R,
) -> Result<Self, UsageTrackerError>where
R: Read,
👎Deprecated since 0.2: please only use this function if you have to load files from v0.1
pub fn load_usage_information_from_ron_file<R>(
rdr: R,
) -> Result<Self, UsageTrackerError>where
R: Read,
Loads a UsageInformation object from a RON file.
§Explanation
With v0.2, the data layout was changed. To make the transition from v0.1 easier for users, this function was created. It is able to read the RON files produced by v0.1 and convert them into the data structure of v0.2.
§Deprecation
If it still exists by then, v1.0 will see this function removed.
§Possible errors
UsageTrackerError::FileLoadErrorRon
Sourcepub fn prune(
&mut self,
name: &String,
before: &Option<DateTime<Utc>>,
) -> Result<(), UsageTrackerError>
pub fn prune( &mut self, name: &String, before: &Option<DateTime<Utc>>, ) -> Result<(), UsageTrackerError>
Removes usages from an object.
If before
is None
, all usages are removed. Otherwise, only usages before before
are
removed.
§Possible errors:
UsageTrackerError::ObjectNotTracked
Sourcepub fn record_use(
&mut self,
name: &String,
add_if_new: bool,
) -> Result<(), UsageTrackerError>
pub fn record_use( &mut self, name: &String, add_if_new: bool, ) -> Result<(), UsageTrackerError>
Sourcepub fn usage(
&self,
name: &String,
time_frame: &Duration,
) -> Result<f64, UsageTrackerError>
pub fn usage( &self, name: &String, time_frame: &Duration, ) -> Result<f64, UsageTrackerError>
Calculates the number of usages of the specified object within the specified amount of time.
This works by calculating how much the specified time frame is in comparison to the time since the oldest recorded usage. This relationship is the multiplied by the number of total uses, to calculate a specific number.
§Possible errors
UsageTrackerError::ObjectNeverUsed
UsageTrackerError::ObjectNotTracked
Trait Implementations§
Source§impl Clone for UsageInformation
impl Clone for UsageInformation
Source§fn clone(&self) -> UsageInformation
fn clone(&self) -> UsageInformation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more