pub struct StartPrecondition {
pub workflow: WorkflowKey,
pub phases: Vec<Value>,
pub reason: LocalizedText,
}Expand description
What must already be true of another case before this workflow may be started.
§Why a declaration
A projector is pure and cannot read another case, and the executor is the wrong place for a domain rule about when a case may exist: «a traveler is registered only while a trip is open» belongs to neither. The workflow declares what it needs; the runtime, which has the other cases in hand already, decides whether it is there.
§What it costs when it is not met
The start act is not offered at all, so it cannot be proposed and cannot be
refused later. The reason travels in the catalogue instead,
which is the honest limit of this shape: with no act there is no refusal to
attach a notice to, so whether the user hears why depends on the sentence
the writing stage produces. A deployment that needs the reason guaranteed
should keep an operation that refuses it rather than one that is absent.
Fields§
§workflow: WorkflowKeyThe workflow the required case belongs to.
phases: Vec<Value>The phases that satisfy it, as that workflow’s phase serializes.
reason: LocalizedTextWhy, in words a user can read, when it is not met.
Implementations§
Source§impl StartPrecondition
impl StartPrecondition
Sourcepub fn new(
workflow: impl Into<WorkflowKey>,
phases: impl IntoIterator<Item = Value>,
reason: LocalizedText,
) -> Self
pub fn new( workflow: impl Into<WorkflowKey>, phases: impl IntoIterator<Item = Value>, reason: LocalizedText, ) -> Self
Requires a case of workflow to be in one of phases, already
serialized.
The infallible primitive. Prefer Self::requires, which takes the
other workflow’s own phase type so the compiler checks the spelling.
Sourcepub fn requires<P: Serialize>(
workflow: impl Into<WorkflowKey>,
phases: &[P],
reason: LocalizedText,
) -> Result<Self, HashError>
pub fn requires<P: Serialize>( workflow: impl Into<WorkflowKey>, phases: &[P], reason: LocalizedText, ) -> Result<Self, HashError>
Sourcepub fn satisfied_by(&self, view: &ErasedWorkflowView) -> bool
pub fn satisfied_by(&self, view: &ErasedWorkflowView) -> bool
Whether view is a case that satisfies this precondition.
Trait Implementations§
Source§impl Clone for StartPrecondition
impl Clone for StartPrecondition
Source§impl Debug for StartPrecondition
impl Debug for StartPrecondition
Source§impl<'de> Deserialize<'de> for StartPrecondition
impl<'de> Deserialize<'de> for StartPrecondition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for StartPrecondition
Source§impl PartialEq for StartPrecondition
impl PartialEq for StartPrecondition
Source§impl Serialize for StartPrecondition
impl Serialize for StartPrecondition
impl StructuralPartialEq for StartPrecondition
Auto Trait Implementations§
impl Freeze for StartPrecondition
impl RefUnwindSafe for StartPrecondition
impl Send for StartPrecondition
impl Sync for StartPrecondition
impl Unpin for StartPrecondition
impl UnsafeUnpin for StartPrecondition
impl UnwindSafe for StartPrecondition
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.