Skip to main content

memory_adjustment_for

Function memory_adjustment_for 

Source
pub fn memory_adjustment_for(
    memory: &ChallengeMemory,
    domain: &str,
    target_class: TargetClass,
) -> f64
Expand description

Compute the risk-score adjustment a ChallengeMemory would apply for a (domain, target_class) key, using the ChallengeFeedbackPolicy::default clamp.

Returns 0.0 when the memory has no entry for the key (the common case on first contact with a new target).

ยงExample

use stygian_charon::challenge_feedback::{
    memory_adjustment_for, ChallengeMemory, ChallengeOutcome,
};
use stygian_charon::types::TargetClass;

let memory = ChallengeMemory::with_defaults();
memory.record("example.com", TargetClass::ContentSite, ChallengeOutcome::Captcha);
let delta = memory_adjustment_for(&memory, "example.com", TargetClass::ContentSite);
assert!(delta > 0.0);