pub struct FaultInjector { /* private fields */ }Expand description
Deterministic fault injector for testing.
Uses a simple hash of the request ID to decide whether to inject a fault, making tests reproducible.
Implementations§
Source§impl FaultInjector
impl FaultInjector
Sourcepub fn new(config: FaultConfig) -> Self
pub fn new(config: FaultConfig) -> Self
Create a new injector with the given config.
Sourcepub fn check(&self, request_id: u64) -> Option<&FaultType>
pub fn check(&self, request_id: u64) -> Option<&FaultType>
Check if a fault should be injected for the given request ID.
Returns the first matching fault, or None if no fault fires.
Uses deterministic hashing so the same request ID always produces
the same result.
Sourcepub fn config(&self) -> &FaultConfig
pub fn config(&self) -> &FaultConfig
Returns the config.
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).