Skip to main content

InjectionStrategy

Enum InjectionStrategy 

Source
pub enum InjectionStrategy {
    Never,
    AtSequence(u64),
    AtPoint(AwaitPoint),
    EveryNth(u64),
    AllPoints,
    RandomSample(usize),
    SpecificPoints(Vec<u64>),
    FirstN(usize),
    Probabilistic(f64),
    WindowAround {
        center: u64,
        radius: u64,
    },
    ExceptFirst(usize),
    LastN(usize),
}
Expand description

Strategy for selecting which await points to inject cancellation at.

This controls which points are selected for injection during a test run. Use with InjectionRunner::run_with_injection for automated test execution.

Variants§

§

Never

Never inject cancellation (recording mode only).

§

AtSequence(u64)

Inject at a specific await point sequence number.

§

AtPoint(AwaitPoint)

Inject at a specific await point.

§

EveryNth(u64)

Inject at every Nth await point.

§

AllPoints

Test every await point (most thorough, N+1 runs for N await points).

§

RandomSample(usize)

Test n randomly-selected await points using deterministic RNG.

§

SpecificPoints(Vec<u64>)

Test only specified await points.

§

FirstN(usize)

Test first n await points.

§

Probabilistic(f64)

Each await point has probability p (0.0-1.0) of injection.

§

WindowAround

Test a window of points around a center point.

Selects all recorded points in [center - radius, center + radius]. Useful for targeting a specific code region (e.g., around a known cancel checkpoint) without testing every point in the entire run.

Fields

§center: u64

The center await point sequence number.

§radius: u64

Number of points on each side to include.

§

ExceptFirst(usize)

Skip the first N points, test the rest.

Useful for bypassing initialization and focusing on steady-state or cleanup/finalization phases where cancellation handling matters most.

§

LastN(usize)

Test only the last N recorded await points.

Targets the tail of execution — typically the finalization and cleanup phases — where cancel-correctness bugs are most common.

Implementations§

Source§

impl InjectionStrategy

Source

pub fn select_points(&self, recorded: &[u64], seed: u64) -> Vec<u64>

Selects the await points to test based on this strategy.

§Arguments
  • recorded - The await points recorded during the recording run
  • seed - Deterministic seed for random selection
§Returns

A vector of await point sequence numbers to test

Trait Implementations§

Source§

impl Clone for InjectionStrategy

Source§

fn clone(&self) -> InjectionStrategy

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InjectionStrategy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for InjectionStrategy

Source§

fn default() -> InjectionStrategy

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V