pub struct FakeClassifier { /* private fields */ }Expand description
An in-memory Classifier for module tests: records every ask it
answered and answers according to its ClassifierMode.
The mode is global by default and can be overridden per question
(FakeClassifier::set_answer_for), mirroring FakeTextModel’s
per-tier override: one test can script one question’s probabilities
while the rest stay deterministic.
An ask that failed (NotConfigured, Rejected, Transient or
Error) is not recorded, the same rule FakeTextModel applies
to a completion — the recording means “the classifier answered”, so a
caller that retried on Transient { .. } sees one recorded ask per
attempt that got answers.
Implementations§
Source§impl FakeClassifier
impl FakeClassifier
pub fn new(mode: ClassifierMode) -> Self
Sourcepub fn asks(&self) -> Vec<Ask>
pub fn asks(&self) -> Vec<Ask>
Every ask answered so far, in order. An ask that failed is not recorded.
Sourcepub fn set_mode(&self, mode: ClassifierMode)
pub fn set_mode(&self, mode: ClassifierMode)
Switches the mode every question without an override answers with
(e.g. flip to NotConfigured mid-test).
Sourcepub fn set_answer_for(&self, question_id: impl Into<String>, answer: Answer)
pub fn set_answer_for(&self, question_id: impl Into<String>, answer: Answer)
Makes one question answer with answer, whatever the mode is —
scripting one question’s probabilities while the rest stay
deterministic, say.
Sourcepub fn clear_answer_for(&self, question_id: &str)
pub fn clear_answer_for(&self, question_id: &str)
Drops one question’s override, putting it back on the mode.
Sourcepub fn set_profile(&self, calibration: Calibration, max_state_chars: usize)
pub fn set_profile(&self, calibration: Calibration, max_state_chars: usize)
Reports calibration and max_state_chars from
Classifier::profile, so a test can exercise a module’s
calibration- or truncation-aware behaviour against either family.
Trait Implementations§
Source§impl Classifier for FakeClassifier
impl Classifier for FakeClassifier
Source§fn profile(&self) -> ClassifierProfile
fn profile(&self) -> ClassifierProfile
confidence comes from, and
how much state it will carry.