Skip to main content

FakeDriver

Struct FakeDriver 

Source
pub struct FakeDriver { /* private fields */ }
Expand description

In-memory WorkflowDriver with scripted replies.

Unmatched spawns complete immediately with done:<description>. Rules are matched by substring against the request description, first match wins.

Implementations§

Source§

impl FakeDriver

Source

pub fn new() -> Self

A fake with no rules, no budget ceiling, and echo replies.

Source

pub fn on(&self, needle: &str, reply: FakeReply)

Add a reply rule: requests whose description contains needle get reply immediately.

Source

pub fn on_with_delay(&self, needle: &str, reply: FakeReply, delay: Duration)

Like FakeDriver::on, but the completion is delivered after delay (the spawn itself still returns immediately).

Source

pub fn set_budget(&self, total: Option<u64>, spend_per_task: u64)

Configure the budget pool: ceiling plus a fixed spend debited at each spawn (simulating the driver-side reservation of design §5.3).

Source

pub fn requests(&self) -> Vec<TaskRequest>

Every request received so far, in spawn order.

Source

pub fn request_descriptions(&self) -> Vec<String>

Descriptions of every request, in spawn order.

Source

pub fn spawn_count(&self) -> usize

Number of admitted spawn calls.

Source

pub fn events(&self) -> Vec<ProgressEvent>

Every progress event received so far, in emit order.

Source

pub fn cancel_all_calls(&self) -> usize

How many times cancel_all has been invoked.

Trait Implementations§

Source§

impl Debug for FakeDriver

Source§

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

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

impl Default for FakeDriver

Source§

fn default() -> FakeDriver

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

impl WorkflowDriver for FakeDriver

Source§

fn spawn_task<'life0, 'async_trait>( &'life0 self, request: TaskRequest, ) -> Pin<Box<dyn Future<Output = Result<SpawnedTask, DriverError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Admit and start one task. Errors surface as a JS throw on the corresponding task() call.
Source§

fn cancel_all(&self)

Cancel every in-flight task belonging to this run. Idempotent.
Source§

fn budget(&self) -> BudgetSnapshot

Current snapshot of the run’s shared token pool.
Source§

fn progress(&self, event: ProgressEvent)

Receive a script progress event (ordered, synchronous).

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ParallelSend for T

Source§

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

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.