pub trait ValidateState {
// Required method
fn validate_state(&self) -> Result<(), RillError>;
}Expand description
Unified state-validation interface for restorable model types.
Implementations enforce type-specific invariants that cannot be violated
by a semantically valid serde deserialization. This trait is the single
hook used by Snapshot::into_validated_model and by every Python/WASM
from_json entry point, so adding a new restorable type only requires
implementing this trait once.
§When to implement
Implement ValidateState for every public type that can appear inside a
Snapshot and be restored from untrusted JSON. At minimum this covers
all types exposed via Python and WASM from_json.
§What to check
- Dimensions / vector lengths match the type’s own recorded feature count.
- All stored floating-point values are finite.
- Counts and statistics are non-negative.
- Optimizer parameter counts match the model’s feature count.
- Encoder mapping consistency (no dangling indices).
- Pipeline transformer/model dimensions agree.
- Bandit arm state length matches the configured arm count.
- Drift detector buffer length respects the configured capacity.
§Errors
Return RillError::InvalidState with a descriptive message so callers
can distinguish validation failures from version mismatches.
Required Methods§
Sourcefn validate_state(&self) -> Result<(), RillError>
fn validate_state(&self) -> Result<(), RillError>
Validate the in-memory state of this type.
This method must be idempotent and must not mutate self.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl ValidateState for AdwinPortableStateV1
impl ValidateState for ClippedMean
impl ValidateState for DecisionReplayHarness
bandit only.impl ValidateState for DriftConsensus
impl ValidateState for KswinPortableStateV1
impl ValidateState for LinUcbFast
bandit only.