pub struct DecayModel {
pub id: TemporalId,
pub label: String,
pub initial_value: f64,
pub current_value: f64,
pub reference_time: DateTime<Utc>,
pub decay_type: DecayType,
pub floor: f64,
pub last_calculated: DateTime<Utc>,
pub tags: Vec<String>,
}Expand description
Models how value/relevance decays over time.
Fields§
§id: TemporalIdUnique identifier.
label: StringWhat this decay applies to.
initial_value: f64Initial value (at t=0).
current_value: f64Current calculated value.
reference_time: DateTime<Utc>Reference time (when value was initial_value).
decay_type: DecayTypeDecay function.
floor: f64Minimum value (floor).
last_calculated: DateTime<Utc>When last calculated.
Tags.
Implementations§
Source§impl DecayModel
impl DecayModel
Sourcepub fn new(
label: impl Into<String>,
initial_value: f64,
decay_type: DecayType,
) -> Self
pub fn new( label: impl Into<String>, initial_value: f64, decay_type: DecayType, ) -> Self
Create a new decay model.
Sourcepub fn calculate_value(&self, at: DateTime<Utc>) -> f64
pub fn calculate_value(&self, at: DateTime<Utc>) -> f64
Calculate value at a specific time.
Sourcepub fn time_until(&self, threshold: f64) -> Option<ChronoDuration>
pub fn time_until(&self, threshold: f64) -> Option<ChronoDuration>
Time until value reaches threshold.
Trait Implementations§
Source§impl Clone for DecayModel
impl Clone for DecayModel
Source§fn clone(&self) -> DecayModel
fn clone(&self) -> DecayModel
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DecayModel
impl Debug for DecayModel
Source§impl<'de> Deserialize<'de> for DecayModel
impl<'de> Deserialize<'de> for DecayModel
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
Auto Trait Implementations§
impl Freeze for DecayModel
impl RefUnwindSafe for DecayModel
impl Send for DecayModel
impl Sync for DecayModel
impl Unpin for DecayModel
impl UnsafeUnpin for DecayModel
impl UnwindSafe for DecayModel
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