pub struct TimeCrystal {
pub id: Uuid,
pub name: String,
pub period: TemporalPeriod,
pub occurrences: Vec<TemporalOccurrence>,
pub distribution: Vec<f32>,
pub confidence: f32,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}Expand description
A time crystal capturing periodic behavior patterns.
Named after the physics concept of time crystals that exhibit periodic structure in time rather than space.
Fields§
§id: UuidUnique identifier.
name: StringPattern name/description.
period: TemporalPeriodThe periodic interval of this pattern.
occurrences: Vec<TemporalOccurrence>Observed occurrences within the period.
distribution: Vec<f32>Computed distribution over the period.
confidence: f32Confidence in this pattern (0.0 to 1.0).
created_at: DateTime<Utc>When this crystal was created.
updated_at: DateTime<Utc>When this crystal was last updated.
Implementations§
Source§impl TimeCrystal
impl TimeCrystal
Sourcepub fn new(name: impl Into<String>, period: TemporalPeriod) -> Self
pub fn new(name: impl Into<String>, period: TemporalPeriod) -> Self
Create a new time crystal for a given period.
Sourcepub fn record(&mut self, timestamp: DateTime<Utc>, value: f32)
pub fn record(&mut self, timestamp: DateTime<Utc>, value: f32)
Record an occurrence at a specific time.
Sourcepub fn record_now(&mut self, value: f32)
pub fn record_now(&mut self, value: f32)
Record an occurrence now.
Sourcepub fn predict(&self, timestamp: &DateTime<Utc>) -> f32
pub fn predict(&self, timestamp: &DateTime<Utc>) -> f32
Get the expected value at a given time.
Sourcepub fn predict_now(&self) -> f32
pub fn predict_now(&self) -> f32
Get the expected value now.
Sourcepub fn is_anomalous(
&self,
timestamp: &DateTime<Utc>,
value: f32,
threshold: f32,
) -> bool
pub fn is_anomalous( &self, timestamp: &DateTime<Utc>, value: f32, threshold: f32, ) -> bool
Check if current time is anomalous compared to pattern.
Sourcepub fn period_description(&self) -> String
pub fn period_description(&self) -> String
Get the period description.
Trait Implementations§
Source§impl Clone for TimeCrystal
impl Clone for TimeCrystal
Source§fn clone(&self) -> TimeCrystal
fn clone(&self) -> TimeCrystal
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 TimeCrystal
impl Debug for TimeCrystal
Source§impl<'de> Deserialize<'de> for TimeCrystal
impl<'de> Deserialize<'de> for TimeCrystal
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 TimeCrystal
impl RefUnwindSafe for TimeCrystal
impl Send for TimeCrystal
impl Sync for TimeCrystal
impl Unpin for TimeCrystal
impl UnsafeUnpin for TimeCrystal
impl UnwindSafe for TimeCrystal
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request