Skip to main content

TripWorkflow

Struct TripWorkflow 

Source
#[non_exhaustive]
pub struct TripWorkflow { /* private fields */ }
Expand description

The trip workflow: the disruption case of one booking.

Implementations§

Source§

impl TripWorkflow

Source

pub const fn new() -> Self

Builds the workflow: a rebooking is the only step a card confirms.

Source

pub const fn with_cards(self) -> Self

The same workflow with a click for withdrawing and a review card for changing the traveler, for exercising the card machinery; the sample itself asks for neither.

Source

pub fn phase_of(state: &TripState) -> TripPhase

The phase a stored status projects to.

Trait Implementations§

Source§

impl Clone for TripWorkflow

Source§

fn clone(&self) -> Self

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 Copy for TripWorkflow

Source§

impl Debug for TripWorkflow

Source§

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

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

impl Default for TripWorkflow

Source§

fn default() -> Self

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

impl PureWorkflow for TripWorkflow

Source§

fn apply( &self, state: Option<&TripState>, command: &TripCommand, ) -> Result<Applied<TripState, TripEvent>, DomainRejection>

Applies one command to one state, refusing it the way the real domain would. Must be deterministic and must not mutate state.
Source§

fn event_type(&self, event: &TripEvent) -> String

Stable event type label of an event, e.g. "trip.extra_added".
Source§

impl WorkflowDefinition for TripWorkflow

Source§

fn obligation_act( &self, state: Option<&TripState>, obligation: &TripObligation, ) -> Option<ObligationAct>

Each obligation as the question that closes it. An extra’s payer is asked of that extra: the answer gives only the payer.

Source§

fn narratable_state(&self, state: Option<&TripState>) -> Vec<StateField>

The values a person may be told back, which here is what they gave and the booking they gave it on; never the lifecycle or the ticket number.

Source§

fn briefing(&self, view: &ViewOf<Self>) -> Option<String>

Guidance that changes with the phase: while a case is being filled in, what a kept leg means; once the rebooking card is up, to read the message as an answer to it.

Source§

fn transition_briefing(&self, view: &ViewOf<Self>) -> Option<String>

What the sample wants said while it acknowledges and asks.

Source§

fn answer_briefing(&self, view: &ViewOf<Self>) -> Option<String>

And something else for the stage that answers.

Source§

fn artifacts(&self, view: &ViewOf<Self>) -> Vec<ArtifactRef>

The itinerary a quoted rebooking has, declared from the projection so it is there on a turn where the user asks instead of clicking.

Source§

fn confirmation_subject( &self, state: Option<&TripState>, _view: &ViewOf<Self>, act: &ResolvedAct, ) -> Option<ConfirmationSubject>

What the destructive confirmation is about, in words that name the thing.

Source§

fn enumerations(&self, _view: &ViewOf<Self>) -> Vec<DomainEnumeration>

The payers this workflow accepts, and no others.

Source§

fn next_steps( &self, state: Option<&TripState>, view: &ViewOf<Self>, ) -> Vec<NextStep>

A complete trip can take another extra, and the rebooking of the quoted leg once a quote is in; one still owing something offers nothing, because what it owes is asked first. The runtime offers a step only when its dry run on the record passes.

Source§

fn nothing_changed( &self, state: Option<&TripState>, act: &ResolvedAct, ) -> Option<LocalizedText>

Why nothing changed: the name already there.

Source§

type State = TripState

Persisted case state.
Source§

type Phase = TripPhase

Lifecycle phase.
Source§

type Obligation = TripObligation

Open obligation, possibly parameterized.
Source§

type Command = TripCommand

Typed command.
Source§

type Event = TripEvent

Typed domain event.
Source§

type Outcome = TripOutcome

Terminal outcome.
Source§

fn key(&self) -> WorkflowKey

Stable key.
Source§

fn version(&self) -> WorkflowVersion

Version; must change when projection semantics change (spec §8.4).
Source§

fn phase_ownership(&self, phase: &TripPhase) -> PhaseOwnership

Who must act in a phase. Drives the §8.4 invariants.
Source§

fn obligation_sentence( &self, obligation: &TripObligation, ) -> Option<LocalizedText>

One obligation, in words a person would recognise. Read more
Source§

fn project(&self, case_ref: CaseRef, state: Option<&TripState>) -> ViewOf<Self>

Pure projection (I2). Read more
Source§

fn summary(&self) -> Option<String>

One line saying what the workflow is for, shown when a message is split into requests. None, the default, shows the workflow’s key alone.
Source§

fn noun(&self) -> Option<LocalizedText>

What one record of this workflow is called, in each language its users speak («traveler», «viaggiatore»), for the sentences the runtime writes about one. None, the default, uses the workflow’s key.
Source§

fn glossary(&self) -> Vec<GlossaryTerm>

Terms this workflow’s users say, and what they mean here.
Source§

fn operations(&self, view: &ViewOf<Self>) -> Vec<OperationSpec>

The operations offered in this view, with their arguments, labels and examples.
Source§

fn record_operations(&self) -> Vec<OperationSpec>

Every operation a record of this workflow may offer, in any phase. Understanding is shown them while none of its records is in view, so a request for one is told there is none yet, and offered to open one, instead of going unread. The default is empty.
Source§

fn compile_act( &self, state: Option<&TripState>, _view: &ViewOf<Self>, act: &ResolvedAct, ) -> Result<Vec<TripCommand>, DomainRejection>

Compiles a resolved act into typed commands (spec §21.2).
Source§

fn command_policy( &self, state: Option<&TripState>, command: &TripCommand, ) -> CommandPolicy

Policy of a command. Unknown commands must default to CommandPolicy::conservative.
Source§

fn validate_command( &self, state: Option<&TripState>, command: &TripCommand, ) -> Result<(), DomainRejection>

Deterministic validation before execution.
Source§

fn state_after( &self, state: Option<&TripState>, command: &TripCommand, ) -> Option<TripState>

The state a valid command leaves state in, when the workflow can tell without executing it. An act on a record an earlier act of the same message opens is compiled and validated against the state the opening leaves; with None, the default, it is checked against no state, and a domain that needs the record refuses.
Source§

fn receipts( &self, events: &[ReceiptEvent<TripEvent>], locale: &Locale, ) -> Vec<OperationalReceipt>

Renders receipts from committed events (spec §17.3). Read more
Source§

fn build_interaction( &self, state: Option<&TripState>, view: &ViewOf<Self>, requirement: &InteractionRequirement, ) -> Result<InteractionSpec, DomainRejection>

Turns a requirement of the view into a full interaction spec. Read more
Source§

fn start_preconditions(&self) -> Vec<StartPrecondition>

What must already be true of another case before this workflow may be started. Read more
Source§

fn start_behaviour(&self) -> StartBehaviour

What starting this workflow means when a case of it is already open. Read more
Source§

fn may_open_beside( &self, open: &[WorkflowView<Self::Phase, Self::Obligation, Self::Outcome>], ) -> Result<(), DomainRejection>

Whether a new case may be opened while open ones are: an operation aimed at a new record, the door StartBehaviour does not govern. Read more
Source§

impl WorkflowModel<TripWorkflow> for TripModel

Source§

fn initial_states(&self) -> Vec<Option<TripState>>

The states exploration starts from. None means “the case does not exist yet”, which is where most workflows begin — and it never means “the case is over”, because a case’s identity outlives its content.
Source§

fn candidate_commands(&self, state: Option<&TripState>) -> Vec<TripCommand>

Commands worth trying in this state, in a stable order. Include commands you expect to be refused: the explorer checks that a refusal changes nothing.
Source§

fn simulate( &self, state: Option<&TripState>, command: &TripCommand, ) -> SimulatedTransition<TripState, TripEvent>

Applies one candidate command purely.
Source§

fn declared_outcomes(&self) -> Vec<TripOutcome>

Outcomes the workflow claims it can reach. The explorer reports every declared outcome no reachable state projects. The default is empty, which disables the check.

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> AsOut<T> for T
where T: Copy,

Source§

fn as_out(&mut self) -> Out<'_, T>

Returns an out reference to self.
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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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: Span) -> Instrumented<Self> ⓘ

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

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.

Source§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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