pub async fn check_existing_instance<B>(
instance_id: &str,
definition_hash: &str,
backend: &B,
conflict_policy: ConflictPolicy,
) -> Result<Option<(WorkflowStatus, Option<Bytes>)>, RuntimeError>where
B: SnapshotStore,Expand description
Check for an existing instance before encoding input.
For Fail and UseExisting policies, this avoids unnecessary codec
work by checking the backend before the caller serialises the workflow input.
Returns Ok(Some((status, output))) when the caller should return early
(instance exists and the policy says to reuse it, or the policy rejects the
duplicate). Returns Ok(None) when the caller should proceed to encode
input and call prepare_run.
TerminateExisting always returns Ok(None) — the actual cleanup is
deferred to prepare_run.
§Errors
Returns RuntimeError::InstanceAlreadyExists for Fail when the
instance already exists, WorkflowError::DefinitionMismatch when the
existing snapshot has a different definition hash, or propagates backend
I/O errors.