Skip to main content

Scenario

Struct Scenario 

Source
pub struct Scenario<C> {
    pub config: Config,
    pub nodes: Vec<NodeId>,
    pub steps: Vec<(Duration, Step<C>)>,
    pub horizon: Duration,
}
Expand description

A whole run, as data.

Executing one twice produces the same trace, by the determinism the simulator already guarantees: the configuration carries the seed, and nothing else in a run is drawn from anywhere but the generator that seed starts.

Fields§

§config: Config

Network conditions and the seed. The seed lives here rather than beside it, because it is what the simulator already treats as part of a configuration.

§nodes: Vec<NodeId>

The processes in the run.

§steps: Vec<(Duration, Step<C>)>

What happens, and when — each time measured from the start of the run, in non-decreasing order. Two steps at the same time happen in the order given, with nothing dispatched between them.

§horizon: Duration

How long to run after the last step.

Implementations§

Source§

impl<C> Scenario<C>

Source

pub fn new(config: Config, nodes: impl IntoIterator<Item = NodeId>) -> Self

An empty run over nodes with no steps and no horizon.

Source

pub fn at(self, at: Duration, step: Step<C>) -> Self

Add a step at at, measured from the start of the run.

§Panics

If at precedes the last step already added. A description is executed in the order it is written, and the clock does not go backwards, so an out-of-order step would silently happen at the wrong moment rather than where it reads.

Source

pub fn horizon(self, horizon: Duration) -> Self

Run until horizon after the start.

Source

pub fn end(&self) -> Duration

The time the run ends: the horizon, or the last step if that is later.

Source§

impl<C: Clone> Scenario<C>

Source

pub fn is_well_formed(&self) -> bool
where C: PartialEq,

Whether every Resume has a Suspend and every Restart a Crash, in order.

A scenario written by hand can be wrong; one produced by a reduction cannot, because every reduction repairs. Exposed so a test can say which it is holding.

Source§

impl<C: Debug> Scenario<C>

Source

pub fn to_rust(&self, name: &str) -> String

Render as Rust that reconstructs this scenario, as a function named name.

The end of a reduction should be something to paste, not something to transcribe. The command is rendered with its Debug, which is valid Rust for the derived implementations this repository’s commands all use, provided their variants are in scope where the output is pasted.

Trait Implementations§

Source§

impl<C: Clone> Clone for Scenario<C>

Source§

fn clone(&self) -> Scenario<C>

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<C: Debug> Debug for Scenario<C>

Source§

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

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

impl<C: PartialEq> PartialEq for Scenario<C>

Source§

fn eq(&self, other: &Scenario<C>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<C: PartialEq> StructuralPartialEq for Scenario<C>

Auto Trait Implementations§

§

impl<C> Freeze for Scenario<C>

§

impl<C> RefUnwindSafe for Scenario<C>
where C: RefUnwindSafe,

§

impl<C> Send for Scenario<C>
where C: Send,

§

impl<C> Sync for Scenario<C>
where C: Sync,

§

impl<C> Unpin for Scenario<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for Scenario<C>

§

impl<C> UnwindSafe for Scenario<C>
where C: UnwindSafe,

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
§

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

§

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

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

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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more