pub struct HalfLife(/* private fields */);Expand description
A per-class half-life, stored as milliseconds but constructed explicitly in days or millis.
The agent-facing mimir.toml loader and the librarian default
table both deal in days; internal decay math is in milliseconds.
The newtype keeps the unit explicit at the boundary so a future
caller can’t accidentally drop a ClockTime into a half-life
slot (or vice versa).
The infinity case (HalfLife::no_decay() == HalfLife::ZERO)
maps to the spec § 5.3 encoding — effective_confidence returns
stored for any memory whose class has HalfLife::ZERO.
§Examples
use mimir_core::decay::{HalfLife, DAY_MS};
assert_eq!(HalfLife::from_days(180).as_millis(), 180 * DAY_MS);
assert_eq!(HalfLife::from_millis(500).as_millis(), 500);
assert!(HalfLife::no_decay().is_no_decay());
assert!(!HalfLife::from_days(1).is_no_decay());Implementations§
Source§impl HalfLife
impl HalfLife
Sourcepub const fn from_millis(millis: u64) -> Self
pub const fn from_millis(millis: u64) -> Self
Construct from a raw millisecond count. 0 encodes
Self::no_decay.
Sourcepub const fn as_millis(self) -> u64
pub const fn as_millis(self) -> u64
Raw millisecond representation — for the internal decay
math. Unit-explicit callers should prefer
HalfLife-typed values everywhere else.
Sourcepub const fn is_no_decay(self) -> bool
pub const fn is_no_decay(self) -> bool
true when this half-life encodes the spec § 5.3 infinity
case.
Trait Implementations§
impl Copy for HalfLife
impl Eq for HalfLife
impl StructuralPartialEq for HalfLife
Auto Trait Implementations§
impl Freeze for HalfLife
impl RefUnwindSafe for HalfLife
impl Send for HalfLife
impl Sync for HalfLife
impl Unpin for HalfLife
impl UnsafeUnpin for HalfLife
impl UnwindSafe for HalfLife
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.