pub struct FaultInjector { /* private fields */ }Expand description
Fault injector for simulation testing.
TigerStyle:
- Explicit fault registration
- Deterministic through RNG
- Statistics tracked
- Interior mutability for sharing via Arc
Implementations§
Source§impl FaultInjector
impl FaultInjector
Sourcepub fn new(rng: DeterministicRng) -> Self
pub fn new(rng: DeterministicRng) -> Self
Create a new fault injector with the given RNG.
Sourcepub fn register(&mut self, config: FaultConfig)
pub fn register(&mut self, config: FaultConfig)
Register a fault configuration.
Note: Registration must happen before sharing via Arc.
Sourcepub fn should_inject(&self, operation: &str) -> Option<FaultType>
pub fn should_inject(&self, operation: &str) -> Option<FaultType>
Check if a fault should be injected for the given operation.
Returns the fault type if one should be injected, None otherwise.
TigerStyle: Uses interior mutability (Mutex) so can be called on &self, allowing FaultInjector to be shared via Arc.
Sourcepub fn injection_stats(&self) -> HashMap<String, u64>
pub fn injection_stats(&self) -> HashMap<String, u64>
Get injection statistics.
Sourcepub fn total_injections(&self) -> u64
pub fn total_injections(&self) -> u64
Get total number of injections.
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset all statistics.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FaultInjector
impl RefUnwindSafe for FaultInjector
impl Send for FaultInjector
impl Sync for FaultInjector
impl Unpin for FaultInjector
impl UnwindSafe for FaultInjector
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