pub struct ChangeDetector { /* private fields */ }Expand description
Deterministic change-feed detector.
The detector is Copy so it can live in a static
configuration struct without a wrapper. The default
configuration (ChangeDetector::new) uses the
documented defaults — every field has a public
constant and every value can be overridden through
ChangeDetector::with_thresholds.
§Example
use stygian_charon::change_feed::{
ChangeDeltaInput, ChangeDetector, InMemoryChangeFeedSink, DeltaSeverity, DeltaSource,
};
let detector = ChangeDetector::new();
let sink = InMemoryChangeFeedSink::new();
let deltas = vec![ChangeDeltaInput::new(
DeltaSource::Canary,
"example.com",
0.05,
DeltaSeverity::Clean,
"canary blip",
)];
let report = detector.detect(&deltas, &sink);
// A Clean-severity canary blip is the noise
// default — no event is emitted.
assert!(report.noise_targets.iter().any(|t| t == "example.com"));
assert!(sink.is_empty());Implementations§
Source§impl ChangeDetector
impl ChangeDetector
Sourcepub const fn with_thresholds(self, thresholds: ChangeFeedThresholds) -> Self
pub const fn with_thresholds(self, thresholds: ChangeFeedThresholds) -> Self
Replace the thresholds.
Sourcepub const fn thresholds(&self) -> ChangeFeedThresholds
pub const fn thresholds(&self) -> ChangeFeedThresholds
Current thresholds.
Sourcepub fn detect<S: ChangeEventSink + ?Sized>(
&self,
deltas: &[ChangeDeltaInput],
sink: &S,
) -> ChangeFeedReport
pub fn detect<S: ChangeEventSink + ?Sized>( &self, deltas: &[ChangeDeltaInput], sink: &S, ) -> ChangeFeedReport
Classify a slice of deltas and emit one
ChangeEvent per Suspected / Probable
target into sink. Returns the full
ChangeFeedReport regardless of band —
callers can inspect noise_targets /
suspected_targets / probable_targets to
drive dashboards without parsing events.
Trait Implementations§
Source§impl Clone for ChangeDetector
impl Clone for ChangeDetector
Source§fn clone(&self) -> ChangeDetector
fn clone(&self) -> ChangeDetector
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 ChangeDetector
impl Debug for ChangeDetector
Source§impl Default for ChangeDetector
impl Default for ChangeDetector
Source§impl<'de> Deserialize<'de> for ChangeDetector
impl<'de> Deserialize<'de> for ChangeDetector
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
Source§impl PartialEq for ChangeDetector
impl PartialEq for ChangeDetector
Source§impl Serialize for ChangeDetector
impl Serialize for ChangeDetector
impl Copy for ChangeDetector
impl StructuralPartialEq for ChangeDetector
Auto Trait Implementations§
impl Freeze for ChangeDetector
impl RefUnwindSafe for ChangeDetector
impl Send for ChangeDetector
impl Sync for ChangeDetector
impl Unpin for ChangeDetector
impl UnsafeUnpin for ChangeDetector
impl UnwindSafe for ChangeDetector
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