pub struct PatternStats {
pub pattern_id: String,
pub error_code: String,
pub total_uses: usize,
pub uses_in_window: usize,
pub successes: usize,
pub failures: usize,
pub last_used: Option<SystemTime>,
pub superseded_by: Option<String>,
}Expand description
Usage statistics for a pattern
Fields§
§pattern_id: StringPattern identifier
error_code: StringError code this pattern addresses
total_uses: usizeTotal number of times pattern was used
uses_in_window: usizeUses within the evaluation window
successes: usizeSuccessful applications
failures: usizeFailed applications
last_used: Option<SystemTime>Timestamp of last use
superseded_by: Option<String>ID of a better pattern if one exists
Implementations§
Source§impl PatternStats
impl PatternStats
Sourcepub fn new(pattern_id: impl Into<String>, error_code: impl Into<String>) -> Self
pub fn new(pattern_id: impl Into<String>, error_code: impl Into<String>) -> Self
Create new pattern stats
Sourcepub fn record_use(&mut self, success: bool)
pub fn record_use(&mut self, success: bool)
Record a use of the pattern
Sourcepub fn success_rate(&self) -> f32
pub fn success_rate(&self) -> f32
Get success rate
Sourcepub fn reset_window(&mut self)
pub fn reset_window(&mut self)
Reset window usage (called at window boundary)
Sourcepub fn mark_superseded(&mut self, better_pattern_id: impl Into<String>)
pub fn mark_superseded(&mut self, better_pattern_id: impl Into<String>)
Mark as superseded by another pattern
Trait Implementations§
Source§impl Clone for PatternStats
impl Clone for PatternStats
Source§fn clone(&self) -> PatternStats
fn clone(&self) -> PatternStats
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 PatternStats
impl Debug for PatternStats
Source§impl<'de> Deserialize<'de> for PatternStats
impl<'de> Deserialize<'de> for PatternStats
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 PatternStats
impl RefUnwindSafe for PatternStats
impl Send for PatternStats
impl Sync for PatternStats
impl Unpin for PatternStats
impl UnsafeUnpin for PatternStats
impl UnwindSafe for PatternStats
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